From 104f0a2cc8de0604d6f2c61cd2da53d8395ba9e6 Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 12 Oct 2023 14:28:02 +0200 Subject: [PATCH] tweak and fixes for T-Deck and esp32-arduino 3.x.x --- src/ESP32-Chimera-Core.cpp | 2 +- src/drivers/ESP32-S3-Box/Audio/src/bsp_i2c.c | 5 +++++ src/drivers/ESP32-S3-Box/Audio/src/i2c_bus.c | 5 +++++ src/drivers/T-Deck/keyboard.h | 6 +++--- src/drivers/T-Deck/trackball.h | 5 ++--- src/drivers/common/Audio/Mic_Class.cpp | 12 ++++++++++++ src/drivers/common/Audio/Mic_Class.hpp | 12 ++++++++++++ src/drivers/common/MPU6886/MahonyAHRS.cpp | 9 +++++---- src/drivers/common/MPU6886/MahonyAHRS.h | 4 ++-- src/drivers/common/Speaker/Speaker.h | 5 ++++- 10 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/ESP32-Chimera-Core.cpp b/src/ESP32-Chimera-Core.cpp index 82323bd..1545241 100644 --- a/src/ESP32-Chimera-Core.cpp +++ b/src/ESP32-Chimera-Core.cpp @@ -128,7 +128,7 @@ namespace ChimeraCore log_d("Enabling Keyboard"); Keyboard = new Keyboard_Class( &Wire1, KEYBOARD_I2C_ADDR, KEYBOARD_INT_PIN, - [](uint8_t key) { char c[2]={key,0}; log_d("Keyboard Interrupt: char=%s (0x%02x)", c, key); } + [](uint8_t key) { [[maybe_unused]]char c[2]={key,0}; log_d("Keyboard Interrupt: char=%s (0x%02x)", c, key); } ); #endif diff --git a/src/drivers/ESP32-S3-Box/Audio/src/bsp_i2c.c b/src/drivers/ESP32-S3-Box/Audio/src/bsp_i2c.c index 855abae..46099b3 100644 --- a/src/drivers/ESP32-S3-Box/Audio/src/bsp_i2c.c +++ b/src/drivers/ESP32-S3-Box/Audio/src/bsp_i2c.c @@ -11,6 +11,8 @@ #include "i2c_bus.h" static const char *TAG = "bsp_i2c"; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat" #define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/ @@ -134,3 +136,6 @@ i2c_bus_handle_t bsp_i2c_bus_get_handle(void) { return i2c_bus_handle; } + + +#pragma GCC diagnostic pop diff --git a/src/drivers/ESP32-S3-Box/Audio/src/i2c_bus.c b/src/drivers/ESP32-S3-Box/Audio/src/i2c_bus.c index a0d42fd..bd68d56 100644 --- a/src/drivers/ESP32-S3-Box/Audio/src/i2c_bus.c +++ b/src/drivers/ESP32-S3-Box/Audio/src/i2c_bus.c @@ -22,6 +22,9 @@ #define I2C_BUS_MUTEX_TICKS_TO_WAIT (I2C_BUS_MS_TO_WAIT/portTICK_RATE_MS) static const char *TAG = "i2c_bus"; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat" + static i2c_bus_t s_i2c_bus[I2C_NUM_MAX]; #define I2C_BUS_CHECK(a, str, ret) if(!(a)) { \ @@ -466,3 +469,5 @@ inline static bool i2c_config_compare(i2c_port_t port, const i2c_config_t *conf) return false; } + +#pragma GCC diagnostic pop diff --git a/src/drivers/T-Deck/keyboard.h b/src/drivers/T-Deck/keyboard.h index d3845b6..9fb8ad5 100644 --- a/src/drivers/T-Deck/keyboard.h +++ b/src/drivers/T-Deck/keyboard.h @@ -25,7 +25,7 @@ namespace ChimeraCore TDeck_Keyboard_Class( TwoWire* bus, uint8_t dev_addr, fire_event_t fire_event ) : _bus(bus), _dev_addr(dev_addr), _fire_event(fire_event) { init(); } TDeck_Keyboard_Class( TwoWire* bus, uint8_t dev_addr, gpio_num_t pin_int, fire_event_t fire_event ) - : _bus(bus), _dev_addr(dev_addr), _pin_int(pin_int), _fire_event(fire_event) { _has_interrupt = true; init(); } + : _bus(bus), _pin_int(pin_int), _dev_addr(dev_addr), _fire_event(fire_event) { _has_interrupt = true; init(); } TDeck_Keyboard_Class( gpio_num_t pin_sda, gpio_num_t pin_scl, uint8_t dev_addr, fire_event_t fire_event ) : _pin_sda(pin_sda), _pin_scl(pin_scl), _dev_addr(dev_addr), _fire_event(fire_event) { _bus=&Wire1; _has_pins=true; init(); } TDeck_Keyboard_Class( gpio_num_t pin_sda, gpio_num_t pin_scl, gpio_num_t pin_int, uint8_t dev_addr, fire_event_t fire_event ) @@ -121,14 +121,14 @@ namespace ChimeraCore TwoWire* _bus; - fire_event_t _fire_event; - gpio_num_t _pin_sda; gpio_num_t _pin_scl; gpio_num_t _pin_int; uint8_t _dev_addr = -1; + fire_event_t _fire_event; + uint32_t _i2c_freq = 800000UL; bool _has_interrupt = false; diff --git a/src/drivers/T-Deck/trackball.h b/src/drivers/T-Deck/trackball.h index dcfd9b3..df44ae4 100644 --- a/src/drivers/T-Deck/trackball.h +++ b/src/drivers/T-Deck/trackball.h @@ -152,11 +152,10 @@ namespace ChimeraCore const uint32_t _width; const uint32_t _height; - int16_t _x; - int16_t _y; - fire_event_t _fire_event; + int16_t _x; + int16_t _y; void init() { diff --git a/src/drivers/common/Audio/Mic_Class.cpp b/src/drivers/common/Audio/Mic_Class.cpp index 3ac28f7..c3fa974 100644 --- a/src/drivers/common/Audio/Mic_Class.cpp +++ b/src/drivers/common/Audio/Mic_Class.cpp @@ -3,6 +3,15 @@ #include "Mic_Class.hpp" + +#if __has_include() // platformio has optional esp_arduino_version + #include +#endif + +#if defined ESP_ARDUINO_VERSION_VAL + #if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2,0,14) + + #include "../../../ESP32-Chimera-Core.h" #if __has_include () @@ -313,3 +322,6 @@ namespace ChimeraCore return true; } } + +#endif +#endif diff --git a/src/drivers/common/Audio/Mic_Class.hpp b/src/drivers/common/Audio/Mic_Class.hpp index 169daaf..e2785d0 100644 --- a/src/drivers/common/Audio/Mic_Class.hpp +++ b/src/drivers/common/Audio/Mic_Class.hpp @@ -4,10 +4,20 @@ #ifndef __M5_Mic_Class_H__ #define __M5_Mic_Class_H__ + +#if __has_include() // platformio has optional esp_arduino_version + #include +#endif + +#if defined ESP_ARDUINO_VERSION_VAL + #if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2,0,14) + // version>=3.0.0 => 'driver/i2s_std.h', 'driver/i2s_pdm.h' or 'driver/i2s_tdm.h' + #include #include #include + namespace ChimeraCore { class ECCKernel; @@ -145,3 +155,5 @@ namespace ChimeraCore } #endif +#endif +#endif diff --git a/src/drivers/common/MPU6886/MahonyAHRS.cpp b/src/drivers/common/MPU6886/MahonyAHRS.cpp index 8f64de8..4e06905 100644 --- a/src/drivers/common/MPU6886/MahonyAHRS.cpp +++ b/src/drivers/common/MPU6886/MahonyAHRS.cpp @@ -29,10 +29,10 @@ //--------------------------------------------------------------------------------------------------- // Variable definitions -volatile float twoKp = twoKpDef; // 2 * proportional gain (Kp) -volatile float twoKi = twoKiDef; // 2 * integral gain (Ki) -volatile float q0 = 1.0, q1 = 0.0, q2 = 0.0, q3 = 0.0; // quaternion of sensor frame relative to auxiliary frame -volatile float integralFBx = 0.0f, integralFBy = 0.0f, integralFBz = 0.0f; // integral error terms scaled by Ki +float twoKp = twoKpDef; // 2 * proportional gain (Kp) +float twoKi = twoKiDef; // 2 * integral gain (Ki) +float q0 = 1.0, q1 = 0.0, q2 = 0.0, q3 = 0.0; // quaternion of sensor frame relative to auxiliary frame +float integralFBx = 0.0f, integralFBy = 0.0f, integralFBz = 0.0f; // integral error terms scaled by Ki //--------------------------------------------------------------------------------------------------- // Function declarations @@ -241,6 +241,7 @@ void MahonyAHRSupdateIMU(float gx, float gy, float gz, float ax, float ay, float #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic ignored "-Wuninitialized" // false positive with "error: 'y' is used uninitialized" float invSqrt(float x) { float halfx = 0.5f * x; diff --git a/src/drivers/common/MPU6886/MahonyAHRS.h b/src/drivers/common/MPU6886/MahonyAHRS.h index bae082d..c3bac13 100644 --- a/src/drivers/common/MPU6886/MahonyAHRS.h +++ b/src/drivers/common/MPU6886/MahonyAHRS.h @@ -16,8 +16,8 @@ //---------------------------------------------------------------------------------------------------- // Variable declaration -extern volatile float twoKp; // 2 * proportional gain (Kp) -extern volatile float twoKi; // 2 * integral gain (Ki) +extern float twoKp; // 2 * proportional gain (Kp) +extern float twoKi; // 2 * integral gain (Ki) //volatile float q0, q1, q2, q3; // quaternion of sensor frame relative to auxiliary frame //--------------------------------------------------------------------------------------------------- diff --git a/src/drivers/common/Speaker/Speaker.h b/src/drivers/common/Speaker/Speaker.h index dfd6f9e..341f5b2 100644 --- a/src/drivers/common/Speaker/Speaker.h +++ b/src/drivers/common/Speaker/Speaker.h @@ -12,7 +12,10 @@ #if defined ESP_ARDUINO_VERSION_VAL #if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2,0,14) #include - #else + #else // ESP_ARDUINO_VERSION_VAL >= 3.0.0 + #define SOC_DAC_SUPPORTED 1 // why ??? + #include + #include #include #endif #else