refactor(ui): centralise EINK_DISPLAY_MODEL toggles in Features.h

Five sites in UITask.cpp + MyMesh.cpp branched on EINK_DISPLAY_MODEL
purely for runtime-shape decisions (blink rate, default pref values,
refresh intervals). Replace with a constexpr Features namespace:
IS_EINK, BLINK_INDICATORS, CLOCK_HIDE_SECONDS_DEFAULT, HOME_REFRESH_MS,
LOCKSCREEN_REFRESH_MS. Compiler dead-branch-eliminates so cost is
identical to the preprocessor branch, but the code stays reachable to
tooling and the policy lives in one file.

SettingsScreen and driver headers still need real #ifdef — they
condition enum members and class field layouts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-24 20:41:25 +02:00
co-authored by Claude Sonnet 4.6
parent e16ecbd690
commit 7c81ea0f52
3 changed files with 36 additions and 23 deletions
+26
View File
@@ -0,0 +1,26 @@
#pragma once
// Build-time feature flags derived from board defines.
// Use these instead of `#ifdef EINK_DISPLAY_MODEL` for runtime-shape decisions
// (booleans, timings, defaults). Compiler dead-branch-eliminates on the
// constexpr, so cost is identical to a preprocessor branch but the code
// remains readable and reachable to tooling. Conditional struct members
// (enum entries, NodePrefs fields) still need a real `#if defined(...)`.
namespace Features {
#if defined(EINK_DISPLAY_MODEL)
static constexpr bool IS_EINK = true;
static constexpr bool BLINK_INDICATORS = false; // e-ink avoids high-rate redraws
static constexpr bool CLOCK_HIDE_SECONDS_DEFAULT = true; // pref starting value
static constexpr unsigned HOME_REFRESH_MS = 30000; // slow display polls less
static constexpr unsigned LOCKSCREEN_REFRESH_MS = 30000;
#else
static constexpr bool IS_EINK = false;
static constexpr bool BLINK_INDICATORS = true;
static constexpr bool CLOCK_HIDE_SECONDS_DEFAULT = false;
static constexpr unsigned HOME_REFRESH_MS = 1000;
static constexpr unsigned LOCKSCREEN_REFRESH_MS = 1000;
#endif
} // namespace Features