![](/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
commander.h@32:9a4046224b11, 2015-12-17 (annotated)
- Committer:
- dreamselec
- Date:
- Thu Dec 17 17:23:24 2015 +0100
- Revision:
- 32:9a4046224b11
- Parent:
- 24:02c61793f90b
Comments and clean up.
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 |
32:9a4046224b11 | 4 | // |
dreamselec |
32:9a4046224b11 | 5 | // Parses and executes commands received from the PC. |
dreamselec |
32:9a4046224b11 | 6 | // |
dreamselec |
6:98fe30430194 | 7 | |
dreamselec | 2:7a55cb10259f | 8 | #include "globals.h" |
dreamselec | 2:7a55cb10259f | 9 | |
dreamselec |
6:98fe30430194 | 10 | #ifndef _commander_h_ |
dreamselec |
6:98fe30430194 | 11 | #define _commander_h_ |
dreamselec | 2:7a55cb10259f | 12 | |
dreamselec |
8:e1da2ae62885 | 13 | const int kMaxCommandCount = 10; |
dreamselec |
23:db91aaa43a9e | 14 | enum CommandObjectRaw { InvalidObject = -1, MBED = 0, PC = 1, ColourSensor = 2, Servos = 3, Port = 4, BreakBeam = 5 }; |
dreamselec | 24:02c61793f90b | 15 | extern std::string CommandObjectValue [6]; |
dreamselec | 24:02c61793f90b | 16 | extern std::string CommandObjectCommandsValue [6][kMaxCommandCount]; |
dreamselec |
8:e1da2ae62885 | 17 | |
dreamselec | 2:7a55cb10259f | 18 | |
dreamselec | 24:02c61793f90b | 19 | class Commander { |
dreamselec | 24:02c61793f90b | 20 | public: |
dreamselec | 24:02c61793f90b | 21 | Commander(); |
dreamselec | 24:02c61793f90b | 22 | |
dreamselec | 24:02c61793f90b | 23 | CommandTypeRaw typeRaw; |
dreamselec | 24:02c61793f90b | 24 | char typeChar; |
dreamselec | 24:02c61793f90b | 25 | CommandObjectRaw objectRaw; |
dreamselec | 24:02c61793f90b | 26 | std::string object; |
dreamselec | 24:02c61793f90b | 27 | std::string command[kMaxCommandCount - 1]; |
dreamselec | 24:02c61793f90b | 28 | std::string commandValue[kMaxCommandCount - 1]; |
dreamselec | 24:02c61793f90b | 29 | int commandIndex[kMaxCommandCount -1]; |
dreamselec |
14:cf2f255b5560 | 30 | bool replyCommands; |
dreamselec | 24:02c61793f90b | 31 | |
dreamselec | 24:02c61793f90b | 32 | void decodeCommand(CommandTypeRaw type); |
dreamselec | 24:02c61793f90b | 33 | std::string description(); |
dreamselec | 24:02c61793f90b | 34 | |
dreamselec | 24:02c61793f90b | 35 | virtual ~Commander(); |
dreamselec | 24:02c61793f90b | 36 | |
dreamselec | 24:02c61793f90b | 37 | private: |
dreamselec | 24:02c61793f90b | 38 | void readCommandObject(); |
dreamselec | 24:02c61793f90b | 39 | bool readCommand(CommandObjectRaw objectRaw); |
dreamselec | 24:02c61793f90b | 40 | void executeCommand(); |
dreamselec | 24:02c61793f90b | 41 | void resetVariables(); |
dreamselec |
6:98fe30430194 | 42 | }; |
dreamselec | 2:7a55cb10259f | 43 | |
dreamselec |
8:e1da2ae62885 | 44 | #endif |