Code for a quadrapod robot.

Dependencies:   ArthropodIK MMA8451Q MODSERIAL TSI TextLCD mbed-rtos mbed PolyServo

Revision:
10:11176c9c42fc
Parent:
7:68e488d28f67
--- a/main.cpp	Sat Jul 04 20:24:54 2015 +0000
+++ b/main.cpp	Tue Jul 07 07:01:53 2015 +0000
@@ -2,6 +2,7 @@
 #include "rtos.h"
 #include "MODSERIAL.h"
 #include <vector>
+#include "mbed_rpc.h"
 
 #include "quadrapod_defs.h" //Includes pins and stuff
 #include "ArthropodIK.h"    // IK solver based on Oscar Liang. 
@@ -12,11 +13,20 @@
 ***************************************************************************/
 
 
-MODSERIAL serial(USBTX, USBRX);
+MODSERIAL pc(USBTX, USBRX);
 
 DigitalOut led_green(LED_GREEN);
 DigitalOut led_red(LED_RED);
-PwmOut led_blue(LED_BLUE);
+DigitalOut led_blue(LED_BLUE);
+
+PwmOut LCD_red(LED_BL_RED);
+PwmOut LCD_grn(LED_BL_GRN);
+PwmOut LCD_blu(LED_BL_BLU);
+
+float red_intensity, green_intensity, blue_intensity; 
+RPCVariable<float> rpc_bl_red(&red_intensity, "red_lvl");
+RPCVariable<float> rpc_bl_grn(&green_intensity, "green_lvl");
+RPCVariable<float> rpc_bl_blu(&blue_intensity, "blue_lvl");
 
 ArthropodSolver IKsolver();
 
@@ -46,7 +56,7 @@
 
 int main() {
   // It's always nice to know what version is deployed.
-  serial.printf("Built " __DATE__ " " __TIME__ "\r\n");
+  //serial.printf("Built " __DATE__ " " __TIME__ "\r\n");
   
   // Quick blink on startup.
   led_green = 0;  // Note that the internal LED is active low.
@@ -63,7 +73,25 @@
   // Set a timer to periodically call led_blink_periodic().
   RtosTimer ledBlinkTimer(led_blink_periodic);
   ledBlinkTimer.start(1000);
+  char buf[256], outbuf[256];
 
   // Work is done in the threads, so main() can sleep.
+    while (1) {
+        Thread::wait(100);
+        LCD_red = red_intensity;
+        LCD_grn = green_intensity;
+        LCD_blu = blue_intensity;   
+        
+        
+        pc.gets(buf, 256);
+        //Call the static call method on the RPC class
+        RPC::call(buf, outbuf); 
+        pc.printf("%s\n", outbuf);
+        
+        
+    }
+  
+  
+  
   Thread::wait(osWaitForever);
 }
\ No newline at end of file