Replaced Logger usage with LOG_x (#548)
This commit is contained in:
committed by
GitHub
parent
ecad2248d9
commit
9d5993930d
@@ -2,9 +2,9 @@
|
||||
|
||||
#include <Gt911Touch.h>
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <esp_err.h>
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <soc/spi_periph.h>
|
||||
#include <driver/spi_master.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("St7701Display");
|
||||
constexpr auto* TAG = "St7701Display";
|
||||
|
||||
// GPIO47/48 are physically shared between this bit-banged 3-wire command bus
|
||||
// and the SD card's real SPI2 bus (no alternate pins exist on this PCB).
|
||||
@@ -171,29 +171,29 @@ bool St7701Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_st7701(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel");
|
||||
LOG_E(TAG, "Failed to create panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to reset panel");
|
||||
LOG_E(TAG, "Failed to reset panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to init panel");
|
||||
LOG_E(TAG, "Failed to init panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_invert_color(panelHandle, false) != ESP_OK) {
|
||||
LOGGER.error("Failed to invert color");
|
||||
LOG_E(TAG, "Failed to invert color");
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_lcd_panel_set_gap(panelHandle, 0, 0);
|
||||
|
||||
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
|
||||
LOGGER.error("Failed to turn display on");
|
||||
LOG_E(TAG, "Failed to turn display on");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#include <Gt911Touch.h>
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
constexpr auto LCD_PIN_RESET = GPIO_NUM_0; // Match P4 EV board reset line
|
||||
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_23;
|
||||
@@ -36,7 +36,7 @@ static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
// Initialize PWM backlight
|
||||
if (!driver::pwmbacklight::init(LCD_PIN_BACKLIGHT, 20000, LEDC_TIMER_1, LEDC_CHANNEL_0)) {
|
||||
tt::Logger("jc1060p470ciwy").warn("Failed to initialize backlight");
|
||||
LOG_W("jc1060p470ciwy", "Failed to initialize backlight");
|
||||
}
|
||||
|
||||
auto touch = createTouch();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "Jd9165Display.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <esp_lcd_jd9165.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("JD9165");
|
||||
constexpr auto* TAG = "JD9165";
|
||||
|
||||
// MIPI DSI PHY power configuration
|
||||
#define MIPI_DSI_PHY_PWR_LDO_CHAN 3 // LDO_VO3 connects to VDD_MIPI_DPHY
|
||||
@@ -87,11 +87,11 @@ bool Jd9165Display::createMipiDsiBus() {
|
||||
};
|
||||
|
||||
if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) {
|
||||
LOGGER.error("Failed to acquire LDO channel for MIPI DSI PHY");
|
||||
LOG_E(TAG, "Failed to acquire LDO channel for MIPI DSI PHY");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("MIPI DSI PHY powered on");
|
||||
|
||||
LOG_I(TAG, "MIPI DSI PHY powered on");
|
||||
|
||||
// Create MIPI DSI bus
|
||||
// TODO: use MIPI_DSI_PHY_CLK_SRC_DEFAULT() in future ESP-IDF 6.0.0 update with esp_lcd_jd9165 library version 2.x
|
||||
@@ -103,11 +103,11 @@ bool Jd9165Display::createMipiDsiBus() {
|
||||
};
|
||||
|
||||
if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) {
|
||||
LOGGER.error("Failed to create MIPI DSI bus");
|
||||
LOG_E(TAG, "Failed to create MIPI DSI bus");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("MIPI DSI bus created");
|
||||
LOG_I(TAG, "MIPI DSI bus created");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ bool Jd9165Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
|
||||
esp_lcd_dbi_io_config_t dbi_config = JD9165_PANEL_IO_DBI_CONFIG();
|
||||
|
||||
if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel IO");
|
||||
LOG_E(TAG, "Failed to create panel IO");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -184,11 +184,11 @@ bool Jd9165Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, const
|
||||
mutable_panel_config.vendor_config = &vendor_config;
|
||||
|
||||
if (esp_lcd_new_panel_jd9165(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel");
|
||||
LOG_E(TAG, "Failed to create panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("JD9165 panel created successfully");
|
||||
LOG_I(TAG, "JD9165 panel created successfully");
|
||||
// Defer reset/init to base class applyConfiguration to avoid double initialization
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "Power.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <ChargeFromVoltage.h>
|
||||
#include <tactility/log.h>
|
||||
#include <esp_adc/adc_oneshot.h>
|
||||
#include <esp_adc/adc_cali.h>
|
||||
#include <esp_adc/adc_cali_scheme.h>
|
||||
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
static const auto LOGGER = tt::Logger("JcPower");
|
||||
constexpr auto* TAG = "JcPower";
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
.ulp_mode = ADC_ULP_MODE_DISABLE,
|
||||
};
|
||||
if (adc_oneshot_new_unit(&init_cfg, &adcHandle) != ESP_OK) {
|
||||
LOGGER.error("ADC unit init failed");
|
||||
LOG_E(TAG, "ADC unit init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
.bitwidth = ADC_BITWIDTH_DEFAULT,
|
||||
};
|
||||
if (adc_oneshot_config_channel(adcHandle, ADC_CHANNEL, &chan_cfg) != ESP_OK) {
|
||||
LOGGER.error("ADC channel config failed");
|
||||
LOG_E(TAG, "ADC channel config failed");
|
||||
adc_oneshot_del_unit(adcHandle);
|
||||
adcHandle = nullptr;
|
||||
return false;
|
||||
@@ -100,7 +100,7 @@ private:
|
||||
};
|
||||
if (adc_cali_create_scheme_line_fitting(&cali_config, &caliHandle) == ESP_OK) {
|
||||
calScheme = CaliScheme::Line;
|
||||
LOGGER.info("ADC calibration (line fitting) enabled");
|
||||
LOG_I(TAG, "ADC calibration (line fitting) enabled");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -114,19 +114,19 @@ private:
|
||||
};
|
||||
if (adc_cali_create_scheme_curve_fitting(&curve_cfg, &caliHandle) == ESP_OK) {
|
||||
calScheme = CaliScheme::Curve;
|
||||
LOGGER.info("ADC calibration (curve fitting) enabled");
|
||||
LOG_I(TAG, "ADC calibration (curve fitting) enabled");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
LOGGER.warn("ADC calibration not available, using raw scaling");
|
||||
LOG_W(TAG, "ADC calibration not available, using raw scaling");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool readBatteryMilliVolt(uint32_t& outMv) {
|
||||
int raw = 0;
|
||||
if (adc_oneshot_read(adcHandle, ADC_CHANNEL, &raw) != ESP_OK) {
|
||||
LOGGER.error("ADC read failed");
|
||||
LOG_E(TAG, "ADC read failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "Axs15231bDisplay.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/hal/touch/TouchDevice.h>
|
||||
#include <Axs15231b/Axs15231bTouch.h>
|
||||
#include <EspLcdDisplayDriver.h>
|
||||
@@ -9,8 +8,9 @@
|
||||
#include <esp_lcd_panel_commands.h>
|
||||
#include <esp_lcd_panel_ops.h>
|
||||
#include <esp_heap_caps.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("AXS15231B");
|
||||
constexpr auto* TAG = "AXS15231B";
|
||||
|
||||
static const axs15231b_lcd_init_cmd_t lcd_init_cmds[] = {
|
||||
{0xBB, (uint8_t[]){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0xA5}, 8, 0},
|
||||
@@ -74,7 +74,7 @@ void Axs15231bDisplay::lvgl_port_flush_callback(lv_display_t *drv, const lv_area
|
||||
MALLOC_CAP_SPIRAM);
|
||||
if (self->tempBuf == nullptr) {
|
||||
if (!allocationErrorLogged) {
|
||||
LOGGER.error("Failed to allocate rotation buffer, drawing unrotated");
|
||||
LOG_E(TAG, "Failed to allocate rotation buffer, drawing unrotated");
|
||||
allocationErrorLogged = true;
|
||||
}
|
||||
if (esp_lcd_panel_draw_bitmap(panel_handle, 0, 0, self->configuration->horizontalResolution, self->configuration->verticalResolution, draw_buf) != ESP_OK) {
|
||||
@@ -145,7 +145,7 @@ void Axs15231bDisplay::lvgl_port_flush_callback(lv_display_t *drv, const lv_area
|
||||
if (ret != ESP_OK) {
|
||||
// If SPI transfer failed, on_color_trans_done won't fire.
|
||||
// Manually signal flush ready to prevent LVGL from hanging.
|
||||
LOGGER.error("draw_bitmap failed: {}", esp_err_to_name(ret));
|
||||
LOG_E(TAG, "draw_bitmap failed: %s", esp_err_to_name(ret));
|
||||
lv_display_flush_ready(drv);
|
||||
}
|
||||
}
|
||||
@@ -169,13 +169,13 @@ void IRAM_ATTR Axs15231bDisplay::teIsrHandler(void* arg) {
|
||||
|
||||
bool Axs15231bDisplay::setupTeSync() {
|
||||
if (configuration->tePin == GPIO_NUM_NC) {
|
||||
LOGGER.info("TE pin not configured, skipping TE sync");
|
||||
LOG_I(TAG, "TE pin not configured, skipping TE sync");
|
||||
return true;
|
||||
}
|
||||
|
||||
teSyncSemaphore = xSemaphoreCreateBinary();
|
||||
if (teSyncSemaphore == nullptr) {
|
||||
LOGGER.error("Failed to create TE sync semaphore");
|
||||
LOG_E(TAG, "Failed to create TE sync semaphore");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ bool Axs15231bDisplay::setupTeSync() {
|
||||
io_conf.pin_bit_mask = (1ULL << configuration->tePin);
|
||||
|
||||
if (gpio_config(&io_conf) != ESP_OK) {
|
||||
LOGGER.error("Failed to configure TE GPIO");
|
||||
LOG_E(TAG, "Failed to configure TE GPIO");
|
||||
vSemaphoreDelete(teSyncSemaphore);
|
||||
teSyncSemaphore = nullptr;
|
||||
return false;
|
||||
@@ -197,14 +197,14 @@ bool Axs15231bDisplay::setupTeSync() {
|
||||
if (err == ESP_OK) {
|
||||
isrServiceInstalledByUs = true;
|
||||
} else if (err != ESP_ERR_INVALID_STATE) {
|
||||
LOGGER.error("Failed to install GPIO ISR service");
|
||||
LOG_E(TAG, "Failed to install GPIO ISR service");
|
||||
vSemaphoreDelete(teSyncSemaphore);
|
||||
teSyncSemaphore = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_isr_handler_add(configuration->tePin, teIsrHandler, (void*)teSyncSemaphore) != ESP_OK) {
|
||||
LOGGER.error("Failed to add TE ISR handler");
|
||||
LOG_E(TAG, "Failed to add TE ISR handler");
|
||||
gpio_intr_disable(configuration->tePin);
|
||||
if (isrServiceInstalledByUs) {
|
||||
gpio_uninstall_isr_service();
|
||||
@@ -216,7 +216,7 @@ bool Axs15231bDisplay::setupTeSync() {
|
||||
}
|
||||
|
||||
teIsrInstalled = true;
|
||||
LOGGER.info("TE sync enabled on GPIO {}", (int)configuration->tePin);
|
||||
LOG_I(TAG, "TE sync enabled on GPIO %d", (int)configuration->tePin);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -285,19 +285,19 @@ bool Axs15231bDisplay::createPanelHandle() {
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_axs15231b(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create axs15231b");
|
||||
LOG_E(TAG, "Failed to create axs15231b");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to reset panel");
|
||||
LOG_E(TAG, "Failed to reset panel");
|
||||
esp_lcd_panel_del(panelHandle);
|
||||
panelHandle = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to init panel");
|
||||
LOG_E(TAG, "Failed to init panel");
|
||||
esp_lcd_panel_del(panelHandle);
|
||||
panelHandle = nullptr;
|
||||
return false;
|
||||
@@ -305,28 +305,28 @@ bool Axs15231bDisplay::createPanelHandle() {
|
||||
|
||||
//SWAPXY Doesn't work with the JC3248W535... Left in for future compatibility.
|
||||
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
|
||||
LOGGER.error("Failed to swap XY");
|
||||
LOG_E(TAG, "Failed to swap XY");
|
||||
esp_lcd_panel_del(panelHandle);
|
||||
panelHandle = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
|
||||
LOGGER.error("Failed to mirror panel");
|
||||
LOG_E(TAG, "Failed to mirror panel");
|
||||
esp_lcd_panel_del(panelHandle);
|
||||
panelHandle = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
|
||||
LOGGER.error("Failed to invert color");
|
||||
LOG_E(TAG, "Failed to invert color");
|
||||
esp_lcd_panel_del(panelHandle);
|
||||
panelHandle = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_disp_on_off(panelHandle, false) != ESP_OK) {
|
||||
LOGGER.error("Failed to turn off panel");
|
||||
LOG_E(TAG, "Failed to turn off panel");
|
||||
esp_lcd_panel_del(panelHandle);
|
||||
panelHandle = nullptr;
|
||||
return false;
|
||||
@@ -343,19 +343,19 @@ Axs15231bDisplay::Axs15231bDisplay(std::unique_ptr<Configuration> inConfiguratio
|
||||
|
||||
bool Axs15231bDisplay::start() {
|
||||
if (!createIoHandle()) {
|
||||
LOGGER.error("Failed to create IO handle");
|
||||
LOG_E(TAG, "Failed to create IO handle");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!createPanelHandle()) {
|
||||
LOGGER.error("Failed to create panel handle");
|
||||
LOG_E(TAG, "Failed to create panel handle");
|
||||
esp_lcd_panel_io_del(ioHandle);
|
||||
ioHandle = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!setupTeSync()) {
|
||||
LOGGER.warn("TE sync setup failed, continuing without TE synchronization");
|
||||
LOG_W(TAG, "TE sync setup failed, continuing without TE synchronization");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -372,12 +372,12 @@ bool Axs15231bDisplay::stop() {
|
||||
displayDriver.reset();
|
||||
|
||||
if (panelHandle != nullptr && esp_lcd_panel_del(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to delete panel");
|
||||
LOG_E(TAG, "Failed to delete panel");
|
||||
}
|
||||
panelHandle = nullptr;
|
||||
|
||||
if (ioHandle != nullptr && esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to delete IO");
|
||||
LOG_E(TAG, "Failed to delete IO");
|
||||
}
|
||||
ioHandle = nullptr;
|
||||
|
||||
@@ -386,7 +386,7 @@ bool Axs15231bDisplay::stop() {
|
||||
|
||||
bool Axs15231bDisplay::startLvgl() {
|
||||
if (lvglDisplay != nullptr) {
|
||||
LOGGER.error("LVGL already started");
|
||||
LOG_E(TAG, "LVGL already started");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ bool Axs15231bDisplay::startLvgl() {
|
||||
buffer1 = (uint16_t*)heap_caps_malloc(bufferSize, MALLOC_CAP_SPIRAM);
|
||||
buffer2 = (uint16_t*)heap_caps_malloc(bufferSize, MALLOC_CAP_SPIRAM);
|
||||
if (buffer1 == nullptr || buffer2 == nullptr) {
|
||||
LOGGER.error("Failed to allocate buffers");
|
||||
LOG_E(TAG, "Failed to allocate buffers");
|
||||
heap_caps_free(buffer1);
|
||||
heap_caps_free(buffer2);
|
||||
buffer1 = nullptr;
|
||||
@@ -419,7 +419,7 @@ bool Axs15231bDisplay::startLvgl() {
|
||||
.on_color_trans_done = onColorTransDone,
|
||||
};
|
||||
if (esp_lcd_panel_io_register_event_callbacks(ioHandle, &cbs, lvglDisplay) != ESP_OK) {
|
||||
LOGGER.error("Failed to register panel IO callbacks");
|
||||
LOG_E(TAG, "Failed to register panel IO callbacks");
|
||||
heap_caps_free(buffer1);
|
||||
heap_caps_free(buffer2);
|
||||
buffer1 = nullptr;
|
||||
@@ -474,11 +474,11 @@ bool Axs15231bDisplay::stopLvgl() {
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDriver> Axs15231bDisplay::getDisplayDriver() {
|
||||
if (lvglDisplay != nullptr) {
|
||||
LOGGER.error("Cannot get DisplayDriver while LVGL is active - call stopLvgl() first");
|
||||
LOG_E(TAG, "Cannot get DisplayDriver while LVGL is active - call stopLvgl() first");
|
||||
return nullptr;
|
||||
}
|
||||
if (panelHandle == nullptr) {
|
||||
LOGGER.error("Cannot get DisplayDriver - display is not started");
|
||||
LOG_E(TAG, "Cannot get DisplayDriver - display is not started");
|
||||
return nullptr;
|
||||
}
|
||||
if (displayDriver == nullptr) {
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#include <Tactility/hal/gps/GpsConfiguration.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("T-Deck");
|
||||
constexpr auto* TAG = "T-Deck";
|
||||
|
||||
constexpr auto TDECK_POWERON_GPIO = GPIO_NUM_10;
|
||||
|
||||
@@ -37,9 +37,9 @@ static bool powerOn() {
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
LOGGER.info(LOG_MESSAGE_POWER_ON_START);
|
||||
LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
|
||||
if (!powerOn()) {
|
||||
LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED);
|
||||
LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ bool initBoot() {
|
||||
* when moving the brightness slider rapidly from a lower setting to 100%.
|
||||
* This is not a slider bug (data was debug-traced) */
|
||||
if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) {
|
||||
LOGGER.error("Backlight init failed");
|
||||
LOG_E(TAG, "Backlight init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ bool initBoot() {
|
||||
gps_service->getGpsConfigurations(gps_configurations);
|
||||
if (gps_configurations.empty()) {
|
||||
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "uart0", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) {
|
||||
LOGGER.info("Configured internal GPS");
|
||||
LOG_I(TAG, "Configured internal GPS");
|
||||
} else {
|
||||
LOGGER.error("Failed to configure internal GPS");
|
||||
LOG_E(TAG, "Failed to configure internal GPS");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,23 +69,23 @@ bool initBoot() {
|
||||
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) {
|
||||
auto kbBacklight = tt::hal::findDevice("Keyboard Backlight");
|
||||
if (kbBacklight != nullptr) {
|
||||
LOGGER.info("{} starting", kbBacklight->getName());
|
||||
LOG_I(TAG, "%s starting", kbBacklight->getName().c_str());
|
||||
auto kbDevice = std::static_pointer_cast<KeyboardBacklightDevice>(kbBacklight);
|
||||
if (kbDevice->start()) {
|
||||
LOGGER.info("{} started", kbBacklight->getName());
|
||||
LOG_I(TAG, "%s started", kbBacklight->getName().c_str());
|
||||
} else {
|
||||
LOGGER.error("{} start failed", kbBacklight->getName());
|
||||
LOG_E(TAG, "%s start failed", kbBacklight->getName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
auto trackball = tt::hal::findDevice("Trackball");
|
||||
if (trackball != nullptr) {
|
||||
LOGGER.info("{} starting", trackball->getName());
|
||||
LOG_I(TAG, "%s starting", trackball->getName().c_str());
|
||||
auto tbDevice = std::static_pointer_cast<TrackballDevice>(trackball);
|
||||
if (tbDevice->start()) {
|
||||
LOGGER.info("{} started", trackball->getName());
|
||||
LOG_I(TAG, "%s started", trackball->getName().c_str());
|
||||
} else {
|
||||
LOGGER.error("{} start failed", trackball->getName());
|
||||
LOG_E(TAG, "%s start failed", trackball->getName().c_str());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include "KeyboardBacklight.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <esp_log.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("KeyboardBacklight");
|
||||
constexpr auto* TAG = "KeyboardBacklight";
|
||||
|
||||
namespace keyboardbacklight {
|
||||
|
||||
@@ -21,16 +20,16 @@ bool init(i2c_port_t i2cPort, uint8_t slaveAddress) {
|
||||
g_i2cPort = i2cPort;
|
||||
g_slaveAddress = slaveAddress;
|
||||
|
||||
LOGGER.info("Initialized on I2C port {}, address 0x{:02X}", static_cast<int>(g_i2cPort), g_slaveAddress);
|
||||
|
||||
LOG_I(TAG, "Initialized on I2C port %d, address 0x%02X", static_cast<int>(g_i2cPort), (unsigned)g_slaveAddress);
|
||||
|
||||
// Set a reasonable default brightness
|
||||
if (!setDefaultBrightness(127)) {
|
||||
LOGGER.error("Failed to set default brightness");
|
||||
LOG_E(TAG, "Failed to set default brightness");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!setBrightness(127)) {
|
||||
LOGGER.error("Failed to set brightness");
|
||||
LOG_E(TAG, "Failed to set brightness");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -39,16 +38,16 @@ bool init(i2c_port_t i2cPort, uint8_t slaveAddress) {
|
||||
|
||||
bool setBrightness(uint8_t brightness) {
|
||||
if (g_i2cPort >= I2C_NUM_MAX) {
|
||||
LOGGER.error("Not initialized");
|
||||
LOG_E(TAG, "Not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Skip if brightness is already at target value (avoid I2C spam on every keypress)
|
||||
if (brightness == g_currentBrightness) {
|
||||
return true;
|
||||
}
|
||||
|
||||
LOGGER.info("Setting brightness to {} on I2C port {}, address 0x{:02X}", brightness, static_cast<int>(g_i2cPort), g_slaveAddress);
|
||||
|
||||
LOG_I(TAG, "Setting brightness to %d on I2C port %d, address 0x%02X", brightness, static_cast<int>(g_i2cPort), (unsigned)g_slaveAddress);
|
||||
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
@@ -62,20 +61,20 @@ bool setBrightness(uint8_t brightness) {
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
g_currentBrightness = brightness;
|
||||
LOGGER.info("Successfully set brightness to {}", brightness);
|
||||
LOG_I(TAG, "Successfully set brightness to %d", brightness);
|
||||
return true;
|
||||
} else {
|
||||
LOGGER.error("Failed to set brightness: {} (0x{:02X})", esp_err_to_name(ret), ret);
|
||||
LOG_E(TAG, "Failed to set brightness: %s (0x%02X)", esp_err_to_name(ret), (unsigned)ret);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool setDefaultBrightness(uint8_t brightness) {
|
||||
if (g_i2cPort >= I2C_NUM_MAX) {
|
||||
LOGGER.error("Not initialized");
|
||||
LOG_E(TAG, "Not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Clamp to valid range for default brightness
|
||||
if (brightness < 30) {
|
||||
brightness = 30;
|
||||
@@ -92,17 +91,17 @@ bool setDefaultBrightness(uint8_t brightness) {
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
LOGGER.debug("Set default brightness to {}", brightness);
|
||||
LOG_D(TAG, "Set default brightness to %d", brightness);
|
||||
return true;
|
||||
} else {
|
||||
LOGGER.error("Failed to set default brightness: {}", esp_err_to_name(ret));
|
||||
LOG_E(TAG, "Failed to set default brightness: %s", esp_err_to_name(ret));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t getBrightness() {
|
||||
if (g_i2cPort >= I2C_NUM_MAX) {
|
||||
LOGGER.error("Not initialized");
|
||||
LOG_E(TAG, "Not initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "Trackball.h"
|
||||
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <atomic>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Trackball");
|
||||
constexpr auto* TAG = "Trackball";
|
||||
|
||||
namespace trackball {
|
||||
|
||||
@@ -133,7 +133,7 @@ static void read_cb(lv_indev_t* indev, lv_indev_data_t* data) {
|
||||
|
||||
lv_indev_t* init(const TrackballConfig& config) {
|
||||
if (g_initialized.load(std::memory_order_relaxed)) {
|
||||
LOGGER.warn("Already initialized");
|
||||
LOG_W(TAG, "Already initialized");
|
||||
return g_indev;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ lv_indev_t* init(const TrackballConfig& config) {
|
||||
// ESP_ERR_INVALID_STATE means already installed, which is fine
|
||||
isr_service_installed = true;
|
||||
} else {
|
||||
LOGGER.error("Failed to install GPIO ISR service: {}", esp_err_to_name(err));
|
||||
LOG_E(TAG, "Failed to install GPIO ISR service: %s", esp_err_to_name(err));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ lv_indev_t* init(const TrackballConfig& config) {
|
||||
io_conf.pin_bit_mask = (1ULL << dirPins[i]);
|
||||
esp_err_t err = gpio_config(&io_conf);
|
||||
if (err != ESP_OK) {
|
||||
LOGGER.error("Failed to configure GPIO {}: {}", static_cast<int>(dirPins[i]), esp_err_to_name(err));
|
||||
LOG_E(TAG, "Failed to configure GPIO %d: %s", static_cast<int>(dirPins[i]), esp_err_to_name(err));
|
||||
// Cleanup previously added handlers
|
||||
for (int j = 0; j < handlersAdded; j++) {
|
||||
gpio_isr_handler_remove(dirPins[j]);
|
||||
@@ -200,7 +200,7 @@ lv_indev_t* init(const TrackballConfig& config) {
|
||||
|
||||
err = gpio_isr_handler_add(dirPins[i], trackball_isr_handler, reinterpret_cast<void*>(static_cast<intptr_t>(dirPins[i])));
|
||||
if (err != ESP_OK) {
|
||||
LOGGER.error("Failed to add ISR for GPIO {}: {}", static_cast<int>(dirPins[i]), esp_err_to_name(err));
|
||||
LOG_E(TAG, "Failed to add ISR for GPIO %d: %s", static_cast<int>(dirPins[i]), esp_err_to_name(err));
|
||||
// Cleanup previously added handlers
|
||||
for (int j = 0; j < handlersAdded; j++) {
|
||||
gpio_isr_handler_remove(dirPins[j]);
|
||||
@@ -215,7 +215,7 @@ lv_indev_t* init(const TrackballConfig& config) {
|
||||
io_conf.pin_bit_mask = (1ULL << config.pinClick);
|
||||
esp_err_t err = gpio_config(&io_conf);
|
||||
if (err != ESP_OK) {
|
||||
LOGGER.error("Failed to configure button GPIO {}: {}", static_cast<int>(config.pinClick), esp_err_to_name(err));
|
||||
LOG_E(TAG, "Failed to configure button GPIO %d: %s", static_cast<int>(config.pinClick), esp_err_to_name(err));
|
||||
// Cleanup direction handlers
|
||||
for (int i = 0; i < 4; i++) {
|
||||
gpio_isr_handler_remove(dirPins[i]);
|
||||
@@ -225,7 +225,7 @@ lv_indev_t* init(const TrackballConfig& config) {
|
||||
|
||||
err = gpio_isr_handler_add(config.pinClick, button_isr_handler, nullptr);
|
||||
if (err != ESP_OK) {
|
||||
LOGGER.error("Failed to add button ISR: {}", esp_err_to_name(err));
|
||||
LOG_E(TAG, "Failed to add button ISR: %s", esp_err_to_name(err));
|
||||
// Cleanup direction handlers
|
||||
for (int i = 0; i < 4; i++) {
|
||||
gpio_isr_handler_remove(dirPins[i]);
|
||||
@@ -239,7 +239,7 @@ lv_indev_t* init(const TrackballConfig& config) {
|
||||
// Register as LVGL encoder input device for group navigation (default mode)
|
||||
g_indev = lv_indev_create();
|
||||
if (g_indev == nullptr) {
|
||||
LOGGER.error("Failed to register LVGL input device");
|
||||
LOG_E(TAG, "Failed to register LVGL input device");
|
||||
// Cleanup ISR handlers on failure
|
||||
const gpio_num_t pins[5] = {
|
||||
config.pinRight, config.pinUp, config.pinLeft,
|
||||
@@ -255,7 +255,7 @@ lv_indev_t* init(const TrackballConfig& config) {
|
||||
lv_indev_set_type(g_indev, LV_INDEV_TYPE_ENCODER);
|
||||
lv_indev_set_read_cb(g_indev, read_cb);
|
||||
g_initialized.store(true, std::memory_order_relaxed);
|
||||
LOGGER.info("Initialized with interrupts (R:{} U:{} L:{} D:{} Click:{})",
|
||||
LOG_I(TAG, "Initialized with interrupts (R:%d U:%d L:%d D:%d Click:%d)",
|
||||
static_cast<int>(config.pinRight),
|
||||
static_cast<int>(config.pinUp),
|
||||
static_cast<int>(config.pinLeft),
|
||||
@@ -276,7 +276,7 @@ static void createCursor() {
|
||||
// Set cursor image
|
||||
lv_image_set_src(g_cursor, TT_ASSETS_UI_CURSOR);
|
||||
lv_indev_set_cursor(g_indev, g_cursor);
|
||||
LOGGER.debug("Cursor created");
|
||||
LOG_D(TAG, "Cursor created");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ static void destroyCursor() {
|
||||
// Delete the cursor object - this automatically detaches it from the indev
|
||||
lv_obj_delete(g_cursor);
|
||||
g_cursor = nullptr;
|
||||
LOGGER.debug("Cursor destroyed");
|
||||
LOG_D(TAG, "Cursor destroyed");
|
||||
}
|
||||
|
||||
void deinit() {
|
||||
@@ -317,14 +317,14 @@ void deinit() {
|
||||
g_initialized.store(false, std::memory_order_relaxed);
|
||||
g_mode.store(Mode::Encoder, std::memory_order_relaxed);
|
||||
g_enabled.store(true, std::memory_order_relaxed);
|
||||
LOGGER.info("Deinitialized");
|
||||
LOG_I(TAG, "Deinitialized");
|
||||
}
|
||||
|
||||
void setEncoderSensitivity(uint8_t sensitivity) {
|
||||
if (sensitivity > 0) {
|
||||
// Only update the atomic - ISR reads from atomic, not g_config
|
||||
g_encoderSensitivity.store(sensitivity, std::memory_order_relaxed);
|
||||
LOGGER.debug("Encoder sensitivity set to {}", sensitivity);
|
||||
LOG_D(TAG, "Encoder sensitivity set to %d", sensitivity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ void setPointerSensitivity(uint8_t sensitivity) {
|
||||
if (sensitivity > 0) {
|
||||
// Only update the atomic - ISR reads from atomic, not g_config
|
||||
g_pointerSensitivity.store(sensitivity, std::memory_order_relaxed);
|
||||
LOGGER.debug("Pointer sensitivity set to {}", sensitivity);
|
||||
LOG_D(TAG, "Pointer sensitivity set to %d", sensitivity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,13 +355,13 @@ void setEnabled(bool enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info("{}", enabled ? "Enabled" : "Disabled");
|
||||
LOG_I(TAG, "%s", enabled ? "Enabled" : "Disabled");
|
||||
}
|
||||
|
||||
void setMode(Mode mode) {
|
||||
// Note: Must be called from LVGL thread (main thread) for thread safety
|
||||
if (!g_initialized.load(std::memory_order_relaxed) || g_indev == nullptr) {
|
||||
LOGGER.warn("Cannot set mode - not initialized");
|
||||
LOG_W(TAG, "Cannot set mode - not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -381,13 +381,13 @@ void setMode(Mode mode) {
|
||||
// Reset cursor to center when switching modes
|
||||
g_cursorX.store(SCREEN_WIDTH / 2, std::memory_order_relaxed);
|
||||
g_cursorY.store(SCREEN_HEIGHT / 2, std::memory_order_relaxed);
|
||||
LOGGER.info("Switched to Pointer mode");
|
||||
LOG_I(TAG, "Switched to Pointer mode");
|
||||
} else {
|
||||
// Switch to encoder mode
|
||||
destroyCursor();
|
||||
lv_indev_set_type(g_indev, LV_INDEV_TYPE_ENCODER);
|
||||
g_encoderDiff.store(0, std::memory_order_relaxed); // Reset encoder diff
|
||||
LOGGER.info("Switched to Encoder mode");
|
||||
LOG_I(TAG, "Switched to Encoder mode");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include "TdeckKeyboard.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>
|
||||
#include <tactility/log.h>
|
||||
|
||||
using tt::hal::findFirstDevice;
|
||||
|
||||
static const auto LOGGER = tt::Logger("TdeckKeyboard");
|
||||
constexpr auto* TAG = "TdeckKeyboard";
|
||||
|
||||
constexpr uint8_t TDECK_KEYBOARD_SLAVE_ADDRESS = 0x55;
|
||||
|
||||
@@ -34,15 +34,11 @@ static void keyboard_read_callback(lv_indev_t* indev, lv_indev_data_t* data) {
|
||||
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);
|
||||
}
|
||||
LOG_D(TAG, "Released %d", last_buffer);
|
||||
data->key = last_buffer;
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
} else if (read_buffer != 0) {
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Pressed {}", read_buffer);
|
||||
}
|
||||
LOG_D(TAG, "Pressed %d", read_buffer);
|
||||
data->key = read_buffer;
|
||||
data->state = LV_INDEV_STATE_PRESSED;
|
||||
// TODO: Avoid performance hit by calling loadOrGetDefault() on each key press
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "TrackballDevice.h"
|
||||
#include <Trackball/Trackball.h> // Driver
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/settings/TrackballSettings.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("TrackballDevice");
|
||||
constexpr auto* TAG = "TrackballDevice";
|
||||
|
||||
bool TrackballDevice::start() {
|
||||
if (initialized) {
|
||||
@@ -40,7 +40,7 @@ bool TrackballDevice::start() {
|
||||
trackball::setEnabled(tbSettings.trackballEnabled);
|
||||
tt::lvgl::unlock();
|
||||
} else {
|
||||
LOGGER.warn("Failed to acquire LVGL lock for trackball settings");
|
||||
LOG_W(TAG, "Failed to acquire LVGL lock for trackball settings");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
#include "devices/Display.h"
|
||||
|
||||
#include "PwmBacklight.h"
|
||||
#include "Tactility/kernel/SystemEvents.h"
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#define TAG "tdisplay-s3"
|
||||
|
||||
@@ -28,14 +29,14 @@ static bool powerOn() {
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
ESP_LOGI(TAG, "Powering on the board...");
|
||||
LOG_I(TAG, "Powering on");
|
||||
if (!powerOn()) {
|
||||
ESP_LOGE(TAG, "Failed to power on the board.");
|
||||
LOG_E(TAG, "Power on failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!driver::pwmbacklight::init(DISPLAY_BL, 30000)) {
|
||||
ESP_LOGE(TAG, "Failed to initialize backlight.");
|
||||
LOG_E(TAG, "Backlight init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "PwmBacklight.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("T-Dongle S3");
|
||||
constexpr auto* TAG = "T-Dongle S3";
|
||||
|
||||
bool initBoot() {
|
||||
if (!driver::pwmbacklight::init(GPIO_NUM_38, 12000)) {
|
||||
LOGGER.error("Backlight init failed");
|
||||
LOG_E(TAG, "Backlight init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#include "devices/Display.h"
|
||||
|
||||
#include "PwmBacklight.h"
|
||||
#include "Tactility/kernel/SystemEvents.h"
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <tactility/log.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
#define TAG "thmi"
|
||||
@@ -32,16 +33,16 @@ static bool powerOn() {
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
ESP_LOGI(TAG, "Powering on the board...");
|
||||
LOG_I(TAG, "Powering on the board...");
|
||||
if (!powerOn()) {
|
||||
ESP_LOGE(TAG, "Failed to power on the board.");
|
||||
LOG_E(TAG, "Failed to power on the board.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!driver::pwmbacklight::init(DISPLAY_BL, 30000)) {
|
||||
ESP_LOGE(TAG, "Failed to initialize backlight.");
|
||||
LOG_E(TAG, "Failed to initialize backlight.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#include "Power.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <driver/adc.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Power");
|
||||
constexpr auto* TAG = "Power";
|
||||
|
||||
bool Power::adcInitCalibration() {
|
||||
bool calibrated = false;
|
||||
|
||||
esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT);
|
||||
if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) {
|
||||
LOGGER.warn("Calibration scheme not supported, skip software calibration");
|
||||
LOG_W(TAG, "Calibration scheme not supported, skip software calibration");
|
||||
} else if (efuse_read_result == ESP_ERR_INVALID_VERSION) {
|
||||
LOGGER.warn("eFuse not burnt, skip software calibration");
|
||||
LOG_W(TAG, "eFuse not burnt, skip software calibration");
|
||||
} else if (efuse_read_result == ESP_OK) {
|
||||
calibrated = true;
|
||||
LOGGER.info("Calibration success");
|
||||
LOG_I(TAG, "Calibration success");
|
||||
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics);
|
||||
} else {
|
||||
LOGGER.warn("eFuse read failed, skipping calibration");
|
||||
LOG_W(TAG, "eFuse read failed, skipping calibration");
|
||||
}
|
||||
|
||||
return calibrated;
|
||||
@@ -26,16 +26,16 @@ bool Power::adcInitCalibration() {
|
||||
|
||||
uint32_t Power::adcReadValue() const {
|
||||
int adc_raw = adc1_get_raw(ADC1_CHANNEL_4);
|
||||
LOGGER.debug("Raw data: {}", adc_raw);
|
||||
LOG_D(TAG, "Raw data: %d", adc_raw);
|
||||
|
||||
uint32_t voltage;
|
||||
|
||||
if (calibrated) {
|
||||
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics);
|
||||
LOGGER.debug("Calibrated data: {} mV", voltage);
|
||||
LOG_D(TAG, "Calibrated data: %d mV", (int)voltage);
|
||||
} else {
|
||||
voltage = (adc_raw * 3300) / 4095; // fallback
|
||||
LOGGER.debug("Estimated data: {} mV", voltage);
|
||||
LOG_D(TAG, "Estimated data: %d mV", (int)voltage);
|
||||
}
|
||||
|
||||
return voltage;
|
||||
@@ -45,12 +45,12 @@ bool Power::ensureInitialized() {
|
||||
if (!initialized) {
|
||||
|
||||
if (adc1_config_width(ADC_WIDTH_BIT_12) != ESP_OK) {
|
||||
LOGGER.error("ADC1 config width failed");
|
||||
LOG_E(TAG, "ADC1 config width failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_DB_11) != ESP_OK) {
|
||||
LOGGER.error("ADC1 config attenuation failed");
|
||||
LOG_E(TAG, "ADC1 config attenuation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <Bq27220.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
@@ -8,17 +7,18 @@
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <PwmBacklight.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("T-Lora Pager");
|
||||
constexpr auto* TAG = "T-Lora Pager";
|
||||
|
||||
bool tpagerInit() {
|
||||
LOGGER.info(LOG_MESSAGE_POWER_ON_START);
|
||||
LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
|
||||
|
||||
/* 32 Khz and higher gives an issue where the screen starts dimming again above 80% brightness
|
||||
* when moving the brightness slider rapidly from a lower setting to 100%.
|
||||
* This is not a slider bug (data was debug-traced) */
|
||||
if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) {
|
||||
LOGGER.error("Backlight init failed");
|
||||
LOG_E(TAG, "Backlight init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ bool tpagerInit() {
|
||||
.baudRate = 38400,
|
||||
.model = tt::hal::gps::GpsModel::UBLOX10
|
||||
})) {
|
||||
LOGGER.info("Configured internal GPS");
|
||||
LOG_I(TAG, "Configured internal GPS");
|
||||
} else {
|
||||
LOGGER.error("Failed to configure internal GPS");
|
||||
LOG_E(TAG, "Failed to configure internal GPS");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "TpagerEncoder.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("TpagerEncoder");
|
||||
constexpr auto* TAG = "TpagerEncoder";
|
||||
|
||||
constexpr auto ENCODER_A = GPIO_NUM_40;
|
||||
constexpr auto ENCODER_B = GPIO_NUM_41;
|
||||
@@ -58,7 +58,7 @@ bool TpagerEncoder::initEncoder() {
|
||||
};
|
||||
|
||||
if (pcnt_new_unit(&unit_config, &encPcntUnit) != ESP_OK) {
|
||||
LOGGER.error("Pulsecounter initialization failed");
|
||||
LOG_E(TAG, "Pulsecounter initialization failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ bool TpagerEncoder::initEncoder() {
|
||||
};
|
||||
|
||||
if (pcnt_unit_set_glitch_filter(encPcntUnit, &filter_config) != ESP_OK) {
|
||||
LOGGER.error("Pulsecounter glitch filter config failed");
|
||||
LOG_E(TAG, "Pulsecounter glitch filter config failed");
|
||||
pcnt_del_unit(encPcntUnit);
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
@@ -102,7 +102,7 @@ bool TpagerEncoder::initEncoder() {
|
||||
|
||||
if ((pcnt_new_channel(encPcntUnit, &chan_1_config, &pcnt_chan_1) != ESP_OK) ||
|
||||
(pcnt_new_channel(encPcntUnit, &chan_2_config, &pcnt_chan_2) != ESP_OK)) {
|
||||
LOGGER.error("Pulsecounter channel config failed");
|
||||
LOG_E(TAG, "Pulsecounter channel config failed");
|
||||
pcnt_del_unit(encPcntUnit);
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
@@ -111,7 +111,7 @@ bool TpagerEncoder::initEncoder() {
|
||||
// Second argument is rising edge, third argument is falling edge
|
||||
if ((pcnt_channel_set_edge_action(pcnt_chan_1, PCNT_CHANNEL_EDGE_ACTION_DECREASE, PCNT_CHANNEL_EDGE_ACTION_INCREASE) != ESP_OK) ||
|
||||
(pcnt_channel_set_edge_action(pcnt_chan_2, PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_DECREASE) != ESP_OK)) {
|
||||
LOGGER.error("Pulsecounter edge action config failed");
|
||||
LOG_E(TAG, "Pulsecounter edge action config failed");
|
||||
pcnt_del_unit(encPcntUnit);
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
@@ -120,7 +120,7 @@ bool TpagerEncoder::initEncoder() {
|
||||
// Second argument is low level, third argument is high level
|
||||
if ((pcnt_channel_set_level_action(pcnt_chan_1, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK) ||
|
||||
(pcnt_channel_set_level_action(pcnt_chan_2, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK)) {
|
||||
LOGGER.error("Pulsecounter level action config failed");
|
||||
LOG_E(TAG, "Pulsecounter level action config failed");
|
||||
pcnt_del_unit(encPcntUnit);
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
@@ -128,28 +128,28 @@ bool TpagerEncoder::initEncoder() {
|
||||
|
||||
if ((pcnt_unit_add_watch_point(encPcntUnit, LOW_LIMIT) != ESP_OK) ||
|
||||
(pcnt_unit_add_watch_point(encPcntUnit, HIGH_LIMIT) != ESP_OK)) {
|
||||
LOGGER.error("Pulsecounter watch point config failed");
|
||||
LOG_E(TAG, "Pulsecounter watch point config failed");
|
||||
pcnt_del_unit(encPcntUnit);
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pcnt_unit_enable(encPcntUnit) != ESP_OK) {
|
||||
LOGGER.error("Pulsecounter could not be enabled");
|
||||
LOG_E(TAG, "Pulsecounter could not be enabled");
|
||||
pcnt_del_unit(encPcntUnit);
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pcnt_unit_clear_count(encPcntUnit) != ESP_OK) {
|
||||
LOGGER.error("Pulsecounter could not be cleared");
|
||||
LOG_E(TAG, "Pulsecounter could not be cleared");
|
||||
pcnt_del_unit(encPcntUnit);
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pcnt_unit_start(encPcntUnit) != ESP_OK) {
|
||||
LOGGER.error("Pulsecounter could not be started");
|
||||
LOG_E(TAG, "Pulsecounter could not be started");
|
||||
pcnt_del_unit(encPcntUnit);
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
@@ -168,16 +168,16 @@ bool TpagerEncoder::deinitEncoder() {
|
||||
assert(encPcntUnit != nullptr);
|
||||
|
||||
if (pcnt_unit_stop(encPcntUnit) != ESP_OK) {
|
||||
LOGGER.warn("Failed to stop encoder");
|
||||
LOG_W(TAG, "Failed to stop encoder");
|
||||
}
|
||||
|
||||
if (pcnt_del_unit(encPcntUnit) != ESP_OK) {
|
||||
LOGGER.warn("Failed to delete encoder");
|
||||
LOG_W(TAG, "Failed to delete encoder");
|
||||
encPcntUnit = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("Deinitialized");
|
||||
LOG_I(TAG, "Deinitialized");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ bool TpagerEncoder::stopLvgl() {
|
||||
|
||||
if (encPcntUnit != nullptr && !deinitEncoder()) {
|
||||
// We're not returning false as LVGL as effectively deinitialized
|
||||
LOGGER.warn("Deinitialization failed");
|
||||
LOG_W(TAG, "Deinitialization failed");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include "TpagerKeyboard.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <driver/i2c.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("TpagerKeyboard");
|
||||
constexpr auto* TAG = "TpagerKeyboard";
|
||||
|
||||
constexpr auto BACKLIGHT = GPIO_NUM_46;
|
||||
|
||||
@@ -173,7 +172,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
|
||||
};
|
||||
|
||||
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
|
||||
LOGGER.error("Backlight timer config failed");
|
||||
LOG_E(TAG, "Backlight timer config failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -192,7 +191,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
|
||||
};
|
||||
|
||||
if (ledc_channel_config(&ledc_channel) != ESP_OK) {
|
||||
LOGGER.error("Backlight channel config failed");
|
||||
LOG_E(TAG, "Backlight channel config failed");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -200,7 +199,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
|
||||
|
||||
bool TpagerKeyboard::setBacklightDuty(uint8_t duty) {
|
||||
if (!backlightOkay) {
|
||||
LOGGER.error("Backlight not ready");
|
||||
LOG_E(TAG, "Backlight not ready");
|
||||
return false;
|
||||
}
|
||||
return (ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK) &&
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "TpagerPower.h"
|
||||
|
||||
#include <Bq25896.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("TpagerPower");
|
||||
constexpr auto* TAG = "TpagerPower";
|
||||
|
||||
TpagerPower::~TpagerPower() {}
|
||||
|
||||
@@ -66,7 +66,7 @@ void TpagerPower::powerOff() {
|
||||
});
|
||||
|
||||
if (device == nullptr) {
|
||||
LOGGER.error("BQ25896 not found");
|
||||
LOG_E(TAG, "BQ25896 not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#include "CardputerPower.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <driver/adc.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("CardputerPower");
|
||||
constexpr auto* TAG = "CardputerPower";
|
||||
|
||||
bool CardputerPower::adcInitCalibration() {
|
||||
bool calibrated = false;
|
||||
|
||||
esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT);
|
||||
if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) {
|
||||
LOGGER.warn("Calibration scheme not supported, skip software calibration");
|
||||
LOG_W(TAG, "Calibration scheme not supported, skip software calibration");
|
||||
} else if (efuse_read_result == ESP_ERR_INVALID_VERSION) {
|
||||
LOGGER.warn("eFuse not burnt, skip software calibration");
|
||||
LOG_W(TAG, "eFuse not burnt, skip software calibration");
|
||||
} else if (efuse_read_result == ESP_OK) {
|
||||
calibrated = true;
|
||||
LOGGER.info("Calibration success");
|
||||
LOG_I(TAG, "Calibration success");
|
||||
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics);
|
||||
} else {
|
||||
LOGGER.warn("eFuse read failed, skipping calibration");
|
||||
LOG_W(TAG, "eFuse read failed, skipping calibration");
|
||||
}
|
||||
|
||||
return calibrated;
|
||||
@@ -26,11 +26,11 @@ bool CardputerPower::adcInitCalibration() {
|
||||
|
||||
uint32_t CardputerPower::adcReadValue() const {
|
||||
int adc_raw = adc1_get_raw(ADC1_CHANNEL_9);
|
||||
LOGGER.debug("Raw data: {}", adc_raw);
|
||||
LOG_D(TAG, "Raw data: %d", adc_raw);
|
||||
float voltage;
|
||||
if (calibrated) {
|
||||
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics);
|
||||
LOGGER.debug("Calibrated data: {} mV", voltage);
|
||||
LOG_D(TAG, "Calibrated data: %f mV", voltage);
|
||||
} else {
|
||||
voltage = 0.0f;
|
||||
}
|
||||
@@ -42,11 +42,11 @@ bool CardputerPower::ensureInitialized() {
|
||||
calibrated = adcInitCalibration();
|
||||
|
||||
if (adc1_config_width(static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT)) != ESP_OK) {
|
||||
LOGGER.error("ADC1 config width failed");
|
||||
LOG_E(TAG, "ADC1 config width failed");
|
||||
return false;
|
||||
}
|
||||
if (adc1_config_channel_atten(ADC1_CHANNEL_9, ADC_ATTEN_DB_11) != ESP_OK) {
|
||||
LOGGER.error("ADC1 config attenuation failed");
|
||||
LOG_E(TAG, "ADC1 config attenuation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "CardputerKeyboard.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Keyboard");
|
||||
constexpr auto* TAG = "Keyboard";
|
||||
|
||||
bool CardputerKeyboard::startLvgl(lv_display_t* display) {
|
||||
keyboard.init();
|
||||
@@ -56,7 +56,7 @@ void CardputerKeyboard::readCallback(lv_indev_t* indev, lv_indev_data_t* data) {
|
||||
}
|
||||
} else {
|
||||
if (self->keyboard.keysState().del) {
|
||||
LOGGER.info("del");
|
||||
LOG_I(TAG, "del");
|
||||
data->key = LV_KEY_DEL;
|
||||
data->state = LV_INDEV_STATE_PRESSED;
|
||||
} else {
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#include "CardputerPower.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <driver/adc.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("CardputerPower");
|
||||
constexpr auto* TAG = "CardputerPower";
|
||||
|
||||
bool CardputerPower::adcInitCalibration() {
|
||||
bool calibrated = false;
|
||||
|
||||
esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT);
|
||||
if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) {
|
||||
LOGGER.warn("Calibration scheme not supported, skip software calibration");
|
||||
LOG_W(TAG, "Calibration scheme not supported, skip software calibration");
|
||||
} else if (efuse_read_result == ESP_ERR_INVALID_VERSION) {
|
||||
LOGGER.warn("eFuse not burnt, skip software calibration");
|
||||
LOG_W(TAG, "eFuse not burnt, skip software calibration");
|
||||
} else if (efuse_read_result == ESP_OK) {
|
||||
calibrated = true;
|
||||
LOGGER.info("Calibration success");
|
||||
LOG_I(TAG, "Calibration success");
|
||||
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics);
|
||||
} else {
|
||||
LOGGER.warn("eFuse read failed, skipping calibration");
|
||||
LOG_W(TAG, "eFuse read failed, skipping calibration");
|
||||
}
|
||||
|
||||
return calibrated;
|
||||
@@ -26,11 +26,11 @@ bool CardputerPower::adcInitCalibration() {
|
||||
|
||||
uint32_t CardputerPower::adcReadValue() const {
|
||||
int adc_raw = adc1_get_raw(ADC1_CHANNEL_9);
|
||||
LOGGER.debug("Raw data: {}", adc_raw);
|
||||
LOG_D(TAG, "Raw data: %d", adc_raw);
|
||||
float voltage;
|
||||
if (calibrated) {
|
||||
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics);
|
||||
LOGGER.debug("Calibrated data: {} mV", voltage);
|
||||
LOG_D(TAG, "Calibrated data: %f mV", voltage);
|
||||
} else {
|
||||
voltage = 0.0f;
|
||||
}
|
||||
@@ -42,11 +42,11 @@ bool CardputerPower::ensureInitialized() {
|
||||
calibrated = adcInitCalibration();
|
||||
|
||||
if (adc1_config_width(static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT)) != ESP_OK) {
|
||||
LOGGER.error("ADC1 config width failed");
|
||||
LOG_E(TAG, "ADC1 config width failed");
|
||||
return false;
|
||||
}
|
||||
if (adc1_config_channel_atten(ADC1_CHANNEL_9, ADC_ATTEN_DB_11) != ESP_OK) {
|
||||
LOGGER.error("ADC1 config attenuation failed");
|
||||
LOG_E(TAG, "ADC1 config attenuation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "InitBoot.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("CoreS3");
|
||||
constexpr auto* TAG = "CoreS3";
|
||||
|
||||
std::shared_ptr<Axp2101> axp2101;
|
||||
std::shared_ptr<Aw9523> aw9523;
|
||||
@@ -13,7 +13,7 @@ std::shared_ptr<Aw9523> aw9523;
|
||||
* and schematic: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/K128%20CoreS3/Sch_M5_CoreS3_v1.0.pdf
|
||||
*/
|
||||
bool initGpioExpander() {
|
||||
LOGGER.info("AW9523 init");
|
||||
LOG_I(TAG, "AW9523 init");
|
||||
|
||||
/**
|
||||
* P0 pins:
|
||||
@@ -58,33 +58,33 @@ bool initGpioExpander() {
|
||||
|
||||
/* AW9523 P0 is in push-pull mode */
|
||||
if (!aw9523->writeCTL(0x10)) {
|
||||
LOGGER.error("AW9523: Failed to set CTL");
|
||||
LOG_E(TAG, "AW9523: Failed to set CTL");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aw9523->writeP0(p0_state)) {
|
||||
LOGGER.error("AW9523: Failed to set P0");
|
||||
LOG_E(TAG, "AW9523: Failed to set P0");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aw9523->writeP1(p1_state)) {
|
||||
LOGGER.error("AW9523: Failed to set P1");
|
||||
LOG_E(TAG, "AW9523: Failed to set P1");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (axp2101->isVBus()) {
|
||||
float voltage = 0.0f;
|
||||
axp2101->getVBusVoltage(voltage);
|
||||
LOGGER.info("AXP2101: VBus at {:.2f}", voltage);
|
||||
LOG_I(TAG, "AXP2101: VBus at %.2f", voltage);
|
||||
} else {
|
||||
LOGGER.warn("AXP2101: VBus disabled");
|
||||
LOG_W(TAG, "AXP2101: VBus disabled");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initPowerControl() {
|
||||
LOGGER.info("Init power control (AXP2101)");
|
||||
LOG_I(TAG, "Init power control (AXP2101)");
|
||||
|
||||
// Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L61
|
||||
aw9523->bitOnP1(0b10000000); // SY7088 boost enable
|
||||
@@ -135,16 +135,16 @@ bool initPowerControl() {
|
||||
};
|
||||
|
||||
if (axp2101->setRegisters((uint8_t*)reg_data_array, sizeof(reg_data_array))) {
|
||||
LOGGER.info("AXP2101 initialized with {} registers", sizeof(reg_data_array) / 2);
|
||||
LOG_I(TAG, "AXP2101 initialized with %d registers", (int)(sizeof(reg_data_array) / 2));
|
||||
return true;
|
||||
} else {
|
||||
LOGGER.error("AXP2101: Failed to set registers");
|
||||
LOG_E(TAG, "AXP2101: Failed to set registers");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
LOGGER.info("initBoot()");
|
||||
LOG_I(TAG, "initBoot()");
|
||||
|
||||
auto controller = device_find_by_name("i2c_internal");
|
||||
axp2101 = std::make_shared<Axp2101>(controller);
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#include <Axp2101.h>
|
||||
#include <Ft5x06Touch.h>
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("CoreS3Display");
|
||||
constexpr auto* TAG = "CoreS3Display";
|
||||
|
||||
static void setBacklightDuty(uint8_t backlightDuty) {
|
||||
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
|
||||
@@ -15,7 +15,7 @@ static void setBacklightDuty(uint8_t backlightDuty) {
|
||||
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");
|
||||
LOG_E(TAG, "Failed to set display backlight voltage");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <Tactility/Logger.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Paper S3");
|
||||
constexpr auto* TAG = "Paper S3";
|
||||
|
||||
constexpr gpio_num_t VBAT_PIN = GPIO_NUM_3;
|
||||
constexpr gpio_num_t CHARGE_STATUS_PIN = GPIO_NUM_4;
|
||||
@@ -9,38 +9,38 @@ constexpr gpio_num_t USB_DETECT_PIN = GPIO_NUM_5;
|
||||
|
||||
static bool powerOn() {
|
||||
if (gpio_reset_pin(CHARGE_STATUS_PIN) != ESP_OK) {
|
||||
LOGGER.error("Failed to reset CHARGE_STATUS_PIN");
|
||||
LOG_E(TAG, "Failed to reset CHARGE_STATUS_PIN");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_set_direction(CHARGE_STATUS_PIN, GPIO_MODE_INPUT) != ESP_OK) {
|
||||
LOGGER.error("Failed to set direction for CHARGE_STATUS_PIN");
|
||||
LOG_E(TAG, "Failed to set direction for CHARGE_STATUS_PIN");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_reset_pin(USB_DETECT_PIN) != ESP_OK) {
|
||||
LOGGER.error("Failed to reset USB_DETECT_PIN");
|
||||
LOG_E(TAG, "Failed to reset USB_DETECT_PIN");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_set_direction(USB_DETECT_PIN, GPIO_MODE_INPUT) != ESP_OK) {
|
||||
LOGGER.error("Failed to set direction for USB_DETECT_PIN");
|
||||
LOG_E(TAG, "Failed to set direction for USB_DETECT_PIN");
|
||||
return false;
|
||||
}
|
||||
|
||||
// VBAT_PIN is used as ADC input; only reset it here to clear any previous
|
||||
// configuration. The ADC driver (ChargeFromAdcVoltage) configures it for ADC use.
|
||||
if (gpio_reset_pin(VBAT_PIN) != ESP_OK) {
|
||||
LOGGER.error("Failed to reset VBAT_PIN");
|
||||
LOG_E(TAG, "Failed to reset VBAT_PIN");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
LOGGER.info("Power on");
|
||||
LOG_I(TAG, "Power on");
|
||||
if (!powerOn()) {
|
||||
LOGGER.error("Power on failed");
|
||||
LOG_E(TAG, "Power on failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
#include <Axp2101.h>
|
||||
#include <Ft6x36Touch.h>
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("StackChanDisplay");
|
||||
constexpr auto* TAG = "StackChanDisplay";
|
||||
|
||||
static void setBacklightDuty(uint8_t backlightDuty) {
|
||||
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100]
|
||||
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");
|
||||
LOG_E(TAG, "Failed to set display backlight voltage");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "Detect.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/i2c_controller.h>
|
||||
#include <tactility/log.h>
|
||||
#include <esp_lcd_touch_gt911.h>
|
||||
#include <esp_lcd_touch_st7123.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Tab5Detect");
|
||||
constexpr auto* TAG = "Tab5Detect";
|
||||
|
||||
Tab5Variant detectVariant() {
|
||||
// Allow time for touch IC to fully boot after expander reset in initBoot().
|
||||
@@ -27,19 +27,19 @@ Tab5Variant detectVariant() {
|
||||
// It may also appear at 0x14 (backup) if the pin happened to be driven low
|
||||
if (i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS, PROBE_TIMEOUT) == ERROR_NONE ||
|
||||
i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP, PROBE_TIMEOUT) == ERROR_NONE) {
|
||||
LOGGER.info("Detected GT911 touch — using ILI9881C display");
|
||||
LOG_I(TAG, "Detected GT911 touch — using ILI9881C display");
|
||||
return Tab5Variant::Ili9881c_Gt911;
|
||||
}
|
||||
|
||||
// Probe for ST7123 touch (new variant)
|
||||
if (i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_ST7123_ADDRESS, PROBE_TIMEOUT) == ERROR_NONE) {
|
||||
LOGGER.info("Detected ST7123 touch — using ST7123 display");
|
||||
LOG_I(TAG, "Detected ST7123 touch — using ST7123 display");
|
||||
return Tab5Variant::St7123;
|
||||
}
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
|
||||
LOGGER.warn("No known touch controller detected, defaulting to ST7123");
|
||||
LOG_W(TAG, "No known touch controller detected, defaulting to ST7123");
|
||||
return Tab5Variant::St7123;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
|
||||
#include <Gt911Touch.h>
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/hal/gpio/Gpio.h>
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/log.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Tab5Display");
|
||||
constexpr auto* TAG = "Tab5Display";
|
||||
|
||||
// LCD reset is wired to the PI4IOE5V6408 IO expander (io_expander0, bit 4), pulsed in
|
||||
// Configuration.cpp's initExpander0() before display creation - not a direct SoC GPIO.
|
||||
@@ -55,7 +55,7 @@ static std::shared_ptr<tt::hal::touch::TouchDevice> createSt7123Touch() {
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
// Initialize PWM backlight
|
||||
if (!driver::pwmbacklight::init(LCD_PIN_BACKLIGHT, 5000, LEDC_TIMER_1, LEDC_CHANNEL_0)) {
|
||||
LOGGER.warn("Failed to initialize backlight");
|
||||
LOG_W(TAG, "Failed to initialize backlight");
|
||||
}
|
||||
|
||||
Tab5Variant variant = detectVariant();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "Ili9881cDisplay.h"
|
||||
#include "ili9881_init_data.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <esp_lcd_ili9881c.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("ILI9881C");
|
||||
constexpr auto* TAG = "ILI9881C";
|
||||
|
||||
Ili9881cDisplay::~Ili9881cDisplay() {
|
||||
// TODO: This should happen during ::stop(), but this isn't currently exposed
|
||||
@@ -30,11 +30,11 @@ bool Ili9881cDisplay::createMipiDsiBus() {
|
||||
};
|
||||
|
||||
if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) {
|
||||
LOGGER.error("Failed to acquire LDO channel for MIPI DSI PHY");
|
||||
LOG_E(TAG, "Failed to acquire LDO channel for MIPI DSI PHY");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("Powered on");
|
||||
|
||||
LOG_I(TAG, "Powered on");
|
||||
|
||||
// Create bus
|
||||
// TODO: use MIPI_DSI_PHY_CLK_SRC_DEFAULT() in future ESP-IDF 6.0.0 update with esp_lcd_jd9165 library version 2.x
|
||||
@@ -46,13 +46,13 @@ bool Ili9881cDisplay::createMipiDsiBus() {
|
||||
};
|
||||
|
||||
if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) {
|
||||
LOGGER.error("Failed to create bus");
|
||||
LOG_E(TAG, "Failed to create bus");
|
||||
esp_ldo_release_channel(ldoChannel);
|
||||
ldoChannel = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("Bus created");
|
||||
LOG_I(TAG, "Bus created");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ bool Ili9881cDisplay::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
|
||||
esp_lcd_dbi_io_config_t dbi_config = ILI9881C_PANEL_IO_DBI_CONFIG();
|
||||
|
||||
if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel IO");
|
||||
LOG_E(TAG, "Failed to create panel IO");
|
||||
esp_lcd_del_dsi_bus(mipiDsiBus);
|
||||
mipiDsiBus = nullptr;
|
||||
esp_ldo_release_channel(ldoChannel);
|
||||
@@ -135,11 +135,11 @@ bool Ili9881cDisplay::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, cons
|
||||
mutable_panel_config.vendor_config = &vendor_config;
|
||||
|
||||
if (esp_lcd_new_panel_ili9881c(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel");
|
||||
LOG_E(TAG, "Failed to create panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("Panel created successfully");
|
||||
LOG_I(TAG, "Panel created successfully");
|
||||
// Defer reset/init to base class applyConfiguration to avoid double initialization
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "St7123Display.h"
|
||||
#include "st7123_init_data.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <esp_lcd_st7123.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("St7123");
|
||||
constexpr auto* TAG = "St7123";
|
||||
|
||||
St7123Display::~St7123Display() {
|
||||
// TODO: This should happen during ::stop(), but this isn't currently exposed
|
||||
@@ -30,11 +30,11 @@ bool St7123Display::createMipiDsiBus() {
|
||||
};
|
||||
|
||||
if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) {
|
||||
LOGGER.error("Failed to acquire LDO channel for MIPI DSI PHY");
|
||||
LOG_E(TAG, "Failed to acquire LDO channel for MIPI DSI PHY");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("Powered on");
|
||||
LOG_I(TAG, "Powered on");
|
||||
|
||||
const esp_lcd_dsi_bus_config_t bus_config = {
|
||||
.bus_id = 0,
|
||||
@@ -44,13 +44,13 @@ bool St7123Display::createMipiDsiBus() {
|
||||
};
|
||||
|
||||
if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) {
|
||||
LOGGER.error("Failed to create bus");
|
||||
LOG_E(TAG, "Failed to create bus");
|
||||
esp_ldo_release_channel(ldoChannel);
|
||||
ldoChannel = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("Bus created");
|
||||
LOG_I(TAG, "Bus created");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ bool St7123Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel IO");
|
||||
LOG_E(TAG, "Failed to create panel IO");
|
||||
esp_lcd_del_dsi_bus(mipiDsiBus);
|
||||
mipiDsiBus = nullptr;
|
||||
esp_ldo_release_channel(ldoChannel);
|
||||
@@ -130,11 +130,11 @@ bool St7123Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, const
|
||||
mutable_panel_config.vendor_config = &vendor_config;
|
||||
|
||||
if (esp_lcd_new_panel_st7123(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel");
|
||||
LOG_E(TAG, "Failed to create panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.info("Panel created successfully");
|
||||
LOG_I(TAG, "Panel created successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "St7123Touch.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/drivers/esp32_i2c_master.h>
|
||||
#include <tactility/log.h>
|
||||
#include <esp_lcd_touch_st7123.h>
|
||||
#include <esp_err.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("ST7123Touch");
|
||||
constexpr auto* TAG = "ST7123Touch";
|
||||
|
||||
bool St7123Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_ST7123_CONFIG();
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
static const auto LOGGER = tt::Logger("FreeRTOS");
|
||||
#include <tactility/log.h>
|
||||
|
||||
constexpr auto* TAG = "FreeRTOS";
|
||||
|
||||
namespace simulator {
|
||||
|
||||
@@ -16,10 +18,10 @@ void setMain(MainFunction newMainFunction) {
|
||||
}
|
||||
|
||||
static void freertosMainTask(void* parameter) {
|
||||
LOGGER.info("starting app_main()");
|
||||
LOG_I(TAG, "starting app_main()");
|
||||
assert(simulator::mainFunction);
|
||||
mainFunction();
|
||||
LOGGER.info("returned from app_main()");
|
||||
LOG_I(TAG, "returned from app_main()");
|
||||
vTaskDelete(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "UnPhoneFeatures.h"
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/Preferences.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <esp_sleep.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("unPhone");
|
||||
constexpr auto* TAG = "unPhone";
|
||||
|
||||
std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
|
||||
static std::unique_ptr<tt::Thread> powerThread;
|
||||
@@ -49,10 +49,10 @@ public:
|
||||
}
|
||||
|
||||
void printInfo() {
|
||||
LOGGER.info("Device stats:");
|
||||
LOGGER.info(" boot: {}", getValue(bootCountKey));
|
||||
LOGGER.info(" power off: {}", getValue(powerOffCountKey));
|
||||
LOGGER.info(" power sleep: {}", getValue(powerSleepKey));
|
||||
LOG_I(TAG, "Device stats:");
|
||||
LOG_I(TAG, " boot: %d", (int)getValue(bootCountKey));
|
||||
LOG_I(TAG, " power off: %d", (int)getValue(powerOffCountKey));
|
||||
LOG_I(TAG, " power sleep: %d", (int)getValue(powerSleepKey));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -92,11 +92,11 @@ static void updatePowerSwitch() {
|
||||
if (!unPhoneFeatures->isPowerSwitchOn()) {
|
||||
if (last_state != PowerState::Off) {
|
||||
last_state = PowerState::Off;
|
||||
LOGGER.warn("Power off");
|
||||
LOG_W(TAG, "Power off");
|
||||
}
|
||||
|
||||
if (!unPhoneFeatures->isUsbPowerConnected()) { // and usb unplugged we go into shipping mode
|
||||
LOGGER.warn("Shipping mode until USB connects");
|
||||
LOG_W(TAG, "Shipping mode until USB connects");
|
||||
|
||||
#if DEBUG_POWER_STATES
|
||||
unPhoneFeatures.setExpanderPower(true);
|
||||
@@ -110,7 +110,7 @@ static void updatePowerSwitch() {
|
||||
|
||||
unPhoneFeatures->setShipping(true); // tell BM to stop supplying power until USB connects
|
||||
} else { // When power switch is off, but USB is plugged in, we wait (deep sleep) until USB is unplugged.
|
||||
LOGGER.warn("Waiting for USB disconnect to power off");
|
||||
LOG_W(TAG, "Waiting for USB disconnect to power off");
|
||||
|
||||
#if DEBUG_POWER_STATES
|
||||
powerInfoBuzz(2);
|
||||
@@ -129,7 +129,7 @@ static void updatePowerSwitch() {
|
||||
} else {
|
||||
if (last_state != PowerState::On) {
|
||||
last_state = PowerState::On;
|
||||
LOGGER.warn("Power on");
|
||||
LOG_W(TAG, "Power on");
|
||||
|
||||
#if DEBUG_POWER_STATES
|
||||
powerInfoBuzz(1);
|
||||
@@ -166,7 +166,7 @@ static bool unPhonePowerOn() {
|
||||
unPhoneFeatures = std::make_shared<UnPhoneFeatures>(bq24295);
|
||||
|
||||
if (!unPhoneFeatures->init()) {
|
||||
LOGGER.error("UnPhoneFeatures init failed");
|
||||
LOG_E(TAG, "UnPhoneFeatures init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@ static bool unPhonePowerOn() {
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
LOGGER.info(LOG_MESSAGE_POWER_ON_START);
|
||||
LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
|
||||
|
||||
if (!unPhonePowerOn()) {
|
||||
LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED);
|
||||
LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "UnPhoneFeatures.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/app/App.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
@@ -8,8 +7,9 @@
|
||||
#include <driver/rtc_io.h>
|
||||
#include <esp_io_expander.h>
|
||||
#include <esp_sleep.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("unPhoneFeatures");
|
||||
constexpr auto* TAG = "unPhoneFeatures";
|
||||
|
||||
namespace pin {
|
||||
static const gpio_num_t BUTTON1 = GPIO_NUM_45; // left button
|
||||
@@ -42,7 +42,7 @@ static int32_t buttonHandlingThreadMain(const bool* interrupted) {
|
||||
while (!*interrupted) {
|
||||
if (xQueueReceive(interruptQueue, &pinNumber, portMAX_DELAY)) {
|
||||
// The buttons might generate more than 1 click because of how they are built
|
||||
LOGGER.info("Pressed button {}", pinNumber);
|
||||
LOG_I(TAG, "Pressed button %d", pinNumber);
|
||||
if (pinNumber == pin::BUTTON1) {
|
||||
tt::app::stop();
|
||||
}
|
||||
@@ -75,7 +75,7 @@ bool UnPhoneFeatures::initPowerSwitch() {
|
||||
};
|
||||
|
||||
if (gpio_config(&config) != ESP_OK) {
|
||||
LOGGER.error("Power pin init failed");
|
||||
LOG_E(TAG, "Power pin init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,14 +83,14 @@ bool UnPhoneFeatures::initPowerSwitch() {
|
||||
rtc_gpio_pulldown_en(pin::POWER_SWITCH) == ESP_OK) {
|
||||
return true;
|
||||
} else {
|
||||
LOGGER.error("Failed to set RTC for power switch");
|
||||
LOG_E(TAG, "Failed to set RTC for power switch");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool UnPhoneFeatures::initNavButtons() {
|
||||
if (!initGpioExpander()) {
|
||||
LOGGER.error("GPIO expander init failed");
|
||||
LOG_E(TAG, "GPIO expander init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ bool UnPhoneFeatures::initNavButtons() {
|
||||
};
|
||||
|
||||
if (gpio_config(&config) != ESP_OK) {
|
||||
LOGGER.error("Nav button pin init failed");
|
||||
LOG_E(TAG, "Nav button pin init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ bool UnPhoneFeatures::initNavButtons() {
|
||||
gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON2)) != ESP_OK ||
|
||||
gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON3)) != ESP_OK
|
||||
) {
|
||||
LOGGER.error("Nav buttons ISR init failed");
|
||||
LOG_E(TAG, "Nav buttons ISR init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ bool UnPhoneFeatures::initOutputPins() {
|
||||
};
|
||||
|
||||
if (gpio_config(&config) != ESP_OK) {
|
||||
LOGGER.error("Output pin init failed");
|
||||
LOG_E(TAG, "Output pin init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ bool UnPhoneFeatures::initGpioExpander() {
|
||||
// ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110 corresponds with 0x26 from the docs at
|
||||
// https://gitlab.com/hamishcunningham/unphonelibrary/-/blob/main/unPhone.h?ref_type=heads#L206
|
||||
if (esp_io_expander_new_i2c_tca95xx_16bit(I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110, &ioExpander) != ESP_OK) {
|
||||
LOGGER.error("IO expander init failed");
|
||||
LOG_E(TAG, "IO expander init failed");
|
||||
return false;
|
||||
}
|
||||
assert(ioExpander != nullptr);
|
||||
@@ -201,25 +201,25 @@ bool UnPhoneFeatures::initGpioExpander() {
|
||||
}
|
||||
|
||||
bool UnPhoneFeatures::init() {
|
||||
LOGGER.info("init");
|
||||
LOG_I(TAG, "init");
|
||||
|
||||
if (!initGpioExpander()) {
|
||||
LOGGER.error("GPIO expander init failed");
|
||||
LOG_E(TAG, "GPIO expander init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!initNavButtons()) {
|
||||
LOGGER.error("Input pin init failed");
|
||||
LOG_E(TAG, "Input pin init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!initOutputPins()) {
|
||||
LOGGER.error("Output pin init failed");
|
||||
LOG_E(TAG, "Output pin init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!initPowerSwitch()) {
|
||||
LOGGER.error("Power button init failed");
|
||||
LOG_E(TAG, "Power button init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ void UnPhoneFeatures::printInfo() const {
|
||||
batteryManagement->printInfo();
|
||||
bool backlight_power;
|
||||
const char* backlight_power_state = getBacklightPower(backlight_power) && backlight_power ? "on" : "off";
|
||||
LOGGER.info("Backlight: {}", backlight_power_state);
|
||||
LOG_I(TAG, "Backlight: %s", backlight_power_state);
|
||||
}
|
||||
|
||||
bool UnPhoneFeatures::setRgbLed(bool red, bool green, bool blue) const {
|
||||
@@ -286,11 +286,11 @@ void UnPhoneFeatures::turnPeripheralsOff() const {
|
||||
|
||||
bool UnPhoneFeatures::setShipping(bool on) const {
|
||||
if (on) {
|
||||
LOGGER.warn("setShipping: on");
|
||||
LOG_W(TAG, "setShipping: on");
|
||||
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Disabled);
|
||||
batteryManagement->setBatFetOn(false);
|
||||
} else {
|
||||
LOGGER.warn("setShipping: off");
|
||||
LOG_W(TAG, "setShipping: off");
|
||||
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s);
|
||||
batteryManagement->setBatFetOn(true);
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
#include "Touch.h"
|
||||
|
||||
#include <UnPhoneFeatures.h>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <hx8357/disp_spi.h>
|
||||
#include <hx8357/hx8357.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Hx8357Display");
|
||||
constexpr auto* TAG = "Hx8357Display";
|
||||
|
||||
constexpr auto BUFFER_SIZE = (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_DRAW_BUFFER_HEIGHT * LV_COLOR_DEPTH / 8);
|
||||
|
||||
extern std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
|
||||
|
||||
bool Hx8357Display::start() {
|
||||
LOGGER.info("start");
|
||||
LOG_I(TAG, "start");
|
||||
|
||||
disp_spi_add_device(SPI2_HOST);
|
||||
|
||||
@@ -27,16 +27,16 @@ bool Hx8357Display::start() {
|
||||
}
|
||||
|
||||
bool Hx8357Display::stop() {
|
||||
LOGGER.info("stop");
|
||||
LOG_I(TAG, "stop");
|
||||
disp_spi_remove_device();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Hx8357Display::startLvgl() {
|
||||
LOGGER.info("startLvgl");
|
||||
LOG_I(TAG, "startLvgl");
|
||||
|
||||
if (lvglDisplay != nullptr) {
|
||||
LOGGER.warn("LVGL was already started");
|
||||
LOG_W(TAG, "LVGL was already started");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ bool Hx8357Display::startLvgl() {
|
||||
lv_display_set_flush_cb(lvglDisplay, hx8357_flush);
|
||||
|
||||
if (lvglDisplay == nullptr) {
|
||||
LOGGER.info("Failed");
|
||||
LOG_I(TAG, "Failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ bool Hx8357Display::startLvgl() {
|
||||
}
|
||||
|
||||
bool Hx8357Display::stopLvgl() {
|
||||
LOGGER.info("stopLvgl");
|
||||
LOG_I(TAG, "stopLvgl");
|
||||
|
||||
if (lvglDisplay == nullptr) {
|
||||
LOGGER.warn("LVGL was already stopped");
|
||||
LOG_W(TAG, "LVGL was already stopped");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ bool Hx8357Display::stopLvgl() {
|
||||
|
||||
auto touch_device = getTouchDevice();
|
||||
if (touch_device != nullptr && touch_device->getLvglIndev() != nullptr) {
|
||||
LOGGER.info("Stopping touch device");
|
||||
LOG_I(TAG, "Stopping touch device");
|
||||
touch_device->stopLvgl();
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ bool Hx8357Display::stopLvgl() {
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> Hx8357Display::getTouchDevice() {
|
||||
if (touchDevice == nullptr) {
|
||||
touchDevice = std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(createTouch());
|
||||
LOGGER.info("Created touch device");
|
||||
LOG_I(TAG, "Created touch device");
|
||||
}
|
||||
|
||||
return touchDevice;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <tactility/log.h>
|
||||
#include <driver/ledc.h>
|
||||
|
||||
constexpr auto* TAG = "Waveshare";
|
||||
@@ -38,7 +39,7 @@ void initBacklight() {
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
|
||||
LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
|
||||
initBacklight();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#include "Jd9853Display.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <esp_lcd_jd9853.h>
|
||||
#include <esp_lcd_panel_commands.h>
|
||||
#include <esp_lvgl_port.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("JD9853");
|
||||
constexpr auto* TAG = "JD9853";
|
||||
|
||||
bool Jd9853Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||
const esp_lcd_panel_io_spi_config_t panel_io_config = {
|
||||
@@ -54,42 +53,42 @@ bool Jd9853Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_jd9853(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel");
|
||||
LOG_E(TAG, "Failed to create panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to reset panel");
|
||||
LOG_E(TAG, "Failed to reset panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to init panel");
|
||||
LOG_E(TAG, "Failed to init panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
|
||||
LOGGER.error("Failed to swap XY");
|
||||
LOG_E(TAG, "Failed to swap XY");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
|
||||
LOGGER.error("Failed to set panel to mirror");
|
||||
LOG_E(TAG, "Failed to set panel to mirror");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
|
||||
LOGGER.error("Failed to set panel to invert");
|
||||
LOG_E(TAG, "Failed to set panel to invert");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
|
||||
LOGGER.error("Failed to turn display on");
|
||||
LOG_E(TAG, "Failed to turn display on");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_set_gap(panelHandle, 34, 0) != ESP_OK) {
|
||||
LOGGER.error("Failed to set panel gap");
|
||||
LOG_E(TAG, "Failed to set panel gap");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -157,6 +156,6 @@ void Jd9853Display::setGammaCurve(uint8_t index) {
|
||||
};
|
||||
|
||||
if (esp_lcd_panel_io_tx_param(getIoHandle() , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
|
||||
LOGGER.error("Failed to set gamma");
|
||||
LOG_E(TAG, "Failed to set gamma");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user