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-19
Revision:
4:86d0d04cc055
Parent:
3:078e9a1e8be3
Child:
5:e36e0538a903

File content as of revision 4:86d0d04cc055:

#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, Line 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;


/******************************************************************************/
/***                     <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("LCD Initialized");
}


/******************************************************************************/
/***              <Parent Device Class Initializations>                     ***/
/******************************************************************************/

int numDevices = sizeof(DeviceNames)/sizeof(DeviceNames[0]);
int currNumDevices = 0;

vector<Device*> devices;