Add low memory warning (#417)

This commit is contained in:
Ken Van Hoeylandt
2025-11-14 15:43:00 +01:00
committed by GitHub
parent dddca1ea76
commit a4f4784ed9
7 changed files with 145 additions and 4 deletions
@@ -0,0 +1,33 @@
#pragma once
#include "Tactility/service/Service.h"
#include <Tactility/Mutex.h>
#include <Tactility/Timer.h>
namespace tt::service::memorychecker {
/**
* Runs a background timer that validates if there's sufficient memory available.
* It shows a statusbar icon when memory is low. It also outputs warning to the log.
*/
class MemoryCheckerService final : public Service {
Mutex mutex = Mutex(Mutex::Type::Recursive);
Timer timer = Timer(Timer::Type::Periodic, [this] { onTimerUpdate(); });
// LVGL Statusbar icon
int8_t statusbarIconId = -1;
// Keep track of state to minimize UI updates
bool memoryLow = false;
void onTimerUpdate();
public:
bool onStart(ServiceContext& service) override;
void onStop(ServiceContext& service) override;
};
}