我按照这篇文档做的《30分钟用arduino开发属于自己智能灯》,库文件都已经放在libiaries里面了,但是还是报错
我修改后的代码是这个
#include <Gizwits.h> #include <Wire.h> #include <SoftwareSerial.h> #include <ChainableLED.h>
SoftwareSerial mySerial(A2, A3); // A2 -> RX, A3 -> TX
Gizwits myGizwits;
#define KEY1 6 #define KEY2 7 #define KEY1_SHORT_PRESS 1 #define KEY1_LONG_PRESS 2 #define KEY2_SHORT_PRESS 4 #define KEY2_LONG_PRESS 8 #define NO_KEY 0 #define KEY_LONG_TIMER 3 unsigned long Last_KeyTime = 0; uint8_t Set_LedStatus = 0;
ChainableLED leds(A5,A4,1);
void LED_RGB_Control(byte red,byte green,byte blue) { leds.setColorRGB(0,red,green,blue); }
unsigned long gokit_time_s(void) { return millis() / 1000; }
char gokit_key1down(void) { unsigned long keep_time = 0; if (digitalRead(KEY1) == LOW) { delay(100); if (digitalRead(KEY1) == LOW) { keep_time = gokit_time_s(); while (digitalRead(KEY1) == LOW) { if ((gokit_time_s() - keep_time) > KEY_LONG_TIMER) { Last_KeyTime = gokit_time_s(); return KEY1_LONG_PRESS; } } //until open the key
if ((gokit_time_s() - Last_KeyTime) > KEY_LONG_TIMER) { return KEY1_SHORT_PRESS; } return 0; } return 0; } return 0; }
char gokit_key2down(void) { int unsigned long keep_time = 0; if (digitalRead(KEY2) == LOW) { delay(100); if (digitalRead(KEY2) == LOW) { keep_time = gokit_time_s(); while (digitalRead(KEY2) == LOW) //until open the key {
if ((gokit_time_s() - keep_time) > KEY_LONG_TIMER) { Last_KeyTime = gokit_time_s(); return KEY2_LONG_PRESS; } }
if ((gokit_time_s() - Last_KeyTime) > KEY_LONG_TIMER) { return KEY2_SHORT_PRESS; } return 0; } return 0; } return 0; }
char gokit_keydown(void) { char ret = 0; ret |= gokit_key2down(); ret |= gokit_key1down(); return ret;
}
/** * KEY_Handle * @param none * @return none */ void KEY_Handle(void) { /* Press for over than 3 second is Long Press */ switch (gokit_keydown()) { case KEY1_SHORT_PRESS: mySerial.println(F("KEY1_SHORT_PRESS , Production Test Mode ")); myGizwits.setBindMode(WIFI_PRODUCTION_TEST); break; case KEY1_LONG_PRESS: mySerial.println(F("KEY1_LONG_PRESS ,Wifi Reset")); myGizwits.setBindMode(WIFI_RESET_MODE); break; case KEY2_SHORT_PRESS: mySerial.println(F("KEY2_SHORT_PRESS Soft AP mode")); myGizwits.setBindMode(WIFI_SOFTAP_MODE); //Soft AP mode break; case KEY2_LONG_PRESS: mySerial.println(F("KEY2_LONG_PRESS ,AirLink mode")); myGizwits.setBindMode(WIFI_AIRLINK_MODE); //AirLink mode break; default: break; } }
/** * Serial Init , Gizwits Init * @param none * @return none */ void setup() { // put your setup code here, to run once: mySerial.begin(115200); leds.init(); digitalWrite(A0,HIGH); pinMode(KEY1, INPUT_PULLUP); pinMode(KEY2, INPUT_PULLUP); pinMode(5,OUTPUT);
myGizwits.begin();
mySerial.println("GoKit init OK \n"); }
/** * Wifi status printf * @param none * @return none */ void wifiStatusHandle() { if(myGizwits.wifiHasBeenSet(WIFI_SOFTAP)) { mySerial.println(F("WIFI_SOFTAP!")); } if(myGizwits.wifiHasBeenSet(WIFI_AIRLINK)) { mySerial.println(F("WIFI_AIRLINK!")); } if(myGizwits.wifiHasBeenSet(WIFI_STATION)) { mySerial.println(F("WIFI_STATION!")); } if(myGizwits.wifiHasBeenSet(WIFI_CON_ROUTER)) { mySerial.println(F("WIFI_CON_ROUTER!")); } if(myGizwits.wifiHasBeenSet(WIFI_DISCON_ROUTER)) { mySerial.println(F("WIFI_DISCON_ROUTER!")); } if(myGizwits.wifiHasBeenSet(WIFI_CON_M2M)) { mySerial.println(F("WIFI_CON_M2M!")); } if(myGizwits.wifiHasBeenSet(WIFI_DISCON_M2M)) { mySerial.println(F("WIFI_DISCON_M2M!")); } }
/** * Arduino loop * @param none * @return none */ void loop() { KEY_Handle();//key handle , network configure wifiStatusHandle();//WIFI Status Handle
bool varR_LED = 0; if(myGizwits.hasBeenSet(EVENT_LED)) { myGizwits.read(EVENT_LED,&varR_LED);//Address for storing data if (varR_LED == 1) { LED_RGB_Control(200,0,0); } else { LED_RGB_Control(0,0,0); }
} myGizwits.process(); }
报错的信息是这个
Arduino:1.8.4 (Windows 8.1), 开发板:"Arduino/Genuino Uno"
In file included from C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.c:16:0:
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.c: In function 'returnNtp2Wt':
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.h:67:23: warning: integer overflow in expression [-Woverflow]
#define DAY_SEC (24*60*60)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.c:246:21: note: in expansion of macro 'DAY_SEC'
if(utc >= x*DAY_SEC)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.h:67:23: warning: integer overflow in expression [-Woverflow]
#define DAY_SEC (24*60*60)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.c:248:22: note: in expansion of macro 'DAY_SEC'
utc -= x*DAY_SEC;
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.h:67:23: warning: integer overflow in expression [-Woverflow]
#define DAY_SEC (24*60*60)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.c:262:27: note: in expansion of macro 'DAY_SEC'
if(utc >= mons*DAY_SEC)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.h:67:23: warning: integer overflow in expression [-Woverflow]
#define DAY_SEC (24*60*60)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.c:264:28: note: in expansion of macro 'DAY_SEC'
utc -= mons*DAY_SEC;
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.h:67:23: warning: integer overflow in expression [-Woverflow]
#define DAY_SEC (24*60*60)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.c:277:19: note: in expansion of macro 'DAY_SEC'
if(utc >= DAY_SEC)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.h:67:23: warning: integer overflow in expression [-Woverflow]
#define DAY_SEC (24*60*60)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\common.c:279:20: note: in expansion of macro 'DAY_SEC'
utc -= DAY_SEC;
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\gizwits_protocol.c: In function 'gizwitsHandle':
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\gizwits_protocol.c:1243:13: warning: implicit declaration of function 'gizwitsEventProcess' [-Wimplicit-function-declaration]
gizwitsEventProcess(&gizwitsProtocol.issuedProcessEvent, (uint8_t *)&gizwitsProtocol.gizCurrentDataPoint, sizeof(dataPoint_t));
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:21:13: error: variable or field 'rb_new' declared void
void rb_new(RingBuffer* rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:21:13: error: 'RingBuffer' was not declared in this scope
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:21:25: error: 'rb' was not declared in this scope
void rb_new(RingBuffer* rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:34:15: error: variable or field 'rb_free' declared void
void rb_free(RingBuffer *rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:34:15: error: 'RingBuffer' was not declared in this scope
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:34:27: error: 'rb' was not declared in this scope
void rb_free(RingBuffer *rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:39:24: error: 'RingBuffer' was not declared in this scope
size_t rb_capacity(RingBuffer *rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:39:36: error: 'rb' was not declared in this scope
size_t rb_capacity(RingBuffer *rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:40:1: error: expected ',' or ';' before '{' token
{
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:44:24: error: 'RingBuffer' was not declared in this scope
size_t rb_can_read(RingBuffer *rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:44:36: error: 'rb' was not declared in this scope
size_t rb_can_read(RingBuffer *rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:45:1: error: expected ',' or ';' before '{' token
{
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:51:25: error: 'RingBuffer' was not declared in this scope
size_t rb_can_write(RingBuffer *rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:51:37: error: 'rb' was not declared in this scope
size_t rb_can_write(RingBuffer *rb)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:52:1: error: expected ',' or ';' before '{' token
{
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:57:20: error: 'RingBuffer' was not declared in this scope
size_t rb_read(RingBuffer *rb, void *data, size_t count)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:57:32: error: 'rb' was not declared in this scope
size_t rb_read(RingBuffer *rb, void *data, size_t count)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:57:36: error: expected primary-expression before 'void'
size_t rb_read(RingBuffer *rb, void *data, size_t count)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:57:55: error: expected primary-expression before 'count'
size_t rb_read(RingBuffer *rb, void *data, size_t count)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:57:60: warning: expression list treated as compound expression in initializer [-fpermissive]
size_t rb_read(RingBuffer *rb, void *data, size_t count)
^
C:\Users\Administrator\Documents\Arduino\libraries\Gizwits\ringbuffer.cpp:58:1: error: expected ',' or ';' before '{' token
{
^
exit status 1 为开发板 Arduino/Genuino Uno 编译时出错。
在文件 -> 首选项开启 “编译过程中显示详细输出”选项 这份报告会包含更多信息。
感觉不该有问题才对啊 求前辈们指点
|