![](/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
Diff: Devices/PinIN.cpp
- Revision:
- 4:86d0d04cc055
- Child:
- 5:e36e0538a903
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Devices/PinIN.cpp Fri Sep 19 01:54:00 2014 +0000 @@ -0,0 +1,121 @@ +#include "PinIN.hpp" +//#include "mbed.h" +//#include "LocalPinNames.h" +//#include "BridgeDriver.h" + +//Constructor +PinIN::PinIN(Line lineData){ + + string _pinName = lineData.word[3]; + + if(_pinName.compare("DIO0") == 0) + this->pinName = DIO0; + else if(_pinName.compare("DIO1") == 0) + this->pinName = DIO1; + else if(_pinName.compare("DIO2") == 0) + this->pinName = DIO2; + else if(_pinName.compare("DIO3") == 0) + this->pinName = DIO3; + else if(_pinName.compare("DIO4") == 0) + this->pinName = DIO4; + else if(_pinName.compare("DIO5") == 0) + this->pinName = DIO5; + else if(_pinName.compare("DIO6") == 0) + this->pinName = DIO6; + else if(_pinName.compare("DIO7") == 0) + this->pinName = DIO7; + else if(_pinName.compare("DIO8") == 0) + this->pinName = DIO8; + else if(_pinName.compare("DIO9") == 0) + this->pinName = DIO9; + else if(_pinName.compare("DIO10") == 0) + this->pinName = DIO10; + else if(_pinName.compare("DIO11") == 0) + this->pinName = DIO11; + + else if(_pinName.compare("AI0") == 0) + this->pinName = AI0; + else if(_pinName.compare("AI1") == 0) + this->pinName = AI1; + else if(_pinName.compare("AI2") == 0) + this->pinName = AI2; + else if(_pinName.compare("AI3") == 0) + this->pinName = AI3; + else if(_pinName.compare("AI4") == 0) + this->pinName = AI4; + else if(_pinName.compare("AI5") == 0) + this->pinName = AI5; + +} +/* + #define DIO0 P2_2 +#define DIO1 P2_3 +#define DIO2 P2_4 +#define DIO3 P2_5 +#define DIO4 P2_6 +#define DIO5 P2_7 +#define DIO6 P2_8 +#define DIO7 P2_9 +#define DIO8 P1_1 +#define DIO9 P1_4 +#define DIO10 P1_8 +#define DIO11 P1_9 +#define SS1 P0_19 +#define SS2 P0_20 +#define SS3 P0_21 +#define SS4 P0_22 +#define SS_ADC P1_0 +#define AI0 P0_23 +#define AI1 P0_24 +#define AI2 P0_25 +#define AI3 P0_26 +#define AI4 P1_30 +#define AI5 P1_31 +#define KILL P2_11 +#define CAN1_RX P0_0 +#define CAN1_TX P0_1 +#define CAN2_RX P0_4 +#define CAN2_TX P0_5 + */ + + +//A line consists of [ __(Local_Name)__ __(function)__ __(parameter1)__ __(parameter2)__ __(parameter3)__ ... and so on] +int PinIN::interpret(Line &lineData){ + /* + lcd.setAddress(0,2); + lcd.printf("CHECK Motor 123456"); + lcd.setAddress(0,3); + lcd.printf("func: %s ", lineData.word[1]); + wait(2);*/ + + DigitalIn signal(pinName); + + //Order of Line: Local_Name, Function_Name, Param1, Param2, Param3,....... + string func = lineData.word[1]; + + /******************************************************************************/ + /*** <Func: wait> ***/ + /******************************************************************************/ + if (func.compare("wait") == 0){ + + if (lineData.numWords != 3){ + //Error Check, incorrect number of parameter, error out + return 0; + } + + //Initialize and Convert Parameters + string pinValue = lineData.word[2]; + int pinValue_Value = 0; + sscanf(pinValue.c_str(), "%d", &pinValue_Value); + + while(signal.read() != pinValue_Value); + } + + else { + return 0; + + } + + return 1; +} +