mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-01 17:56:12 +00:00
Adds Tools › Breadcrumb. Enter on the screen toggles tracking; while active, UITask::loop samples GPS at the cadence chosen in settings (default 1 min) and drops the point into a 256-entry RAM ring guarded by a min-distance gate (default 25 m). A "G" indicator joins "A" in the status bar with the same blink convention. New storage: - examples/companion_radio/Breadcrumb.h — BreadcrumbStore class - 256 × 12 B = 3 KB RAM (survives auto-off, lost on reboot — explicit flash-slot save comes in phase 4) - Haversine min-delta gate, total distance, elapsed seconds, current km/h, bounding-box helper New screen: - examples/companion_radio/ui-new/BreadcrumbScreen.h — Summary view with Status, Points, Dist (m or km), Time (h:mm), Speed; Enter toggles tracking, Esc returns to Tools Schema bump 0xC0DE0002 → 0xC0DE0003 for two new NodePrefs bytes: breadcrumb_interval_idx (1min default) and breadcrumb_min_delta_idx (25m default). Older saves leave both at zero, which matches the new defaults. DataStore::loadPrefsInt/savePrefs read/write the pair. Logging on/off is a runtime flag inside BreadcrumbStore — not a preference — so reboot returns to the off state cleanly; the user will be able to persist a snapshot to a slot in phase 4. Phase 2 (map view), 3 (point list), 4 (slot save/load, GPX export over USB), and 5 (settings UI) follow incrementally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
#pragma once
|
|
// Custom screen — not part of upstream UITask.cpp
|
|
// Included by UITask.cpp just before HomeScreen.
|
|
|
|
class ToolsScreen : public UIScreen {
|
|
UITask* _task;
|
|
int _sel;
|
|
|
|
static const int ITEM_COUNT = 5;
|
|
static const char* ITEMS[ITEM_COUNT];
|
|
|
|
public:
|
|
ToolsScreen(UITask* task) : _task(task), _sel(0) {}
|
|
|
|
int render(DisplayDriver& display) override {
|
|
display.setTextSize(1);
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
display.drawTextCentered(display.width() / 2, 0, "TOOLS");
|
|
display.fillRect(0, display.headerH() - 1, display.width(), display.sepH());
|
|
|
|
int item_h = display.lineStep();
|
|
int start_y = display.listStart();
|
|
int cw = display.getCharWidth();
|
|
|
|
for (int i = 0; i < ITEM_COUNT; i++) {
|
|
int y = start_y + i * item_h;
|
|
bool sel = (i == _sel);
|
|
display.drawSelectionRow(0, y - 1, display.width(), item_h, sel);
|
|
display.setCursor(0, y);
|
|
display.print(sel ? ">" : " ");
|
|
display.setCursor(cw + 2, y);
|
|
display.print(ITEMS[i]);
|
|
}
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
return 500;
|
|
}
|
|
|
|
bool handleInput(char c) override {
|
|
if (c == KEY_UP && _sel > 0) { _sel--; return true; }
|
|
if (c == KEY_DOWN && _sel < ITEM_COUNT - 1) { _sel++; return true; }
|
|
if (c == KEY_CANCEL || c == KEY_CONTEXT_MENU) { _task->gotoHomeScreen(); return true; }
|
|
if (c == KEY_ENTER) {
|
|
if (_sel == 0) { _task->gotoRingtoneEditor(); return true; }
|
|
if (_sel == 1) { _task->gotoBotScreen(); return true; }
|
|
if (_sel == 2) { _task->gotoNearbyScreen(); return true; }
|
|
if (_sel == 3) { _task->gotoAutoAdvertScreen(); return true; }
|
|
if (_sel == 4) { _task->gotoBreadcrumbScreen(); return true; }
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
const char* ToolsScreen::ITEMS[5] = { "Ringtone Editor", "Auto-Reply Bot", "Nearby Nodes", "Auto-Advert", "Breadcrumb" };
|