final
Dependencies: DISCO_L475VG_IOT01A_wifi
DataCheck.cpp@4:33b80026a3ee, 2019-08-22 (annotated)
- Committer:
- ascension2
- Date:
- Thu Aug 22 08:16:51 2019 +0000
- Revision:
- 4:33b80026a3ee
- Parent:
- 3:32b328935a54
final
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ascension2 | 0:dc1150daf908 | 1 | #include "mbed.h" |
ascension2 | 0:dc1150daf908 | 2 | #include "Motorcontrol.h" |
ascension2 | 0:dc1150daf908 | 3 | #include "LEDcontrol.h" |
ascension2 | 2:a460007a35c7 | 4 | #include "dustsensor.h" |
ascension2 | 0:dc1150daf908 | 5 | |
ascension2 | 0:dc1150daf908 | 6 | /* |
ascension2 | 0:dc1150daf908 | 7 | data[0] mode 0 send 1 receive |
ascension2 | 0:dc1150daf908 | 8 | data[1] window motor 0 close 1 open |
ascension2 | 0:dc1150daf908 | 9 | data[2] blind motor 0 close 1 open |
ascension2 | 0:dc1150daf908 | 10 | date[3] dust 0 |
ascension2 | 0:dc1150daf908 | 11 | date[4] illuminate 0 dark 1 bright |
ascension2 | 0:dc1150daf908 | 12 | date[5] LED 0 off 1 on 2 auto |
ascension2 | 0:dc1150daf908 | 13 | date[6] R100 value of R |
ascension2 | 0:dc1150daf908 | 14 | date[7] R10 |
ascension2 | 0:dc1150daf908 | 15 | date[8] R1 |
ascension2 | 0:dc1150daf908 | 16 | date[9] G100 value of G |
ascension2 | 0:dc1150daf908 | 17 | date[10] G10 |
ascension2 | 0:dc1150daf908 | 18 | date[11] G1 |
ascension2 | 0:dc1150daf908 | 19 | date[12] B100 value of B |
ascension2 | 0:dc1150daf908 | 20 | date[13] B10 |
ascension2 | 0:dc1150daf908 | 21 | date[14] B1 |
ascension2 | 0:dc1150daf908 | 22 | */ |
ascension2 | 0:dc1150daf908 | 23 | |
ascension2 | 2:a460007a35c7 | 24 | int AutoMode; |
ascension2 | 0:dc1150daf908 | 25 | float R,B,G; |
ascension2 | 0:dc1150daf908 | 26 | void Data_Receive(uint8_t S[]) |
ascension2 | 0:dc1150daf908 | 27 | { |
ascension2 | 0:dc1150daf908 | 28 | |
ascension2 | 0:dc1150daf908 | 29 | printf("data checking\n"); |
ascension2 | 0:dc1150daf908 | 30 | |
ascension2 | 2:a460007a35c7 | 31 | if(S[0]=='0') |
ascension2 | 2:a460007a35c7 | 32 | { |
ascension2 | 2:a460007a35c7 | 33 | AutoMode=0; // auto off |
ascension2 | 2:a460007a35c7 | 34 | } |
ascension2 | 2:a460007a35c7 | 35 | else if(S[0]=='1') |
ascension2 | 2:a460007a35c7 | 36 | { |
ascension2 | 2:a460007a35c7 | 37 | AutoMode=1; // auto on |
ascension2 | 2:a460007a35c7 | 38 | } |
ascension2 | 2:a460007a35c7 | 39 | |
ascension2 | 0:dc1150daf908 | 40 | if(S[1]=='0') |
ascension2 | 0:dc1150daf908 | 41 | { |
ascension2 | 3:32b328935a54 | 42 | motor1CCW(10); |
ascension2 | 0:dc1150daf908 | 43 | } |
ascension2 | 0:dc1150daf908 | 44 | else if(S[1]=='1') |
ascension2 | 0:dc1150daf908 | 45 | { |
ascension2 | 3:32b328935a54 | 46 | motor1CW(10); |
ascension2 | 0:dc1150daf908 | 47 | } |
ascension2 | 0:dc1150daf908 | 48 | |
ascension2 | 2:a460007a35c7 | 49 | else motor1Stop(); |
ascension2 | 2:a460007a35c7 | 50 | |
ascension2 | 0:dc1150daf908 | 51 | if(S[2]=='0') |
ascension2 | 0:dc1150daf908 | 52 | { |
ascension2 | 3:32b328935a54 | 53 | motor2CCW(10); |
ascension2 | 0:dc1150daf908 | 54 | } |
ascension2 | 0:dc1150daf908 | 55 | else if(S[2]=='1') |
ascension2 | 0:dc1150daf908 | 56 | { |
ascension2 | 3:32b328935a54 | 57 | motor2CW(10); |
ascension2 | 0:dc1150daf908 | 58 | } |
ascension2 | 2:a460007a35c7 | 59 | else motor2Stop(); |
ascension2 | 0:dc1150daf908 | 60 | if(S[5]=='0') |
ascension2 | 0:dc1150daf908 | 61 | { |
ascension2 | 0:dc1150daf908 | 62 | int j=6; |
ascension2 | 0:dc1150daf908 | 63 | R= ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); j=j+3; |
ascension2 | 0:dc1150daf908 | 64 | G = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 );j=j+3; |
ascension2 | 0:dc1150daf908 | 65 | B = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); |
ascension2 | 0:dc1150daf908 | 66 | setRGB(R,G,B,0); |
ascension2 | 0:dc1150daf908 | 67 | } |
ascension2 | 0:dc1150daf908 | 68 | else if(S[5]=='1') |
ascension2 | 0:dc1150daf908 | 69 | { |
ascension2 | 0:dc1150daf908 | 70 | int j=6; |
ascension2 | 0:dc1150daf908 | 71 | R= ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); j=j+3; |
ascension2 | 0:dc1150daf908 | 72 | G = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 );j=j+3; |
ascension2 | 0:dc1150daf908 | 73 | B = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); |
ascension2 | 0:dc1150daf908 | 74 | setRGB(R,G,B,1); |
ascension2 | 0:dc1150daf908 | 75 | } |
ascension2 | 0:dc1150daf908 | 76 | else if(S[5]=='2') |
ascension2 | 0:dc1150daf908 | 77 | { |
ascension2 | 0:dc1150daf908 | 78 | int j=6; |
ascension2 | 0:dc1150daf908 | 79 | R= ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); j=j+3; |
ascension2 | 0:dc1150daf908 | 80 | G = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 );j=j+3; |
ascension2 | 0:dc1150daf908 | 81 | B = ((S[j]-48)*100 )+((S[j+1]-48)*10 )+((S[j+2]-48)*1 ); |
ascension2 | 0:dc1150daf908 | 82 | setRGB(R,G,B,2); |
ascension2 | 3:32b328935a54 | 83 | printf("R=%f G=%f B=%f\n",R,G,B); |
ascension2 | 0:dc1150daf908 | 84 | } |
ascension2 | 2:a460007a35c7 | 85 | Dustcheck(); |
ascension2 | 0:dc1150daf908 | 86 | |
ascension2 | 0:dc1150daf908 | 87 | } |