Psi Swarm robot library version 0.9
Fork of PsiSwarmV9 by
Revision 20:2b6ebe60929d, committed 2019-07-08
- Comitter:
- richardredpath
- Date:
- Mon Jul 08 10:50:40 2019 +0000
- Parent:
- 19:3e3b03d80ea3
- Commit message:
- Fixed deprecated warnings for callbacks throughout the library
Changed in this revision
diff -r 3e3b03d80ea3 -r 2b6ebe60929d animations.cpp --- a/animations.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/animations.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -74,7 +74,7 @@ led.set_leds(green_state,red_state); animation_counter++; if(animation_counter < 21) { - animation_timeout.attach(this, &Animations::IF_led_run1, 0.05f); + animation_timeout.attach(callback(this, &Animations::IF_led_run1), 0.05f); } else { animation_counter = 0; led.restore_led_states(); @@ -110,7 +110,7 @@ float wiggle_timeout_period = 0.06; //Move less on first 'wiggle' so that we stay in roughly the same place! if(animation_counter == 0) wiggle_timeout_period = 0.03; - animation_timeout.attach(this, &Animations::IF_vibrate, wiggle_timeout_period); + animation_timeout.attach(callback(this, &Animations::IF_vibrate), wiggle_timeout_period); } else { animation_counter = 0; motors.brake();
diff -r 3e3b03d80ea3 -r 2b6ebe60929d colour.cpp --- a/colour.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/colour.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -121,7 +121,7 @@ { colour_ticker_on = 1; colour_ticker_period = period_ms; - colour_ticker.attach_us(this,&Colour::IF_colour_ticker_start, 100); + colour_ticker.attach_us(callback(this, &Colour::IF_colour_ticker_start), 100); } void Colour::stop_colour_ticker() @@ -134,7 +134,7 @@ { led.set_base_led(1); enable_base_colour_sensor(); - colour_ticker.attach_us(this,&Colour::IF_colour_ticker_main, 25000); + colour_ticker.attach_us(callback(this, &Colour::IF_colour_ticker_main), 25000); } void Colour::IF_colour_ticker_main() @@ -148,7 +148,7 @@ get_calibrated_colour(rgb_readings,adjusted); last_detected_colour = identify_colour_from_calibrated_colour_scores(adjusted); } - if(colour_ticker_on == 1)colour_ticker.attach_us(this,&Colour::IF_colour_ticker_start, colour_ticker_period * 1000); + if(colour_ticker_on == 1)colour_ticker.attach_us(callback(this, &Colour::IF_colour_ticker_start), colour_ticker_period * 1000); }
diff -r 3e3b03d80ea3 -r 2b6ebe60929d demo.cpp --- a/demo.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/demo.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -126,7 +126,7 @@ if(!handling_event) { handling_event = 1; last_switch_pressed = switch_pressed; - demo_event.attach_us(this,&Demo::demo_event_thread, 1000); + demo_event.attach_us(callback(this, &Demo::demo_event_thread), 1000); } } @@ -866,7 +866,7 @@ display.write_string(bottomline); // Periodically update when on sensors menu if(top_menu == 2 && level == 1) { - demo_event.attach(this,&Demo::demo_event_thread, 0.25); + demo_event.attach(callback(this, &Demo::demo_event_thread), 0.25); } } @@ -1041,7 +1041,7 @@ if(test_step == 4) test_step = 0; } - demo_timeout.attach_us(this,&Demo::quick_test_cycle, wait_period); + demo_timeout.attach_us(callback(this, &Demo::quick_test_cycle), wait_period); } void Demo::toggle_quick_test() @@ -1060,12 +1060,12 @@ } else { // Reset all LEDs, motors, display pc.printf("\n________________________________________\n"); - pc.printf("Self test started at %f\n\n",psi.get_uptime(),test_warnings); + pc.printf("Self test started at %f\n\n", psi.get_uptime());//, test_warnings); display.clear_display(); test_step = 0; test_substep = 0; demo_running = 1; - demo_timeout.attach_us(this,&Demo::quick_test_cycle,1000); + demo_timeout.attach_us(callback(this, &Demo::quick_test_cycle), 1000); } } @@ -1078,7 +1078,7 @@ speed = 0; led_step = 0; demo_running = 1; - demo_timeout.attach_us(this,&Demo::line_demo_cycle,1000); + demo_timeout.attach_us(callback(this, &Demo::line_demo_cycle), 1000); } void Demo::start_obstacle_demo() @@ -1090,7 +1090,7 @@ speed = 0; led_step = 0; demo_running = 1; - demo_timeout.attach_us(this,&Demo::obstacle_demo_cycle,1000); + demo_timeout.attach_us(callback(this, &Demo::obstacle_demo_cycle), 1000); } void Demo::start_colour_demo() @@ -1103,7 +1103,7 @@ led_step = 0; demo_running = 1; colour.start_colour_ticker(100); - demo_timeout.attach_us(this,&Demo::colour_demo_cycle,1000); + demo_timeout.attach_us(callback(this, &Demo::colour_demo_cycle), 1000); } void Demo::start_stress_demo() @@ -1119,7 +1119,7 @@ stress_step = 0; spin_step = 0; demo_running = 1; - demo_timeout.attach_us(this,&Demo::stress_demo_cycle,1000); + demo_timeout.attach_us(callback(this, &Demo::stress_demo_cycle), 1000); } void Demo::start_spinning_demo() @@ -1132,7 +1132,7 @@ led_step = 0; spin_step = 0; demo_running = 1; - demo_timeout.attach_us(this,&Demo::spinning_demo_cycle,1000); + demo_timeout.attach_us(callback(this, &Demo::spinning_demo_cycle), 1000); } void Demo::line_demo_cycle() @@ -1209,7 +1209,7 @@ demo_timer.reset(); } - if(demo_running == 1)demo_timeout.attach_us(this,&Demo::line_demo_cycle,500); + if(demo_running == 1)demo_timeout.attach_us(callback(this, &Demo::line_demo_cycle), 500); else { motors.stop(); display.set_backlight_brightness(bl_brightness * 0.01f); @@ -1256,7 +1256,7 @@ } demo_timer.reset(); } - if(demo_running == 1)demo_timeout.attach_us(this,&Demo::stress_demo_cycle,500); + if(demo_running == 1)demo_timeout.attach_us(callback(this, &Demo::stress_demo_cycle), 500); else { motors.stop(); display.set_backlight_brightness(bl_brightness * 0.01f); @@ -1494,7 +1494,7 @@ } demo_timer.reset(); } - if(demo_running == 1)demo_timeout.attach_us(this,&Demo::spinning_demo_cycle,500); + if(demo_running == 1)demo_timeout.attach_us(callback(this, &Demo::spinning_demo_cycle), 500); else { motors.stop(); display.set_backlight_brightness(bl_brightness * 0.01f); @@ -1562,7 +1562,7 @@ } demo_timer.reset(); } - if(demo_running == 1)demo_timeout.attach_us(this,&Demo::colour_demo_cycle,200); + if(demo_running == 1)demo_timeout.attach_us(callback(this, &Demo::colour_demo_cycle), 200); else { motors.stop(); display.set_backlight_brightness(bl_brightness * 0.01f); @@ -1639,7 +1639,7 @@ } demo_timer.reset(); } - if(demo_running == 1)demo_timeout.attach_us(this,&Demo::obstacle_demo_cycle,200); + if(demo_running == 1)demo_timeout.attach_us(callback(this, &Demo::obstacle_demo_cycle), 200); else { motors.stop(); display.set_backlight_brightness(bl_brightness * 0.01f);
diff -r 3e3b03d80ea3 -r 2b6ebe60929d display.cpp --- a/display.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/display.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -102,7 +102,7 @@ write_string(" YORK ROBOTICS"); set_position(1,0); write_string(" LABORATORY"); - init_timeout.attach(this,&Display::post_init,0.25);} + init_timeout.attach(callback(this, &Display::post_init),0.25);} else { set_position(0,0); write_string("Hold button to"); @@ -144,7 +144,7 @@ sprintf(line,"VERSION %1.2f", SOFTWARE_VERSION_CODE ); set_position(1,0); write_string(line); - init_timeout.attach(this,&Display::post_post_init,0.25); + init_timeout.attach(callback(this, &Display::post_post_init), 0.25); } void Display::post_post_init(){ @@ -235,7 +235,7 @@ backlight_off_time = 10000 - backlight_on_time; backlight_step = 0; _backlight = 0; - backlight_timeout.attach_us(this,&Display::IF_backlight_toggle,backlight_off_time); + backlight_timeout.attach_us(callback(this, &Display::IF_backlight_toggle), backlight_off_time); } } } @@ -244,11 +244,11 @@ if(backlight_step == 0){ _backlight = 1; backlight_step = 1; - backlight_timeout.attach_us(this,&Display::IF_backlight_toggle,backlight_on_time); + backlight_timeout.attach_us(callback(this, &Display::IF_backlight_toggle), backlight_on_time); } else { _backlight = 0; backlight_step = 0; - backlight_timeout.attach_us(this,&Display::IF_backlight_toggle,backlight_off_time); + backlight_timeout.attach_us(callback(this, &Display::IF_backlight_toggle), backlight_off_time); } } void Display::clear_display(){ @@ -295,8 +295,8 @@ if(multipage_mode == 1){ strncpy(multipage, message + 32, length - 32); multipage_length = length - 32; - debug_timeout.attach(this,&Display::IF_debug_multipage,PAGE_TIME); - } else debug_timeout.attach(this,&Display::IF_restore_page,CLEAR_TIME); + debug_timeout.attach(callback(this, &Display::IF_debug_multipage), PAGE_TIME); + } else debug_timeout.attach(callback(this,&Display::IF_restore_page), CLEAR_TIME); } void Display::IF_restore_page(){ @@ -344,8 +344,8 @@ strncpy(temp, multipage + 32, multipage_length - 32); multipage_length -= 32; strncpy(multipage, temp, multipage_length); - debug_timeout.attach(this,&Display::IF_debug_multipage,PAGE_TIME); - }else debug_timeout.attach(this,&Display::IF_restore_page,CLEAR_TIME); + debug_timeout.attach(callback(this, &Display::IF_debug_multipage), PAGE_TIME); + }else debug_timeout.attach(callback(this,&Display::IF_restore_page), CLEAR_TIME); } void Display::_set_display(){
diff -r 3e3b03d80ea3 -r 2b6ebe60929d i2c_setup.cpp --- a/i2c_setup.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/i2c_setup.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -207,7 +207,7 @@ testing_voltage_regulators_flag = 0; //Setup interrupt handler for GPIO interrupts gpio_interrupt.mode(PullUp); - gpio_interrupt.rise(this,&Setup::IF_handle_gpio_interrupt); + gpio_interrupt.rise(callback(this, &Setup::IF_handle_gpio_interrupt)); //pc.printf("%c %c",gpio_byte0,gpio_byte1); //Secondary GPIO expansion IC is MCP23009 @@ -227,7 +227,7 @@ primary_i2c.write(AUX_IC_ADDRESS,data,2,false); //My interrupt is not so reliable: poll with a 50ms timeout in case interrupts aren't handled - update_timeout.attach_us(this,&Setup::IF_update_gpio_inputs,50000); + update_timeout.attach_us(callback(this, &Setup::IF_update_gpio_inputs),50000); //return ret_val; } @@ -378,7 +378,7 @@ if(data[1]!=gpio_byte1) { IF_parse_gpio_byte1(data[1]); } - update_timeout.attach_us(this,&Setup::IF_update_gpio_inputs,50000); + update_timeout.attach_us(callback(this, &Setup::IF_update_gpio_inputs),50000); }
diff -r 3e3b03d80ea3 -r 2b6ebe60929d led.cpp --- a/led.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/led.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -72,7 +72,7 @@ { save_led_states(); set_leds(0xFF,0xFF); - blink_led_timeout.attach(this,&Led::restore_led_states, timeout); + blink_led_timeout.attach(callback(this, &Led::restore_led_states), timeout); } void Led::set_center_led(char state)
diff -r 3e3b03d80ea3 -r 2b6ebe60929d motors.cpp --- a/motors.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/motors.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -108,7 +108,7 @@ //Start moving forward(speed); brake_when_done = brake; - time_based_action_timeout.attach_us(this,&Motors::IF_end_time_based_action,microseconds); + time_based_action_timeout.attach_us(callback(this, &Motors::IF_end_time_based_action), microseconds); } //Turn for a set period of time @@ -120,7 +120,7 @@ //Start turning turn(speed); brake_when_done = brake; - time_based_action_timeout.attach_us(this,&Motors::IF_end_time_based_action,microseconds); + time_based_action_timeout.attach_us(callback(this, &Motors::IF_end_time_based_action), microseconds); } //Returns the limit of degrees available to turn in given time @@ -188,7 +188,7 @@ turn(speed); brake_when_done = brake; - time_based_action_timeout.attach_us(this,&Motors::IF_end_time_based_action,turn_time); + time_based_action_timeout.attach_us(callback(this, &Motors::IF_end_time_based_action), turn_time); return turn_time; } }
diff -r 3e3b03d80ea3 -r 2b6ebe60929d psiswarm.cpp --- a/psiswarm.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/psiswarm.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -169,7 +169,7 @@ { firmware_version=0; timer_minute_count = 0; - timer_ticker.attach(this,&Psiswarm::IF_update_minutes, 300); + timer_ticker.attach(callback(this, &Psiswarm::IF_update_minutes), 300); uptime.start(); primary_i2c.frequency(400000); serial.setup_serial_interfaces(); @@ -285,7 +285,7 @@ char demo_on = 0; if(ENABLE_DEMO == 1 && switchstate > 0) demo_on=1; display.init_display_end(demo_on); - event_handler.attach_us(this,&Psiswarm::IF_handle_events, 1000); + event_handler.attach_us(callback(this, &Psiswarm::IF_handle_events), 1000); if(demo_on > 0) { debug("- Demo mode button is pressed\n"); wait(0.6); @@ -386,7 +386,7 @@ { user_code_restore_mode = user_code_running; user_code_running = 0; - pause_usercode_timeout.attach(this,&Psiswarm::IF_end_pause_user_code, period); + pause_usercode_timeout.attach(callback(this, &Psiswarm::IF_end_pause_user_code), period); } void Psiswarm::IF_end_pause_user_code()
diff -r 3e3b03d80ea3 -r 2b6ebe60929d sensors.cpp --- a/sensors.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/sensors.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -33,7 +33,7 @@ void Sensors::enable_ultrasonic_ticker() { - ultrasonic_ticker.attach_us(this,&Sensors::update_ultrasonic_measure,100000); + ultrasonic_ticker.attach_us(callback(this, &Sensors::update_ultrasonic_measure), 100000); } void Sensors::disable_ultrasonic_ticker() @@ -51,7 +51,7 @@ command[1] = 0x51; // Get result is centimeters primary_i2c.write(ULTRASONIC_ADDRESS, command, 2); // Send the command to start a ranging burst } - ultrasonic_timeout.attach_us(this,&Sensors::IF_read_ultrasonic_measure,70000); + ultrasonic_timeout.attach_us(callback(this, &Sensors::IF_read_ultrasonic_measure), 70000); } else { psi.debug("WARNING: Ultrasonic sensor called too frequently.\n"); }
diff -r 3e3b03d80ea3 -r 2b6ebe60929d serial.cpp --- a/serial.cpp Mon Jun 05 22:47:14 2017 +0000 +++ b/serial.cpp Mon Jul 08 10:50:40 2019 +0000 @@ -55,11 +55,11 @@ { if(ENABLE_PC_SERIAL) { pc.baud(PC_BAUD); - pc.attach(this,&SerialControl::IF_pc_rx_callback, Serial::RxIrq); + pc.attach(callback(this, &SerialControl::IF_pc_rx_callback), Serial::RxIrq); } if(ENABLE_BLUETOOTH) { bt.baud(BLUETOOTH_BAUD); - bt.attach(this,&SerialControl::IF_bt_rx_callback, Serial::RxIrq); + bt.attach(callback(this, &SerialControl::IF_bt_rx_callback), Serial::RxIrq); } } @@ -77,7 +77,7 @@ file_length = 0; user_code_restore_mode = user_code_running; user_code_running = 0; - ft_timeout.attach(this,&SerialControl::IF_file_transfer_timeout,2.0); + ft_timeout.attach(callback(this, &SerialControl::IF_file_transfer_timeout), 2.0); } @@ -138,7 +138,7 @@ psi.debug("Target filename:%s\n",filename); //Send acknowledge ("FN") ft_timeout.detach(); - ft_timeout.attach(this,&SerialControl::IF_file_transfer_timeout,2.0); + ft_timeout.attach(callback(this, &SerialControl::IF_file_transfer_timeout), 2.0); bt.printf("%c%c%s",RESPONSE_MESSAGE_BYTE,2,"FN"); file_transfer_state = 1; } @@ -171,7 +171,7 @@ //file_data = (char *) malloc(target_size); psi.debug("File size %d bytes (%d blocks of %d bytes)\n",file_length,final_block,block_size); ft_timeout.detach(); - ft_timeout.attach(this,&SerialControl::IF_file_transfer_timeout,1.0); + ft_timeout.attach(callback(this, &SerialControl::IF_file_transfer_timeout), 1.0); //Send acknowledge (size of file) bt.printf("%c%c%c%c%c",RESPONSE_MESSAGE_BYTE,3,message[1],message[2],message[3]); } @@ -209,7 +209,7 @@ psi.debug("Message packet %d received and written\n",block_index); //Send acknowledge ("D") ft_timeout.detach(); - ft_timeout.attach(this,&SerialControl::IF_file_transfer_timeout,1.0); + ft_timeout.attach(callback(this, &SerialControl::IF_file_transfer_timeout), 1.0); bt.printf("%c%c%s",RESPONSE_MESSAGE_BYTE,1,"D"); } else { //Last data block written @@ -1168,7 +1168,7 @@ } else { if(count == 1) { if(tc == COMMAND_MESSAGE_BYTE) { - pc_command_timeout.attach(this,&SerialControl::IF_pc_rx_command_timeout,command_timeout_period); + pc_command_timeout.attach(callback(this, &SerialControl::IF_pc_rx_command_timeout), command_timeout_period); pc_command_message_started = 1; pc_command_message_byte = 0; @@ -1321,7 +1321,7 @@ count = 5; } } else { - bt_command_timeout.attach(this,&SerialControl::IF_bt_rx_command_timeout,command_timeout_period); + bt_command_timeout.attach(callback(this, &SerialControl::IF_bt_rx_command_timeout), command_timeout_period); bt_command_message[bt_command_message_byte] = tc; bt_command_message_byte ++; }