From 89405da69e2d435437a027077534aee591f673b8 Mon Sep 17 00:00:00 2001 From: Higanbana <71262281+kounocom@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:13:10 +0200 Subject: [PATCH 1/4] Remove ESP32-C3 USB CDC warning (#311) --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index f112996c4..eb39b2f00 100644 --- a/README.md +++ b/README.md @@ -95,13 +95,6 @@ Firmware can work with both ESP8266 and ESP32. Please edit `defines.h` and set y - Calibration data is written to the flash of your MCU and is unique for each BMI160, keep that in mind if you have detachable aux trackers. -## Infos about ESP32-C3 with direct connection to USB - -The ESP32-C3 has two ways to connect the serial port. One is directly via the onboard USB CDC or via the onboard UART. -When the chip is connected to the USB CDC, the serial port shows as `USB Serial Port` in Device Manager. The SlimeVR server will currently not connect to this port. -If you want to set your WiFi credentials, you can use the PlatformIO serial console. -There you have to enter the following: `SET WIFI "SSID" "PASSWORD"` - ## Uploading On Linux Follow the instructions in this link [PlatformIO](https://docs.platformio.org/en/latest//faq.html#platformio-udev-rules), this should solve any permission denied errors From c26ec17ae9ddde1f1ec668332d3c6c40bd9d2e9c Mon Sep 17 00:00:00 2001 From: Butterscotch! Date: Fri, 12 Jan 2024 03:18:28 -0500 Subject: [PATCH 2/4] Update BMI remap example and remove trailing spaces (#309) Update BMI remap example & remove trailing spaces --- src/defines.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/defines.h b/src/defines.h index 79f4d94b3..bb32739e8 100644 --- a/src/defines.h +++ b/src/defines.h @@ -43,7 +43,7 @@ #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, BMI160_QMC_REMAP) \ +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 @@ -53,8 +53,8 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #endif // Battery monitoring options (comment to disable): -// BAT_EXTERNAL for ADC pin, -// BAT_INTERNAL for internal - can detect only low battery, +// 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 @@ -75,7 +75,7 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P // LED_PIN // - Number or Symbol (D1,..) of the Output // - To turn off the LED, set LED_PIN to LED_OFF -// LED_INVERTED +// LED_INVERTED // - false for output 3.3V on high // - true for pull down to GND on high @@ -91,7 +91,7 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #ifndef BATTERY_SHIELD_RESISTANCE #define BATTERY_SHIELD_RESISTANCE 0 #endif - #ifndef BATTERY_SHIELD_R1 + #ifndef BATTERY_SHIELD_R1 #define BATTERY_SHIELD_R1 10 #endif #ifndef BATTERY_SHIELD_R2 @@ -108,7 +108,7 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #ifndef BATTERY_SHIELD_RESISTANCE #define BATTERY_SHIELD_RESISTANCE 0 #endif - #ifndef BATTERY_SHIELD_R1 + #ifndef BATTERY_SHIELD_R1 #define BATTERY_SHIELD_R1 10 #endif #ifndef BATTERY_SHIELD_R2 @@ -125,7 +125,7 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #ifndef BATTERY_SHIELD_RESISTANCE #define BATTERY_SHIELD_RESISTANCE 180 #endif - #ifndef BATTERY_SHIELD_R1 + #ifndef BATTERY_SHIELD_R1 #define BATTERY_SHIELD_R1 100 #endif #ifndef BATTERY_SHIELD_R2 From 35da44b1f9758bfd3a3fa149982a27bdd98a9398 Mon Sep 17 00:00:00 2001 From: Higanbana <71262281+kounocom@users.noreply.github.com> Date: Fri, 19 Jan 2024 04:24:04 +0200 Subject: [PATCH 3/4] ESP32: Fix ADC/battery sense logic (#310) * ESP32: Fix ADC voltage readings * Forgot endif oops * Refactor a little bit * Fix spelling of 'resolution' --- src/batterymonitor.cpp | 9 ++++++--- src/batterymonitor.h | 14 +++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/batterymonitor.cpp b/src/batterymonitor.cpp index 42ec85c01..45066a2cc 100644 --- a/src/batterymonitor.cpp +++ b/src/batterymonitor.cpp @@ -77,8 +77,11 @@ void BatteryMonitor::Loop() } } #endif - #if BATTERY_MONITOR == BAT_EXTERNAL - voltage = ((float)analogRead(PIN_BATTERY_LEVEL)) * batteryADCMultiplier; + #if ESP8266 && BATTERY_MONITOR == BAT_EXTERNAL + voltage = ((float)analogRead(PIN_BATTERY_LEVEL)) * ADCVoltageMax / ADCResolution * ADCMultiplier; + #endif + #if ESP32 && BATTERY_MONITOR == BAT_EXTERNAL + voltage = ((float)analogReadMilliVolts(PIN_BATTERY_LEVEL)) / 1000 * ADCMultiplier; #endif #if BATTERY_MONITOR == BAT_MCP3021 || BATTERY_MONITOR == BAT_INTERNAL_MCP3021 if (address > 0) @@ -91,7 +94,7 @@ void BatteryMonitor::Loop() if (status == 0) { float v = (((uint16_t)(MSB & 0x0F) << 6) | (uint16_t)(LSB >> 2)); - v *= batteryADCMultiplier; + v *= ADCMultiplier; voltage = (voltage > 0) ? min(voltage, v) : v; } } diff --git a/src/batterymonitor.h b/src/batterymonitor.h index 62c642e66..e13644e5b 100644 --- a/src/batterymonitor.h +++ b/src/batterymonitor.h @@ -30,15 +30,11 @@ #include "logging/Logger.h" #if ESP8266 - #define ADCResulution 1023.0 // ESP8266 has 12bit ADC + #define ADCResolution 1023.0 // ESP8266 has 10bit ADC #define ADCVoltageMax 1.0 // ESP8266 input is 1.0 V = 1023.0 #endif -#if ESP32 - #define ADCResulution 4095.0 // ESP32 has 12bit ADC - #define ADCVoltageMax 3.3 // ESP32 input is 3.3 V = 4095.0 -#endif -#ifndef ADCResulution - #define ADCResulution 1023.0 +#ifndef ADCResolution + #define ADCResolution 1023.0 #endif #ifndef ADCVoltageMax #define ADCVoltageMax 1.0 @@ -64,10 +60,10 @@ // Diagramm: // (Battery)--- [BATTERY_SHIELD_RESISTANCE] ---(INPUT_BOARD)--- [BATTERY_SHIELD_R2] ---(ESP_INPUT)--- [BATTERY_SHIELD_R1] --- (GND) // SlimeVR Board can handle max 5V > so analogRead of 5.0V input will result in 1023.0 - #define batteryADCMultiplier ADCVoltageMax / ADCResulution * (BATTERY_SHIELD_R1 + BATTERY_SHIELD_R2 + BATTERY_SHIELD_RESISTANCE) / BATTERY_SHIELD_R1 + #define ADCMultiplier (BATTERY_SHIELD_R1 + BATTERY_SHIELD_R2 + BATTERY_SHIELD_RESISTANCE) / BATTERY_SHIELD_R1 #elif BATTERY_MONITOR == BAT_MCP3021 || BATTERY_MONITOR == BAT_INTERNAL_MCP3021 // Default recommended resistors are 9.1k and 5.1k - #define batteryADCMultiplier 3.3 / 1023.0 * 14.2 / 9.1 + #define ADCMultiplier 3.3 / 1023.0 * 14.2 / 9.1 #endif class BatteryMonitor From 2c8e41ce0855f1bded50c2394e542dd2af362d1c Mon Sep 17 00:00:00 2001 From: DevMiner Date: Fri, 19 Jan 2024 03:24:45 +0100 Subject: [PATCH 4/4] feat: allow connecting to one specific server IP without broadcasting (#301) --- platformio.ini | 5 ++++- src/network/connection.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 01e6fdd65..bf3ac8ec6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -35,6 +35,9 @@ build_flags = ; -DWIFI_STATIC_GATEWAY=192,168,XXX,XXX ; -DWIFI_STATIC_SUBNET=255,255,255,0 +; -DSERVER_IP='"192.168.XXX.XXX"' +; -DSERVER_PORT=6969 + ; Uncomment below if your board are using 40MHz crystal instead of 26MHz for ESP8266 ; -DF_CRYSTAL=40000000 @@ -93,7 +96,7 @@ upload_speed = 921600 ;[env:esp32c3] ;platform = espressif32 @ 6.1.0 -;build_flags = +;build_flags = ; ${env.build_flags} ; -DESP32C3 ;board = lolin_c3_mini diff --git a/src/network/connection.h b/src/network/connection.h index 1231ee247..7b8f7b6a2 100644 --- a/src/network/connection.h +++ b/src/network/connection.h @@ -37,6 +37,16 @@ namespace Network { class Connection { public: + Connection() { +#ifdef SERVER_IP + m_ServerHost.fromString(SERVER_IP); +#endif + +#ifdef SERVER_PORT + m_ServerPort = SERVER_PORT; +#endif + } + void searchForServer(); void update(); void reset();