Rob Dobson / Mbed 2 deprecated SpideyWallWeb

Dependencies:   EthernetInterfacePlusHostname RdWebServer mbed-rtos mbed

Revision:
5:910909f34907
Parent:
4:b521815f2657
Child:
6:8df79fe1afcd
diff -r b521815f2657 -r 910909f34907 main.cpp
--- a/main.cpp	Mon Aug 31 15:21:47 2015 +0000
+++ b/main.cpp	Tue Sep 01 15:53:52 2015 +0000
@@ -10,6 +10,7 @@
 #include "EthernetInterface.h"
 #include "RdWebServer.h"
 #include "DrawingManager.h"
+#include "Idler.h"
 #include <string.h>
 
 // Web port
@@ -30,6 +31,9 @@
 // Drawing Manager
 DrawingManager drawingManager;
 
+// Idler - to display something when not being driven by the web interface
+Idler idler(&led2, &drawingManager);
+
 // General response string for REST requests
 char* generalRespStr = "HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Methods: POST, GET, OPTIONS\r\nAccess-Control-Allow-Headers:accept, content-type\r\nContent-Length: 0\r\nContent-Type: application/octet-stream\r\n\r\n";
 
@@ -45,6 +49,7 @@
 char* lightwallClear(int method, char*cmdStr, char* argStr, char* msgBuffer, int msgLen, 
                 int contentLen, unsigned char* pPayload, int payloadLen, int splitPayloadPos)
 {
+    idler.notIdle();
     drawingManager.Clear();
     return generalRespStr;
 }
@@ -54,6 +59,7 @@
 char* lightwallRawFill(int method, char*cmdStr, char* argStr, char* msgBuffer, int msgLen, 
                 int contentLen, unsigned char* pPayload, int payloadLen, int splitPayloadPos)
 {
+    idler.notIdle();
     drawingManager.RawFill(argStr, pPayload, payloadLen, splitPayloadPos);
     return generalRespStr;
 }
@@ -64,6 +70,7 @@
 char* lightwallFill(int method, char*cmdStr, char* argStr, char* msgBuffer, int msgLen, 
                 int contentLen, unsigned char* pPayload, int payloadLen, int splitPayloadPos)
 {
+    idler.notIdle();
     drawingManager.Fill(argStr);
     return generalRespStr;
 }
@@ -75,6 +82,7 @@
     // Blink LED
     led1 = !led1;
     // Show LEDS
+    idler.notIdle();
     drawingManager.ShowLeds();
     return generalRespStr;
 }
@@ -131,7 +139,7 @@
     // Init
     pc.baud(115200);
     pc.printf("Light Wall - Rob Dobson 2015\r\n");
-    
+
     // Get the configuration of the system
     getSystemConfig();
 
@@ -143,14 +151,14 @@
     mbed_mac_address(macAddr);
     pc.printf("Ethernet MAC address: %02x:%02x:%02x:%02x:%02x:%02x\r\n", macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], macAddr[5]); 
     pc.printf("Connecting to ethernet ...\r\n");
-    
+
     // Init ethernet
     EthernetInterface::init();
 
     // Using code described here https://developer.mbed.org/questions/1602/How-to-set-the-TCPIP-stack-s-hostname-pr/
     // to setName on the ethernet interface
     EthernetInterface::setName(systemName);
-    
+
     // Connect ethernet
     EthernetInterface::connect();
     pc.printf("IP Address: %s HostName %s\r\n", EthernetInterface::getIPAddress(), EthernetInterface::getName());
@@ -161,7 +169,7 @@
     // This is the previous code...
     // Thread httpServer(&http_server, NULL, osPriorityNormal, (DEFAULT_STACK_SIZE * 3));
     http_server("");
-      
+
     // Forever - actually it won't even get here as the server has a forever loop in it too
     while(true)
     {