ControllerBox directs electromechanical equipment in restaurants to display information.
Dependencies: TextLCD MbedJSONValue libMotiv picojson mbed-rtos mbed
Fork of Mbed_MotiVControllerBox by
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD/TextLCD.h" 00003 #include "Controller.h" 00004 //#include "picojson.h" 00005 //#include "EthernetInterface.h" 00006 //#include "HTTPClient.h" 00007 #include "libMotiv.h" 00008 #include <string> 00009 00010 /***************** 00011 Global vars 00012 ******************/ 00013 //the object "lcd" is initialized to act as a TextLCD with 20x4 characters 00014 TextLCD lcd(p26, p25, p24, p23, p22, p20, p19, TextLCD::LCD20x4); 00015 00016 //Timer for keeping track of intervals 00017 Timer tim; 00018 int intervalSec = 10; 00019 00020 00021 00022 //inputs 00023 DigitalIn Up(p8); 00024 DigitalIn Down(p14); 00025 bool pushedUp = false; 00026 bool pushedDown = false; 00027 00028 //outputs 00029 DigitalOut led(p6); 00030 00031 //Comms 00032 Serial pc(USBTX, USBRX); //tx, rx 00033 Serial rfd(p9, p10); //tx, rx 00034 00035 //TODO: Should be the responsibility of Controller 00036 //EthernetInterface eth; //Doeesn't want to initialize in the objects Controller->mAPI 00037 //HTTPClient http; 00038 //char str[1024]; 00039 00040 //Storage 00041 //SD card 00042 //CS P14 00043 //MOSI P11 00044 //CLK P13 00045 //MISO P12 00046 //SDFileSystem sdfs(p11,p12,p13,p14, "sdCard"); 00047 00048 00049 00050 //Controller mainly directs the program. It directs data and also controls the lcd output. 00051 Controller c(&lcd, &rfd/*, ð*/); 00052 00053 /********************** 00054 Declare functions 00055 ***********************/ 00056 00057 void setup(); //Called once to setup 00058 void runProgram(); //Program with loop 00059 void runController(); //Controller loop 00060 00061 /**************** 00062 MAIN 00063 *****************/ 00064 int main() 00065 { 00066 // eth.init(); 00067 // eth.connect(); 00068 printf("int main()\r\n"); 00069 c.init(); 00070 setup(); 00071 00072 runController(); 00073 } 00074 00075 /************************* 00076 Implement Function 00077 *************************/ 00078 00079 void setup() 00080 { 00081 pc.printf("Setup Controller Box\r\n"); 00082 c.setStatus(Controller::INIT); 00083 rfd.baud(9600); 00084 lcd.clearDisplay(); 00085 wait_ms(200); 00086 } 00087 00088 void runController() 00089 { 00090 int count; 00091 tim.start(); 00092 while(1) {//programma loop 00093 if(tim.read() > intervalSec) { //polling interval passed, update tables 00094 printf("\r\n\r\n*%f seconds passed, reset timer*\r\n", tim.read()); 00095 tim.reset(); 00096 c.update();//update Table collection with API data 00097 } 00098 c.sendCommands(&tim, intervalSec);//Send a number of commands if commands in commandList 00099 } 00100 }
Generated on Wed Jul 20 2022 02:32:00 by 1.7.2