Skip to content

Commit

Permalink
tweak and fixes for T-Deck and esp32-arduino 3.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Oct 12, 2023
1 parent 033fc23 commit 104f0a2
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/ESP32-Chimera-Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions src/drivers/ESP32-S3-Box/Audio/src/bsp_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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*/

Expand Down Expand Up @@ -134,3 +136,6 @@ i2c_bus_handle_t bsp_i2c_bus_get_handle(void)
{
return i2c_bus_handle;
}


#pragma GCC diagnostic pop
5 changes: 5 additions & 0 deletions src/drivers/ESP32-S3-Box/Audio/src/i2c_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) { \
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions src/drivers/T-Deck/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/drivers/T-Deck/trackball.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
12 changes: 12 additions & 0 deletions src/drivers/common/Audio/Mic_Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

#include "Mic_Class.hpp"


#if __has_include(<esp_arduino_version.h>) // platformio has optional esp_arduino_version
#include <esp_arduino_version.h>
#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 (<esp_idf_version.h>)
Expand Down Expand Up @@ -313,3 +322,6 @@ namespace ChimeraCore
return true;
}
}

#endif
#endif
12 changes: 12 additions & 0 deletions src/drivers/common/Audio/Mic_Class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@
#ifndef __M5_Mic_Class_H__
#define __M5_Mic_Class_H__


#if __has_include(<esp_arduino_version.h>) // platformio has optional esp_arduino_version
#include <esp_arduino_version.h>
#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 <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <driver/i2s.h>


namespace ChimeraCore
{
class ECCKernel;
Expand Down Expand Up @@ -145,3 +155,5 @@ namespace ChimeraCore
}

#endif
#endif
#endif
9 changes: 5 additions & 4 deletions src/drivers/common/MPU6886/MahonyAHRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/common/MPU6886/MahonyAHRS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

//---------------------------------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion src/drivers/common/Speaker/Speaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
#if defined ESP_ARDUINO_VERSION_VAL
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2,0,14)
#include <esp32-hal.h>
#else
#else // ESP_ARDUINO_VERSION_VAL >= 3.0.0
#define SOC_DAC_SUPPORTED 1 // why ???
#include <esp32-hal.h>
#include <esp32-hal-ledc.h>
#include <esp32-hal-dac.h>
#endif
#else
Expand Down

0 comments on commit 104f0a2

Please sign in to comment.