I have this code running in STM32F469 DISCO KIT: https://github.com/neuberfran/discovery7/blob/main/applications/lvgl/demo/ui/ui_events.cpp
The lib SmartDrive Makes the motor run for 5 seconds (by default). When I want to stop the motor before that time, I click the stop button it works ok. Or else the motor stops by itself in 5s
But, when I want the motor to run for more than 5 seconds I need to put this routine: smd.Run_Unlimited(SmartDrive_Motor_ID_1, SmartDrive_Dir_Reverse, 90); in While - Loop.
At that moment my issue enters because I am not able to stop the motor through the code below. Does anyone have any tips on how to resolve this? Would I have to use interrupt? Would I have to use another task? How to use?
New ui_events.cpp File with issue:
#include <Arduino.h>
#include "ui.h"
#include <SmartDrive.h>
SmartDrive smd = SmartDrive(SmartDrive_DefaultAddress);
bool STOP01 = true;
#define STOP02 0
void run01right(lv_event_t * e)
{
// Your code here
while (STOP01)
{
smd.Run_Unlimited(SmartDrive_Motor_ID_1, SmartDrive_Dir_Reverse, 90);
}
STOP01 = true;
}
void stopmotor01(lv_event_t * e)
{
// Your code here
STOP01 = false;
smd.StopMotor(SmartDrive_Motor_ID_1, SmartDrive_Action_Brake);
STOP01 = true;
}
void run01left(lv_event_t * e)
{
// Your code here
while (STOP01)
{
smd.Run_Unlimited(SmartDrive_Motor_ID_1, SmartDrive_Dir_Forward, 90);
}
STOP01 = true;
}
Note: As the First photo below, it is not possible to implement void loop in this case. 2022-09-09 <-> I was wrong. It is possible to implement void setup() and void loop() and it was done. And so it resolved