Practical Robotics Modular Robot Library
Diff: robot.h
- Revision:
- 4:c2e933d53bea
- Parent:
- 3:8762f6b2ea8d
- Child:
- 5:6da8daaeb9f7
--- a/robot.h Mon Nov 28 22:41:14 2016 +0000 +++ b/robot.h Mon Jan 02 15:17:22 2017 +0000 @@ -1,5 +1,3 @@ - - #ifndef ROBOT_H #define ROBOT_H @@ -8,9 +6,16 @@ #include "sensors.h" #include "motors.h" #include "calibration.h" +#include "serialcomms.h" #define LED_ADDRESS 0xC0 #define ADC_ADDRESS 0x90 +#define COMMAND_MESSAGE_BYTE 0x1D +#define ACKNOWLEDGE_MESSAGE_BYTE 0x1E +#define RESPONSE_MESSAGE_BYTE 0x1F +#define STATUS_MESSAGE_BYTE 0x1C +#define IR_MESSAGE_BYTE 0x1B +#define SOFTWARE_VERSION_CODE 0.10 // SERIAL INTERFACES SETTINGS @@ -24,15 +29,15 @@ /* BLUETOOTH_BAUD [recommended=115200]: Baud rate for the BlueSMIRF module */ #define BLUETOOTH_BAUD 115200 -/* PC_BAUD [recommended=460800 for optimal performance, 115200 for compatability]: Baud rate for the PC USB serial module */ -//#define PC_BAUD 460800 -#define PC_BAUD 115200 +/* PC_BAUD [recommended=460800 for optimal performance with RPi, 115200 for compatability]: Baud rate for the RPi USB serial module */ +//#define PC_BAUD 115200 +#define PC_BAUD 460800 /* DEBUG_MODE [1=on, 0=off]: Enable to allow debug messages to be sent of one of the serial interfaces */ #define DEBUG_MODE 1 -/* DEBUG_OUTPUT_STREAM [1=PC\USB 2=BlueSmirf 4=Display]: Specify which output stream(s) should be used by default for debug messages, if enabled*/ -#define DEBUG_OUTPUT_STREAM 1 +/* DEBUG_OUTPUT_STREAM [1=PC\USB 2=BlueSmirf 4=Display]: Specify which output stream(s) should be used by default for debug messages, if enabled. Recommended to use BT for debug messages.*/ +#define DEBUG_OUTPUT_STREAM 2 // To update sensors 10 times a second (8 x 0.0125 = 0.1) #define SENSOR_TICKER_PERIOD 0.0125 @@ -51,13 +56,18 @@ extern DigitalOut mbed_led2; extern DigitalOut mbed_led3; extern DigitalOut mbed_led4; +extern DigitalOut case_led; extern AnalogIn vin_battery; extern Serial pc; +extern Serial bt; +extern SerialComms serial; extern Led led; extern Sensors sensors; extern Motors motors; extern volatile char i2c_lock; -extern char status_message [16]; +extern char debug_mode; +extern char debug_output; +extern char status_message []; /** * The Robot class contains the core functions for the robot @@ -94,21 +104,22 @@ */ void debug(const char* format, ...); - /** - * Setup the serial interfaces (pc, bt) at the correct baud rate and attach listeners - */ - void setup_serial_interfaces(void); /** - * Updates the 14-byte status message + * Toggles the current state of the MBED case led (use with a ticker to blink LED etc) */ + void case_led_toggle(void); + + + /** + * Update the global 8-character status message + */ void update_status_message(void); private: void _update_minutes(void); - void _bt_rx_callback(void); - void _pc_rx_callback(void); }; +extern Robot robot; #endif \ No newline at end of file