hh
Dependencies: DISCO_L475VG_IOT01A_wifi
DataCheck.cpp
- Committer:
- ascension2
- Date:
- 2019-08-20
- Revision:
- 0:db42952db1a5
File content as of revision 0:db42952db1a5:
#include "LEDcontrol.h" #include "mbed.h" #include "Motorcontrol.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_sensor 0 date[4] CDS_sensor 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 */ void Data_Receive(uint8_t S[]); void RGB_value_cal(uint8_t re[]); float R,B,G; void Data_Receive(uint8_t S[]) { printf("data checking\n"); if(S[1]=='0') { motorCCW(100); } else if(S[1]=='1') { motorCW(100); } if(S[2]=='0') { motorCCW(100); } else if(S[2]=='1') { motorCW(100); } if(S[5]=='0') { RGB_value_cal(S); setRGB(R,G,B,0); } else if(S[5]=='1') { RGB_value_cal(S); setRGB(R,G,B,1); } else if(S[5]=='2') { RGB_value_cal(S); setRGB(R,G,B,2); } } void RGB_value_cal(uint8_t re[]) { int j=6; R= ((re[j]-48)*100 )+((re[j+1]-48)*10 )+((re[j+2]-48)*1 ); j=j+3; G = ((re[j]-48)*100 )+((re[j+1]-48)*10 )+((re[j+2]-48)*1 );j=j+3; B = ((re[j]-48)*100 )+((re[j+1]-48)*10 )+((re[j+2]-48)*1 ); }