ControllerBox directs electromechanical equipment in restaurants to display information.
Dependencies: TextLCD MbedJSONValue libMotiv picojson mbed-rtos mbed
Fork of Mbed_MotiVControllerBox by
Diff: main.cpp
- Revision:
- 0:2279181caaa1
- Child:
- 1:d54aed10ddf3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Oct 25 00:11:12 2014 +0000 @@ -0,0 +1,100 @@ +#include "mbed.h" +//the library "TextLCD.h" was slightly altered to work with the GDM2004D LCD +#include "TextLCD/TextLCD.h" +#include "Controller.h" +#include "MODSERIAL.h" +#include <string> + +//the object "lcd" is initialized to act as a TextLCD with 20x4 characters +TextLCD lcd(p26, p25, p24, p23, p22, p20, p19, TextLCD::LCD20x4); + + +//inputs +DigitalIn Up(p8); +DigitalIn Down(p14); + +//outputs +DigitalOut led(p6); + +//Comms +Serial pc(USBTX, USBRX); //tx, rx +MODSERIAL rfd(p9, p10); //tx, rx + +// +string displayLines[26] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; + +//Main functionality in here +Controller c(&lcd); + +void setup(); //Called once to setup +void runProgram(); //Program with loop + +int main() +{ + setup(); + + //the LCD is cleared using function .cls() + lcd.cls(); + //a "\n" in a text string causes a line feed + lcd.printf("HELLO WORLDZ\n"); + //if the end of a line is reached, the text is written to the next line automatically + //lcd.printf("Testbed for mbed\nLCD example software with altered library"); + + pc.printf("Entering loop\r\n"); + + //the endless loop keeps mbed in low power mode + runProgram(); +} + + +void setup() +{ + pc.printf("Setup Controller Box\r\n"); + rfd.baud(9600); +} + +void runProgram() +{ + c._lcd->cls(); + c._lcd->locate(0,0); + c.displayStatus(); + + if(!rfd.writeable()) + { + c._lcd->locate(0,1); + c._lcd->clearLine(); + c._lcd->printf("rfd not writeable"); + } else { + c._lcd->locate(0,1); + c._lcd->clearLine(); + c._lcd->printf("rfd writeable"); + if(!rfd.txBufferSane()) + { + c._lcd->locate(0,3); + c._lcd->printf("buffer not sane"); + } + } + + char received = 'a'; + + + while(1) { +// rfd.printf("aaiPoesjes"); //TEST broadcast text + received = rfd.txGetLastChar(); + c.displWriteLine(3, 'a'); + pc.printf("%c", received); + received = 'b'; + if(!Up) + { + c.setStatus(c.BUSY); + wait(1); + rfd.printf("%s","161;"); + wait_ms(100); + rfd.printf("%s","308;"); + } else { + c.setStatus(c.READY); + } + wait_ms(1000); + //__WFI(); + } +} \ No newline at end of file