![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Component Test's Software to work with "Universal Controller Box" - Software is an interpreter or "compiler" for programs to be done with a .txt file and read off of the SD Card
Dependencies: BridgeDriver FrontPanelButtons MCP23017 SDFileSystem TextLCD mbed
Initialization.hpp@9:5a0c4c6e39c7, 2014-09-24 (annotated)
- Committer:
- mehatfie
- Date:
- Wed Sep 24 22:23:00 2014 +0000
- Revision:
- 9:5a0c4c6e39c7
- Parent:
- 6:d1594fd2ec5a
- Child:
- 11:bc9cd2869f95
- System error checking and syntax checking should be completed; --- Compiled code still functions correctly; --- All error checking has not been checked that they indeed error out / not error out and function as planned
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mehatfie | 0:22618cf06f45 | 1 | #ifndef INITIALIZATION_HPP |
mehatfie | 0:22618cf06f45 | 2 | #define INITIALIZATION_HPP |
mehatfie | 0:22618cf06f45 | 3 | |
mehatfie | 0:22618cf06f45 | 4 | #include "mbed.h" |
mehatfie | 0:22618cf06f45 | 5 | #include "LocalPinNames.h" |
mehatfie | 0:22618cf06f45 | 6 | #include "BridgeDriver.h" |
mehatfie | 0:22618cf06f45 | 7 | #include "FrontPanelButtons.h" |
mehatfie | 0:22618cf06f45 | 8 | #include "TextLCD.h" |
mehatfie | 0:22618cf06f45 | 9 | #include "SDFileSystem.h" |
mehatfie | 2:3e7baa3e3fec | 10 | #include <string> |
mehatfie | 2:3e7baa3e3fec | 11 | #include <vector> |
mehatfie | 0:22618cf06f45 | 12 | |
mehatfie | 3:078e9a1e8be3 | 13 | |
mehatfie | 3:078e9a1e8be3 | 14 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 15 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 16 | /************************** <MUST MODIFY> *************************/ |
mehatfie | 3:078e9a1e8be3 | 17 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 18 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 19 | |
mehatfie | 4:86d0d04cc055 | 20 | enum DeviceType{MOTOR, VOLTAGE_DRIVER, PIN_IN}; //ADD DEVICE NAME |
mehatfie | 4:86d0d04cc055 | 21 | static const enum DeviceType Device_Map[] = {MOTOR, VOLTAGE_DRIVER, PIN_IN}; //AND HERE ***NOTE TO KEEP SAME ORDER |
mehatfie | 3:078e9a1e8be3 | 22 | |
mehatfie | 3:078e9a1e8be3 | 23 | /************************** <MUST MODIFY> *************************/ |
mehatfie | 3:078e9a1e8be3 | 24 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 25 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 26 | |
mehatfie | 3:078e9a1e8be3 | 27 | |
mehatfie | 3:078e9a1e8be3 | 28 | |
mehatfie | 3:078e9a1e8be3 | 29 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 30 | /*** <Global Initializations> ***/ |
mehatfie | 3:078e9a1e8be3 | 31 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 32 | |
mehatfie | 0:22618cf06f45 | 33 | //Initializations |
mehatfie | 2:3e7baa3e3fec | 34 | extern Timer timer; // general purpose timer |
mehatfie | 2:3e7baa3e3fec | 35 | extern I2C i2c; // I2C bus (SDA, SCL) |
mehatfie | 2:3e7baa3e3fec | 36 | extern BridgeDriver bridges; // Bridge |
mehatfie | 2:3e7baa3e3fec | 37 | extern TextLCD_I2C lcd; // LCD |
mehatfie | 2:3e7baa3e3fec | 38 | extern SDFileSystem sd; // the pinout on the mbed LPC1768 |
mehatfie | 0:22618cf06f45 | 39 | |
mehatfie | 2:3e7baa3e3fec | 40 | extern DigitalIn killSw; |
mehatfie | 2:3e7baa3e3fec | 41 | |
mehatfie | 2:3e7baa3e3fec | 42 | extern const int MAX_LINE_LENGTH; |
mehatfie | 6:d1594fd2ec5a | 43 | extern int DummyMode; |
mehatfie | 3:078e9a1e8be3 | 44 | |
mehatfie | 3:078e9a1e8be3 | 45 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 46 | /*** <Function Initializations> ***/ |
mehatfie | 3:078e9a1e8be3 | 47 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 48 | |
mehatfie | 3:078e9a1e8be3 | 49 | void fullInit(); //Perform and call any needed initializations |
mehatfie | 0:22618cf06f45 | 50 | |
mehatfie | 3:078e9a1e8be3 | 51 | void initLCD(void); //Initialize the LCD |
mehatfie | 3:078e9a1e8be3 | 52 | |
mehatfie | 9:5a0c4c6e39c7 | 53 | void ErrorOut(string, int); //Outputs error message, line number, and formatting to LCD |
mehatfie | 0:22618cf06f45 | 54 | |
mehatfie | 3:078e9a1e8be3 | 55 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 56 | /*** <Line Data Struct Initializations> ***/ |
mehatfie | 3:078e9a1e8be3 | 57 | /******************************************************************************/ |
mehatfie | 0:22618cf06f45 | 58 | |
mehatfie | 5:e36e0538a903 | 59 | struct LineData{ |
mehatfie | 0:22618cf06f45 | 60 | |
mehatfie | 5:e36e0538a903 | 61 | //string fullLine; //full line, starting from the beginning |
mehatfie | 5:e36e0538a903 | 62 | int lineNumber; //current line number in the program txt file that is running |
mehatfie | 2:3e7baa3e3fec | 63 | //vector<string> word; |
mehatfie | 5:e36e0538a903 | 64 | string word[50]; //array of words from the line of text, assuming no more than 50 words will be in any given line |
mehatfie | 5:e36e0538a903 | 65 | //in this initialization there are 15 string (pointers) of size MAX_LINE_LENGTH each |
mehatfie | 5:e36e0538a903 | 66 | int numWords; //Number of words in the given line |
mehatfie | 1:5731f31f96be | 67 | int lineAddress; |
mehatfie | 0:22618cf06f45 | 68 | }; |
mehatfie | 0:22618cf06f45 | 69 | |
mehatfie | 2:3e7baa3e3fec | 70 | // |
mehatfie | 5:e36e0538a903 | 71 | //extern struct Line lineData; |
mehatfie | 0:22618cf06f45 | 72 | |
mehatfie | 2:3e7baa3e3fec | 73 | |
mehatfie | 2:3e7baa3e3fec | 74 | |
mehatfie | 3:078e9a1e8be3 | 75 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 76 | /*** <Parent Device Class Initializations> ***/ |
mehatfie | 3:078e9a1e8be3 | 77 | /******************************************************************************/ |
mehatfie | 2:3e7baa3e3fec | 78 | |
mehatfie | 3:078e9a1e8be3 | 79 | extern const string DeviceNames[]; |
mehatfie | 2:3e7baa3e3fec | 80 | extern int numDevices; |
mehatfie | 2:3e7baa3e3fec | 81 | extern int currNumDevices; |
mehatfie | 2:3e7baa3e3fec | 82 | |
mehatfie | 2:3e7baa3e3fec | 83 | |
mehatfie | 2:3e7baa3e3fec | 84 | class Device{ |
mehatfie | 2:3e7baa3e3fec | 85 | |
mehatfie | 2:3e7baa3e3fec | 86 | public: |
mehatfie | 2:3e7baa3e3fec | 87 | string name; |
mehatfie | 9:5a0c4c6e39c7 | 88 | int errorFlag; |
mehatfie | 2:3e7baa3e3fec | 89 | enum DeviceType type; |
mehatfie | 5:e36e0538a903 | 90 | static Device* newDevice(int, string, LineData); |
mehatfie | 5:e36e0538a903 | 91 | virtual int interpret(LineData&) = 0; |
mehatfie | 9:5a0c4c6e39c7 | 92 | virtual int off() = 0; |
mehatfie | 2:3e7baa3e3fec | 93 | }; |
mehatfie | 2:3e7baa3e3fec | 94 | |
mehatfie | 2:3e7baa3e3fec | 95 | extern vector<Device*> devices; //Initialize array of devices, initially assume 15 devices will be used (will expand as needed) |
mehatfie | 2:3e7baa3e3fec | 96 | |
mehatfie | 2:3e7baa3e3fec | 97 | |
mehatfie | 0:22618cf06f45 | 98 | #endif |