Psi Swarm robot library version 0.9

Fork of PsiSwarmV9 by Psi Swarm Robot

Revision:
11:312663037b8c
Parent:
10:e58323951c08
Child:
12:878c6e9d9e60
--- a/demo.cpp	Sun Oct 16 16:00:20 2016 +0000
+++ b/demo.cpp	Sun Oct 16 21:06:15 2016 +0000
@@ -77,7 +77,7 @@
 
 
 
-void demo_mode()
+void Demo::start_demo_mode()
 {
     debug("- Starting Demo Mode\n");
     if(use_flash_basic == 1) top_menu = 7;
@@ -118,16 +118,16 @@
     debug("- Demo mode ended\n");
 }
 
-void demo_handle_switch_event(char switch_pressed)
+void Demo::demo_handle_switch_event(char switch_pressed)
 {
     if(!handling_event) {
         handling_event = 1;
         last_switch_pressed = switch_pressed;
-        demo_event.attach_us(&demo_event_thread, 1000);
+        demo_event.attach_us(this,&Demo::demo_event_thread, 1000);
     }
 }
 
-void demo_event_thread()
+void Demo::demo_event_thread()
 {
     handling_event = 0;
     if(started == 1) {
@@ -881,11 +881,11 @@
     display.set_position(1,0);
     display.write_string(bottomline);
     if(top_menu == 1  && level == 1) {
-        demo_event.attach(&demo_event_thread, 0.25);
+        demo_event.attach(this,&Demo::demo_event_thread, 0.25);
     }
 }
 
-void start_line_demo()
+void Demo::start_line_demo()
 {
     display.set_backlight_brightness(0);
     time_out = 0.25f;
@@ -894,10 +894,10 @@
     speed = 0;
     led_step = 0;
     demo_running = 1;
-    demo_timeout.attach_us(&line_demo_cycle,1000);
+    demo_timeout.attach_us(this,&Demo::line_demo_cycle,1000);
 }
 
-void start_obstacle_demo()
+void Demo::start_obstacle_demo()
 {
     display.set_backlight_brightness(0);
     time_out = 0.25f;
@@ -906,10 +906,10 @@
     speed = 0;
     led_step = 0;
     demo_running = 1;
-    demo_timeout.attach_us(&obstacle_demo_cycle,1000);
+    demo_timeout.attach_us(this,&Demo::obstacle_demo_cycle,1000);
 }
 
-void start_stress_demo()
+void Demo::start_stress_demo()
 {
     display.set_backlight_brightness(0.25);
     display.write_string("STRESS TEST");
@@ -922,10 +922,10 @@
     stress_step = 0;
     spin_step = 0;
     demo_running = 1;
-    demo_timeout.attach_us(&stress_demo_cycle,1000);
+    demo_timeout.attach_us(this,&Demo::stress_demo_cycle,1000);
 }
 
-void start_spinning_demo()
+void Demo::start_spinning_demo()
 {
     display.set_backlight_brightness(0);
     time_out = 0.0f;
@@ -935,10 +935,10 @@
     led_step = 0;
     spin_step = 0;
     demo_running = 1;
-    demo_timeout.attach_us(&spinning_demo_cycle,1000);
+    demo_timeout.attach_us(this,&Demo::spinning_demo_cycle,1000);
 }
 
-void line_demo_cycle()
+void Demo::line_demo_cycle()
 {
     if(demo_timer.read() > time_out) {
         sensors.store_line_position();
@@ -1012,14 +1012,14 @@
 
         demo_timer.reset();
     }
-    if(demo_running == 1)demo_timeout.attach_us(&line_demo_cycle,500);
+    if(demo_running == 1)demo_timeout.attach_us(this,&Demo::line_demo_cycle,500);
     else {
         motors.stop();
         display.set_backlight_brightness(bl_brightness * 0.01f);
     }
 }
 
-void stress_demo_cycle()
+void Demo::stress_demo_cycle()
 {
     if(demo_timer.read() > time_out) {
         float pct = 0.25 + (0.25 * stress_step);
@@ -1059,14 +1059,14 @@
         }
         demo_timer.reset();
     }
-    if(demo_running == 1)demo_timeout.attach_us(&stress_demo_cycle,500);
+    if(demo_running == 1)demo_timeout.attach_us(this,&Demo::stress_demo_cycle,500);
     else {
         motors.stop();
         display.set_backlight_brightness(bl_brightness * 0.01f);
     }
 }
 
-void spinning_demo_cycle()
+void Demo::spinning_demo_cycle()
 {
     if(demo_timer.read() > time_out) {
         switch(state) {
@@ -1297,14 +1297,14 @@
         }
         demo_timer.reset();
     }
-    if(demo_running == 1)demo_timeout.attach_us(&spinning_demo_cycle,500);
+    if(demo_running == 1)demo_timeout.attach_us(this,&Demo::spinning_demo_cycle,500);
     else {
         motors.stop();
         display.set_backlight_brightness(bl_brightness * 0.01f);
     }
 }
 
-void obstacle_demo_cycle()
+void Demo::obstacle_demo_cycle()
 {
     if(demo_timer.read() > time_out) {
         switch(state) {
@@ -1372,14 +1372,14 @@
         }
         demo_timer.reset();
     }
-    if(demo_running == 1)demo_timeout.attach_us(&obstacle_demo_cycle,200);
+    if(demo_running == 1)demo_timeout.attach_us(this,&Demo::obstacle_demo_cycle,200);
     else {
         motors.stop();
         display.set_backlight_brightness(bl_brightness * 0.01f);
     }
 }
 
-void demo_update_leds()
+void Demo::demo_update_leds()
 {
     char red = 0;
     char green = 0;