recieveController
recieveController.cpp@0:57fc300625c4, 2017-09-01 (annotated)
- Committer:
- WAT34
- Date:
- Fri Sep 01 11:18:24 2017 +0900
- Revision:
- 0:57fc300625c4
- Child:
- 1:445486d27613
- Child:
- 2:ead1b55ec5f0
- Child:
- 4:114dd09583b8
first commit
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:57fc300625c4 | 7 | for(int i = 0;i<5;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 | 0:57fc300625c4 | 28 | intensity = strtok(NULL,"-"); |
WAT34 | 0:57fc300625c4 | 29 | |
WAT34 | 0:57fc300625c4 | 30 | //printf("%d\n",strtoul(button_,0,16) ); |
WAT34 | 0:57fc300625c4 | 31 | buttons[0] = strtoul(button_,0,16); |
WAT34 | 0:57fc300625c4 | 32 | buttons[1] = strtoul(analog[0],0,16); |
WAT34 | 0:57fc300625c4 | 33 | buttons[2] = strtoul(analog[1],0,16); |
WAT34 | 0:57fc300625c4 | 34 | buttons[3] = strtoul(analog[2],0,16); |
WAT34 | 0:57fc300625c4 | 35 | buttons[4] = strtoul(analog[3],0,16); |
WAT34 | 0:57fc300625c4 | 36 | return; |
WAT34 | 0:57fc300625c4 | 37 | } |