Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BridgeDriver FrontPanelButtons MCP23017 SDFileSystem TextLCD mbed
Diff: DeviceClasses.hpp
- Revision:
- 4:86d0d04cc055
- Parent:
- 3:078e9a1e8be3
- Child:
- 5:e36e0538a903
--- a/DeviceClasses.hpp Fri Sep 19 00:46:26 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,406 +0,0 @@
-///*#include "mbed.h"
-//#include "LocalPinNames.h"
-//#include "TextLCD.h"
-//#include "BridgeDriver.h"
-//*/
-//#include "Device.hpp"
-////#include <string>
-//
-///**********************************************************************************************************************************/
-///**********************************************************************************************************************************/
-///*************************** <CLASS: Voltage_Driver> ****************************/
-///**********************************************************************************************************************************/
-///**********************************************************************************************************************************/
-//
-//class Voltage_Driver{
-//
-// public :
-// //uint8_t ch123; //Channel value this device is set to
-// int ch;
-// int test;
-//
-// int interpret();
-// int forceBrake();
-// //int forceFloat();
-// float drive();
-//
-// //Voltage_Driver();
-// void setChannel(int channel){
-// Voltage_Driver::ch = channel;
-// }
-//
-// int getChannel(){
-// return Voltage_Driver::ch;
-// }
-//};
-//
-////Voltage_Driver::Voltage_Driver(void){
-////}
-//
-////A line consists of [ __(Local_Name)__ __(function)__ __(parameter1)__ __(parameter2)__ __(parameter3)__ ... and so on]
-//int Voltage_Driver::interpret(){
-// /*
-// lcd.cls(); //clear the display
-// lcd.setAddress(0,3);
-// lcd.printf("Test2 ");
-// lcd.setAddress(0,1);
-// lcd.printf("wrd1: %s", lineData.word[0]);
-// lcd.setAddress(0,2);
-// lcd.printf("wrd2: %s", lineData.word[1]);
-// wait(3);
-//*/
-//
-//
-// string firstWord = lineData.word[0]; //get the first word in the line
-///*
-// lcd.setAddress(0,2);
-// lcd.printf("fW: %s", firstWord);
-// lcd.setAddress(0,3);
-// lcd.printf("ch: %d", ch);
-// wait(3);*/
-//
-// //Initialize the class and device
-// if (firstWord.compare("device") == 0){
-// //Order of Line: Command, Local_Name, VOLTAGE_DRIVER, Channel(1,2,3,4,5,6,7,8)
-//
-// test = 10;
-//
-// if (lineData.numWords != 4){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-//
-// string channel = lineData.word[3]; //Parameter is a number
-// int channelValue = 0;
-// sscanf(channel.c_str(), "%d", &channelValue);
-//
-// //Channel Value between 1 to 8
-// if (channelValue >= 1 && channelValue <= 8){
-//
-// setChannel(channelValue);
-// //ch = channelValue;
-//
-// lcd.setAddress(0,2);
-// lcd.printf("fW: %s", firstWord);
-// //lcd.setAddress(0,3);
-// //lcd.printf("ch: %d", getChannel());
-// lcd.setAddress(0,3);
-// lcd.printf("test: %d", test);
-// //lcd.setAddress(0,3);
-// //lcd.printf("chString: %s", chString);
-// wait(2);
-//
-// switch (channelValue){
-// case 1:
-// case 2:
-// bridges.enablePwm(BridgeDriver::MOTOR_A, 0);
-// break;
-// case 3:
-// case 4:
-// bridges.enablePwm(BridgeDriver::MOTOR_B, 0);
-// break;
-// case 5:
-// case 6:
-// bridges.enablePwm(BridgeDriver::MOTOR_C, 0);
-// break;
-// case 7:
-// case 8:
-// bridges.enablePwm(BridgeDriver::MOTOR_D, 0);
-// break;
-// }
-// /* lcd.setAddress(0,2);
-// lcd.printf("AchannelVal: %d", channelValue);
-// lcd.setAddress(0,3);
-// lcd.printf("Ach: %d", ch);
-// wait(3);*/
-//
-// }
-// else{
-// //ERROR Out
-// //Unacceptable channel, or conversion function failed when converting string to int
-// }
-// }
-//
-// //if the first word is not "device" it means that it's trying to perform a function to a specific Motor
-// else{
-//
-//
-//
-// //Order of Line: Local_Name, Function_Name, Param1, Param2, Param3,.......
-// string localname = lineData.word[0]; //just for the sake of following the variable easily and understanding
-// string func = lineData.word[1];
-//
-// /******************************************************************************/
-// /*** <Func: forceBrake> ***/
-// /******************************************************************************/
-// if (func.compare("forceBrake") == 0){
-//
-// if (lineData.numWords != 3){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-//
-// bridges.forceBrake(ch);
-// }
-//
-//
-// /******************************************************************************/
-// /*** <Func: drive> ***/
-// /******************************************************************************/
-// else if (func.compare("drive") == 0){
-// //Order of Line: Local_Name, drive
-//
-// lcd.setAddress(0,0);
-// lcd.printf("lclN: %s ", localname);
-// lcd.setAddress(0,2);
-// lcd.printf("func: %s ", func);
-// //lcd.setAddress(0,3);
-// //lcd.printf("3ch: %d ", getChannel());
-// lcd.setAddress(0,3);
-// lcd.printf("test: %d", test);
-// //lcd.setAddress(0,3);
-// //lcd.printf("chString: %s ", chString);
-// wait(3);
-//
-// if (lineData.numWords != 2){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-// /*
-// int State = 2;
-// int channelValue = atoi(chString);
-// State = bridges.drive(channelValue, 1); //Turn channel on
-// lcd.setAddress(0,2);
-// lcd.printf("TEST ch: %d, State: %d", channelValue, State);
-// wait(3);*/
-//
-// }
-//
-//
-// /******************************************************************************/
-// /**** <Func: off> ****/
-// /******************************************************************************/
-// else if (func.compare("drive") == 0){
-// //Order of Line: Local_Name, drive, duration
-//
-// if (lineData.numWords != 2){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-//
-// bridges.drive(getChannel(), 0); //Turn channel off
-// }
-//
-// else {
-// return 0;
-//
-// }
-// }
-// /*
-// lcd.setAddress(0,3);
-// lcd.printf("ENDch: %d ", getChannel());
-// wait(3);*/
-//
-// return 1;
-//}
-//
-//
-//
-///**********************************************************************************************************************************/
-///**********************************************************************************************************************************/
-///******************************** <CLASS: Motor> ********************************/
-///**********************************************************************************************************************************/
-///**********************************************************************************************************************************/
-//
-//class Motor{
-//
-// enum BridgeDriver::Motors motor;
-//
-// public :
-// int interpret();
-// void enableBrake();
-// int forceBrake();
-// //int forceFloat();
-// float drive();
-//
-//
-// void setMotor(BridgeDriver::Motors selectedMotor){
-// motor = selectedMotor;
-// }
-//
-// enum BridgeDriver::Motors getMotor(){
-// return motor;
-// }
-//
-//};
-//
-////A line consists of [ __(Local_Name)__ __(function)__ __(parameter1)__ __(parameter2)__ __(parameter3)__ ... and so on]
-//int Motor::interpret(){
-// /*
-// lcd.cls(); //clear the display
-// lcd.setAddress(0,3);
-// lcd.printf("Test2 ");
-// lcd.setAddress(0,1);
-// lcd.printf("wrd1: %s", lineData.word[0]);
-// lcd.setAddress(0,2);
-// lcd.printf("wrd2: %s", lineData.word[1]);
-// wait(3);
-//*/
-// /*
-// lcd.setAddress(0,2);
-// lcd.printf("wrd1: %s", lineData.word[0]);
-// lcd.setAddress(0,3);
-// lcd.printf("TEST1 ");
-// wait(1);*/
-//
-// string firstWord = lineData.word[0]; //splits the str based on a space delimeter
-//
-// if (firstWord.compare("device") == 0){
-// //Order of Line: Command, Local_Name, VOLTAGE_DRIVER, Channel(1,2,3,4,5,6,7,8)
-//
-// if (lineData.numWords != 4){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-//
-// string channel = lineData.word[3]; //Parameter is a single character, so dereference the point to the word
-//
-// if ((channel.compare("A") == 0) || (channel.compare("a") == 0))
-// setMotor(BridgeDriver::MOTOR_A);
-// else if ((channel.compare("B") == 0) || (channel.compare("b") == 0))
-// setMotor(BridgeDriver::MOTOR_B);
-// else if ((channel.compare("C") == 0) || (channel.compare("c") == 0))
-// setMotor(BridgeDriver::MOTOR_C);
-// else if ((channel.compare("D") == 0) || (channel.compare("d") == 0))
-// setMotor(BridgeDriver::MOTOR_D);
-// }
-//
-// //if the first word is not "device" it means that it's trying to perform a function to a specific Motor
-// else{
-// //Order of Line: Local_Name, Function_Name, Param1, Param2, Param3,.......
-// //char localname[15] = lineData.word[0]; //just for the sake of following the variable easily and understanding
-// string func = lineData.word[1];
-//
-// /******************************************************************************/
-// /*** <Func: enableBrake> ***/
-// /******************************************************************************/
-// if (func.compare("enableBrake") == 0){
-//
-// if (lineData.numWords != 4){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-//
-// //Initialize and Convert Parameters
-// string enable = lineData.word[2];
-// int enableValue = 0;
-// sscanf(enable.c_str(), "%d", &enableValue);
-//
-// bridges.enableBraking(getMotor(), enableValue);
-// }
-//
-// /******************************************************************************/
-// /*** <Func: forceBrake> ***/
-// /******************************************************************************/
-// else if (func.compare("forceBrake") == 0){
-//
-// if (lineData.numWords != 3){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-//
-// bridges.forceBrake(getMotor());
-// }
-//
-//
-// /******************************************************************************/
-// /*** <Func: drive> ***/
-// /******************************************************************************/
-// else if (func.compare("drive") == 0){
-//
-// /*lcd.setAddress(0,2);
-// lcd.printf("wrd2: %s", lineData.word[1]);
-// lcd.setAddress(0,3);
-// lcd.printf("TEST2 ");
-// wait(1);*/
-//
-// if (lineData.numWords != 4){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-//
-// //Initialize Parameters
-// string speed = lineData.word[2];
-// string dir = lineData.word[3];
-//
-// //Initialize Convertion Variables if needed
-// float speedValue;
-// int dirValue = 0;
-//
-// //Convert string to usable values
-// //NOTE both atof and atoi functions return 0 if no valid conversion could be performed
-// sscanf(speed.c_str(), "%f", &speedValue);
-// speedValue = speedValue / 100;
-//
-// if (speedValue <= 0)
-// return 0; //Error Out because a value gives no functionality or is wrong
-//
-// if (dir.compare("CC") == 0 || dir.compare("cc") == 0)
-// dirValue = -1; //Turn Clockwise
-// else if (dir.compare("C") == 0 || dir.compare("c") == 0)
-// dirValue = 1; //Turn CounterClockwise
-// else
-// return 0; //Error Out since the parameter is incorrect
-//
-// bridges.drive(getMotor(), dirValue, speedValue); //Turn on the Motor
-//
-// }
-// /******************************************************************************/
-// /**** <Func: off> ****/
-// /******************************************************************************/
-// else if (func.compare("off") == 0){
-//
-// /*lcd.setAddress(0,2);
-// lcd.printf("wrd2: %s", lineData.word[1]);
-// lcd.setAddress(0,3);
-// lcd.printf("TEST2 ");
-// wait(1);*/
-//
-// if (lineData.numWords != 2){
-// //Error Check, incorrect number of parameter, error out
-// return 0;
-// }
-//
-// bridges.drive(getMotor(), 0, 0); //Turn off the Motor
-// }
-//
-// else {
-// return 0;
-//
-// }
-// }
-//
-// return 1;
-//}
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//