recieveController

Dependents:   hayatoShooter

Committer:
WAT34
Date:
Fri Dec 01 18:15:58 2017 +0900
Revision:
1:445486d27613
Parent:
0:57fc300625c4
Child:
3:6287618256b5
PS3edition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WAT34 0:57fc300625c4 1 #include "recieveController.h"
WAT34 0:57fc300625c4 2
WAT34 0:57fc300625c4 3 recieveController::recieveController(PinName tx,PinName rx,const uint8_t& id):serial(tx,rx)
WAT34 0:57fc300625c4 4 {
WAT34 0:57fc300625c4 5 id_ = id;
WAT34 0:57fc300625c4 6 serial.baud(115200);
WAT34 1:445486d27613 7 for(int i = 0;i<7;i++)
WAT34 0:57fc300625c4 8 {
WAT34 0:57fc300625c4 9 buttons[i] = 0;
WAT34 0:57fc300625c4 10 }
WAT34 0:57fc300625c4 11
WAT34 0:57fc300625c4 12 }
WAT34 0:57fc300625c4 13
WAT34 0:57fc300625c4 14
WAT34 0:57fc300625c4 15 void recieveController::update()
WAT34 0:57fc300625c4 16 {
WAT34 0:57fc300625c4 17 // printf("updating");
WAT34 0:57fc300625c4 18 char data[50],*data2,*data3,*button_,*analog[4],*intensity,*bt,*tmpdata;
WAT34 0:57fc300625c4 19
WAT34 0:57fc300625c4 20 serial.gets(data,50);
WAT34 0:57fc300625c4 21 // printf("%s",data);
WAT34 0:57fc300625c4 22 strtok(data,"-");
WAT34 0:57fc300625c4 23 button_ = strtok(NULL,"-");
WAT34 0:57fc300625c4 24 analog[0] = strtok(NULL,"-");
WAT34 0:57fc300625c4 25 analog[1] = strtok(NULL,"-");
WAT34 0:57fc300625c4 26 analog[2] = strtok(NULL,"-");
WAT34 0:57fc300625c4 27 analog[3] = strtok(NULL,"-");
WAT34 1:445486d27613 28 analog[4] = strtok(NULL,"-");
WAT34 1:445486d27613 29 analog[5] = strtok(NULL,"-");
WAT34 0:57fc300625c4 30 intensity = strtok(NULL,"-");
WAT34 0:57fc300625c4 31
WAT34 0:57fc300625c4 32 //printf("%d\n",strtoul(button_,0,16) );
WAT34 0:57fc300625c4 33 buttons[0] = strtoul(button_,0,16);
WAT34 0:57fc300625c4 34 buttons[1] = strtoul(analog[0],0,16);
WAT34 0:57fc300625c4 35 buttons[2] = strtoul(analog[1],0,16);
WAT34 0:57fc300625c4 36 buttons[3] = strtoul(analog[2],0,16);
WAT34 0:57fc300625c4 37 buttons[4] = strtoul(analog[3],0,16);
WAT34 1:445486d27613 38 buttons[5] = strtoul(analog[4],0,16);
WAT34 1:445486d27613 39 buttons[6] = strtoul(analog[5],0,16);
WAT34 0:57fc300625c4 40 }