![](/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
main.cpp
- Committer:
- dreamselec
- Date:
- 2015-10-30
- Revision:
- 2:7a55cb10259f
- Parent:
- 1:92a2a5ef65a8
- Child:
- 3:843b830ee8bd
File content as of revision 2:7a55cb10259f:
#include "mbed.h" #include "WattBob_TextLCD.h" #include "TCS3472_I2C.h" #include "MCP23017.h" #include <string> #include <time.h> //#include <future> #include "globals.h" #include "commander.h" #define BACKLIGHT_ON(INTERFACE) INTERFACE->write_bit(1, 4); #define BACKLIGHT_OFF(INTERFACE) INTERFACE->write_bit(0, 4); #define PRINT_LCD(TEXT) lcd->printf(TEXT); #define CLEAR_LCD() lcd->cls(); #define LCDFL() lcd->locate(0,0); #define LCDSL() lcd->locate(1,0); #define D_LEDS_OFF() i2cport->write_bit(0, 12); i2cport->write_bit(0, 13); i2cport->write_bit(0, 14); i2cport->write_bit(0, 15); #define U_LEDS_OFF() myLED1 = 0; myLED2 = 0; myLED3 = 0; myLED4 = 0; DigitalOut myLED1(LED1); DigitalOut myLED2(LED2); DigitalOut myLED3(LED3); DigitalOut myLED4(LED4); MCP23017 *i2cport; WattBob_TextLCD *lcd; TCS3472_I2C rgb_sensor(p28, p27); Serial pc(USBTX, USBRX); Command myCommand; void initPort(){ myLED3 = 1; pc.baud(gBaudRate); pc.format(8, SerialBase::None, gStopBits); myLED4 = 1; wait (0.1); } int main(){ i2cport = new MCP23017(p9, p10, 0x40); lcd = new WattBob_TextLCD(i2cport); myLED1 = 1; BACKLIGHT_ON(i2cport); CLEAR_LCD(); LCDFL(); PRINT_LCD("Initilizing..."); myLED2 = 1; initPort(); srand((unsigned)time(NULL)); U_LEDS_OFF(); CLEAR_LCD(); myLED1 = 1; FOREVER { Type type; do { type = listenForCommand(); } while (type != -1); recieveCommand(&myCommand, type); pc.printf("%s\r\n<%s>\r\n%s;\r\n", myCommand.commandType, myCommand.commandObject, myCommand.commandString); decodeCommand(&myCommand); } }