UvA NetCentric Computing listener

Dependencies:   AndroidAccessory Controls HBridge MotorController mbed

Fork of uva_nc by Jurgen Baas

Revision:
1:3cde55629b1d
Parent:
0:0f9ceecf1db8
Child:
3:0229ad4f2db1
--- a/NetCentricApp.cpp	Thu May 22 08:33:12 2014 +0000
+++ b/NetCentricApp.cpp	Wed Jan 06 13:28:45 2016 +0000
@@ -1,5 +1,8 @@
 #include "NetCentricApp.h"
 #include "MbedCommand.h"
+#include "HBridge.h"
+#include "MotorController.h"
+#include "PcControls.h"
 
 // Process commands here.
 MbedResponse *NetCentricApp::getResponse(MbedRequest *request) {
@@ -9,6 +12,8 @@
         return avgCommand(request);
     } else if (request->commandId == COMMAND_LED) {
         return ledCommand(request);
+    } else if (request->commandId == COMMAND_MOTOR) {
+        return motorCommand(request);
     }
     
     MbedResponse *commandNotFound = new MbedResponse();
@@ -85,6 +90,32 @@
     return r;
 }
 
+// Move the motor
+MbedResponse *NetCentricApp::motorCommand(MbedRequest *request) {
+    // HBridge, AnalogIn
+    AnalogIn motorInput(p16);
+    DigitalOut outSignal(p18);
+
+    HBridge motor(p18,p15,p22);
+
+    // MotorController, PcControls
+    MotorController motorController(motor, motorInput);
+    MotorControlsPc pcControls(motorController);
+    
+    // process the input 
+    char c = (char) request->args[0];
+    pcControls.ProcessPcInput(c);
+
+    // generate response
+    MbedResponse *r = new MbedResponse();
+    r->requestId = request->id;
+    r->commandId = request->commandId;
+    r->error = NO_ERROR;
+    r->n = 5;
+    
+    return r;
+}
+
 // Setup once a device is connected.
 void NetCentricApp::setupDevice() {
     printf("Connected to Android!\r\n");