New kernel drivers and more (#560)
- Added kernel base drivers for: display, pointer (touch, mouse, etc.), keyboard, adc, power supply and backlight - Implement new kernel driver modules: `st7789-module` and `gt911-module` - Implement ESP32 ADC "oneshot" kernel driver - Implement ESP32 backlight kernel driver with ledc API - Implemented `battery-sense` driver that allows for voltage measurement and creates a power supply child device - Updated github actions - Updated flash scripts - Fix for esp32 legacy driver conflict with ADC - Created separate `lilygo-tdeck` and `lilygo-tdeck-plus` devices - Created `lilygo-module` with LilyGO kernel drivers - Fix for intermittent errors in build related to code generation of `devicetree.c` - `lvgl-module` can now map kernel drivers onto LVGL devices - Created `KernelDisplayApp` as a mirror of `HalDisplayApp` (formerly `DisplayApp`) - Removed `struct` and `enum` prefix in a lot of kernel driver cpp source files - `lilygo-tdeck` and `lilygo-tdeck-plus` are now fully relying on kernel drivers and don't use any of the old HAL
This commit is contained in:
committed by
GitHub
parent
c4406b24ba
commit
50c0a14a93
@@ -9,9 +9,8 @@
|
||||
#include <Tactility/settings/KeyboardSettings.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
namespace keyboardbacklight {
|
||||
bool setBrightness(uint8_t brightness);
|
||||
}
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/backlight.h>
|
||||
|
||||
namespace tt::service::keyboardidle {
|
||||
|
||||
@@ -25,6 +24,17 @@ class KeyboardIdleService final : public Service {
|
||||
return hal::findFirstDevice<hal::keyboard::KeyboardDevice>(hal::Device::Type::Keyboard);
|
||||
}
|
||||
|
||||
static Device* getKeyboardBacklight() {
|
||||
return device_find_by_name("keyboard_backlight");
|
||||
}
|
||||
|
||||
void setKeyboardBacklightBrightness(uint8_t brightness) {
|
||||
Device* backlight = getKeyboardBacklight();
|
||||
if (backlight != nullptr) {
|
||||
backlight_set_brightness(backlight, brightness);
|
||||
}
|
||||
}
|
||||
|
||||
void tick() {
|
||||
// Settings are now cached and event-driven (no file I/O in timer callback!)
|
||||
// This prevents watchdog timeout from blocking the Timer Service task
|
||||
@@ -42,15 +52,15 @@ class KeyboardIdleService final : public Service {
|
||||
// If timeout disabled, ensure backlight restored if we had dimmed it
|
||||
if (!cachedKeyboardSettings.backlightTimeoutEnabled || cachedKeyboardSettings.backlightTimeoutMs == 0) {
|
||||
if (keyboardDimmed) {
|
||||
keyboardbacklight::setBrightness(cachedKeyboardSettings.backlightEnabled ? cachedKeyboardSettings.backlightBrightness : 0);
|
||||
setKeyboardBacklightBrightness(cachedKeyboardSettings.backlightEnabled ? cachedKeyboardSettings.backlightBrightness : 0);
|
||||
keyboardDimmed = false;
|
||||
}
|
||||
} else {
|
||||
if (!keyboardDimmed && inactive_ms >= cachedKeyboardSettings.backlightTimeoutMs) {
|
||||
keyboardbacklight::setBrightness(0);
|
||||
setKeyboardBacklightBrightness(0);
|
||||
keyboardDimmed = true;
|
||||
} else if (keyboardDimmed && inactive_ms < 100) {
|
||||
keyboardbacklight::setBrightness(cachedKeyboardSettings.backlightEnabled ? cachedKeyboardSettings.backlightBrightness : 0);
|
||||
setKeyboardBacklightBrightness(cachedKeyboardSettings.backlightEnabled ? cachedKeyboardSettings.backlightBrightness : 0);
|
||||
keyboardDimmed = false;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +72,8 @@ public:
|
||||
// Load settings once at startup and cache them
|
||||
// This eliminates file I/O from timer callback (prevents watchdog timeout)
|
||||
cachedKeyboardSettings = settings::keyboard::loadOrGetDefault();
|
||||
|
||||
setKeyboardBacklightBrightness(cachedKeyboardSettings.backlightEnabled ? cachedKeyboardSettings.backlightBrightness : 0);
|
||||
|
||||
// Note: Settings changes require service restart to take effect
|
||||
// TODO: Add KeyboardSettingsChanged events for dynamic updates
|
||||
|
||||
@@ -80,7 +91,7 @@ public:
|
||||
// Ensure keyboard restored on stop
|
||||
auto keyboard = getKeyboard();
|
||||
if (keyboard && keyboardDimmed) {
|
||||
keyboardbacklight::setBrightness(cachedKeyboardSettings.backlightEnabled ? cachedKeyboardSettings.backlightBrightness : 0);
|
||||
setKeyboardBacklightBrightness(cachedKeyboardSettings.backlightEnabled ? cachedKeyboardSettings.backlightBrightness : 0);
|
||||
keyboardDimmed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
#include <tactility/drivers/power_supply.h>
|
||||
#include <tactility/filesystem/file_system.h>
|
||||
#include <Tactility/lvgl/Lvgl.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
@@ -90,10 +90,10 @@ static const char* getSdCardStatusIcon(bool mounted) {
|
||||
|
||||
static const char* getPowerStatusIcon() {
|
||||
// TODO: Support multiple power devices?
|
||||
std::shared_ptr<hal::power::PowerDevice> power;
|
||||
hal::findDevices<hal::power::PowerDevice>(hal::Device::Type::Power, [&power](const auto& device) {
|
||||
if (device->supportsMetric(hal::power::PowerDevice::MetricType::ChargeLevel)) {
|
||||
power = device;
|
||||
Device* power = nullptr;
|
||||
device_for_each_of_type(&POWER_SUPPLY_TYPE, &power, [](Device* device, void* context) {
|
||||
if (device_is_ready(device) && power_supply_supports_property(device, POWER_SUPPLY_PROP_CAPACITY)) {
|
||||
*static_cast<Device**>(context) = device;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -103,12 +103,12 @@ static const char* getPowerStatusIcon() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
hal::power::PowerDevice::MetricData charge_level;
|
||||
if (!power->getMetric(hal::power::PowerDevice::MetricType::ChargeLevel, charge_level)) {
|
||||
PowerSupplyPropertyValue charge_level;
|
||||
if (power_supply_get_property(power, POWER_SUPPLY_PROP_CAPACITY, &charge_level) != ERROR_NONE) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t charge = charge_level.valueAsUint8;
|
||||
int charge = charge_level.int_value;
|
||||
|
||||
if (charge >= 95) {
|
||||
return LVGL_ICON_STATUSBAR_BATTERY_ANDROID_FRAME_FULL;
|
||||
|
||||
Reference in New Issue
Block a user