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
commander.h@8:e1da2ae62885, 2015-11-16 (annotated)
- Committer:
- dreamselec
- Date:
- Mon Nov 16 22:20:11 2015 +0000
- Revision:
- 8:e1da2ae62885
- Parent:
- 6:98fe30430194
- Child:
- 12:f485796016f8
Ready for PC command parsing testing. Currently only prints command to PC.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dreamselec |
6:98fe30430194 | 1 | // |
dreamselec |
6:98fe30430194 | 2 | // commander.h |
dreamselec |
6:98fe30430194 | 3 | // Created by Chandan Siyag on 14/11/2015. |
dreamselec |
6:98fe30430194 | 4 | |
dreamselec | 2:7a55cb10259f | 5 | #include "globals.h" |
dreamselec | 2:7a55cb10259f | 6 | |
dreamselec |
6:98fe30430194 | 7 | #ifndef _commander_h_ |
dreamselec |
6:98fe30430194 | 8 | #define _commander_h_ |
dreamselec | 2:7a55cb10259f | 9 | |
dreamselec |
8:e1da2ae62885 | 10 | const int kMaxCommandCount = 10; |
dreamselec |
8:e1da2ae62885 | 11 | enum CommandObjectRaw { InvalidObject = -1, MBED = 0, PC = 1, ColourSensor = 2, Servos = 3, Port = 4 }; |
dreamselec |
8:e1da2ae62885 | 12 | extern std::string CommandObjectValue [5]; |
dreamselec |
8:e1da2ae62885 | 13 | extern std::string CommandObjectCommandsValue [5][kMaxCommandCount]; |
dreamselec |
8:e1da2ae62885 | 14 | |
dreamselec | 2:7a55cb10259f | 15 | |
dreamselec |
6:98fe30430194 | 16 | class Commander { |
dreamselec |
6:98fe30430194 | 17 | public: |
dreamselec |
6:98fe30430194 | 18 | Commander(); |
dreamselec |
6:98fe30430194 | 19 | |
dreamselec |
6:98fe30430194 | 20 | CommandTypeRaw typeRaw; |
dreamselec |
6:98fe30430194 | 21 | char typeChar; |
dreamselec |
8:e1da2ae62885 | 22 | CommandObjectRaw objectRaw; |
dreamselec |
6:98fe30430194 | 23 | std::string object; |
dreamselec |
6:98fe30430194 | 24 | std::string command; |
dreamselec |
8:e1da2ae62885 | 25 | std::string commandValue; |
dreamselec |
8:e1da2ae62885 | 26 | int commandValueIndex; |
dreamselec |
6:98fe30430194 | 27 | |
dreamselec |
6:98fe30430194 | 28 | void decodeCommand(CommandTypeRaw type); |
dreamselec |
6:98fe30430194 | 29 | std::string description(); |
dreamselec |
6:98fe30430194 | 30 | |
dreamselec |
6:98fe30430194 | 31 | virtual ~Commander(); |
dreamselec |
6:98fe30430194 | 32 | |
dreamselec |
6:98fe30430194 | 33 | private: |
dreamselec |
6:98fe30430194 | 34 | void readCommandObject(); |
dreamselec |
8:e1da2ae62885 | 35 | void readCommand(CommandObjectRaw objectRaw); |
dreamselec |
8:e1da2ae62885 | 36 | void executeCommand(); |
dreamselec |
8:e1da2ae62885 | 37 | void resetVariables(); |
dreamselec |
6:98fe30430194 | 38 | }; |
dreamselec | 2:7a55cb10259f | 39 | |
dreamselec |
8:e1da2ae62885 | 40 | #endif |