收藏官网首页
查看: 22718|回复: 13

[求助] GOKIT Arduino开发板长按KEY2 绿灯不亮

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
跳转到指定楼层
楼主
发表于 2017-3-6 21:18:50 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
汉枫LPB120模块
新手求助,我将networkconfig.ino 上传至arduinoUnoWiFi 成功后,长按KEY2 绿灯不亮,我刚拿到板子时,用板子自带的程序是可以的,求教是什么原因,怎么解决?多谢!

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
沙发
 楼主| 发表于 2017-3-6 21:22:34 | 只看该作者
长传的时候显示长传不成功,我将ESP8266-12F拿下后,再长传就成功了,这时候按KEY2,绿灯就不亮 ,我的是G2板

321

主题

1054

帖子

4504

积分

论坛元老

Rank: 8Rank: 8

积分
4504
QQ
板凳
发表于 2017-3-6 21:27:25 | 只看该作者
一会是arduinoUnoWiFi 板卡,一会是Gokit2,到底是哪个板子呢

点评

您好,还得麻烦您一下,现在长按KEY2时RGB_LED绿灯亮,但是添加设备的时候搜索不到设备,请教一下这是为什么?怎么解决?谢谢!  详情 回复 发表于 2017-3-7 13:32
我看了一下邮件,发给我的是Gokit二代  详情 回复 发表于 2017-3-6 21:35
不好意思,我是去年免费申请的,MCU开发是时候选择的是arduinoUnoWiFi ,新手,不明白二者的区别,见谅  详情 回复 发表于 2017-3-6 21:32
1、机智云QQ群:G1群:104975951 G2群:491509598 G3群:287087942
机智云爱好者-APP开发群: 599735135
QQ群目前非常活跃,欢迎大家参与进来,交流,讨论,答疑,解惑~~
2、机智云微信公众号: 机智云 gizwits、 机智云智能宠物屋go-iot
关注机智云Gizwits官方公众号随时掌握最新资讯和活动信息

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
地板
 楼主| 发表于 2017-3-6 21:32:55 | 只看该作者
bigfanofloT 发表于 2017-3-6 21:27
一会是arduinoUnoWiFi 板卡,一会是Gokit2,到底是哪个板子呢

不好意思,我是去年免费申请的,MCU开发是时候选择的是arduinoUnoWiFi ,新手,不明白二者的区别,见谅

点评

那么你选择错了。arduinoUnoWiFi是另一款板卡,比这个gokit2需要选择mcu+wifi方案,先把文档中心的东西通读一遍吧,文档中心做了很大的改变。  详情 回复 发表于 2017-3-6 21:37

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
5#
 楼主| 发表于 2017-3-6 21:35:35 | 只看该作者
校园创客福利
bigfanofloT 发表于 2017-3-6 21:27
一会是arduinoUnoWiFi 板卡,一会是Gokit2,到底是哪个板子呢

我看了一下邮件,发给我的是Gokit二代

321

主题

1054

帖子

4504

积分

论坛元老

Rank: 8Rank: 8

积分
4504
QQ
6#
发表于 2017-3-6 21:37:26 | 只看该作者
绣衣直指 发表于 2017-3-6 21:32
不好意思,我是去年免费申请的,MCU开发是时候选择的是arduinoUnoWiFi ,新手,不明白二者的区别,见谅 ...

那么你选择错了。arduinoUnoWiFi是另一款板卡,你这个gokit2需要选择mcu+wifi方案,先把文档中心的东西通读一遍吧,文档中心做了很大的改变。

点评

好的,谢谢,打扰了  详情 回复 发表于 2017-3-6 21:38
1、机智云QQ群:G1群:104975951 G2群:491509598 G3群:287087942
机智云爱好者-APP开发群: 599735135
QQ群目前非常活跃,欢迎大家参与进来,交流,讨论,答疑,解惑~~
2、机智云微信公众号: 机智云 gizwits、 机智云智能宠物屋go-iot
关注机智云Gizwits官方公众号随时掌握最新资讯和活动信息

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
7#
 楼主| 发表于 2017-3-6 21:38:51 | 只看该作者
bigfanofloT 发表于 2017-3-6 21:37
那么你选择错了。arduinoUnoWiFi是另一款板卡,你这个gokit2需要选择mcu+wifi方案,先把文档中心的东西通 ...

好的,谢谢,打扰了

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
8#
 楼主| 发表于 2017-3-7 13:32:07 | 只看该作者
bigfanofloT 发表于 2017-3-6 21:27
一会是arduinoUnoWiFi 板卡,一会是Gokit2,到底是哪个板子呢

您好,还得麻烦您一下,现在长按KEY2时RGB_LED绿灯亮,但是添加设备的时候搜索不到设备,请教一下这是为什么?怎么解决?谢谢!

点评

方便的的话,把工程代码发上来看下  详情 回复 发表于 2017-3-7 13:43

321

主题

1054

帖子

4504

积分

论坛元老

Rank: 8Rank: 8

积分
4504
QQ
9#
发表于 2017-3-7 13:43:18 | 只看该作者
绣衣直指 发表于 2017-3-7 13:32
您好,还得麻烦您一下,现在长按KEY2时RGB_LED绿灯亮,但是添加设备的时候搜索不到设备,请教一下这是为 ...

方便的的话,把工程代码发上来看下

点评

就是官网上下的微信宠物屋程序  详情 回复 发表于 2017-3-7 14:21
麻烦了,不胜感激  详情 回复 发表于 2017-3-7 13:48
1、机智云QQ群:G1群:104975951 G2群:491509598 G3群:287087942
机智云爱好者-APP开发群: 599735135
QQ群目前非常活跃,欢迎大家参与进来,交流,讨论,答疑,解惑~~
2、机智云微信公众号: 机智云 gizwits、 机智云智能宠物屋go-iot
关注机智云Gizwits官方公众号随时掌握最新资讯和活动信息

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
10#
 楼主| 发表于 2017-3-7 13:47:22 | 只看该作者
注册成为机智云开发者,手机加虚拟设备快速开发
bigfanofloT 发表于 2017-3-7 13:43
方便的的话,把工程代码发上来看下
  1. /**************************************
  2. *
  3. * @file      [gokit_2.ino]
  4. * @author    [True]
  5. * @version   V2.3
  6. * @date      2015-07-06
  7. *
  8. * @brief     机智云 只为智能硬件而生
  9. *            Gizwits Smart Cloud  for Smart Products
  10. *            链接|增值|开放|中立|安全|自有|自由|生态
  11. *            www.gizwits.com
  12. *
  13. **************************************/

  14. #include <Arduino.h>
  15. #include <DHT.h>
  16. #include <I2Cdev.h>
  17. #include <MemoryFree.h>
  18. #include <MsTimer2.h>
  19. #include <ChainableLED.h>
  20. #include <SoftwareSerial.h>
  21. #include <Wire.h>
  22. #include <GizWits.h>
  23. #include <ringbuffer.h>

  24. /****************** HAL define ******************/
  25. #define   Infrared_PIN      2
  26. #define   DHTPIN            3
  27. #define   MOTOR_PINA        4
  28. #define   MOTOR_PINB        5
  29. #define   KEY1              6
  30. #define   KEY2              7

  31. #define   DHTTYPE           DHT11

  32. #define   KEY1_SHORT_PRESS  1
  33. #define   KEY1_LONG_PRESS   2
  34. #define   KEY2_SHORT_PRESS  4
  35. #define   KEY2_LONG_PRESS   8
  36. #define   NO_KEY            0
  37. #define   KEY_LONG_TIMER    3   //( 3s )

  38. #define   MOTOR_MAX         100
  39. #define   MOTOR_MAX1        -100
  40. #define   MOTOR_MIN         0
  41. #define   MOTOR_16

  42. uint8_t gaterSensorFlag ;
  43. uint8_t Set_LedStatus = 0;
  44. uint8_t NetConfigureFlag = 0;
  45. uint32_t Last_KeyTime = 0;
  46. uint8_t lastTem = 0, lastHum = 0;

  47. DHT dht(DHTPIN, DHTTYPE);
  48. ChainableLED leds(A5, A4, 1);

  49. #if(DEBUG == 1)
  50. SoftwareSerial mySerial(8, 9); // RX, TX
  51. #endif

  52. #ifdef  MOTOR_16
  53. typedef uint16_t MOTOR_T;
  54. #else
  55. typedef uint8_t MOTOR_T;
  56. #endif

  57. typedef enum
  58. {
  59.   SetLED_OnOff    = 0x01,
  60.   SetLED_Color    = 0x02,
  61.   SetLED_R        = 0x04,
  62.   SetLED_G        = 0x08,
  63.   SetLED_B        = 0x10,
  64.   SetMotor        = 0x20,

  65. } Attr_FlagsTypeDef;

  66. typedef enum
  67. {
  68.   LED_OnOff       = 0x00,
  69.   LED_OnOn        = 0x01,
  70.   LED_Costom      = 0x00,
  71.   LED_Yellow      = 0x02,
  72.   LED_Purple      = 0x04,
  73.   LED_Pink        = 0x06,

  74. } LED_ColorTypeDef;

  75. typedef struct
  76. {
  77.   uint8_t       LED_Cmd;
  78.   uint8_t       LED_R;
  79.   uint8_t       LED_G;
  80.   uint8_t       LED_B;
  81.   MOTOR_T       Motor;
  82.   uint8_t       Infrared;
  83.   uint8_t       Temperature;
  84.   uint8_t       Humidity;
  85.   uint8_t       Alert;
  86.   uint8_t       Fault;
  87. } ReadTypeDef_t;

  88. typedef struct
  89. {
  90.   uint8_t             Attr_Flags;
  91.   uint8_t             LED_Cmd;
  92.   uint8_t             LED_R;
  93.   uint8_t             LED_G;
  94.   uint8_t             LED_B;
  95.   MOTOR_T             Motor;
  96. } WirteTypeDef_t;

  97. WirteTypeDef_t  WirteTypeDef;
  98. ReadTypeDef_t ReadTypeDef;
  99. void GizWits_GatherSensorData(void);
  100. void GizWits_ControlDeviceHandle(void);
  101. void Motor_status(MOTOR_T motor_speed);

  102. /*************************************
  103. *    function      : DHT11_Read_Data
  104. *    Description   : set gokit colorrgb led
  105. *    return        : none
  106. *
  107. *    Add by Alex.lin    --2015-7-1
  108. ************************************/
  109. void DHT11_Read_Data(unsigned char * temperature, unsigned char * humidity)
  110. {
  111.   *temperature = (unsigned char)dht.readTemperature();
  112.   *humidity = (unsigned char)dht.readHumidity();
  113.   return;
  114. }

  115. /*************************************
  116. *    function      : IR_Handle
  117. *    Description   : set gokit colorrgb led
  118. *    return        : none
  119. *
  120. *    Add by Alex.lin    --2015-7-1
  121. ************************************/
  122. bool IR_Handle(void)
  123. {
  124.   if (digitalRead(Infrared_PIN))
  125.   {
  126.     return 0;
  127.   }
  128.   else
  129.   {
  130.     return 1;
  131.   }
  132. }

  133. /*************************************
  134. *    function      : LED_RGB_Control
  135. *    Description   : set gokit colorrgb led
  136. *    return        : none
  137. *
  138. *    Add by Alex.lin    --2015-7-1
  139. ************************************/
  140. void LED_RGB_Control(byte red, byte green, byte blue)
  141. {
  142.   leds.setColorRGB(0, red, green, blue);
  143. }

  144. /*************************************
  145. *    function      : gokit_motor_init
  146. *    Description   : init gokit motor.
  147. *    return        : none
  148. *
  149. *    Add by Alex.lin    --2014-12-25
  150. ************************************/
  151. void Motor_Init(void)
  152. {
  153.   pinMode(MOTOR_PINA, OUTPUT);
  154.   pinMode(MOTOR_PINB, OUTPUT);
  155.   digitalWrite(MOTOR_PINB, LOW);
  156.   digitalWrite(MOTOR_PINA, LOW);
  157.   Motor_status((MOTOR_T)5);
  158. }

  159. /*************************************
  160. *    function      : Motor_status
  161. *    Description   : set gokit motor speed.
  162. *    return        : none
  163. *
  164. *    --2015-7-1
  165. ************************************/
  166. void Motor_status(MOTOR_T motor_speed)
  167. {

  168.   unsigned char Temp_motor_speed = 0;
  169.   if (motor_speed == 5) //停止
  170.   {
  171.     digitalWrite(MOTOR_PINA, LOW);
  172.     digitalWrite(MOTOR_PINB, LOW);
  173.   }
  174.   if (motor_speed > 5) //正转
  175.   {
  176.     Temp_motor_speed = (motor_speed - 5) * 51;
  177.     if (Temp_motor_speed > 255) Temp_motor_speed = 255;
  178.     digitalWrite(MOTOR_PINA, LOW);
  179.     analogWrite( MOTOR_PINB, Temp_motor_speed);
  180.   }
  181.   if (motor_speed < 5) //反转
  182.   {
  183.    Temp_motor_speed = 255 - (5 - motor_speed) * 51; //Temp_motor_speed = (255 - (5 + motor_speed)) * 51;
  184.     if (Temp_motor_speed > 255) Temp_motor_speed = 255;
  185.     digitalWrite(MOTOR_PINA, HIGH);
  186.     analogWrite( MOTOR_PINB, Temp_motor_speed );
  187.   }
  188. }

  189. /*************************************
  190. *    function      : gokit_time_ms
  191. *    Description   : gokit running time form power on
  192. *    return        : gokit running time(ms).
  193. *    Add by Alex.lin    --2014-12-25
  194. ************************************/
  195. unsigned long gokit_time_ms(void)
  196. {
  197.   return millis();
  198. }
  199. /*************************************
  200. *    function      : gokit_time_m
  201. *    Description   : gokit running time form power on
  202. *    return        : gokit running time(m).
  203. *    Add by Alex.lin    --2014-12-25
  204. ************************************/
  205. unsigned long gokit_time_s(void)
  206. {
  207.   return millis() / 1000;
  208. }

  209. /*************************************
  210. *    function      : gokit_key1down
  211. *    Description   : check the gokit key1 event
  212. *    return        : KEY1_LONG_PRESS  KEY1_SHORT_PRESS
  213. *                     0-no keydown event.
  214. *    Add by Alex.lin    --2014-12-25
  215. ************************************/
  216. char gokit_key1down(void)
  217. {
  218.   int unsigned long keep_time = 0;
  219.   if (digitalRead(KEY1) == LOW)
  220.   {
  221.     delay(100);
  222.     if (digitalRead(KEY1) == LOW)
  223.     {
  224.       keep_time = gokit_time_s();
  225.       while (digitalRead(KEY1) == LOW)
  226.       {
  227.         if ((gokit_time_s() - keep_time) > KEY_LONG_TIMER)
  228.         {
  229.           Last_KeyTime = gokit_time_s();
  230.           return KEY1_LONG_PRESS;
  231.         }
  232.       } //until open the key

  233.       if ((gokit_time_s() - Last_KeyTime) > KEY_LONG_TIMER)
  234.       {
  235.         return KEY1_SHORT_PRESS;
  236.       }
  237.       return 0;
  238.     }
  239.     return 0;
  240.   }
  241.   return 0;
  242. }

  243. /*************************************
  244. *    function      : gokit_key2down
  245. *    Description   : check the gokit key2 event
  246. *    return        : KEY2_LONG_PRESS  KEY2_SHORT_PRESS
  247. *                     0-no keydown event.
  248. *    Add by Alex.lin    --2014-12-25
  249. ************************************/
  250. char gokit_key2down(void)
  251. {
  252.   int unsigned long keep_time = 0;
  253.   if (digitalRead(KEY2) == LOW)
  254.   {
  255.     delay(100);
  256.     if (digitalRead(KEY2) == LOW)
  257.     {
  258.       keep_time = gokit_time_s();
  259.       while (digitalRead(KEY2) == LOW) //until open the key
  260.       {

  261.         if ((gokit_time_s() - keep_time) > KEY_LONG_TIMER)
  262.         {
  263.           Last_KeyTime = gokit_time_s();
  264.           return KEY2_LONG_PRESS;
  265.         }
  266.       }

  267.       if ((gokit_time_s() - Last_KeyTime) > KEY_LONG_TIMER)
  268.       {
  269.         return KEY2_SHORT_PRESS;
  270.       }
  271.       return 0;
  272.     }
  273.     return 0;
  274.   }
  275.   return 0;
  276. }

  277. /*************************************
  278. *    function      : gokit_keydown
  279. *    Description   : check the gokit key1 or key2 event
  280. *    return        : KEY1_LONG_PRESS  KEY1_SHORT_PRESS
  281. *                    KEY2_LONG_PRESS  KEY2_SHORT_PRESS
  282. *                     0-no keydown event.
  283. *    Add by Alex.lin    --2014-12-25
  284. ************************************/
  285. char gokit_keydown(void)
  286. {
  287.   char ret = 0;
  288.   ret |= gokit_key2down();
  289.   ret |= gokit_key1down();
  290.   return ret;

  291. }

  292. void KEY_Handle(void)
  293. {
  294.   /*  长按是指按住按键3s以上   */
  295.   switch (gokit_keydown())
  296.   {
  297.     case KEY1_SHORT_PRESS:
  298. #if (DEBUG==1)
  299.       mySerial.println(F("KEY1_SHORT_PRESS"));
  300. #endif
  301.       //LED_RGB_Control(0, 0, 0);
  302.       break;
  303.     case KEY1_LONG_PRESS:
  304. #if (DEBUG==1)
  305.       mySerial.println(F("KEY1_LONG_PRESS ,Wifi Reset"));
  306. #endif
  307.       //LED_RGB_Control(0, 10, 0);
  308.       GizWits_D2WResetCmd();
  309.       break;
  310.     case KEY2_SHORT_PRESS:
  311. #if (DEBUG==1)
  312.       mySerial.println(F("KEY2_SHORT_PRESS Soft AP mode"));
  313. #endif
  314.       //Soft AP mode, RGB red
  315.       LED_RGB_Control(10, 0, 0);
  316.       GizWits_D2WConfigCmd(SoftAp_Mode);
  317.       NetConfigureFlag = 1;
  318.       break;
  319.     case KEY2_LONG_PRESS:
  320. #if (DEBUG==1)
  321.       mySerial.println(F("KEY2_LONG_PRESS ,AirLink mode"));
  322. #endif
  323.       //AirLink mode, RGB green
  324.       LED_RGB_Control(0, 10, 0);
  325.       GizWits_D2WConfigCmd(AirLink_Mode);
  326.       NetConfigureFlag = 1;
  327.       break;
  328.     default:
  329.       break;
  330.   }
  331. }

  332. /*****************************************************
  333. * Function Name  : GizWits_WiFiStatueHandle
  334. * Description    : Callback function , Judge Wifi statue
  335. * Input          : None
  336. * Output         : None
  337. * Return         : Bit , Attr_Flags
  338. * Attention     :
  339. *****************************************************/
  340. void GizWits_WiFiStatueHandle(uint16_t wifiStatue)
  341. {
  342.   if (((wifiStatue & Wifi_ConnClouds) == Wifi_ConnClouds) && (NetConfigureFlag == 1) ) //&& (NetConfigureFlag == 1)
  343.   {
  344. #if(DEBUG==1)
  345.     mySerial.println("W2M->Wifi_ConnClouds");
  346. #endif
  347.     NetConfigureFlag = 0;
  348.     LED_RGB_Control(0, 0, 0);
  349.   }
  350. }

  351. void GoKit_Init()
  352. {
  353. #if(DEBUG==1)
  354.   //自定义引脚通信SoftwareSerial初始
  355.   mySerial.begin(9600);
  356. #endif

  357.   //温度传感初始
  358.   dht.begin();

  359.   //RGB LED初始
  360.   leds.init();
  361.   digitalWrite(A0, HIGH);//使能RGB LED

  362.   //按键初始
  363.   pinMode(KEY1, INPUT_PULLUP); //KEY1 上拉输入
  364.   pinMode(KEY2, INPUT_PULLUP); //KEY2 上拉输入

  365.   //attachInterrupt(0, gokit_IR_event, CHANGE);//当引脚电平发生变化,触发中断函数gokit_IR_event pin 2

  366.   //电机初始
  367.   Motor_Init();
  368.   LED_RGB_Control(0, 0, 0);

  369.   memset(&ReadTypeDef, 0, sizeof(ReadTypeDef));
  370.   ReadTypeDef.Motor = exchangeBytes(5);//“Motor_Speed”默认上报值应该是5
  371.   memset(&WirteTypeDef, 0, sizeof(WirteTypeDef));
  372.   GizWits_init(sizeof(ReadTypeDef_t));
  373. }

  374. void setup()
  375. {
  376.   GoKit_Init();

  377. #if (DEBUG==1)
  378.   mySerial.println(F("GoKit init  OK!"));
  379.   mySerial.print(F("freeMemory()="));
  380.   mySerial.println(freeMemory());
  381. #endif

  382. }
  383. void loop()
  384. {
  385.   uint8_t ret = 0;
  386.   uint8_t buf[256];

  387.   KEY_Handle();
  388.   ret = GizWits_MessageHandle(buf, sizeof(WirteTypeDef_t));
  389.   if (ret == 0)
  390.   {
  391.     memcpy((uint8_t *)&WirteTypeDef, buf, sizeof(WirteTypeDef_t));
  392.     GizWits_ControlDeviceHandle();
  393.     GizWits_DevStatusUpgrade((uint8_t *)&ReadTypeDef, 10 * 60 * 1000, 1, NetConfigureFlag);
  394.   }
  395.   if (gaterSensorFlag != 0)
  396.   {
  397.     GizWits_GatherSensorData();
  398.     gaterSensorFlag = 0;
  399.   }
  400.   GizWits_DevStatusUpgrade((uint8_t *)&ReadTypeDef, 10 * 60 * 1000, 0, NetConfigureFlag);

  401. }

  402. void GizWits_ControlDeviceHandle(void)
  403. {
  404.   if ( (WirteTypeDef.Attr_Flags & (1 << 0)) == (1 << 0))
  405.   {
  406.     if (Set_LedStatus != 1)
  407.     {
  408.       if (WirteTypeDef.LED_Cmd == LED_OnOff)
  409.       {
  410.         LED_RGB_Control(0, 0, 0);
  411.         ReadTypeDef.LED_Cmd = LED_OnOff;
  412. #if(DEBUG==1)
  413.         mySerial.print(F("SetLED_Off")); mySerial.println("");
  414. #endif
  415.       }
  416.       if (WirteTypeDef.LED_Cmd == LED_OnOn)
  417.       {
  418.         ReadTypeDef.LED_Cmd = LED_OnOn;
  419.         LED_RGB_Control(254, 0, 0);
  420. #if(DEBUG==1)
  421.         mySerial.print(F("SetLED_On")); mySerial.println("");
  422. #endif
  423.       }
  424.     }

  425.   }
  426.   if ( (WirteTypeDef.Attr_Flags & (1 << 1)) == (1 << 1))
  427.   {
  428.     if (WirteTypeDef.LED_Cmd == LED_Costom)
  429.     {
  430.       ReadTypeDef.LED_Cmd = LED_Costom;
  431.       ReadTypeDef.LED_R = 0;
  432.       ReadTypeDef.LED_G = 0;
  433.       ReadTypeDef.LED_B = 0;
  434.       Set_LedStatus = 0;
  435.       LED_RGB_Control(0, 0, 0);
  436. #if(DEBUG==1)
  437.       mySerial.print(F("SetLED LED_Costom")); mySerial.println("");
  438. #endif
  439.     }
  440.     if (WirteTypeDef.LED_Cmd == LED_Yellow)
  441.     {
  442.       Set_LedStatus = 1;
  443.       ReadTypeDef.LED_Cmd = LED_Yellow;
  444.       ReadTypeDef.LED_R = 254;
  445.       ReadTypeDef.LED_G = 254;
  446.       ReadTypeDef.LED_B = 0;

  447.       LED_RGB_Control(254, 254, 0);
  448. #if(DEBUG==1)
  449.       mySerial.print(F("SetLED LED_Yellow")); mySerial.println("");
  450. #endif
  451.     }

  452.     if (WirteTypeDef.LED_Cmd == LED_Purple)
  453.     {
  454.       ReadTypeDef.LED_Cmd = LED_Purple;
  455.       ReadTypeDef.LED_R = 254;
  456.       ReadTypeDef.LED_G = 0;
  457.       ReadTypeDef.LED_B = 70;
  458.       Set_LedStatus = 1;
  459.       LED_RGB_Control(254, 0, 70);
  460. #if(DEBUG==1)
  461.       mySerial.print(F("SetLED LED_Purple")); mySerial.println("");
  462. #endif
  463.     }
  464.     if (WirteTypeDef.LED_Cmd == LED_Pink)
  465.     {
  466.       ReadTypeDef.LED_Cmd = LED_Pink;
  467.       ReadTypeDef.LED_R = 238;
  468.       ReadTypeDef.LED_G = 30;
  469.       ReadTypeDef.LED_B = 30;
  470.       Set_LedStatus = 1;
  471.       LED_RGB_Control(238 , 30 , 30);
  472. #if(DEBUG==1)
  473.       mySerial.print(F("SetLED LED_Pink")); mySerial.println("");
  474. #endif
  475.     }
  476.   }
  477.   if ( (WirteTypeDef.Attr_Flags & (1 << 2)) == (1 << 2))
  478.   {
  479.     if (Set_LedStatus != 1)
  480.     {
  481.       ReadTypeDef.LED_R = WirteTypeDef.LED_R;
  482. #if(DEBUG==1)
  483.       mySerial.print(F("W2D Control LED_R = ")); mySerial.print(WirteTypeDef.LED_R, HEX); mySerial.println("");
  484. #endif
  485.       LED_RGB_Control(ReadTypeDef.LED_R, ReadTypeDef.LED_G, ReadTypeDef.LED_B);
  486.     }

  487.   }
  488.   if ( (WirteTypeDef.Attr_Flags & (1 << 3)) == (1 << 3))
  489.   {
  490.     if (Set_LedStatus != 1)
  491.     {
  492.       ReadTypeDef.LED_G = WirteTypeDef.LED_G;
  493. #if(DEBUG==1)
  494.       mySerial.print(F("W2D Control LED_G = ")); mySerial.print(WirteTypeDef.LED_G, HEX); mySerial.println("");
  495. #endif
  496.       LED_RGB_Control(ReadTypeDef.LED_R, ReadTypeDef.LED_G, ReadTypeDef.LED_B);
  497.     }

  498.   }
  499.   if ( (WirteTypeDef.Attr_Flags & (1 << 4)) == (1 << 4))
  500.   {
  501.     if (Set_LedStatus != 1)
  502.     {
  503.       ReadTypeDef.LED_B = WirteTypeDef.LED_B;
  504. #if(DEBUG==1)
  505.       mySerial.print(F("W2D Control LED_B = ")); mySerial.print(WirteTypeDef.LED_B, HEX); mySerial.println("");
  506. #endif
  507.       LED_RGB_Control(ReadTypeDef.LED_R, ReadTypeDef.LED_G, ReadTypeDef.LED_B);
  508.     }

  509.   }
  510.   if ( (WirteTypeDef.Attr_Flags & (1 << 5)) == (1 << 5))
  511.   {
  512.     ReadTypeDef.Motor = WirteTypeDef.Motor;
  513. #ifdef MOTOR_16
  514. #if(DEBUG==1)
  515.     mySerial.print(F("W2D Control Motor = ")); mySerial.print(exchangeBytes(WirteTypeDef.Motor), HEX); mySerial.println("");
  516. #endif
  517.     Motor_status(exchangeBytes(WirteTypeDef.Motor));
  518. #else
  519. #if(DEBUG==1)
  520.     mySerial.print(F("W2D Control Motor = ")); mySerial.print(exchangeBytes(WirteTypeDef.Motor), HEX); mySerial.println("");
  521. #endif
  522.     Motor_status(WirteTypeDef.Motor);
  523. #endif
  524.   }
  525. }

  526. /*****************************************************
  527. * Function Name  : GizWits_GatherSensorData();
  528. * Description    : Gather Sensor Data
  529. * Input          : None
  530. * Output         : None
  531. * Return         : None
  532. * Attention                 : None
  533. *****************************************************/
  534. void GizWits_GatherSensorData(void)
  535. {
  536.   uint8_t curTem, curHum;

  537.   ReadTypeDef.Infrared = IR_Handle();
  538.   DHT11_Read_Data(&curTem, &curHum);
  539.   ReadTypeDef.Temperature = (curTem + lastTem) / 2;
  540.   ReadTypeDef.Humidity = (curHum + lastHum) / 2;
  541.   ReadTypeDef.Temperature = ReadTypeDef.Temperature + 13;//Temperature Data Correction
  542.   lastTem = curTem;
  543.   lastHum = curHum;
  544. }
复制代码

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
11#
 楼主| 发表于 2017-3-7 13:48:10 | 只看该作者
bigfanofloT 发表于 2017-3-7 13:43
方便的的话,把工程代码发上来看下

麻烦了,不胜感激

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
12#
 楼主| 发表于 2017-3-7 14:21:44 | 只看该作者
bigfanofloT 发表于 2017-3-7 13:43
方便的的话,把工程代码发上来看下

就是官网上下的微信宠物屋程序

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
13#
 楼主| 发表于 2017-3-7 14:42:07 | 只看该作者
虽然上传成功但是有这样的提示

CO@TU_@4~MNPO@GZR$G$5OD.png (6.31 KB, 下载次数: 103)

CO@TU_@4~MNPO@GZR$G$5OD.png

点评

改了一下就没这个了  详情 回复 发表于 2017-3-7 14:43

4

主题

22

帖子

106

积分

注册会员

Rank: 2

积分
106
14#
 楼主| 发表于 2017-3-7 14:43:25 | 只看该作者
绣衣直指 发表于 2017-3-7 14:42
虽然上传成功但是有这样的提示

改了一下就没这个了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

加入Q群 返回顶部

版权与免责声明 © 2006-2024 Gizwits IoT Technology Co., Ltd. ( 粤ICP备11090211号 )

快速回复 返回顶部 返回列表