Grove driver, I2C migrations, bugfixes and docs (#532)

This commit is contained in:
Ken Van Hoeylandt
2026-06-19 00:52:31 +02:00
committed by GitHub
parent 8dabda2b5b
commit a35c88c8fd
74 changed files with 937 additions and 483 deletions
@@ -3,11 +3,15 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 41 and interrupt pin is 40
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
800,
480
);
@@ -3,10 +3,14 @@
#include <Gt911Touch.h>
#include <Ili934xDisplay.h>
#include <PwmBacklight.h>
#include <tactility/check.h>
#include <tactility/device.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION
);
@@ -3,10 +3,14 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <St7796Display.h>
#include <tactility/check.h>
#include <tactility/device.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION
);
@@ -3,6 +3,8 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <Tactility/Logger.h>
#include <tactility/check.h>
#include <tactility/device.h>
#include <driver/gpio.h>
#include <esp_err.h>
@@ -221,8 +223,10 @@ lvgl_port_display_rgb_cfg_t St7701Display::getLvglPortDisplayRgbConfig(esp_lcd_p
std::shared_ptr<tt::hal::touch::TouchDevice> St7701Display::getTouchDevice() {
if (touchDevice == nullptr) {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
480,
480
);
@@ -3,12 +3,16 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c_internal");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
800,
480
);
@@ -3,10 +3,14 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <Ili9488Display.h>
#include <tactility/check.h>
#include <tactility/device.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
320,
480
);
@@ -2,12 +2,16 @@
#include <Gt911Touch.h>
#include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
800,
480
);
@@ -3,12 +3,16 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
800,
480
);
@@ -5,21 +5,22 @@
#include <PwmBacklight.h>
#include <Tactility/Logger.h>
#include <Tactility/Mutex.h>
#include <tactility/check.h>
#include <tactility/device.h>
constexpr auto LCD_PIN_RESET = GPIO_NUM_0; // Match P4 EV board reset line
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_23;
constexpr auto LCD_HORIZONTAL_RESOLUTION = 1024;
constexpr auto LCD_VERTICAL_RESOLUTION = 600;
constexpr auto TOUCH_I2C_PORT = I2C_NUM_0;
constexpr auto TOUCH_I2C_SDA = GPIO_NUM_7;
constexpr auto TOUCH_I2C_SCL = GPIO_NUM_8;
constexpr auto TOUCH_PIN_RESET = GPIO_NUM_NC;
constexpr auto TOUCH_PIN_INTERRUPT = GPIO_NUM_NC;
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c_internal");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
TOUCH_I2C_PORT,
i2c,
LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION,
false, // swapXY
@@ -3,12 +3,16 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
800,
480
);
@@ -7,16 +7,20 @@
#include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <tactility/check.h>
#include <tactility/device.h>
bool initBoot();
using namespace tt::hal;
static std::vector<std::shared_ptr<tt::hal::Device>> createDevices() {
auto* i2c_internal = device_find_by_name("i2c0");
check(i2c_internal);
return {
createPower(),
createDisplay(),
std::make_shared<TdeckKeyboard>(),
std::make_shared<TdeckKeyboard>(i2c_internal),
std::make_shared<KeyboardBacklightDevice>(),
std::make_shared<TrackballDevice>(),
createSdCard()
+1 -1
View File
@@ -58,7 +58,7 @@ bool initBoot() {
std::vector<tt::hal::gps::GpsConfiguration> gps_configurations;
gps_service->getGpsConfigurations(gps_configurations);
if (gps_configurations.empty()) {
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "uart1", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) {
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "uart0", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) {
LOGGER.info("Configured internal GPS");
} else {
LOGGER.error("Failed to configure internal GPS");
@@ -3,10 +3,14 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <St7789Display.h>
#include <tactility/check.h>
#include <tactility/device.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
240,
320,
true,
@@ -1,6 +1,5 @@
#include "KeyboardBacklight.h"
#include <KeyboardBacklight/KeyboardBacklight.h> // Driver
#include <Tactility/hal/i2c/I2c.h>
#include <Tactility/settings/KeyboardSettings.h>
// TODO: Add Mutex and consider refactoring into a class
@@ -1,24 +1,18 @@
#include "TdeckKeyboard.h"
#include <Tactility/hal/i2c/I2c.h>
#include <driver/i2c.h>
#include <lvgl.h>
#include <Tactility/settings/KeyboardSettings.h>
#include <Tactility/settings/DisplaySettings.h>
#include <Tactility/hal/display/DisplayDevice.h>
#include <tactility/hal/Device.h>
#include <Tactility/Logger.h>
#include <KeyboardBacklight/KeyboardBacklight.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/settings/DisplaySettings.h>
#include <Tactility/settings/KeyboardSettings.h>
#include <lvgl.h>
#include <tactility/drivers/i2c_controller.h>
using tt::hal::findFirstDevice;
static const auto LOGGER = tt::Logger("TdeckKeyboard");
constexpr auto TDECK_KEYBOARD_I2C_BUS_HANDLE = I2C_NUM_0;
constexpr auto TDECK_KEYBOARD_SLAVE_ADDRESS = 0x55;
static bool keyboard_i2c_read(uint8_t* output) {
return tt::hal::i2c::masterRead(TDECK_KEYBOARD_I2C_BUS_HANDLE, TDECK_KEYBOARD_SLAVE_ADDRESS, output, 1, 100 / portTICK_PERIOD_MS);
}
constexpr uint8_t TDECK_KEYBOARD_SLAVE_ADDRESS = 0x55;
/**
* The callback simulates press and release events, because the T-Deck
@@ -37,7 +31,8 @@ static void keyboard_read_callback(lv_indev_t* indev, lv_indev_data_t* data) {
data->key = 0;
data->state = LV_INDEV_STATE_RELEASED;
if (keyboard_i2c_read(&read_buffer)) {
auto* keyboard = static_cast<TdeckKeyboard*>(lv_indev_get_user_data(indev));
if (i2c_controller_read(keyboard->getI2cController(), TDECK_KEYBOARD_SLAVE_ADDRESS, &read_buffer, 1, 100 / portTICK_PERIOD_MS) == ERROR_NONE) {
if (read_buffer == 0 && read_buffer != last_buffer) {
if (LOGGER.isLoggingDebug()) {
LOGGER.debug("Released {}", last_buffer);
@@ -91,5 +86,5 @@ bool TdeckKeyboard::stopLvgl() {
}
bool TdeckKeyboard::isAttached() const {
return tt::hal::i2c::masterHasDeviceAtAddress(TDECK_KEYBOARD_I2C_BUS_HANDLE, TDECK_KEYBOARD_SLAVE_ADDRESS, 100);
return i2c_controller_has_device_at_address(i2cController, TDECK_KEYBOARD_SLAVE_ADDRESS, 100) == ERROR_NONE;
}
@@ -1,17 +1,23 @@
#pragma once
#include <Tactility/hal/keyboard/KeyboardDevice.h>
#include <Tactility/TactilityCore.h>
struct Device;
class TdeckKeyboard final : public tt::hal::keyboard::KeyboardDevice {
::Device* i2cController;
lv_indev_t* deviceHandle = nullptr;
public:
explicit TdeckKeyboard(::Device* i2cController) : i2cController(i2cController) {}
std::string getName() const override { return "T-Deck Keyboard"; }
std::string getDescription() const override { return "I2C keyboard"; }
::Device* getI2cController() const { return i2cController; }
bool startLvgl(lv_display_t* display) override;
bool stopLvgl() override;
bool isAttached() const override;
+2 -10
View File
@@ -3,6 +3,7 @@
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_ble.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_grove.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_spi.h>
@@ -30,15 +31,6 @@
pin-scl = <&gpio0 8 GPIO_FLAG_NONE>;
};
i2c_external: i2c1 {
compatible = "espressif,esp32-i2c";
status = "disabled";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 43 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 44 GPIO_FLAG_NONE>;
};
i2s0 {
compatible = "espressif,esp32-i2s";
port = <I2S_NUM_0>;
@@ -55,7 +47,7 @@
pin-sclk = <&gpio0 40 GPIO_FLAG_NONE>;
};
uart1 {
uart0 {
compatible = "espressif,esp32-uart";
port = <UART_NUM_1>;
pin-tx = <&gpio0 43 GPIO_FLAG_NONE>;
@@ -4,6 +4,7 @@
#include "devices/TpagerKeyboard.h"
#include "devices/TpagerPower.h"
#include <driver/gpio.h>
#include <tactility/device.h>
#include <Tactility/hal/Configuration.h>
#include <Bq25896.h>
@@ -14,17 +15,18 @@ bool tpagerInit();
using namespace tt::hal;
static DeviceVector createDevices() {
auto bq27220 = std::make_shared<Bq27220>(I2C_NUM_0);
auto* i2c = device_find_by_name("i2c0");
auto bq27220 = std::make_shared<Bq27220>(i2c);
auto power = std::make_shared<TpagerPower>(bq27220);
auto tca8418 = std::make_shared<Tca8418>(I2C_NUM_0);
auto tca8418 = std::make_shared<Tca8418>(i2c);
auto keyboard = std::make_shared<TpagerKeyboard>(tca8418);
return std::vector<std::shared_ptr<tt::hal::Device>> {
tca8418,
std::make_shared<Bq25896>(I2C_NUM_0),
std::make_shared<Bq25896>(i2c),
bq27220,
std::make_shared<Drv2605>(I2C_NUM_0),
std::make_shared<Drv2605>(i2c),
power,
createTpagerSdCard(),
createDisplay(),
@@ -1,6 +1,5 @@
#include "TpagerKeyboard.h"
#include <Tactility/hal/i2c/I2c.h>
#include <Tactility/Logger.h>
#include <driver/i2c.h>
@@ -156,7 +155,7 @@ bool TpagerKeyboard::stopLvgl() {
}
bool TpagerKeyboard::isAttached() const {
return tt::hal::i2c::masterHasDeviceAtAddress(keypad->getPort(), keypad->getAddress(), 100);
return i2c_controller_has_device_at_address(keypad->getController(), keypad->getAddress(), 100) == ERROR_NONE;
}
bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel_t channel) {
@@ -5,8 +5,6 @@
static const auto LOGGER = tt::Logger("TpagerPower");
constexpr auto TPAGER_GAUGE_I2C_BUS_HANDLE = I2C_NUM_0;
TpagerPower::~TpagerPower() {}
bool TpagerPower::supportsMetric(MetricType type) const {
@@ -4,6 +4,7 @@
#include "devices/CardputerPower.h"
#include <driver/gpio.h>
#include <tactility/device.h>
#include <Tactility/hal/Configuration.h>
#include <PwmBacklight.h>
@@ -16,7 +17,7 @@ static bool initBoot() {
}
static DeviceVector createDevices() {
auto tca8418 = std::make_shared<Tca8418>(I2C_NUM_0);
auto tca8418 = std::make_shared<Tca8418>(device_find_by_name("i2c_internal"));
return {
createSdCard(),
createDisplay(),
@@ -1,10 +1,8 @@
#include "CardputerKeyboard.h"
#include <Tactility/hal/i2c/I2c.h>
#include <tactility/drivers/i2c_controller.h>
constexpr auto* TAG = "CardputerKeyb";
constexpr auto BACKLIGHT = GPIO_NUM_46;
constexpr auto KB_ROWS = 14;
constexpr auto KB_COLS = 4;
@@ -151,5 +149,5 @@ bool CardputerKeyboard::stopLvgl() {
}
bool CardputerKeyboard::isAttached() const {
return tt::hal::i2c::masterHasDeviceAtAddress(keypad->getPort(), keypad->getAddress(), 100);
return i2c_controller_has_device_at_address(keypad->getController(), keypad->getAddress(), 100) == ERROR_NONE;
}
@@ -3,6 +3,7 @@
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_ble.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_grove.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_spi.h>
@@ -36,12 +37,14 @@
};
};
i2c_port_a {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 2 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 1 GPIO_FLAG_NONE>;
port_a: grove0 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_I2C>;
pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_1>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
display_spi: spi0 {
@@ -68,12 +71,4 @@
pin-data-out = <&gpio0 42 GPIO_FLAG_NONE>;
pin-data-in = <&gpio0 46 GPIO_FLAG_NONE>;
};
uart_port_a: uart1 {
compatible = "espressif,esp32-uart";
status = "disabled";
port = <UART_NUM_1>;
pin-tx = <&gpio0 1 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 2 GPIO_FLAG_NONE>;
};
};
@@ -3,6 +3,7 @@
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_ble.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_grove.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_spi.h>
@@ -22,12 +23,14 @@
gpio-count = <49>;
};
i2c_port_a {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_0>;
clock-frequency = <400000>;
pin-sda = <&gpio0 2 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 1 GPIO_FLAG_NONE>;
port_a: grove0 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_I2C>;
pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_1>;
i2cPort = <I2C_NUM_0>;
i2cClockFrequency = <400000>;
};
display_spi: spi0 {
@@ -55,12 +58,4 @@
pin-data-out = <&gpio0 42 GPIO_FLAG_NONE>;
pin-data-in = <&gpio0 46 GPIO_FLAG_NONE>;
};
uart_port_a: uart1 {
compatible = "espressif,esp32-uart";
status = "disabled";
port = <UART_NUM_1>;
pin-tx = <&gpio0 1 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 2 GPIO_FLAG_NONE>;
};
};
@@ -1,10 +1,11 @@
#include <Axp192.h>
#include <tactility/device.h>
static std::shared_ptr<Axp192> axp192 = nullptr;
std::shared_ptr<Axp192> createAxp192() {
assert(axp192 == nullptr);
auto configuration = std::make_unique<Axp192::Configuration>(I2C_NUM_0);
auto configuration = std::make_unique<Axp192::Configuration>(device_find_by_name("i2c_internal"));
axp192 = std::make_shared<Axp192>(std::move(configuration));
return axp192;
}
+9 -14
View File
@@ -2,6 +2,7 @@
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_grove.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_spi.h>
@@ -37,12 +38,14 @@
};
};
i2c_port_a {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 32 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 33 GPIO_FLAG_NONE>;
port_a: grove0 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_I2C>;
pinSdaRx = <&gpio0 32 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 33 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_1>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
spi0 {
@@ -63,12 +66,4 @@
pin-data-out = <&gpio0 2 GPIO_FLAG_NONE>;
pin-data-in = <&gpio0 34 GPIO_FLAG_NONE>;
};
uart_port_a: uart1 {
compatible = "espressif,esp32-uart";
status = "disabled";
port = <UART_NUM_1>;
pin-tx = <&gpio0 33 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 32 GPIO_FLAG_NONE>;
};
};
+3 -2
View File
@@ -146,8 +146,9 @@ bool initPowerControl() {
bool initBoot() {
LOGGER.info("initBoot()");
axp2101 = std::make_shared<Axp2101>(I2C_NUM_0);
aw9523 = std::make_shared<Aw9523>(I2C_NUM_0);
auto controller = device_find_by_name("i2c_internal");
axp2101 = std::make_shared<Axp2101>(controller);
aw9523 = std::make_shared<Aw9523>(controller);
return initPowerControl() && initGpioExpander();
}
@@ -4,14 +4,17 @@
#include <Ft5x06Touch.h>
#include <Ili934xDisplay.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/i2c/I2c.h>
#include <tactility/check.h>
static const auto LOGGER = tt::Logger("CoreS3Display");
static void setBacklightDuty(uint8_t backlightDuty) {
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
// TODO: Refactor to use Axp2102 driver subproject. Reference: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/AXP2101_Class.cpp#L42
if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) { // Sets DLD01
auto controller = device_find_by_name("i2c_internal");
check(controller);
if (i2c_controller_write_register(controller, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000) != ERROR_NONE) { // Sets DLD01
LOGGER.error("Failed to set display backlight voltage");
}
}
+25 -28
View File
@@ -3,6 +3,7 @@
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_ble.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_grove.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_spi.h>
@@ -42,30 +43,34 @@
};
};
i2c_port_a {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 2 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 1 GPIO_FLAG_NONE>;
port_a: grove0 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_I2C>;
pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_1>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
i2c_port_b {
compatible = "espressif,esp32-i2c";
status = "disabled";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 9 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 8 GPIO_FLAG_NONE>;
port_b: grove1 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_UART>;
pinSdaRx = <&gpio0 9 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 8 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_1>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
i2c_port_c {
compatible = "espressif,esp32-i2c";
status = "disabled";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 18 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 17 GPIO_FLAG_NONE>;
port_c: grove2 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_UART>;
pinSdaRx = <&gpio0 17 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 18 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_2>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
spi0 {
@@ -89,12 +94,4 @@
pin-data-in = <&gpio0 14 GPIO_FLAG_NONE>;
pin-mclk = <&gpio0 0 GPIO_FLAG_NONE>;
};
uart_port_a: uart1 {
compatible = "espressif,esp32-uart";
status = "disabled";
port = <UART_NUM_1>;
pin-tx = <&gpio0 1 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 2 GPIO_FLAG_NONE>;
};
};
@@ -1,10 +1,14 @@
#include "Display.h"
#include <Gt911Touch.h>
#include <EpdiyDisplayHelper.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c_internal");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
540,
960,
true, // swapXy
@@ -231,7 +231,7 @@ bool initBoot() {
}
// Keep Axp2101 C++ wrapper alive for Axp2101Power (backlight + battery)
axp2101 = std::make_shared<Axp2101>(I2C_NUM_0);
axp2101 = std::make_shared<Axp2101>(i2c);
return true;
}
@@ -4,13 +4,16 @@
#include <Ft6x36Touch.h>
#include <Ili934xDisplay.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/i2c/I2c.h>
#include <tactility/check.h>
static const auto LOGGER = tt::Logger("StackChanDisplay");
static void setBacklightDuty(uint8_t backlightDuty) {
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100]
if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) {
auto controller = device_find_by_name("i2c_internal");
check(controller);
if (i2c_controller_write_register(controller, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000) != ERROR_NONE) { // Sets DLD01
LOGGER.error("Failed to set display backlight voltage");
}
}
+34 -29
View File
@@ -3,6 +3,7 @@
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_ble.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_grove.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_spi.h>
@@ -67,30 +68,43 @@
// TODO: BMM150 magnetometer @ 0x10 — accessible only via BMI270 aux I2C
};
i2c_port_a {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 2 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 1 GPIO_FLAG_NONE>;
// TODO: Servo UART (SCS9009, 1 Mbaud) — TX=GPIO6, RX=GPIO7
uart_port_a: uart1 {
compatible = "espressif,esp32-uart";
status = "disabled";
port = <UART_NUM_1>;
pin-tx = <&gpio0 6 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 7 GPIO_FLAG_NONE>;
};
i2c_port_b {
compatible = "espressif,esp32-i2c";
status = "disabled";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 9 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 8 GPIO_FLAG_NONE>;
port_a: grove0 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_I2C>;
pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_2>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
i2c_port_c {
compatible = "espressif,esp32-i2c";
status = "disabled";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 18 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 17 GPIO_FLAG_NONE>;
port_b: grove1 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_UART>;
pinSdaRx = <&gpio0 9 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 8 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_2>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
port_c: grove2 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_DISABLED>;
pinSdaRx = <&gpio0 17 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 18 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_2>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
spi0 {
@@ -111,13 +125,4 @@
pin-data-in = <&gpio0 14 GPIO_FLAG_NONE>;
pin-mclk = <&gpio0 0 GPIO_FLAG_NONE>;
};
// TODO: Servo UART (SCS9009, 1 Mbaud) — TX=GPIO6, RX=GPIO7
uart_port_a: uart1 {
compatible = "espressif,esp32-uart";
status = "disabled";
port = <UART_NUM_1>;
pin-tx = <&gpio0 1 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 2 GPIO_FLAG_NONE>;
};
};
@@ -1,10 +1,11 @@
#include <Axp192.h>
#include <tactility/device.h>
static std::shared_ptr<Axp192> axp192 = nullptr;
std::shared_ptr<Axp192> createAxp192() {
assert(axp192 == nullptr);
auto configuration = std::make_unique<Axp192::Configuration>(I2C_NUM_0);
auto configuration = std::make_unique<Axp192::Configuration>(device_find_by_name("i2c_internal"));
axp192 = std::make_shared<Axp192>(std::move(configuration));
return axp192;
}
@@ -7,7 +7,6 @@
#include <tactility/drivers/i2c_controller.h>
#include <Tactility/hal/Configuration.h>
#include <Tactility/hal/i2c/I2c.h>
using namespace tt::hal;
@@ -8,6 +8,8 @@
#include <PwmBacklight.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/gpio/Gpio.h>
#include <tactility/check.h>
#include <tactility/device.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
@@ -19,8 +21,10 @@ constexpr auto LCD_PIN_RESET = GPIO_NUM_NC;
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_22;
static std::shared_ptr<tt::hal::touch::TouchDevice> createGt911Touch() {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
720,
1280,
false, // swapXY
+2 -1
View File
@@ -1,4 +1,5 @@
#include "UnPhoneFeatures.h"
#include <tactility/device.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Preferences.h>
@@ -160,7 +161,7 @@ static bool unPhonePowerOn() {
bootStats.printInfo();
bootStats.notifyBootStart();
bq24295 = std::make_shared<Bq24295>(I2C_NUM_0);
bq24295 = std::make_shared<Bq24295>(device_find_by_name("i2c_internal"));
unPhoneFeatures = std::make_shared<UnPhoneFeatures>(bq24295);
@@ -2,12 +2,16 @@
#include <Gt911Touch.h>
#include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
i2c,
800,
480
);