Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neuberfran/bd26ae14b7e5c1935e75b08c772760c6 to your computer and use it in GitHub Desktop.
Save neuberfran/bd26ae14b7e5c1935e75b08c772760c6 to your computer and use it in GitHub Desktop.
#include <Arduino.h>
#include "ui.h"
#include "vGlobal.h"
#include <SmartDrive.h>
SmartDrive smd = SmartDrive(SmartDrive_DefaultAddress);
int led_state = LOW; // the current state of LED
int button_state; // the current state of button
// Nao to usando run01right neste caso
========================================================
void run01right(lv_event_t * e, lv_obj_t * obj)
{
// while(obj != ui_stop && STOP01) {
smd.Run_Unlimited(SmartDrive_Motor_ID_1, SmartDrive_Dir_Reverse, 90);
}
STOP01 = false;
}
// Nao to usando stop01motor neste caso
========================================================
void stop01motor(lv_event_t * e, lv_obj_t * obj)
{
// Your code here
STOP01 = false;
smd.StopMotor(SmartDrive_Motor_ID_1, SmartDrive_Action_Brake);
STOP01 = false;
}
// Abaixo o que estah funcionando no Arduino, mas falta integrar (talvez
via semáforo) a LVGL_Thtread c/ a RTduino_Thread
==========================================================================
void setup(void)
{
Serial.begin(115200); // initialize serial
pinMode(LED_BUILTIN, OUTPUT);
pinMode(BUTTON_BUILTIN, INPUT);
}
void loop(void)
{
// last_button_state = button_state; // save the last state
button_state = digitalRead(BUTTON_BUILTIN); // read new state
while (button_state != LOW) {
Serial.println("The Gira motor");
last_button_state = button_state; // save the last state
button_state = digitalRead(BUTTON_BUILTIN); // read new state
// toggle state of LED
led_state = !led_state;
// control LED arccoding to the toggled state
// digitalWrite(LED_BUILTIN, led_state);
smd.Run_Unlimited(SmartDrive_Motor_ID_1, SmartDrive_Dir_Reverse, 90);
// smd.StopMotor(SmartDrive_Motor_ID_1, SmartDrive_Action_Brake);
}
smd.StopMotor(SmartDrive_Motor_ID_1, SmartDrive_Action_Brake);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment