recieveController

Dependents:   hayatoShooter

recieveController.cpp

Committer:
WAT34
Date:
2017-09-01
Revision:
0:57fc300625c4
Child:
1:445486d27613
Child:
2:ead1b55ec5f0
Child:
4:114dd09583b8

File content as of revision 0:57fc300625c4:

#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;
}