From d4d181e1e3d886a0d6c282e0a98018dada3bd5c1 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Tue, 8 Dec 2020 20:52:05 +0100 Subject: [PATCH 1/7] added pio ini file for build examples (tested with .cpp files) --- .gitignore | 12 +++++++++++- platformio.ini | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 platformio.ini diff --git a/.gitignore b/.gitignore index 69d3944..7edc4c1 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,14 @@ *.out *.app -.vscode/* \ No newline at end of file +.vscode/* +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch + +# Vim backups +*.swp + + diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..9c65201 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,33 @@ +; CanAirIO Sensorlib +; +; Full guide and details: https://github.com/kike-canaries/canairio_sensorlib + + +[platformio] +src_dir = ./examples/Basics/ +lib_dir = ./ + +[env] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +monitor_filters = time +build_flags = + -D SRC_REV=092 + -D CORE_DEBUG_LEVEL=5 +lib_deps = + +[esp32_common] +platform = espressif32 +board = m5stack-core-esp32 +framework = ${env.framework} +upload_speed = ${env.upload_speed} +monitor_speed = ${env.monitor_speed} +lib_deps = ${env.lib_deps} +build_flags = + ${env.build_flags} + +[env:FactoryTest] +extends = esp32_common +src_filter = -<*> + + From 4716d52f2b655190317a3e8f4e4cfbe1808f1d57 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Sun, 20 Dec 2020 21:44:51 +0100 Subject: [PATCH 2/7] unnecessary Adafruit local header instead official header --- examples/Hat/ENV/Adafruit_Sensor.h | 156 ----------------------------- 1 file changed, 156 deletions(-) delete mode 100644 examples/Hat/ENV/Adafruit_Sensor.h diff --git a/examples/Hat/ENV/Adafruit_Sensor.h b/examples/Hat/ENV/Adafruit_Sensor.h deleted file mode 100644 index 8ac638f..0000000 --- a/examples/Hat/ENV/Adafruit_Sensor.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -* Copyright (C) 2008 The Android Open Source Project -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software< /span> -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* Update by K. Townsend (Adafruit Industries) for lighter typedefs, and - * extended sensor support to include color, voltage and current */ - -#ifndef _ADAFRUIT_SENSOR_H -#define _ADAFRUIT_SENSOR_H - -#ifndef ARDUINO - #include -#elif ARDUINO >= 100 - #include "Arduino.h" - #include "Print.h" -#else - #include "WProgram.h" -#endif - -/* Intentionally modeled after sensors.h in the Android API: - * https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h */ - -/* Constants */ -#define SENSORS_GRAVITY_EARTH (9.80665F) /**< Earth's gravity in m/s^2 */ -#define SENSORS_GRAVITY_MOON (1.6F) /**< The moon's gravity in m/s^2 */ -#define SENSORS_GRAVITY_SUN (275.0F) /**< The sun's gravity in m/s^2 */ -#define SENSORS_GRAVITY_STANDARD (SENSORS_GRAVITY_EARTH) -#define SENSORS_MAGFIELD_EARTH_MAX (60.0F) /**< Maximum magnetic field on Earth's surface */ -#define SENSORS_MAGFIELD_EARTH_MIN (30.0F) /**< Minimum magnetic field on Earth's surface */ -#define SENSORS_PRESSURE_SEALEVELHPA (1013.25F) /**< Average sea level pressure is 1013.25 hPa */ -#define SENSORS_DPS_TO_RADS (0.017453293F) /**< Degrees/s to rad/s multiplier */ -#define SENSORS_GAUSS_TO_MICROTESLA (100) /**< Gauss to micro-Tesla multiplier */ - -/** Sensor types */ -typedef enum -{ - SENSOR_TYPE_ACCELEROMETER = (1), /**< Gravity + linear acceleration */ - SENSOR_TYPE_MAGNETIC_FIELD = (2), - SENSOR_TYPE_ORIENTATION = (3), - SENSOR_TYPE_GYROSCOPE = (4), - SENSOR_TYPE_LIGHT = (5), - SENSOR_TYPE_PRESSURE = (6), - SENSOR_TYPE_PROXIMITY = (8), - SENSOR_TYPE_GRAVITY = (9), - SENSOR_TYPE_LINEAR_ACCELERATION = (10), /**< Acceleration not including gravity */ - SENSOR_TYPE_ROTATION_VECTOR = (11), - SENSOR_TYPE_RELATIVE_HUMIDITY = (12), - SENSOR_TYPE_AMBIENT_TEMPERATURE = (13), - SENSOR_TYPE_VOLTAGE = (15), - SENSOR_TYPE_CURRENT = (16), - SENSOR_TYPE_COLOR = (17) -} sensors_type_t; - -/** struct sensors_vec_s is used to return a vector in a common format. */ -typedef struct { - union { - float v[3]; - struct { - float x; - float y; - float z; - }; - /* Orientation sensors */ - struct { - float roll; /**< Rotation around the longitudinal axis (the plane body, 'X axis'). Roll is positive and increasing when moving downward. -90°<=roll<=90° */ - float pitch; /**< Rotation around the lateral axis (the wing span, 'Y axis'). Pitch is positive and increasing when moving upwards. -180°<=pitch<=180°) */ - float heading; /**< Angle between the longitudinal axis (the plane body) and magnetic north, measured clockwise when viewing from the top of the device. 0-359° */ - }; - }; - int8_t status; - uint8_t reserved[3]; -} sensors_vec_t; - -/** struct sensors_color_s is used to return color data in a common format. */ -typedef struct { - union { - float c[3]; - /* RGB color space */ - struct { - float r; /**< Red component */ - float g; /**< Green component */ - float b; /**< Blue component */ - }; - }; - uint32_t rgba; /**< 24-bit RGBA value */ -} sensors_color_t; - -/* Sensor event (36 bytes) */ -/** struct sensor_event_s is used to provide a single sensor event in a common format. */ -typedef struct -{ - int32_t version; /**< must be sizeof(struct sensors_event_t) */ - int32_t sensor_id; /**< unique sensor identifier */ - int32_t type; /**< sensor type */ - int32_t reserved0; /**< reserved */ - int32_t timestamp; /**< time is in milliseconds */ - union - { - float data[4]; - sensors_vec_t acceleration; /**< acceleration values are in meter per second per second (m/s^2) */ - sensors_vec_t magnetic; /**< magnetic vector values are in micro-Tesla (uT) */ - sensors_vec_t orientation; /**< orientation values are in degrees */ - sensors_vec_t gyro; /**< gyroscope values are in rad/s */ - float temperature; /**< temperature is in degrees centigrade (Celsius) */ - float distance; /**< distance in centimeters */ - float light; /**< light in SI lux units */ - float pressure; /**< pressure in hectopascal (hPa) */ - float relative_humidity; /**< relative humidity in percent */ - float current; /**< current in milliamps (mA) */ - float voltage; /**< voltage in volts (V) */ - sensors_color_t color; /**< color in RGB component values */ - }; -} sensors_event_t; - -/* Sensor details (40 bytes) */ -/** struct sensor_s is used to describe basic information about a specific sensor. */ -typedef struct -{ - char name[12]; /**< sensor name */ - int32_t version; /**< version of the hardware + driver */ - int32_t sensor_id; /**< unique sensor identifier */ - int32_t type; /**< this sensor's type (ex. SENSOR_TYPE_LIGHT) */ - float max_value; /**< maximum value of this sensor's value in SI units */ - float min_value; /**< minimum value of this sensor's value in SI units */ - float resolution; /**< smallest difference between two values reported by this sensor */ - int32_t min_delay; /**< min delay in microseconds between events. zero = not a constant rate */ -} sensor_t; - -class Adafruit_Sensor { - public: - // Constructor(s) - Adafruit_Sensor() {} - virtual ~Adafruit_Sensor() {} - - // These must be defined by the subclass - virtual void enableAutoRange(bool enabled) { (void)enabled; /* suppress unused warning */ }; - virtual bool getEvent(sensors_event_t*) = 0; - virtual void getSensor(sensor_t*) = 0; - - private: - bool _autoRange; -}; - -#endif From 1307f66989caffa3d777aa955b3d303bb2ab3992 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Sun, 20 Dec 2020 21:46:35 +0100 Subject: [PATCH 3/7] added PlatformIO/Arduino support --- examples/Hat/ENV/ENV.ino | 2 +- examples/Hat/ENV/platformio.ini | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 examples/Hat/ENV/platformio.ini diff --git a/examples/Hat/ENV/ENV.ino b/examples/Hat/ENV/ENV.ino index 7736d82..2a93455 100644 --- a/examples/Hat/ENV/ENV.ino +++ b/examples/Hat/ENV/ENV.ino @@ -6,7 +6,7 @@ #include #include "DHT12.h" #include -#include "Adafruit_Sensor.h" +#include #include #include "bmm150.h" #include "bmm150_defs.h" diff --git a/examples/Hat/ENV/platformio.ini b/examples/Hat/ENV/platformio.ini new file mode 100644 index 0000000..c5efe9b --- /dev/null +++ b/examples/Hat/ENV/platformio.ini @@ -0,0 +1,29 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . + +[common_env_data] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +lib_deps = + M5StickC + adafruit/Adafruit Unified Sensor + adafruit/Adafruit BMP280 Library + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = ${common_env_data.framework} +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} From 7ce24f97f2a2e5b3401f7d410ed1cf7ca1f0b26f Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Sun, 20 Dec 2020 21:51:08 +0100 Subject: [PATCH 4/7] added PlatformIO support (automatic VL53L0X install) --- examples/Hat/TOF/platformio.ini | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/Hat/TOF/platformio.ini diff --git a/examples/Hat/TOF/platformio.ini b/examples/Hat/TOF/platformio.ini new file mode 100644 index 0000000..b70689c --- /dev/null +++ b/examples/Hat/TOF/platformio.ini @@ -0,0 +1,28 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . + +[common_env_data] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +lib_deps = + pololu/VL53L0X + M5StickC + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = ${common_env_data.framework} +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} From 8e0a0a99163387220b121c57613a9050b887be9e Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Sun, 20 Dec 2020 21:54:02 +0100 Subject: [PATCH 5/7] added PlatformIO/Arduino support --- examples/Basics/AXP192/platformio.ini | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/Basics/AXP192/platformio.ini diff --git a/examples/Basics/AXP192/platformio.ini b/examples/Basics/AXP192/platformio.ini new file mode 100644 index 0000000..c8d8bbf --- /dev/null +++ b/examples/Basics/AXP192/platformio.ini @@ -0,0 +1,27 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . + +[common_env_data] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +lib_deps = + M5StickC + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = ${common_env_data.framework} +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} From 76395673939edd4fb6004bd327bac41fefd8a718 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Sun, 20 Dec 2020 21:58:28 +0100 Subject: [PATCH 6/7] Added PlatformIO support (Arduino compatible) --- examples/Basics/FactoryTest/platformio.ini | 27 ++++++++++++++++++ examples/Games/Dices/platformio.ini | 27 ++++++++++++++++++ examples/Games/FlappyBird/platformio.ini | 27 ++++++++++++++++++ examples/Hat/JoyC/platformio.ini | 27 ++++++++++++++++++ platformio.ini | 33 ---------------------- 5 files changed, 108 insertions(+), 33 deletions(-) create mode 100644 examples/Basics/FactoryTest/platformio.ini create mode 100644 examples/Games/Dices/platformio.ini create mode 100644 examples/Games/FlappyBird/platformio.ini create mode 100644 examples/Hat/JoyC/platformio.ini delete mode 100644 platformio.ini diff --git a/examples/Basics/FactoryTest/platformio.ini b/examples/Basics/FactoryTest/platformio.ini new file mode 100644 index 0000000..e87142a --- /dev/null +++ b/examples/Basics/FactoryTest/platformio.ini @@ -0,0 +1,27 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . +lib_dir = ../../../ + +[common_env_data] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +; lib_deps = + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = ${common_env_data.framework} +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +; lib_deps = ${common_env_data.lib_deps} diff --git a/examples/Games/Dices/platformio.ini b/examples/Games/Dices/platformio.ini new file mode 100644 index 0000000..c8d8bbf --- /dev/null +++ b/examples/Games/Dices/platformio.ini @@ -0,0 +1,27 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . + +[common_env_data] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +lib_deps = + M5StickC + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = ${common_env_data.framework} +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} diff --git a/examples/Games/FlappyBird/platformio.ini b/examples/Games/FlappyBird/platformio.ini new file mode 100644 index 0000000..c8d8bbf --- /dev/null +++ b/examples/Games/FlappyBird/platformio.ini @@ -0,0 +1,27 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . + +[common_env_data] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +lib_deps = + M5StickC + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = ${common_env_data.framework} +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} diff --git a/examples/Hat/JoyC/platformio.ini b/examples/Hat/JoyC/platformio.ini new file mode 100644 index 0000000..c8d8bbf --- /dev/null +++ b/examples/Hat/JoyC/platformio.ini @@ -0,0 +1,27 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . + +[common_env_data] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +lib_deps = + M5StickC + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = ${common_env_data.framework} +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} diff --git a/platformio.ini b/platformio.ini deleted file mode 100644 index 9c65201..0000000 --- a/platformio.ini +++ /dev/null @@ -1,33 +0,0 @@ -; CanAirIO Sensorlib -; -; Full guide and details: https://github.com/kike-canaries/canairio_sensorlib - - -[platformio] -src_dir = ./examples/Basics/ -lib_dir = ./ - -[env] -framework = arduino -upload_speed = 1500000 -monitor_speed = 115200 -monitor_filters = time -build_flags = - -D SRC_REV=092 - -D CORE_DEBUG_LEVEL=5 -lib_deps = - -[esp32_common] -platform = espressif32 -board = m5stack-core-esp32 -framework = ${env.framework} -upload_speed = ${env.upload_speed} -monitor_speed = ${env.monitor_speed} -lib_deps = ${env.lib_deps} -build_flags = - ${env.build_flags} - -[env:FactoryTest] -extends = esp32_common -src_filter = -<*> + - From e0385262e566a6a2fa2af0ae9fd758597f034314 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Sun, 20 Dec 2020 22:08:26 +0100 Subject: [PATCH 7/7] fixed local library issue, added M5SticC pio library --- examples/Basics/FactoryTest/platformio.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Basics/FactoryTest/platformio.ini b/examples/Basics/FactoryTest/platformio.ini index e87142a..c8d8bbf 100644 --- a/examples/Basics/FactoryTest/platformio.ini +++ b/examples/Basics/FactoryTest/platformio.ini @@ -10,13 +10,13 @@ [platformio] src_dir = . -lib_dir = ../../../ [common_env_data] framework = arduino upload_speed = 1500000 monitor_speed = 115200 -; lib_deps = +lib_deps = + M5StickC [env:esp32dev] platform = espressif32 @@ -24,4 +24,4 @@ board = esp32dev framework = ${common_env_data.framework} upload_speed = ${common_env_data.upload_speed} monitor_speed = ${common_env_data.monitor_speed} -; lib_deps = ${common_env_data.lib_deps} +lib_deps = ${common_env_data.lib_deps}