Public Access
Fn+h on any screen, text fields included, and ? outside Text Entry, open a panel over the content area: the screen's own keys, then the ones that work everywhere. Every App declares its keys for the state it is in (pages, viewers, dialogs and text fields answer for themselves); the App manager opens the panel and takes every key while it is open. About 30 hint lines are gone, from every App. What stays on a screen is state. The first-start Setup keeps its hints and teaches the key; a device set up before gets one Toast, once. The guide and the FAQ open with it. `key help` over the consoles. 476 host tests (8 new). Checked on the device with key help and screenshots: the Launcher, all nine Apps and several of their states. 8.5 KB of flash and 40 bytes of static RAM. Decisions Q196 to Q203 in docs/milestones/U1.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
70 lines
2.4 KiB
C++
70 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "app.h"
|
|
#include "key_value_store.h"
|
|
#include "services/battery_service.h"
|
|
#include "services/gnss_service.h"
|
|
#include "services/radio_service.h"
|
|
#include "services/storage_service.h"
|
|
#include "services/wifi_service.h"
|
|
#include "task_stats.h"
|
|
#include "traffic.h"
|
|
|
|
namespace roro {
|
|
|
|
// The System App (docs/milestones/S1.md, Q117 to Q127): what the device is doing, live and
|
|
// read-only. Tab moves between Overview, Tasks, Memory, Network and System. It samples once a
|
|
// second and keeps two minutes of history, only while it's open (Q120).
|
|
class SystemApp : public App {
|
|
public:
|
|
SystemApp(WifiService& wifi, BatteryService& battery, StorageService& storage, RadioService& radio, GnssService& gnss,
|
|
KeyValueStore& store)
|
|
: wifi_(wifi), battery_(battery), storage_(storage), radio_(radio), gnss_(gnss), store_(store) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
bool onKey(const KeyEvent& e) override;
|
|
void update(uint32_t nowMs) override;
|
|
void draw(Canvas& c) override;
|
|
void help(std::vector<KeyHelp>& out) const override;
|
|
const char* helpTitle() const override;
|
|
|
|
private:
|
|
enum class View : uint8_t { Overview, Tasks, Memory, Network, System, Count };
|
|
static constexpr size_t kHistory = 120; // seconds
|
|
static constexpr int kTaskRows = 7;
|
|
|
|
void sample(uint32_t nowMs);
|
|
void drawOverview(Canvas& c);
|
|
void drawTasks(Canvas& c);
|
|
void drawMemory(Canvas& c);
|
|
void drawNetwork(Canvas& c);
|
|
void drawSystem(Canvas& c);
|
|
void footer(Canvas& c, const char* keys);
|
|
|
|
WifiService& wifi_;
|
|
BatteryService& battery_;
|
|
StorageService& storage_;
|
|
RadioService& radio_;
|
|
GnssService& gnss_;
|
|
KeyValueStore& store_;
|
|
View view_ = View::Overview;
|
|
uint32_t sampledMs_ = 0;
|
|
std::vector<TaskSample> before_;
|
|
uint32_t beforeTotal_ = 0;
|
|
std::vector<TaskRow> rows_; // the last second, sorted
|
|
TaskSort sort_ = TaskSort::Share;
|
|
int taskTop_ = 0;
|
|
int load_[2] = {-1, -1};
|
|
History<uint8_t, kHistory> loadHistory_[2];
|
|
History<uint16_t, kHistory> heapHistory_; // free heap, KB
|
|
net::Traffic traffic_[static_cast<size_t>(net::User::Count)];
|
|
uint32_t rateIn_[static_cast<size_t>(net::User::Count)] = {}, rateOut_[static_cast<size_t>(net::User::Count)] = {};
|
|
std::vector<std::string> systemLines_;
|
|
int systemTop_ = 0, wrappedLines_ = 0;
|
|
};
|
|
|
|
} // namespace roro
|