changeset 163:13020c7be732 main

Minor tweaks to cone-bot 1.0
author Bob Cook <bob@bobcookdev.com>
date Sun, 11 Nov 2012 09:07:21 -0800
parents ed9dcbb8df43
children 1b8810100ea9 ad7069f53e31
files main/robots/cone-bot/main.cpp
diffstat 1 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/main/robots/cone-bot/main.cpp	Sat Nov 10 08:09:50 2012 -0800
+++ b/main/robots/cone-bot/main.cpp	Sun Nov 11 09:07:21 2012 -0800
@@ -102,6 +102,9 @@
 
     uint8_t action;
 
+    //--    Randomly assign an action. Certain actions should never follow other actions
+    //      and we never want to repeat the same action twice.
+
     for ( ;; )
     {
         action = static_cast< uint8_t >( random() % ACTION_COUNT );
@@ -125,19 +128,19 @@
 
 static void delay_until_next_action()
 {
-    //--    Delay between 25 and 200 seconds.
+    //--    Delay between 25 and 225 seconds.
 
     uint32_t delay_deadline = ( random() % 200 ) + 25;
     printf_P( PSTR("delay until next action: %ld seconds\n"), delay_deadline );
 
-    //--    Our clock is ~100 Hz e.g. 100 counts per second. So scale and set the time
-    //      of expiry to be in the future of the current time.
+    //--    Our clock is ~100 Hz e.g. 100 ticks  per second. So scale and set the time of
+    //      expiry to be in the future of the current time.
 
     delay_deadline *= 100;
     delay_deadline += tickcount();
 
     //--    Loop while we are still waiting. We can safely sleep the CPU, as the clock
-    //      interrupt will wake us up.
+    //      interrupt will wake us up. Maybe this will reduce power consumption?
 
     while ( delay_deadline > tickcount() )
     {
@@ -205,6 +208,14 @@
     led_one_off();
     led_two_off();
 
+    spinwait_delay_ms( 75 );
+
+    led_one_on();
+    led_two_on();
+    spinwait_delay_ms( 200 );
+    led_one_off();
+    led_two_off();
+
     spinwait_delay_ms( 250 );
 }
 
@@ -280,7 +291,9 @@
     printf_P( PSTR("cone-bot starting in 5 seconds...\n") );
     spinwait_delay_ms( 5000 );
 
-    //--    Main.
+    action_blink();
+
+    //--    Loop forever, doing our silly actions.
 
     for ( ;; )
     {