Mbed Code for ECE4180Project
Dependencies: 4DGL-uLCD-SE RPCInterface mbed
Fork of rpc_mbed by
main.cpp
- Committer:
- bjs9
- Date:
- 2018-05-02
- Revision:
- 1:6e3272a3d9d0
- Parent:
- 0:3c342a2555ef
- Child:
- 2:cf74d941dba8
File content as of revision 1:6e3272a3d9d0:
#include "mbed.h" #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. * This example shows the uses of the RPCDigitalOut wrapper class */ //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; void clearLCD(Arguments *in, Reply *out); RPCFunction rpcClear(&clearLCD, "clearLCD"); void printLCDAndLightRGB(Arguments *in, Reply *out); RPCFunction rpcPrintLCDAndLightRGB(&printLCDAndLightRGB, "printLCDAndLightRGB"); int main() { char buf[256], outbuf[256]; while(1) { pc.gets(buf, 256); //Call the static call method on the RPC class RPC::call(buf, outbuf); pc.printf("%s\n", outbuf); } } void clearLCD(Arguments *in, Reply *out) { uLCD.cls(); //out->putData("Successfully created uLCD object!"); } void printLCDAndLightRGB(Arguments *in, Reply *out) { uLCD.cls(); char * text = in->getArg<char *>(); 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); }