|
8#
楼主 |
发表于 2016-10-18 23:24:33
|
只看该作者
本帖最后由 伯乐 于 2016-10-18 23:26 编辑
你好,谢谢解答。按你的写法呢,下面的判断如何写啊,我写的你看看,还是不行。。。标志位 数据点 结构体,一直没理清思路。麻烦帮忙看看,以后好整理点教程出来。谢谢!
- /******************
- typedef enum
- {
- SetLED_OnOff = 0x01,
- SetLED_Color = 0x02,
- SetLED_R = 0x04,
- SetLED_G = 0x08,
- SetLED_B = 0x10,
- SetMotor = 0x20,
- } Attr_FlagsTypeDef;
- ******************/
- typedef enum
- {
- LED_OnOff = 0x00,
- LED_OnOn = 0x01,
- } LED_TypeDef;
- typedef struct
- {
- uint8_t LED_r;
- uint8_t LED_g;
- uint8_t LED_b;
- } ReadTypeDef_t;
- typedef struct
- {
- uint8_t Attr_Flags;
- uint8_t LED;
- } WirteTypeDef_t;
- WirteTypeDef_t WirteTypeDef;
- ReadTypeDef_t ReadTypeDef;
- void GizWits_GatherSensorData(void);
- void GizWits_ControlDeviceHandle(void);
复制代码 判断语句:
- void GizWits_ControlDeviceHandle(void)
- {
- if ( (WirteTypeDef.Attr_Flags & (1 << 0)) == (1 << 0))
- {
- if (WirteTypeDef.LED == LED_OnOn)
- {
- ReadTypeDef.LED_r = LED_r;
- LED_RGB_Control(254, 0, 0);
- Serial.print(WirteTypeDef.LED);
- Serial.println("LED");
- }else{
- ReadTypeDef.LED_r = false;
- LED_RGB_Control(0, 0, 0);
- }
- }
- if ( (WirteTypeDef.Attr_Flags & (1 << 1)) == (1 << 1))
- {
- if (WirteTypeDef.LED == LED_OnOn)
- {
- ReadTypeDef.LED_g = LED_g;
- LED_RGB_Control(0, 254, 0);
- Serial.print(WirteTypeDef.LED);
- Serial.println("LED");
- }else{
- ReadTypeDef.LED_g = false;
- LED_RGB_Control(0, 0, 0);
- }
- }
- if ( (WirteTypeDef.Attr_Flags & (1 << 2)) == (1 << 2))
- {
- if (WirteTypeDef.LED == 0x01)
- {
- ReadTypeDef.LED_b = LED_b;
- LED_RGB_Control(0, 0, 254);
- }else{
- ReadTypeDef.LED_b = false;
- LED_RGB_Control(0, 0, 0);
- }
- }
- }
复制代码
|
|