![](/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@12:f485796016f8, 2015-11-21 (annotated)
- Committer:
- dreamselec
- Date:
- Sat Nov 21 20:19:54 2015 +0000
- Revision:
- 12:f485796016f8
- Parent:
- 8:e1da2ae62885
- Child:
- 14:cf2f255b5560
Improved command parsing. Now supports multiple commands.
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 |
12:f485796016f8 | 16 | class Commander { |
dreamselec |
12:f485796016f8 | 17 | public: |
dreamselec |
12:f485796016f8 | 18 | Commander(); |
dreamselec |
12:f485796016f8 | 19 | |
dreamselec |
12:f485796016f8 | 20 | CommandTypeRaw typeRaw; |
dreamselec |
12:f485796016f8 | 21 | char typeChar; |
dreamselec |
12:f485796016f8 | 22 | CommandObjectRaw objectRaw; |
dreamselec |
12:f485796016f8 | 23 | std::string object; |
dreamselec |
12:f485796016f8 | 24 | std::string command[kMaxCommandCount - 1]; |
dreamselec |
12:f485796016f8 | 25 | std::string commandValue[kMaxCommandCount - 1]; |
dreamselec |
12:f485796016f8 | 26 | int commandIndex[kMaxCommandCount -1]; |
dreamselec |
12:f485796016f8 | 27 | |
dreamselec |
12:f485796016f8 | 28 | void decodeCommand(CommandTypeRaw type); |
dreamselec |
12:f485796016f8 | 29 | std::string description(); |
dreamselec |
12:f485796016f8 | 30 | |
dreamselec |
12:f485796016f8 | 31 | virtual ~Commander(); |
dreamselec |
12:f485796016f8 | 32 | |
dreamselec |
12:f485796016f8 | 33 | private: |
dreamselec |
12:f485796016f8 | 34 | void readCommandObject(); |
dreamselec |
12:f485796016f8 | 35 | bool readCommand(CommandObjectRaw objectRaw); |
dreamselec |
12:f485796016f8 | 36 | void executeCommand(); |
dreamselec |
12:f485796016f8 | 37 | void resetVariables(); |
dreamselec |
6:98fe30430194 | 38 | }; |
dreamselec | 2:7a55cb10259f | 39 | |
dreamselec |
8:e1da2ae62885 | 40 | #endif |