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.cpp
- Committer:
- mehatfie
- Date:
- 2014-09-24
- Revision:
- 9:5a0c4c6e39c7
- Parent:
- 6:d1594fd2ec5a
- Child:
- 11:bc9cd2869f95
File content as of revision 9:5a0c4c6e39c7:
#include "Initialization.hpp"
#include "Motor.hpp"
#include "VoltageDriver.hpp"
#include "PinIN.hpp"
/**********************************************************************************************************************************/
/**********************************************************************************************************************************/
/************************** <MUST MODIFY> *************************/
/**********************************************************************************************************************************/
/**********************************************************************************************************************************/
// ADD YOUR DEVICE NAME THE \\EXACT SAME WAY\\ AS THE ENUM NAME YOU DECLARED IN THE.hpp
// Must Declare names in reverse order for some reason...., it's the way they're indexed I believe
const string DeviceNames[] = {"MOTOR", "VOLTAGE_DRIVER", "PIN_IN"};
// ADD YOUR DEVICE TO THE LIST BELOW, CALLING YOUR DEVICE CLASS AS SHOWN
Device* Device::newDevice(int deviceFound, string _name, LineData lineData){
switch (Device_Map[deviceFound]){
case MOTOR: return new Motor(lineData); break;
case VOLTAGE_DRIVER: return new VoltageDriver(lineData); break;
case PIN_IN: return new PinIN(lineData); break;
//********** ADD NEXT DEVICE ABOVE **************//
default: break;
}
}
/************************** <MUST MODIFY> *************************/
/**********************************************************************************************************************************/
/**********************************************************************************************************************************/
/******************************************************************************/
/*** <Global Initializations> ***/
/******************************************************************************/
//Initializations
Timer timer; // general purpose timer
I2C i2c( P0_10, P0_11 ); // I2C bus (SDA, SCL)
BridgeDriver bridges(&i2c, 1); // Bridge
TextLCD_I2C lcd( &i2c, MCP23008_SA0, TextLCD::LCD20x4 ); // LCD
SDFileSystem sd(P0_18, P0_17, P0_15, P0_16, "sd"); // the pinout on the mbed LPC1768
DigitalIn killSw(KILL);
const int MAX_LINE_LENGTH = 100;
int DummyMode = 0; // run through the code without performing actions
/******************************************************************************/
/*** <Function Initializations> ***/
/******************************************************************************/
void fullInit() {
killSw.mode(PullUp);
initLCD();
}
void initLCD(void) {
i2c.frequency(1000000);
lcd.setBacklight(TextLCD::LightOn);
wait(.6);
lcd.cls(); //clear the display
lcd.setAddress(0,0);
lcd.printf("Initializing...");
}
void ErrorOut(string message, int lineNumber){
lcd.cls(); //clear the display
lcd.setAddress(0,0);
lcd.printf("Error: %s", message);
lcd.setAddress(0,3);
lcd.printf("Line Number: %d", lineNumber);
}
/******************************************************************************/
/*** <Parent Device Class Initializations> ***/
/******************************************************************************/
int numDevices = sizeof(DeviceNames)/sizeof(DeviceNames[0]);
int currNumDevices = 0;
vector<Device*> devices; //create a vector to hold all of the devices