![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
3rd year group project. Electronic and Electrical Engineering. Heriot-Watt University. This is the code for the mbed for the Automatic Little Object Organiser (ALOO).
Dependencies: MCP23017 TCS3472_I2C WattBob_TextLCD mbed
Diff: globals.cpp
- Revision:
- 17:af373246bf80
- Parent:
- 15:777390eb5afd
- Child:
- 18:44a1c1a30166
diff -r 4a41cb9e525f -r af373246bf80 globals.cpp --- a/globals.cpp Sun Nov 22 21:23:09 2015 +0000 +++ b/globals.cpp Mon Nov 23 23:13:39 2015 +0000 @@ -14,6 +14,7 @@ bool connectedToPC = false; bool runServoTest = false; +PCModes currentMode = None; int readSwitches() { @@ -35,13 +36,14 @@ void connectToPC(CommandTypeRaw typeRaw) { connectedToPC = true; - pc.printf("MBED connected to PC\n"); + pc.printf("INFO:MBED connected to PC.\n"); } void disconnectToPC(CommandTypeRaw typeRaw) { + pc.printf("INFO:MBED disconnected from PC.\n"); connectedToPC = false; - pc.printf("MBED disconnected from PC\n"); + currentMode = None; } void hazBlock(CommandTypeRaw typeRaw) @@ -92,13 +94,13 @@ void getCurrentBlock(CommandTypeRaw typeRaw) { - pc.printf("getting current block readings\n"); + pc.printf("DEBUG: Getting current block readings\n"); } void setIntegrationTimeTo(float integrationTime) { rgbSensor.setIntegrationTime(integrationTime); - pc.printf("setting i-time to %i.\n", integrationTime); + pc.printf("DEBUG: Setting integration-time to %i.\n", integrationTime); } void previewOnPC(bool on) @@ -114,9 +116,15 @@ } -void testServos() +void testServos(Controls state) { + if (state == Start){ + pc.printf("INFO: Running servo test.\n"); runServoTest = true; + }else if (state == Pause){ + pc.printf("INFO: Finished running servo test.\n"); + runServoTest = false; + } } void resetServos() @@ -129,14 +137,16 @@ pc.printf("getting port info.\n"); } -void setPortBaudRate(int baudRate=kDefaultBaudRate) +void setPortBaudRate(int baudRate) { pc.baud(baudRate); - pc.printf("Setting port Baud Rate to: %i\n", baudRate); + wait(0.1); + pc.printf("DEBUG: Setting port Baud Rate to: %i.\n", baudRate); } void setPortParity(int parity){ SerialBase::Parity _parity = static_cast<SerialBase::Parity>(parity); pc.format(8, _parity, 1); - pc.printf("Setting port parity to: %i\n", parity); + wait(0.1); + pc.printf("DEBUG: Setting port parity to: %i.\n", parity); }