mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-08-19 00:15:05 +00:00
Use TactilityKernel's time and delay functions instead of TactilityFreeRtos ones
This commit is contained in:
parent
4ee2931362
commit
b61a7a3f5f
@ -1,4 +1,5 @@
|
||||
#include <tactility/module.h>
|
||||
#include <tactility/delay.h>
|
||||
#include <tactility/error.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
@ -42,7 +43,7 @@ static error_t start() {
|
||||
}
|
||||
|
||||
// Avoids crash when no SD card is inserted. It's unknown why, but likely is related to power draw.
|
||||
tt::kernel::delayMillis(100);
|
||||
delay_millis(100);
|
||||
|
||||
subscribe_events();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include "unphone_nav_buttons.h"
|
||||
|
||||
#include <tactility/delay.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/driver.h>
|
||||
#include <tactility/drivers/gpio_controller.h>
|
||||
@ -76,9 +77,9 @@ static int32_t nav_buttons_thread_main(UnphoneNavButtonsInternal* internal) {
|
||||
|
||||
// Debounce all events for a short period of time
|
||||
// This is easier than keeping track when each button was last pressed
|
||||
tt::kernel::delayMillis(50);
|
||||
delay_millis(50);
|
||||
xQueueReset(internal->event_queue);
|
||||
tt::kernel::delayMillis(50);
|
||||
delay_millis(50);
|
||||
xQueueReset(internal->event_queue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
#include <Tactility/CoreDefines.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/SystemEvents.h>
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/time.h>
|
||||
|
||||
#include <Tactility/CoreDefines.h>
|
||||
#include <list>
|
||||
|
||||
namespace tt::kernel {
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
#include "Tactility/app/alertdialog/AlertDialog.h"
|
||||
|
||||
#include <lvgl/widgets/toolbar.h>
|
||||
#include "Tactility/service/loader/Loader.h"
|
||||
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <lvgl/widgets/toolbar.h>
|
||||
|
||||
namespace tt::app::alertdialog {
|
||||
|
||||
#define PARAMETER_BUNDLE_KEY_TITLE "title"
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#include "Tactility/lvgl/Lvgl.h"
|
||||
#include "tactility/drivers/backlight.h"
|
||||
#include "tactility/drivers/display.h"
|
||||
#include <tactility/delay.h>
|
||||
#include <tactility/drivers/backlight.h>
|
||||
#include <tactility/drivers/display.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/time.h>
|
||||
|
||||
#include <Tactility/CpuAffinity.h>
|
||||
#include <Tactility/Paths.h>
|
||||
@ -10,13 +12,13 @@
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/hal/usb/Usb.h>
|
||||
#include <Tactility/lvgl/Lvgl.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/settings/BootSettings.h>
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@ -108,23 +110,23 @@ class BootApp : public App {
|
||||
}
|
||||
|
||||
static void waitForMinimalSplashDuration(TickType_t startTime) {
|
||||
const auto end_time = kernel::getTicks();
|
||||
const auto end_time = get_ticks();
|
||||
const auto ticks_passed = end_time - startTime;
|
||||
constexpr auto minimum_ticks = (CONFIG_TT_SPLASH_DURATION / portTICK_PERIOD_MS);
|
||||
if (minimum_ticks > ticks_passed) {
|
||||
kernel::delayTicks(minimum_ticks - ticks_passed);
|
||||
delay_ticks(minimum_ticks - ticks_passed);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t bootThreadCallback() {
|
||||
LOG_I(TAG, "Starting boot thread");
|
||||
const auto start_time = kernel::getTicks();
|
||||
const auto start_time = get_ticks();
|
||||
|
||||
// Give the UI some time to redraw
|
||||
// If we don't do this, various init calls will read files and block SPI IO for the display
|
||||
// This would result in a blank/black screen being shown during this phase of the boot process
|
||||
// This works with 5 ms on a T-Lora Pager, so we give it 10 ms to be safe
|
||||
kernel::delayMillis(10);
|
||||
delay_millis(10);
|
||||
|
||||
// TODO: Support for multiple displays
|
||||
LOG_I(TAG, "Setup display");
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/time.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
@ -211,7 +212,7 @@ public:
|
||||
GpsSettingsApp() {
|
||||
// Runs while the screen is shown - there's no push notification for GPS device state
|
||||
// changes, so this is the only way this screen finds out about them.
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, kernel::secondsToTicks(1), [this] {
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, seconds_to_ticks(1), [this] {
|
||||
updateDeviceStates();
|
||||
});
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/power_supply.h>
|
||||
#include <tactility/time.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <lvgl/icons/shared.h>
|
||||
@ -53,7 +54,7 @@ struct DeviceEntry {
|
||||
|
||||
class PowerApp : public App {
|
||||
|
||||
Timer update_timer = Timer(Timer::Type::Periodic, kernel::millisToTicks(1000),[]() { onTimer(); });
|
||||
Timer update_timer = Timer(Timer::Type::Periodic, millis_to_ticks(1000),[]() { onTimer(); });
|
||||
|
||||
std::vector<DeviceEntry> entries;
|
||||
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
#include <Tactility/TactilityConfig.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include "tactility/time.h"
|
||||
|
||||
|
||||
#include <Tactility/Paths.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/TactilityConfig.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
@ -242,7 +245,7 @@ static std::shared_ptr<SystemInfoApp> optApp() {
|
||||
}
|
||||
|
||||
class SystemInfoApp final : public App {
|
||||
Timer memoryTimer = Timer(Timer::Type::Periodic, kernel::millisToTicks(10000), [] {
|
||||
Timer memoryTimer = Timer(Timer::Type::Periodic, millis_to_ticks(10000), [] {
|
||||
auto app = optApp();
|
||||
if (app) {
|
||||
lvgl_lock();
|
||||
@ -251,7 +254,7 @@ class SystemInfoApp final : public App {
|
||||
}
|
||||
});
|
||||
|
||||
Timer tasksTimer = Timer(Timer::Type::Periodic, kernel::millisToTicks(15000), [] {
|
||||
Timer tasksTimer = Timer(Timer::Type::Periodic, millis_to_ticks(15000), [] {
|
||||
auto app = optApp();
|
||||
if (app) {
|
||||
lvgl_lock();
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/time.h>
|
||||
|
||||
#include <lvgl/fonts.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
@ -182,7 +183,7 @@ lv_obj_t* statusbar_create(lv_obj_t* parent) {
|
||||
obj_set_style_bg_invisible(left_spacer);
|
||||
lv_obj_set_flex_grow(left_spacer, 1);
|
||||
|
||||
statusbar_data.mutex.lock(kernel::MAX_TICKS);
|
||||
statusbar_data.mutex.lock(MAX_TICKS);
|
||||
for (int i = 0; i < STATUSBAR_ICON_LIMIT; ++i) {
|
||||
auto* image = lv_image_create(obj);
|
||||
lv_obj_set_size(image, icon_size, icon_size); // regular padding doesn't work
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/service/displayidle/DisplayIdleService.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
#include "BouncingBallsScreensaver.h"
|
||||
#include "MatrixRainScreensaver.h"
|
||||
@ -8,14 +10,14 @@
|
||||
#include "Screensaver.h"
|
||||
#include "StackChanScreensaver.h"
|
||||
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
#include <tactility/delay.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/drivers/display.h>
|
||||
#include <tactility/drivers/backlight.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
namespace tt::service::displayidle {
|
||||
@ -221,7 +223,7 @@ bool DisplayIdleService::onStart(ServiceContext& service) {
|
||||
|
||||
cachedDisplaySettings = settings::display::loadOrGetDefault();
|
||||
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, kernel::millisToTicks(TICK_INTERVAL_MS), [this]{ this->tick(); });
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, millis_to_ticks(TICK_INTERVAL_MS), [this]{ this->tick(); });
|
||||
timer->setCallbackPriority(Thread::Priority::Lower);
|
||||
timer->start();
|
||||
return true;
|
||||
@ -238,7 +240,7 @@ void DisplayIdleService::onStop(ServiceContext& service) {
|
||||
for (int i = 0; i < maxRetries && screensaverOverlay; ++i) {
|
||||
stopScreensaver();
|
||||
if (screensaverOverlay && i < maxRetries - 1) {
|
||||
kernel::delayMillis(50); // Brief delay before retry
|
||||
delay_millis(50); // Brief delay before retry
|
||||
}
|
||||
}
|
||||
if (screensaverOverlay) {
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include <display/lv_display.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
@ -9,10 +10,10 @@
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/settings/KeyboardSettings.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/backlight.h>
|
||||
#include <tactility/drivers/keyboard.h>
|
||||
#include <tactility/time.h>
|
||||
|
||||
namespace tt::service::keyboardidle {
|
||||
|
||||
@ -92,7 +93,7 @@ public:
|
||||
// Note: Settings changes require service restart to take effect
|
||||
// TODO: Add KeyboardSettingsChanged events for dynamic updates
|
||||
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, kernel::millisToTicks(250), [this]{ this->tick(); });
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, millis_to_ticks(250), [this]{ this->tick(); });
|
||||
timer->setCallbackPriority(Thread::Priority::Lower);
|
||||
timer->start();
|
||||
return true;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/service/screenshot/ScreenshotTask.h>
|
||||
|
||||
#include <tactility/delay.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
@ -71,7 +72,7 @@ void ScreenshotTask::taskMain() {
|
||||
if (work.type == TASK_WORK_TYPE_DELAY) {
|
||||
// Splitting up the delays makes it easier to stop the service
|
||||
for (int i = 0; i < (work.delay_in_seconds * 10) && !isInterrupted(); ++i){
|
||||
kernel::delayMillis(100);
|
||||
delay_millis(100);
|
||||
}
|
||||
|
||||
if (!isInterrupted()) {
|
||||
@ -88,14 +89,14 @@ void ScreenshotTask::taskMain() {
|
||||
if (appContext != nullptr) {
|
||||
const app::AppManifest& manifest = appContext->getManifest();
|
||||
if (manifest.appId != last_app_id) {
|
||||
kernel::delayMillis(100);
|
||||
delay_millis(100);
|
||||
last_app_id = manifest.appId;
|
||||
auto filename = std::format("{}/screenshot-{}.png", work.path, manifest.appId);
|
||||
makeScreenshot(filename);
|
||||
}
|
||||
}
|
||||
// Ensure the LVGL widgets are rendered as the app just started
|
||||
kernel::delayMillis(250);
|
||||
delay_millis(250);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,12 +11,12 @@
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/service/wifi/WifiBootSplashInit.h>
|
||||
#include <Tactility/service/wifi/WifiGlobals.h>
|
||||
#include <Tactility/service/wifi/WifiSettings.h>
|
||||
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/wifi.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/time.h>
|
||||
#include <tactility/wifi_auto_scan.h>
|
||||
|
||||
#include <algorithm>
|
||||
@ -76,7 +76,7 @@ struct WifiServiceState {
|
||||
bool connectionTargetRemember = false;
|
||||
settings::WifiApSettings connectionTarget;
|
||||
uint16_t scanRecordLimit = TT_WIFI_SCAN_RECORD_LIMIT;
|
||||
TickType_t lastScanTime = kernel::MAX_TICKS;
|
||||
TickType_t lastScanTime = MAX_TICKS;
|
||||
std::unique_ptr<Timer> autoConnectTimer;
|
||||
kernel::SystemEventSubscription bootEventSubscription = kernel::NoSystemEventSubscription;
|
||||
};
|
||||
@ -165,7 +165,7 @@ void dispatchScan() {
|
||||
LOG_I(TAG, "dispatchScan()");
|
||||
if (!started || state.device == nullptr || !device_is_ready(state.device)) return;
|
||||
|
||||
state.lastScanTime = kernel::getTicks();
|
||||
state.lastScanTime = get_ticks();
|
||||
|
||||
error_t result = wifi_scan(state.device);
|
||||
if (result != ERROR_NONE) {
|
||||
@ -263,7 +263,7 @@ bool shouldScanForAutoConnect() {
|
||||
!state.pauseAutoConnect && !state.externalScanPause.load();
|
||||
if (!radio_scannable) return false;
|
||||
|
||||
TickType_t current_time = kernel::getTicks();
|
||||
TickType_t current_time = get_ticks();
|
||||
bool scan_time_has_looped = current_time < state.lastScanTime;
|
||||
bool no_recent_scan = (current_time - state.lastScanTime) > (AUTO_SCAN_INTERVAL / portTICK_PERIOD_MS);
|
||||
return scan_time_has_looped || no_recent_scan;
|
||||
|
||||
@ -31,6 +31,8 @@ static_assert(configTICK_RATE_HZ == 1000);
|
||||
static_assert(configTICK_RATE_HZ == 1000, "configTICK_RATE_HZ must be 1000");
|
||||
#endif
|
||||
|
||||
#define MAX_TICKS ~((TickType_t)0)
|
||||
|
||||
static inline uint32_t get_tick_frequency() {
|
||||
return configTICK_RATE_HZ;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user