ft. button press reset

Dependencies:   mbed

Fork of BeaconDemo_RobotCodeNew by James O'Keeffe

Revision:
14:f623db1e6184
Parent:
13:f5994956b1ba
Child:
15:d18667eb57f5
--- a/main.cpp	Tue Oct 27 22:49:41 2015 +0000
+++ b/main.cpp	Wed Oct 28 11:41:56 2015 +0000
@@ -53,8 +53,8 @@
 char program_count = 7;
 char program_selection;
 
-float battery_low_threshold = 3.63;      // Threshold at which to interrupt program and start recharging routine: suggest 3.55
-float battery_high_threshold = 3.97;     // Threshold at which to end battery recharging routine and resume normal program: suggest 4.0
+float battery_low_threshold = 3.60;      // Threshold at which to interrupt program and start recharging routine: suggest 3.55
+float battery_high_threshold = 3.95;     // Threshold at which to end battery recharging routine and resume normal program: suggest 4.0
 
 Ticker main_loop_ticker;
 
@@ -62,12 +62,13 @@
 void main_loop()
 {
     if(switch_held == 1)switch_held=2;
-    if(switch_held == 3) {
+    if(switch_held == 3 && choose_program_mode == 0) {
         //The switch has been held right and then released:  stop the current program
         previous_program = main_program_state;
         program_selection = previous_program;
         choose_program_mode = 1;
         set_program(255);
+        set_program_info(get_program_name(program_selection));
     }
     if(use_recharging_program == 1)recharging_program();
     update_display();
@@ -106,6 +107,7 @@
                 break;
             case 255:
                 stop_program();
+                break;
         }
     }
     step_cycle=1-step_cycle;
@@ -162,8 +164,8 @@
             else set_program_info(get_program_name(program_selection));
         }
         if(switch_state == 4) {
-            program_selection --;
-            if(program_selection == 0) program_selection = program_count;   
+            if(program_selection == 0) program_selection = program_count; 
+            else program_selection --;  
             if(program_selection == program_count) set_program_info("RECHARGE");
             else set_program_info(get_program_name(program_selection));
         }
@@ -180,6 +182,7 @@
             switch_held = 0;
         }
     }
+    //out("Switch:%d Switch_held:%d Program_Selection:%d Program_count:%d Prog_Info:%s\n",switch_state,switch_held,program_selection,program_count,prog_info);
 }
 
 /// The main routine: it is recommended to leave this function alone and add user code to the above functions
@@ -221,6 +224,7 @@
             break;
         case 255:
             strcpy(ret_name,"PROGRAM:");
+            break;
     }
     return ret_name;
 }