Lucky13
New member
Здравствуйте! Кто-нибудь подключал к esp8266 датчик жестов apds9960? Я столкнулся с проблемой: код компилируется, но при добавлении библиотек ESP8266WiFi.h и BlynkSimpleEsp8266.h, выдает ошибку. Поискал, оказывается проблема не у меня одного.
А вот собственно код:
Arduino: 1.8.1 (Windows 7), Плата:"WeMos D1 R2 & mini, 80 MHz, 921600, 4M (3M SPIFFS)"
In file included from C:\Users\Gamer\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:28:0,
from C:\Users\Gamer\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp8266.h:21,
from C:\Users\Gamer\Documents\Arduino\ESP8266_APDS996_Gesture_test\ESP8266_APDS996_Gesture_test.ino:42:
C:\Users\Gamer\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/include/wl_definitions.h:46:18: error: expected identifier before '-' token
#define NA_STATE -1
^
C:\Users\Gamer\Documents\Arduino\libraries\SparkFun_APDS9960_RGB_and_Gesture_Sensor\src/SparkFun_APDS9960.h:198:3: note: in expansion of macro 'NA_STATE'
NA_STATE,
^
C:\Users\Gamer\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/include/wl_definitions.h:46:18: error: expected '}' before '-' token
#define NA_STATE -1
^
C:\Users\Gamer\Documents\Arduino\libraries\SparkFun_APDS9960_RGB_and_Gesture_Sensor\src/SparkFun_APDS9960.h:198:3: note: in expansion of macro 'NA_STATE'
NA_STATE,
^
C:\Users\Gamer\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/include/wl_definitions.h:46:18: error: expected unqualified-id before '-' token
#define NA_STATE -1
^
C:\Users\Gamer\Documents\Arduino\libraries\SparkFun_APDS9960_RGB_and_Gesture_Sensor\src/SparkFun_APDS9960.h:198:3: note: in expansion of macro 'NA_STATE'
NA_STATE,
^
In file included from C:\Users\Gamer\Documents\Arduino\ESP8266_APDS996_Gesture_test\ESP8266_APDS996_Gesture_test.ino:44:0:
C:\Users\Gamer\Documents\Arduino\libraries\SparkFun_APDS9960_RGB_and_Gesture_Sensor\src/SparkFun_APDS9960.h:202:1: error: expected declaration before '}' token
};
^
exit status 1
Ошибка компиляции для платы WeMos D1 R2 & mini.
In file included from C:\Users\Gamer\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:28:0,
from C:\Users\Gamer\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp8266.h:21,
from C:\Users\Gamer\Documents\Arduino\ESP8266_APDS996_Gesture_test\ESP8266_APDS996_Gesture_test.ino:42:
C:\Users\Gamer\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/include/wl_definitions.h:46:18: error: expected identifier before '-' token
#define NA_STATE -1
^
C:\Users\Gamer\Documents\Arduino\libraries\SparkFun_APDS9960_RGB_and_Gesture_Sensor\src/SparkFun_APDS9960.h:198:3: note: in expansion of macro 'NA_STATE'
NA_STATE,
^
C:\Users\Gamer\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/include/wl_definitions.h:46:18: error: expected '}' before '-' token
#define NA_STATE -1
^
C:\Users\Gamer\Documents\Arduino\libraries\SparkFun_APDS9960_RGB_and_Gesture_Sensor\src/SparkFun_APDS9960.h:198:3: note: in expansion of macro 'NA_STATE'
NA_STATE,
^
C:\Users\Gamer\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/include/wl_definitions.h:46:18: error: expected unqualified-id before '-' token
#define NA_STATE -1
^
C:\Users\Gamer\Documents\Arduino\libraries\SparkFun_APDS9960_RGB_and_Gesture_Sensor\src/SparkFun_APDS9960.h:198:3: note: in expansion of macro 'NA_STATE'
NA_STATE,
^
In file included from C:\Users\Gamer\Documents\Arduino\ESP8266_APDS996_Gesture_test\ESP8266_APDS996_Gesture_test.ino:44:0:
C:\Users\Gamer\Documents\Arduino\libraries\SparkFun_APDS9960_RGB_and_Gesture_Sensor\src/SparkFun_APDS9960.h:202:1: error: expected declaration before '}' token
};
^
exit status 1
Ошибка компиляции для платы WeMos D1 R2 & mini.
Код:
//#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
//#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <SparkFun_APDS9960.h>
// Pins on wemos D1 mini
#define APDS9960_INT D6 //AKA GPIO12 -- Interupt pin
#define APDS9960_SDA D3 //AKA GPIO0
#define APDS9960_SCL D1 //AKA GPIO5
// Constants
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
volatile bool isr_flag = 0;
void setup() {
//Start I2C with pins defined above
Wire.begin(APDS9960_SDA,APDS9960_SCL);
// Set interrupt pin as input
pinMode(APDS9960_INT, INPUT);
// Initialize Serial port
Serial.begin(115200);
Serial.println();
Serial.println(F("--------------------------------"));
Serial.println(F("SparkFun APDS-9960 - GestureTest"));
Serial.println(F("--------------------------------"));
// Initialize interrupt service routine
attachInterrupt(APDS9960_INT, interruptRoutine, FALLING);
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Start running the APDS-9960 gesture sensor engine
if ( apds.enableGestureSensor(true) ) {
Serial.println(F("Gesture sensor is now running"));
} else {
Serial.println(F("Something went wrong during gesture sensor init!"));
}
}
void loop() {
if( isr_flag == 1 ) {
detachInterrupt(APDS9960_INT);
handleGesture();
isr_flag = 0;
attachInterrupt(APDS9960_INT, interruptRoutine, FALLING);
}
}
void interruptRoutine() {
isr_flag = 1;
}
void handleGesture() {
if ( apds.isGestureAvailable() ) {
switch ( apds.readGesture() ) {
case DIR_UP:
Serial.println("UP");
break;
case DIR_DOWN:
Serial.println("DOWN");
break;
case DIR_LEFT:
Serial.println("LEFT");
break;
case DIR_RIGHT:
Serial.println("RIGHT");
break;
case DIR_NEAR:
Serial.println("NEAR");
break;
case DIR_FAR:
Serial.println("FAR");
break;
default:
Serial.println("NONE");
}
}
}