recieveController

Dependents:   hayatoShooter

Revision:
0:57fc300625c4
Child:
1:445486d27613
Child:
2:ead1b55ec5f0
Child:
4:114dd09583b8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/recieveController.cpp	Fri Sep 01 11:18:24 2017 +0900
@@ -0,0 +1,37 @@
+#include "recieveController.h"
+
+recieveController::recieveController(PinName tx,PinName rx,const uint8_t& id):serial(tx,rx)
+{
+  id_ = id;
+  serial.baud(115200);
+  for(int i = 0;i<5;i++)
+  {
+    buttons[i] = 0;
+  }
+
+}
+
+
+void recieveController::update()
+{
+  // printf("updating");
+  char data[50],*data2,*data3,*button_,*analog[4],*intensity,*bt,*tmpdata;
+
+  serial.gets(data,50);
+  // printf("%s",data);
+  strtok(data,"-");
+  button_ = strtok(NULL,"-");
+  analog[0] = strtok(NULL,"-");
+  analog[1] = strtok(NULL,"-");
+  analog[2] = strtok(NULL,"-");
+  analog[3] = strtok(NULL,"-");
+  intensity = strtok(NULL,"-");
+
+  //printf("%d\n",strtoul(button_,0,16) );
+  buttons[0] = strtoul(button_,0,16);
+  buttons[1] = strtoul(analog[0],0,16);
+  buttons[2] = strtoul(analog[1],0,16);
+  buttons[3] = strtoul(analog[2],0,16);
+  buttons[4] = strtoul(analog[3],0,16);
+  return;
+}