33
Dependencies: DISCO_L475VG_IOT01A_wifi
DataCheck.cpp
- Committer:
- ascension2
- Date:
- 2019-08-21
- Revision:
- 3:32b328935a54
- Parent:
- 2:a460007a35c7
File content as of revision 3:32b328935a54:
#include "mbed.h" #include "Motorcontrol.h" #include "LEDcontrol.h" #include "dustsensor.h" /* data[0] mode 0 send 1 receive data[1] window motor 0 close 1 open data[2] blind motor 0 close 1 open date[3] dust 0 date[4] illuminate 0 dark 1 bright date[5] LED 0 off 1 on 2 auto date[6] R100 value of R date[7] R10 date[8] R1 date[9] G100 value of G date[10] G10 date[11] G1 date[12] B100 value of B date[13] B10 date[14] B1 */ int AutoMode; float R,B,G; void Data_Receive(uint8_t S[]) { printf("data checking\n"); if(S[0]=='0') { AutoMode=0; // auto off } else if(S[0]=='1') { AutoMode=1; // auto on } if(S[1]=='0') { motor1CCW(10); } else if(S[1]=='1') { motor1CW(10); } else motor1Stop(); if(S[2]=='0') { motor2CCW(10); } else if(S[2]=='1') { motor2CW(10); } else motor2Stop(); if(S[5]=='0') { int j=6; R= ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); j=j+3; G = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 );j=j+3; B = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); setRGB(R,G,B,0); } else if(S[5]=='1') { int j=6; R= ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); j=j+3; G = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 );j=j+3; B = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); setRGB(R,G,B,1); } else if(S[5]=='2') { int j=6; R= ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); j=j+3; G = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 );j=j+3; B = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); setRGB(R,G,B,2); printf("R=%f G=%f B=%f\n",R,G,B); } Dustcheck(); }