22

Dependencies:   DISCO_L475VG_IOT01A_wifi

DataCheck.cpp

Committer:
ascension2
Date:
2019-08-20
Revision:
1:98939393d0db
Parent:
0:dc1150daf908

File content as of revision 1:98939393d0db:

#include "mbed.h"
#include "Motorcontrol.h"
#include "LEDcontrol.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
*/


float R,B,G;
void Data_Receive(uint8_t S[])
{
 
  printf("data checking\n");
    
     if(S[1]=='0')
     {
        motor1CCW(100);
     }
     else if(S[1]=='1')
     {
        motor1CW(100);
     }
     
    if(S[2]=='0')
     {
        motor2CCW(100);
     }
     else if(S[2]=='1')
     {
        motor2CW(100);
     }
     
     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);
     }
     
   
}