From 9421c8a935004507145df3c1f581d03f0a09b58f Mon Sep 17 00:00:00 2001 From: gorbit99 Date: Sun, 5 Jan 2025 09:10:29 +0100 Subject: [PATCH] Oops --- platformio.ini | 42 ++++++---- src/defines.h | 209 ++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 216 insertions(+), 35 deletions(-) diff --git a/platformio.ini b/platformio.ini index f6c504f9..fb654067 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,6 +11,9 @@ ; https://docs.slimevr.dev/firmware/configuring-project.html#1-configuring-platformioini ; ================================================ +[platformio] +build_cache_dir = cache + [env] lib_deps= https://github.com/SlimeVR/CmdParser.git @@ -57,13 +60,12 @@ build_unflags = -Os -std=gnu++11 -std=gnu++17 ; Settings for different boards -;[env:esp12e] -;platform = espressif8266 @ 4.2.1 -;board = esp12e +[env:esp12e] +platform = espressif8266 @ 4.2.1 +board = esp12e ; Comment out this line below if you have any trouble uploading the firmware ; and if it has a CP2102 on it (a square chip next to the usb port): change to 3000000 (3 million) for even faster upload speed -;upload_speed = 921600 -;board_build.f_cpu = 160000000L +upload_speed = 921600 ; Uncomment below if you want to build for ESP-01 ;[env:esp01_1m] @@ -98,14 +100,22 @@ build_unflags = -Os -std=gnu++11 -std=gnu++17 ; -DARDUINO_USB_MODE=1 ; -DARDUINO_USB_CDC_ON_BOOT=1 -[env:esp32c3] -platform = espressif32 @ 6.7.0 -platform_packages = - framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.1 - framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.1/esp32-arduino-libs-3.0.1.zip -build_flags = - ${env.build_flags} - -DESP32C3 - -DARDUINO_USB_MODE=1 - -DARDUINO_USB_CDC_ON_BOOT=1 -board = lolin_c3_mini +;[env:esp32c3] +;platform = espressif32 @ 6.7.0 +;platform_packages = +; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.1 +; framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.1/esp32-arduino-libs-3.0.1.zip +;build_flags = +; ${env.build_flags} +; -DESP32C3 +;board = lolin_c3_mini + +; If you want to use a ESP32C6, you can use this (experimental) +;[env:esp32c6] +;platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.06.11/platform-espressif32.zip +;board = esp32-c6-devkitc-1 +;build_flags = +; ${env.build_flags} +; -DESP32C6 +; -DARDUINO_USB_MODE=1 +; -DARDUINO_USB_CDC_ON_BOOT=1 \ No newline at end of file diff --git a/src/defines.h b/src/defines.h index b73b16d1..992c2539 100644 --- a/src/defines.h +++ b/src/defines.h @@ -20,45 +20,216 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// ================================================ +// See docs for configuration options and examples: +// https://docs.slimevr.dev/firmware/configuring-project.html#2-configuring-definesh +// ================================================ -#define IMU IMU_LSM6DSV -#define BOARD BOARD_CUSTOM -#define IMU_ROTATION DEG_90 +// Set parameters of IMU and board used +#define IMU IMU_BNO085 +#define SECOND_IMU IMU +#define BOARD BOARD_SLIMEVR +#define IMU_ROTATION DEG_270 +#define SECOND_IMU_ROTATION DEG_270 #define PRIMARY_IMU_OPTIONAL false +#define SECONDARY_IMU_OPTIONAL true -#define MAX_IMU_COUNT 1 +// Set I2C address here or directly in IMU_DESC_ENTRY for each IMU used +// If not set, default address is used based on the IMU and Sensor ID +// #define PRIMARY_IMU_ADDRESS_ONE 0x4a +// #define SECONDARY_IMU_ADDRESS_TWO 0x4b -#define ON_OFF_BUTTON 1 +#define MAX_IMU_COUNT 2 + +// Axis mapping example +/* +#include "sensors/axisremap.h" +#define BMI160_QMC_REMAP AXIS_REMAP_BUILD(AXIS_REMAP_USE_Y, AXIS_REMAP_USE_XN, +AXIS_REMAP_USE_Z, \ AXIS_REMAP_USE_YN, AXIS_REMAP_USE_X, AXIS_REMAP_USE_Z) + +IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, +PIN_IMU_SDA, PRIMARY_IMU_OPTIONAL, BMI160_QMC_REMAP) \ +*/ #ifndef IMU_DESC_LIST -#define IMU_DESC_LIST \ - IMU_DESC_ENTRY( \ - IMU, \ - PRIMARY_IMU_ADDRESS_ONE, \ - IMU_ROTATION, \ - PIN_IMU_SCL, \ - PIN_IMU_SDA, \ - PRIMARY_IMU_OPTIONAL, \ - PIN_IMU_INT \ +#define IMU_DESC_LIST \ + IMU_DESC_ENTRY( \ + IMU, \ + PRIMARY_IMU_ADDRESS_ONE, \ + IMU_ROTATION, \ + PIN_IMU_SCL, \ + PIN_IMU_SDA, \ + PRIMARY_IMU_OPTIONAL, \ + PIN_IMU_INT \ + ) \ + IMU_DESC_ENTRY( \ + SECOND_IMU, \ + SECONDARY_IMU_ADDRESS_TWO, \ + SECOND_IMU_ROTATION, \ + PIN_IMU_SCL, \ + PIN_IMU_SDA, \ + SECONDARY_IMU_OPTIONAL, \ + PIN_IMU_INT_2 \ ) #endif +// Battery monitoring options (comment to disable): +// BAT_EXTERNAL for ADC pin, +// BAT_INTERNAL for internal - can detect only low battery, +// BAT_MCP3021 for external ADC connected over I2C #define BATTERY_MONITOR BAT_EXTERNAL -#define PIN_IMU_SDA 5 -#define PIN_IMU_SCL 6 +// BAT_EXTERNAL definition override +// D1 Mini boards with ESP8266 have internal resistors. For these boards you only have +// to adjust BATTERY_SHIELD_RESISTANCE. For other boards you can now adjust the other +// resistor values. The diagram looks like this: +// (Battery)--- [BATTERY_SHIELD_RESISTANCE] ---(INPUT_BOARD)--- [BATTERY_SHIELD_R2] +// ---(ESP32_INPUT)--- [BATTERY_SHIELD_R1] --- (GND) +// #define BATTERY_SHIELD_RESISTANCE 180 //130k BatteryShield, 180k SlimeVR or fill in +// external resistor value in kOhm #define BATTERY_SHIELD_R1 100 // Board voltage +// divider resistor Ain to GND in kOhm #define BATTERY_SHIELD_R2 220 // Board voltage +// divider resistor Ain to INPUT_BOARD in kOhm + +// LED configuration: +// Configuration Priority 1 = Highest: +// 1. LED_PIN +// 2. LED_BUILTIN +// +// LED_PIN +// - Number or Symbol (D1,..) of the Output +// - To turn off the LED, set LED_PIN to LED_OFF +// LED_INVERTED +// - false for output 3.3V on high +// - true for pull down to GND on high + +// Board-specific configurations +#if BOARD == BOARD_SLIMEVR +#define PIN_IMU_SDA 14 +#define PIN_IMU_SCL 12 +#define PIN_IMU_INT 16 +#define PIN_IMU_INT_2 13 +#define PIN_BATTERY_LEVEL 17 +#define LED_PIN 2 +#define LED_INVERTED true +#ifndef BATTERY_SHIELD_RESISTANCE +#define BATTERY_SHIELD_RESISTANCE 0 +#endif +#ifndef BATTERY_SHIELD_R1 +#define BATTERY_SHIELD_R1 10 +#endif +#ifndef BATTERY_SHIELD_R2 +#define BATTERY_SHIELD_R2 40.2 +#endif +#elif BOARD == BOARD_SLIMEVR_LEGACY || BOARD == BOARD_SLIMEVR_DEV +#define PIN_IMU_SDA 4 +#define PIN_IMU_SCL 5 +#define PIN_IMU_INT 10 +#define PIN_IMU_INT_2 13 +#define PIN_BATTERY_LEVEL 17 +#define LED_PIN 2 +#define LED_INVERTED true +#ifndef BATTERY_SHIELD_RESISTANCE +#define BATTERY_SHIELD_RESISTANCE 0 +#endif +#ifndef BATTERY_SHIELD_R1 +#define BATTERY_SHIELD_R1 10 +#endif +#ifndef BATTERY_SHIELD_R2 +#define BATTERY_SHIELD_R2 40.2 +#endif +#elif BOARD == BOARD_NODEMCU || BOARD == BOARD_WEMOSD1MINI +#define PIN_IMU_SDA D2 +#define PIN_IMU_SCL D1 +#define PIN_IMU_INT D5 +#define PIN_IMU_INT_2 D6 +#define PIN_BATTERY_LEVEL A0 +// #define LED_PIN 2 +// #define LED_INVERTED true +#ifndef BATTERY_SHIELD_RESISTANCE +#define BATTERY_SHIELD_RESISTANCE 180 +#endif +#ifndef BATTERY_SHIELD_R1 +#define BATTERY_SHIELD_R1 100 +#endif +#ifndef BATTERY_SHIELD_R2 +#define BATTERY_SHIELD_R2 220 +#endif +#elif BOARD == BOARD_ESP01 +#define PIN_IMU_SDA 2 +#define PIN_IMU_SCL 0 #define PIN_IMU_INT 255 #define PIN_IMU_INT_2 255 +#define PIN_BATTERY_LEVEL 255 +#define LED_PIN LED_OFF +#define LED_INVERTED false +#elif BOARD == BOARD_TTGO_TBASE +#define PIN_IMU_SDA 5 +#define PIN_IMU_SCL 4 +#define PIN_IMU_INT 14 +#define PIN_IMU_INT_2 13 +#define PIN_BATTERY_LEVEL A0 +// #define LED_PIN 2 +// #define LED_INVERTED false +#elif BOARD == BOARD_CUSTOM +// Define pins by the examples above +#elif BOARD == BOARD_WROOM32 +#define PIN_IMU_SDA 21 +#define PIN_IMU_SCL 22 +#define PIN_IMU_INT 23 +#define PIN_IMU_INT_2 25 +#define PIN_BATTERY_LEVEL 36 +// #define LED_PIN 2 +// #define LED_INVERTED false +#elif BOARD == BOARD_LOLIN_C3_MINI +#define PIN_IMU_SDA 5 +#define PIN_IMU_SCL 4 +#define PIN_IMU_INT 6 +#define PIN_IMU_INT_2 8 #define PIN_BATTERY_LEVEL 3 -#define LED_PIN 0 +#define LED_PIN 7 +// #define LED_INVERTED false +#elif BOARD == BOARD_BEETLE32C3 +#define PIN_IMU_SDA 8 +#define PIN_IMU_SCL 9 +#define PIN_IMU_INT 6 +#define PIN_IMU_INT_2 7 +#define PIN_BATTERY_LEVEL 3 +#define LED_PIN 10 +#define LED_INVERTED false +#elif BOARD == BOARD_ES32C3DEVKITM1 || BOARD == BOARD_ES32C6DEVKITC1 +#define PIN_IMU_SDA 5 +#define PIN_IMU_SCL 4 +#define PIN_IMU_INT 6 +#define PIN_IMU_INT_2 7 +#define PIN_BATTERY_LEVEL 3 +#define LED_PIN \ + LED_OFF // RGB LED Protocol would need to be implementetet did not brother for the + // test, because the board ideal for tracker ifself +// #define LED_INVERTED false +#elif BOARD == BOARD_WEMOSWROOM02 +#define PIN_IMU_SDA 2 +#define PIN_IMU_SCL 14 +#define PIN_IMU_INT 0 +#define PIN_IMU_INT_2 4 +#define PIN_BATTERY_LEVEL A0 +#define LED_PIN 16 #define LED_INVERTED true +#elif BOARD == BOARD_XIAO_ESP32C3 +#define PIN_IMU_SDA 6 // D4 +#define PIN_IMU_SCL 7 // D5 +#define PIN_IMU_INT 5 // D3 +#define PIN_IMU_INT_2 10 // D10 +#define LED_PIN 4 // D2 +#define LED_INVERTED false +#define PIN_BATTERY_LEVEL 2 // D0 / A0 #ifndef BATTERY_SHIELD_RESISTANCE #define BATTERY_SHIELD_RESISTANCE 0 #endif #ifndef BATTERY_SHIELD_R1 -#define BATTERY_SHIELD_R1 150 +#define BATTERY_SHIELD_R1 100 #endif #ifndef BATTERY_SHIELD_R2 -#define BATTERY_SHIELD_R2 150 +#define BATTERY_SHIELD_R2 100 +#endif #endif