4180 LabTeam - Spring '18 / Mbed 2 deprecated rpc_mbedECE4180Project

Dependencies:   4DGL-uLCD-SE RPCInterface mbed

Fork of rpc_mbed by Nydrel Jack

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "mbed_rpc.h"
00003 #include "uLCD_4DGL.h"
00004 #include <ctype.h>
00005 #include "RGB_LED.h"
00006  
00007 //Use the RPC enabled wrapped class  - see RpcClasses.h for more info
00008 Serial pc(USBTX, USBRX);
00009 PinName tx, rx, rst;
00010 RGBLed myRGBled(p22,p23,p24);
00011 uLCD_4DGL uLCD(p28, p27, p29);
00012 char text;
00013 //string screen;
00014  
00015 void clearLCD(Arguments *in, Reply *out);
00016 RPCFunction rpcClear(&clearLCD, "clearLCD");
00017 
00018 void printLCDAndLightRGB(Arguments *in, Reply *out);
00019 RPCFunction rpcPrintLCDAndLightRGB(&printLCDAndLightRGB, "printLCDAndLightRGB");
00020   
00021 int main() {
00022  
00023     char buf[256], outbuf[256];
00024     while(1) {
00025         pc.gets(buf, 256);
00026         //Call the static call method on the RPC class
00027         RPC::call(buf, outbuf); 
00028         pc.printf("%s\n", outbuf);
00029     }
00030 }
00031 
00032 void clearLCD(Arguments *in, Reply *out)
00033 {
00034     uLCD.cls();
00035 }
00036 
00037 void printLCDAndLightRGB(Arguments *in, Reply *out)
00038 {
00039         uLCD.cls();
00040         char * text = in->getArg<char *>();
00041         int value = strlen(text);
00042         if(text[0] == '1'){
00043           myRGBled.write(0,1.0f,0);
00044           uLCD.printf("Tweet is found!\n");
00045           uLCD.printf("\n");
00046         } else if(text[0] == '0'){
00047           myRGBled.write(0,0,1.0f);
00048         }
00049         text[0] = '-';
00050         for(int i = 0; i< value; i++) {
00051             if(text[i] == '|') {
00052                text[i] = ' ';   
00053             }
00054         }
00055         uLCD.printf(text);
00056  }