New logging and more (#446)
- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>` - Changed default timezone to Europe/Amsterdam - Fix for logic bug in unPhone hardware - Fix for init/deinit in DRV2605 driver - Other fixes - Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
committed by
GitHub
parent
719f7bcece
commit
f620255c41
@@ -1,20 +1,21 @@
|
||||
#include "PwmBacklight.h"
|
||||
#include "Tactility/kernel/SystemEvents.h"
|
||||
#include "Tactility/service/gps/GpsService.h"
|
||||
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <Tactility/hal/gps/GpsConfiguration.h>
|
||||
#include <Tactility/settings/KeyboardSettings.h>
|
||||
|
||||
#include "devices/KeyboardBacklight.h"
|
||||
#include "devices/TrackballDevice.h"
|
||||
#include <KeyboardBacklight/KeyboardBacklight.h>
|
||||
|
||||
#include <Tactility/hal/gps/GpsConfiguration.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
#include <Tactility/settings/KeyboardSettings.h>
|
||||
#include <Trackball/Trackball.h>
|
||||
|
||||
#define TAG "tdeck"
|
||||
#include <KeyboardBacklight/KeyboardBacklight.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("T-Deck");
|
||||
|
||||
// Power on
|
||||
#define TDECK_POWERON_GPIO GPIO_NUM_10
|
||||
constexpr auto TDECK_POWERON_GPIO = GPIO_NUM_10;
|
||||
|
||||
static bool powerOn() {
|
||||
gpio_config_t device_power_signal_config = {
|
||||
@@ -37,9 +38,9 @@ static bool powerOn() {
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
|
||||
LOGGER.info(LOG_MESSAGE_POWER_ON_START);
|
||||
if (!powerOn()) {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
|
||||
LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,7 +48,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)) {
|
||||
TT_LOG_E(TAG, "Backlight init failed");
|
||||
LOGGER.error("Backlight init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,9 +59,9 @@ bool initBoot() {
|
||||
gps_service->getGpsConfigurations(gps_configurations);
|
||||
if (gps_configurations.empty()) {
|
||||
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "Grove", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) {
|
||||
TT_LOG_I(TAG, "Configured internal GPS");
|
||||
LOGGER.info("Configured internal GPS");
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to configure internal GPS");
|
||||
LOGGER.error("Failed to configure internal GPS");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,23 +70,23 @@ bool initBoot() {
|
||||
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) {
|
||||
auto kbBacklight = tt::hal::findDevice("Keyboard Backlight");
|
||||
if (kbBacklight != nullptr) {
|
||||
TT_LOG_I(TAG, "%s starting", kbBacklight->getName().c_str());
|
||||
LOGGER.info("{} starting", kbBacklight->getName());
|
||||
auto kbDevice = std::static_pointer_cast<KeyboardBacklightDevice>(kbBacklight);
|
||||
if (kbDevice->start()) {
|
||||
TT_LOG_I(TAG, "%s started", kbBacklight->getName().c_str());
|
||||
LOGGER.info("{} started", kbBacklight->getName());
|
||||
} else {
|
||||
TT_LOG_E(TAG, "%s start failed", kbBacklight->getName().c_str());
|
||||
LOGGER.error("{} start failed", kbBacklight->getName());
|
||||
}
|
||||
}
|
||||
|
||||
auto trackball = tt::hal::findDevice("Trackball");
|
||||
if (trackball != nullptr) {
|
||||
TT_LOG_I(TAG, "%s starting", trackball->getName().c_str());
|
||||
LOGGER.info("{} starting", trackball->getName());
|
||||
auto tbDevice = std::static_pointer_cast<TrackballDevice>(trackball);
|
||||
if (tbDevice->start()) {
|
||||
TT_LOG_I(TAG, "%s started", trackball->getName().c_str());
|
||||
LOGGER.info("{} started", trackball->getName());
|
||||
} else {
|
||||
TT_LOG_E(TAG, "%s start failed", trackball->getName().c_str());
|
||||
LOGGER.error("{} start failed", trackball->getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ bool initBoot() {
|
||||
auto kbSettings = tt::settings::keyboard::loadOrGetDefault();
|
||||
bool result = keyboardbacklight::setBrightness(kbSettings.backlightEnabled ? kbSettings.backlightBrightness : 0);
|
||||
if (!result) {
|
||||
TT_LOG_W(TAG, "Failed to set keyboard backlight brightness");
|
||||
LOGGER.warn("Failed to set keyboard backlight brightness");
|
||||
}
|
||||
|
||||
trackball::setEnabled(kbSettings.trackballEnabled);
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "KeyboardBacklight.h"
|
||||
#include <esp_log.h>
|
||||
#include <cstring>
|
||||
|
||||
static const char* TAG = "KeyboardBacklight";
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <esp_log.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("KeyboardBacklight");
|
||||
|
||||
namespace keyboardbacklight {
|
||||
|
||||
@@ -18,16 +21,16 @@ bool init(i2c_port_t i2cPort, uint8_t slaveAddress) {
|
||||
g_i2cPort = i2cPort;
|
||||
g_slaveAddress = slaveAddress;
|
||||
|
||||
ESP_LOGI(TAG, "Keyboard backlight initialized on I2C port %d, address 0x%02X", g_i2cPort, g_slaveAddress);
|
||||
LOGGER.info("Initialized on I2C port {}, address 0x{:02X}", static_cast<int>(g_i2cPort), g_slaveAddress);
|
||||
|
||||
// Set a reasonable default brightness
|
||||
if (!setDefaultBrightness(127)) {
|
||||
ESP_LOGE(TAG, "Failed to set default brightness");
|
||||
LOGGER.error("Failed to set default brightness");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!setBrightness(127)) {
|
||||
ESP_LOGE(TAG, "Failed to set brightness");
|
||||
LOGGER.error("Failed to set brightness");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,7 +39,7 @@ bool init(i2c_port_t i2cPort, uint8_t slaveAddress) {
|
||||
|
||||
bool setBrightness(uint8_t brightness) {
|
||||
if (g_i2cPort >= I2C_NUM_MAX) {
|
||||
ESP_LOGE(TAG, "Keyboard backlight not initialized");
|
||||
LOGGER.error("Not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -45,7 +48,7 @@ bool setBrightness(uint8_t brightness) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Setting brightness to %d on I2C port %d, address 0x%02X", brightness, g_i2cPort, g_slaveAddress);
|
||||
LOGGER.info("Setting brightness to {} on I2C port {}, address 0x{:02X}", brightness, static_cast<int>(g_i2cPort), g_slaveAddress);
|
||||
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
@@ -59,17 +62,17 @@ bool setBrightness(uint8_t brightness) {
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
g_currentBrightness = brightness;
|
||||
ESP_LOGI(TAG, "Successfully set brightness to %d", brightness);
|
||||
LOGGER.info("Successfully set brightness to {}", brightness);
|
||||
return true;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to set brightness: %s (0x%x)", esp_err_to_name(ret), ret);
|
||||
LOGGER.error("Failed to set brightness: {} (0x{:02X})", esp_err_to_name(ret), ret);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool setDefaultBrightness(uint8_t brightness) {
|
||||
if (g_i2cPort >= I2C_NUM_MAX) {
|
||||
ESP_LOGE(TAG, "Keyboard backlight not initialized");
|
||||
LOGGER.error("Not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -89,17 +92,17 @@ bool setDefaultBrightness(uint8_t brightness) {
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
ESP_LOGD(TAG, "Set default brightness to %d", brightness);
|
||||
LOGGER.debug("Set default brightness to {}", brightness);
|
||||
return true;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to set default brightness: %s", esp_err_to_name(ret));
|
||||
LOGGER.error("Failed to set default brightness: {}", esp_err_to_name(ret));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t getBrightness() {
|
||||
if (g_i2cPort >= I2C_NUM_MAX) {
|
||||
ESP_LOGE(TAG, "Keyboard backlight not initialized");
|
||||
LOGGER.error("Not initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "Trackball.h"
|
||||
#include <esp_log.h>
|
||||
|
||||
static const char* TAG = "Trackball";
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Trackball");
|
||||
|
||||
namespace trackball {
|
||||
|
||||
@@ -72,7 +73,7 @@ static void read_cb(lv_indev_t* indev, lv_indev_data_t* data) {
|
||||
|
||||
lv_indev_t* init(const TrackballConfig& config) {
|
||||
if (g_initialized) {
|
||||
ESP_LOGW(TAG, "Trackball already initialized");
|
||||
LOGGER.warn("Already initialized");
|
||||
return g_indev;
|
||||
}
|
||||
|
||||
@@ -109,16 +110,19 @@ 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);
|
||||
|
||||
if (g_indev) {
|
||||
if (g_indev != nullptr) {
|
||||
g_initialized = true;
|
||||
ESP_LOGI(TAG, "Trackball initialized as encoder (R:%d U:%d L:%d D:%d Click:%d)",
|
||||
config.pinRight, config.pinUp, config.pinLeft, config.pinDown,
|
||||
config.pinClick);
|
||||
return g_indev;
|
||||
LOGGER.info("Initialized as encoder (R:{} U:{} L:{} D:{} Click:{})",
|
||||
static_cast<int>(config.pinRight),
|
||||
static_cast<int>(config.pinUp),
|
||||
static_cast<int>(config.pinLeft),
|
||||
static_cast<int>(config.pinDown),
|
||||
static_cast<int>(config.pinClick));
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to register LVGL input device");
|
||||
return nullptr;
|
||||
LOGGER.error("Failed to register LVGL input device");
|
||||
}
|
||||
|
||||
return g_indev;
|
||||
}
|
||||
|
||||
void deinit() {
|
||||
@@ -127,19 +131,19 @@ void deinit() {
|
||||
g_indev = nullptr;
|
||||
}
|
||||
g_initialized = false;
|
||||
ESP_LOGI(TAG, "Trackball deinitialized");
|
||||
LOGGER.info("Deinitialized");
|
||||
}
|
||||
|
||||
void setMovementStep(uint8_t step) {
|
||||
if (step > 0) {
|
||||
g_config.movementStep = step;
|
||||
ESP_LOGD(TAG, "Movement step set to %d", step);
|
||||
LOGGER.debug("Movement step set to {}", step);
|
||||
}
|
||||
}
|
||||
|
||||
void setEnabled(bool enabled) {
|
||||
g_enabled = enabled;
|
||||
ESP_LOGI(TAG, "Trackball %s", enabled ? "enabled" : "disabled");
|
||||
LOGGER.info("{}", enabled ? "Enabled" : "Disabled");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <Tactility/hal/Device.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <KeyboardBacklight/KeyboardBacklight.h>
|
||||
|
||||
using tt::hal::findFirstDevice;
|
||||
|
||||
constexpr auto* TAG = "TdeckKeyboard";
|
||||
static const auto LOGGER = tt::Logger("TdeckKeyboard");
|
||||
|
||||
constexpr auto TDECK_KEYBOARD_I2C_BUS_HANDLE = I2C_NUM_0;
|
||||
constexpr auto TDECK_KEYBOARD_SLAVE_ADDRESS = 0x55;
|
||||
|
||||
@@ -37,11 +39,15 @@ static void keyboard_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t*
|
||||
|
||||
if (keyboard_i2c_read(&read_buffer)) {
|
||||
if (read_buffer == 0 && read_buffer != last_buffer) {
|
||||
TT_LOG_D(TAG, "Released %d", last_buffer);
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Released {}", last_buffer);
|
||||
}
|
||||
data->key = last_buffer;
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
} else if (read_buffer != 0) {
|
||||
TT_LOG_D(TAG, "Pressed %d", read_buffer);
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Pressed {}", read_buffer);
|
||||
}
|
||||
data->key = read_buffer;
|
||||
data->state = LV_INDEV_STATE_PRESSED;
|
||||
// TODO: Avoid performance hit by calling loadOrGetDefault() on each key press
|
||||
|
||||
Reference in New Issue
Block a user