Psi Swarm robot library version 0.9
Fork of PsiSwarmV9 by
Diff: psiswarm.cpp
- Revision:
- 11:312663037b8c
- Parent:
- 10:e58323951c08
- Child:
- 12:878c6e9d9e60
diff -r e58323951c08 -r 312663037b8c psiswarm.cpp --- a/psiswarm.cpp Sun Oct 16 16:00:20 2016 +0000 +++ b/psiswarm.cpp Sun Oct 16 21:06:15 2016 +0000 @@ -28,6 +28,11 @@ Eprom eprom; Led led; Sensors sensors; +SerialControl serial; +Sound sound; +Setup i2c_setup; +Demo demo; +Dances dances; //Setup MBED connections to PsiSwarm Robot Serial pc(USBTX,USBRX); @@ -166,7 +171,7 @@ timer_ticker.attach(&IF_update_minutes, 300); uptime.start(); primary_i2c.frequency(400000); - IF_setup_serial_interfaces(); + serial.setup_serial_interfaces(); debug("PsiSwarm Robot Library %1.2f\n\n",SOFTWARE_VERSION_CODE); debug("- Setting up serial interface\n"); debug("- Reading firmware: "); @@ -204,7 +209,7 @@ // IF_check_pic_firmware(); debug("- Setting up LED drivers\n"); led.IF_init_leds(); - if(IF_setup_led_expansion_ic() != 0) { + if(i2c_setup.IF_setup_led_expansion_ic() != 0) { debug("- WARNING: No I2C acknowledge for LED driver\n"); system_warnings += 1; } @@ -212,10 +217,10 @@ motors.init_motors(); debug("- Setting up GPIO expansion\n"); reset_encoders(); - IF_setup_gpio_expansion_ic(); + i2c_setup.IF_setup_gpio_expansion_ic(); if(has_temperature_sensor) { debug("- Setting up temperature sensor\n"); - IF_setup_temperature_sensor(); + i2c_setup.IF_setup_temperature_sensor(); } if(has_base_colour_sensor) { debug("- Setting up base colour sensor\n"); @@ -227,7 +232,7 @@ } debug("- Robot ID: %d\n",robot_id); - char switchstate = IF_get_switch_state(); + char switchstate = i2c_setup.IF_get_switch_state(); debug("- Switch State : %d\n",switchstate); debug("- Battery Voltage: %1.3fV\n",sensors.get_battery_voltage()); debug("- DC Voltage : %1.3fV\n",sensors.get_dc_voltage()); @@ -235,15 +240,15 @@ if(has_temperature_sensor){ debug("- Temperature : %1.3fC\n",sensors.get_temperature()); } - char demo = 0; - if(ENABLE_DEMO == 1 && switchstate > 0) demo=1; - display.init_display(demo); + char demo_on = 0; + if(ENABLE_DEMO == 1 && switchstate > 0) demo_on=1; + display.init_display(demo_on); event_handler.attach_us(&IF_handle_events, 1000); - if(demo > 0) { + if(demo_on > 0) { debug("- Demo mode button is pressed\n"); wait(1.0); - demo = IF_get_switch_state(); - if(demo > 0) demo_mode(); + demo_on = i2c_setup.IF_get_switch_state(); + if(demo_on > 0) demo.start_demo_mode(); display.init_display(0); } } @@ -305,7 +310,7 @@ // In this implementation we will only act on positive changes (rising edges) // Subtracting new_state from (new_state & old_state) gives the positive changes char positive_change = switch_byte - (switch_byte & previous_switch_byte); - if(demo_on) demo_handle_switch_event(positive_change); + if(demo_on) demo.demo_handle_switch_event(positive_change); else handle_switch_event(positive_change); }