app: fix motor speed

This commit is contained in:
King Kévin 2022-08-11 14:19:23 +02:00
parent 3f18fef34c
commit 78bc3b97f3
1 changed files with 4 additions and 7 deletions

View File

@ -664,6 +664,8 @@ static void command_dials(void* argument)
{
if (argument) {
const uint32_t seconds = *(uint32_t*)argument; // get provide value
drv8825_goal = seconds;
drv8825_speed(100);
if (seconds < 12 * 60 * 60) {
const uint32_t goal = DIAL_CYCLE_STEPS * seconds * 1.0 / (12 * 60 * 60);
if (goal != drv8825_goal) {
@ -1057,11 +1059,6 @@ void main(void)
terminal_process = &process_command; // set central function to process commands
terminal_setup(); // start terminal
// start motor to figure out position
gpio_set(GPIO_PORT(DRV8825_RESET_PIN), GPIO_PIN(DRV8825_RESET_PIN)); // power up driver
int32_t speed = 300;
command_speed(&speed);
// draw welcome text
matrix_puts(false, 1, 1, "DACHBODEN", FONT_KING10, false, true, false);
matrix_puts(false, 1, 12, "ZEIT", FONT_KING10, false, true, true);
@ -1117,12 +1114,12 @@ void main(void)
dial_steps = 0; // restart position counter (and clear flag)
drv8825_goal = DIAL_MIDNIGHT_STEPS; // go to midnight
drv8825_reached = false; // wait until it's reached
drv8825_speed(0); // stop motor
action = true;
}
if (drv8825_reached) {
puts("midnight reached\n");
speed = 0; // stop motor
command_speed(&speed); // stop motor
drv8825_speed(0); // stop motor
drv8825_goal = 0; // disable goal
drv8825_reached = false; // clear flag
action = true; // redo main loop