From 9f96a9b23bb6264445f908555cfc9924cfee1dd2 Mon Sep 17 00:00:00 2001 From: gorbit99 Date: Tue, 30 Sep 2025 22:57:24 +0200 Subject: [PATCH] Formatting --- platformio.ini | 45 ++++++++++++------- src/defines.h | 87 +++++++++++++++++++------------------ src/network/wifihandler.cpp | 7 +-- 3 files changed, 78 insertions(+), 61 deletions(-) diff --git a/platformio.ini b/platformio.ini index c1b3b52..fd7dbd0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -62,12 +62,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 +upload_speed = 921600 ; Uncomment below if you want to build for ESP-01 ;[env:esp01_1m] @@ -102,18 +102,16 @@ 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 -monitor_filters = colorize, esp32_exception_decoder +;[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 +;monitor_filters = colorize, esp32_exception_decoder ; If you want to use a ESP32C6, you can use this (experimental) ;[env:esp32c6] @@ -124,3 +122,18 @@ monitor_filters = colorize, esp32_exception_decoder ; -DESP32C6 ; -DARDUINO_USB_MODE=1 ; -DARDUINO_USB_CDC_ON_BOOT=1 + +;[env:BOARD_ESP32S3_SUPERMINI] +;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} +; -DARDUINO_USB_MODE=1 +; -DESP32S3 +;board = esp32s3_supermini +;board_upload.use_1200bps_touch = 1 +;board_upload.wait_for_upload_port = 1 +;board_upload.require_upload_port = 1 +;upload_speed = 921600 diff --git a/src/defines.h b/src/defines.h index 29bc56a..68fca07 100644 --- a/src/defines.h +++ b/src/defines.h @@ -26,50 +26,53 @@ // ================================================ // Set parameters of IMU and board used -#define IMU IMU_ICM45686 -#define SECOND_IMU IMU -#define BOARD BOARD_CUSTOM +#ifndef IMU +#define IMU IMU_AUTO +#endif +#ifndef SECOND_IMU +#define SECOND_IMU IMU_AUTO +#endif +#ifndef BOARD +#define BOARD BOARD_SLIMEVR_V1_2 +#endif +#ifndef IMU_ROTATION #define IMU_ROTATION DEG_270 +#endif +#ifndef SECOND_IMU_ROTATION #define SECOND_IMU_ROTATION DEG_270 - -#define PRIMARY_IMU_OPTIONAL false -#define SECONDARY_IMU_OPTIONAL true - -#define MAX_SENSORS_COUNT 2 -#define TRACKER_TYPE TrackerType::TRACKER_TYPE_SVR_ROTATION - -#ifndef SENSOR_DESC_LIST -#define SENSOR_DESC_LIST \ - SENSOR_DESC_ENTRY( \ - IMU, \ - PRIMARY_IMU_ADDRESS_ONE, \ - IMU_ROTATION, \ - DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), \ - PRIMARY_IMU_OPTIONAL, \ - DIRECT_PIN(PIN_IMU_INT), \ - 0 \ - ) \ - SENSOR_DESC_ENTRY( \ - SECOND_IMU, \ - SECONDARY_IMU_ADDRESS_TWO, \ - SECOND_IMU_ROTATION, \ - DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), \ - SECONDARY_IMU_OPTIONAL, \ - DIRECT_PIN(PIN_IMU_INT_2), \ - 0 \ - ) #endif -#define BATTERY_MONITOR BAT_EXTERNAL +#ifndef PRIMARY_IMU_OPTIONAL +#define PRIMARY_IMU_OPTIONAL false +#endif +#ifndef SECONDARY_IMU_OPTIONAL +#define SECONDARY_IMU_OPTIONAL true +#endif -#define ON_OFF_BUTTON_PIN 1 -#define PIN_IMU_SDA 5 -#define PIN_IMU_SCL 6 -#define PIN_IMU_INT 255 -#define PIN_IMU_INT_2 255 -#define PIN_BATTERY_LEVEL 3 -#define LED_PIN 0 -#define LED_INVERTED true -#define BATTERY_SHIELD_RESISTANCE 0 -#define BATTERY_SHIELD_R1 150 -#define BATTERY_SHIELD_R2 150 +// 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 + +#ifndef BATTERY_MONITOR +// 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 +#endif + +// --- OVERRIDES FOR DEFAULT PINS + +// #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 +// #define BATTERY_SHIELD_RESISTANCE 0 +// #define BATTERY_SHIELD_R1 10 +// #define BATTERY_SHIELD_R2 40.2 + +// ------------------------------ diff --git a/src/network/wifihandler.cpp b/src/network/wifihandler.cpp index b71a583..5a418e1 100644 --- a/src/network/wifihandler.cpp +++ b/src/network/wifihandler.cpp @@ -20,9 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "network/wifihandler.h" + #include "GlobalVars.h" #include "globals.h" -#include "network/wifihandler.h" #if !ESP8266 #include "esp_wifi.h" #include "esp_wifi_types.h" @@ -320,7 +321,7 @@ bool WiFiNetwork::tryHardcodedCredentials() { wifiHandlerLogger.debug("Trying hardcoded credentials with PHY Mode G..."); // Don't need to save hardcoded credentials WiFi.persistent(false); - auto result = tryConnecting(true, WIFI_CREDS_SSID, WIFI_CREDS_PASSWD); + auto result = tryConnecting(true, WIFI_CREDS_SSID, WIFI_CREDS_PASSWD); WiFi.persistent(true); return result; } @@ -328,7 +329,7 @@ bool WiFiNetwork::tryHardcodedCredentials() { retriedOnG = false; wifiState = WiFiReconnectionStatus::HardcodeAttempt; - // Don't need to save hardcoded credentials + // Don't need to save hardcoded credentials WiFi.persistent(false); auto result = tryConnecting(false, WIFI_CREDS_SSID, WIFI_CREDS_PASSWD); WiFi.persistent(true);