From c903c5c432055d5737b934b5df1a73ec5b7470dd Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Fri, 24 Jul 2026 12:18:27 +0200 Subject: [PATCH] Fixes --- Drivers/gps-module/source/ublox.cpp | 1 + Tactility/Source/Tactility.cpp | 2 +- .../Source/service/keyboardidle/KeyboardIdle.cpp | 12 +++++++++++- TactilityKernel/include/tactility/device.h | 4 ++-- TactilityKernel/include/tactility/drivers/keyboard.h | 2 ++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Drivers/gps-module/source/ublox.cpp b/Drivers/gps-module/source/ublox.cpp index 1870fef06..afca86c77 100644 --- a/Drivers/gps-module/source/ublox.cpp +++ b/Drivers/gps-module/source/ublox.cpp @@ -10,6 +10,7 @@ #include #include +#include namespace gps_ublox { diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 50f3bd356..9f592305c 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -406,7 +406,7 @@ void run(Module* dtsModules[], DtsDevice dtsDevices[]) { }); check(module_construct(&lvgl_module) == ERROR_NONE); check(module_add(&lvgl_module) == ERROR_NONE); - module_start(&lvgl_module); + check(module_start(&lvgl_module) == ERROR_NONE); registerAndStartSecondaryServices(); diff --git a/Tactility/Source/service/keyboardidle/KeyboardIdle.cpp b/Tactility/Source/service/keyboardidle/KeyboardIdle.cpp index d8f6c3ba1..3ab69161c 100644 --- a/Tactility/Source/service/keyboardidle/KeyboardIdle.cpp +++ b/Tactility/Source/service/keyboardidle/KeyboardIdle.cpp @@ -22,6 +22,7 @@ class KeyboardIdleService final : public Service { bool keyboardDimmed = false; settings::keyboard::KeyboardSettings cachedKeyboardSettings; + // TODO: This only works for the fist active keyboard. Update it so it works for all keyboards with a backlight. static Device* getKeyboardBacklight() { ::Device* keyboard; if (device_get_first_active_by_type(&KEYBOARD_TYPE, &keyboard) == ERROR_NONE) { @@ -31,13 +32,19 @@ class KeyboardIdleService final : public Service { return backlight; // WARNING: did not increase refcount } // TODO: Remove after all drivers are migrated - return device_find_by_name("keyboard_backlight"); + ::Device* backlight; + if (device_get_by_name("keyboard_backlight", &backlight) != ERROR_NONE) { + return nullptr; + } + + return backlight; } void setKeyboardBacklightBrightness(uint8_t brightness) { Device* backlight = getKeyboardBacklight(); if (backlight != nullptr) { backlight_set_brightness(backlight, brightness); + device_put(backlight); } } @@ -50,6 +57,9 @@ class KeyboardIdleService final : public Service { if (lvgl_try_lock(100)) { inactive_ms = lv_display_get_inactive_time(nullptr); lvgl_unlock(); + } else { + // Assume it's not used + inactive_ms = 100; } // Handle keyboard backlight diff --git a/TactilityKernel/include/tactility/device.h b/TactilityKernel/include/tactility/device.h index c01d48615..bc05dfa72 100644 --- a/TactilityKernel/include/tactility/device.h +++ b/TactilityKernel/include/tactility/device.h @@ -388,7 +388,7 @@ error_t device_get_first_by_type(const struct DeviceType* type, struct Device** * @param[in] type non-null device type pointer * @param[out] out_device receives the found device on success; untouched on failure * @retval ERROR_NOT_FOUND if no started device of that type exists - * @retval ERROR_NONE on success; caller must call device_put(*out_device) exactly once + * @retval ERROR_NONE if a started device of that type exists; must call device_put() exactly once afterwards. */ error_t device_get_first_active_by_type(const struct DeviceType* type, struct Device** out_device); @@ -397,7 +397,7 @@ error_t device_get_first_active_by_type(const struct DeviceType* type, struct De * * @param[in] type non-null device type pointer * @retval ERROR_NOT_FOUND if no started device of that type exists - * @retval ERROR_NONE on success; caller must call device_put(*out_device) exactly once + * @retval ERROR_NONE if a started device of that type exists */ bool device_has_active_by_type(const struct DeviceType* type); diff --git a/TactilityKernel/include/tactility/drivers/keyboard.h b/TactilityKernel/include/tactility/drivers/keyboard.h index 42e4999f9..d902d362e 100644 --- a/TactilityKernel/include/tactility/drivers/keyboard.h +++ b/TactilityKernel/include/tactility/drivers/keyboard.h @@ -40,6 +40,7 @@ struct KeyboardApi { /** * @brief Returns the baclight if the keyboard has one. + * @warning Returns a referenced device. Must call device_put() afterwards. * @param[in] device the keyboard device * @param[out] backlight_device the output backlight device * @retval ERROR_NONE when the backlight_device was set @@ -55,6 +56,7 @@ error_t keyboard_read_key(struct Device* device, struct KeyboardKeyData* data); /** * @brief Returns the backlight if the keyboard has one. + * @warning Returns a referenced device. Must call device_put() afterwards. * @param[in] device the keyboard device * @param[out] backlight_device the output backlight device * @retval ERROR_NONE when the backlight_device was set