Mbed Code for ECE4180Project
Dependencies: 4DGL-uLCD-SE RPCInterface mbed
Fork of rpc_mbed by
Diff: main.cpp
- Revision:
- 1:6e3272a3d9d0
- Parent:
- 0:3c342a2555ef
- Child:
- 2:cf74d941dba8
diff -r 3c342a2555ef -r 6e3272a3d9d0 main.cpp --- a/main.cpp Tue May 01 07:46:31 2018 +0000 +++ b/main.cpp Wed May 02 03:40:27 2018 +0000 @@ -2,6 +2,7 @@ #include "mbed_rpc.h" #include "uLCD_4DGL.h" #include <ctype.h> +#include "RGB_LED.h" /** * This example program has been updated to use the RPC implementation in the new mbed libraries. @@ -11,6 +12,7 @@ //Use the RPC enabled wrapped class - see RpcClasses.h for more info Serial pc(USBTX, USBRX); PinName tx, rx, rst; +RGBLed myRGBled(p22,p23,p24); uLCD_4DGL uLCD(p28, p27, p29); char text; //string screen; @@ -18,8 +20,8 @@ void clearLCD(Arguments *in, Reply *out); RPCFunction rpcClear(&clearLCD, "clearLCD"); -void printLCD(Arguments *in, Reply *out); -RPCFunction rpcPrint(&printLCD, "printLCD"); +void printLCDAndLightRGB(Arguments *in, Reply *out); +RPCFunction rpcPrintLCDAndLightRGB(&printLCDAndLightRGB, "printLCDAndLightRGB"); int main() { @@ -38,9 +40,23 @@ //out->putData("Successfully created uLCD object!"); } -void printLCD(Arguments *in, Reply *out) +void printLCDAndLightRGB(Arguments *in, Reply *out) { + uLCD.cls(); char * text = in->getArg<char *>(); - uLCD.puts(text); - uLCD.puts("\n"); + int value = strlen(text); + if(text[0] == '1'){ + myRGBled.write(0,1.0f,0); + uLCD.printf("Tweet is found!\n"); + uLCD.printf("\n"); + } else if(text[0] == '0'){ + myRGBled.write(0,0,1.0f); + } + text[0] = '-'; + for(int i = 0; i< value; i++) { + if(text[i] == '|') { + text[i] = ' '; + } + } + uLCD.printf(text); } \ No newline at end of file