l6470_gimbal_controller_os5

Dependencies:   X_NUCLEO_IHM02A1

Revision:
1:13fb32a7d8ce
Parent:
0:08a64a788d1f
--- a/main.cpp	Mon Mar 29 23:51:53 2021 +0000
+++ b/main.cpp	Tue Mar 30 00:35:56 2021 +0000
@@ -13,10 +13,10 @@
 /* Definitions ---------------------------------------------------------------*/
 
 // Max time to run looking for a stall to mark home position
-#define HOME_TIMEOUT_S 5
+#define HOME_TIMEOUT 5s
 
 // LED period / 2
-#define LED_ON_S 0.25
+#define LED_ON_TIME 250ms
 
 
 /* Variables -----------------------------------------------------------------*/
@@ -142,13 +142,13 @@
     // Run at a specified speed (in steps/s). 
     //   Goal is to stall and halt using the IRQ, and set the zero position there.
     //   Otherwise, time out
-    t.attach(&timeout_handler, HOME_TIMEOUT_S);
+    t.attach(&timeout_handler, HOME_TIMEOUT);
     // Run "backward" so the farthest "backward" is the zero position.
     motors[0]->run(StepperMotor::BWD, 20000);
     
     while(!(flag_set or timeout_set)) {
         led1 = !led1;
-        wait_ms(LED_ON_S * 1000);
+        ThisThread::sleep_for(LED_ON_TIME);
     }
     
     // We're either there or timed out; halt the timeout and hard stop the motor
@@ -170,12 +170,12 @@
     printf("Home set. Current Position: %d\r\n", motors[0]->get_position());
     
     /*----- Setting far limit (mark) position - run at constant speed until stall -----*/
-    t.attach(&timeout_handler, HOME_TIMEOUT_S);
+    t.attach(&timeout_handler, HOME_TIMEOUT);
     motors[0]->run(StepperMotor::FWD, 20000);
     
     while(!(flag_set or timeout_set)) {
         led1 = !led1;
-        wait_ms(LED_ON_S * 1000);
+        ThisThread::sleep_for(LED_ON_TIME);
     }
     
     // We're either there or timed out; halt the timeout and hard stop the motor