Improve Indicator transport touch UI

This commit is contained in:
mikecarper committed 2026-08-31 15:11:11 -07:00
1 parent 5af7b73ff9
commit 2e026caf4a
10 files changed
+212 -38

No files matched your search

+1 -1
View File
@@ -53,7 +53,7 @@ does not reflect the GoogleTest count -- run the built binary directly
| `test_mqtt_prefs_atomic_store` | `src/helpers/MQTTPrefsAtomicStore.h` | transactional MQTT writes and legacy `/node_prefs` handoff; exact short-write detection; begin/finish/rename failure cleanup; original-file preservation |
| `test_mqtt_prefs_json_import` | `src/helpers/MQTTPrefsJsonImport.h`, `src/helpers/MQTTPrefsSerializer.h` | one-time observer `/mqtt.json` v1 import grammar, strict schema/repair rules, binary-first precedence, future/artifact preservation, display-tail encoding, and atomic commit failure routing |
| `test_display_viewport` | `src/helpers/ui/DisplayViewport.h`, `src/helpers/ui/DisplayFrameSignature.h` | portrait logical-to-physical mapping, span coverage, fitted-width conversion, text scaling, and visible-frame signatures |
| `test_display_driver` | `src/helpers/ui/DisplayDriver.h`, `DisplayTextLayout.h`, `CompanionHomeLayout.h` | UTF-8-safe ellipsis/wrapping; maximum SSID and long setup-address bounds; Indicator home info/pairing separation and 4/5-height PIN placement; compact 128x64 pairing replacement; stale-region clearing |
| `test_display_driver` | `src/helpers/ui/DisplayDriver.h`, `DisplayTextLayout.h`, `CompanionHomeLayout.h` | UTF-8-safe ellipsis/wrapping; maximum SSID and long setup-address bounds; Indicator 320/native-480 home info/pairing separation and enlarged-text placement; compact 128x64 pairing replacement; stale-region clearing |
| `test_indicator_font_stage_v2_protocol` | `src/helpers/IndicatorFontStageV2Protocol.h` | fail-closed STAGEV2 negotiation and legacy fallback; exact cumulative ACK parsing; 512-byte block boundaries, short final blocks, and real font-asset transfer geometry |
| `test_radio_activity_window` | `src/helpers/RadioActivityWindow.h` | rolling minute buckets, derived rates, expiry, warm-up, silence, saturation, and `millis()` rollover |
| `test_observer_dashboard` | `src/helpers/ui/ObserverDashboard.h` | landscape and portrait dashboard layout bounds, compact formatting, graph scaling, row signatures, and partial repaint policy |
+47 -12
View File
@@ -20,8 +20,8 @@ int main() {
if (!layout.show_title) return 1;
if (layout.wifi.x != 2 || layout.wifi.width != 76) return 2;
if (layout.bluetooth.x != 82 || layout.bluetooth.width != 76) return 3;
if (layout.wifi.y != 40 || layout.wifi.height != 72) return 4;
if (layout.title_y != 17 || layout.prompt_y != 138) return 5;
if (layout.wifi.y != 36 || layout.wifi.height != 98) return 4;
if (layout.title_y != 17 || layout.prompt_y != 140) return 5;
const auto small = mesh::ui::makeCompanionTransportSelectorLayout(128, 64);
if (small.show_title) return 6;
@@ -56,15 +56,21 @@ int main() {
)
self.assertEqual(run_result.returncode, 0, run_result.stderr)
logical_glyph_width = 6 * 2
logical_glyph_height = 8 * 2
for text in ("Wi-Fi", "BLE", "ACTIVE", "NEXT"):
self.assertLessEqual(len(text) * logical_glyph_width, 76)
choice_glyph_width = 6 * 3
choice_glyph_height = 8 * 3
for text in ("WiFi", "BLE"):
self.assertLessEqual(len(text) * choice_glyph_width, 76)
status_glyph_width = 6 * 2
status_glyph_height = 8 * 2
for text in ("ACTIVE", "NEXT"):
self.assertLessEqual(len(text) * status_glyph_width, 76)
title_glyph_width = 6 * 2
for text in ("TRANSPORT", "tap a box"):
self.assertLessEqual(len(text) * logical_glyph_width, 160)
self.assertLessEqual(17 + logical_glyph_height, 40)
self.assertLessEqual(89 + logical_glyph_height, 112)
self.assertLessEqual(138 + logical_glyph_height, 160)
self.assertLessEqual(len(text) * title_glyph_width, 160)
self.assertLessEqual(17 + 8 * 2, 36)
self.assertLessEqual(53 + choice_glyph_height, 134)
self.assertLessEqual(109 + status_glyph_height, 134)
self.assertLessEqual(140 + 8, 160)
def test_touch_split_selector_distinguishes_taps_from_swipes(self):
source = r'''
@@ -113,6 +119,35 @@ int main() {
input.update(true, 130, 68, 160, 160, false, &selector);
if (release(input, &selector) != TouchAction::Next) return 6;
// A quick selector tap may occupy only one 25 ms poll. Its bounded target
// remains unambiguous after the normal two-sample release debounce.
input.update(true, 30, 120, 160, 160, false, &selector);
if (release(input, &selector) != TouchAction::SelectLeft) return 7;
input.update(true, 130, 120, 160, 160, false, &selector);
if (release(input, &selector) != TouchAction::SelectRight) return 8;
// The gap, title, and exclusive bottom edge remain inert even for a quick
// contact, while the last pixel inside the taller box is selectable.
input.update(true, 80, 120, 160, 160, false, &selector);
if (release(input, &selector) != TouchAction::None) return 9;
input.update(true, 30, layout.wifi.y - 1, 160, 160, false, &selector);
if (release(input, &selector) != TouchAction::None) return 10;
input.update(true, 30, layout.wifi.y + layout.wifi.height,
160, 160, false, &selector);
if (release(input, &selector) != TouchAction::None) return 11;
input.update(true, 30, layout.wifi.y + layout.wifi.height - 1,
160, 160, false, &selector);
if (release(input, &selector) != TouchAction::SelectLeft) return 12;
// Ordinary pages keep the two-sample protection against a detached swipe
// endpoint being interpreted as a tap.
input.update(true, 30, 70, 160, 160, false, nullptr);
if (release(input, nullptr) != TouchAction::None) return 13;
return 0;
}
'''
@@ -144,11 +179,11 @@ int main() {
source = UI.read_text(encoding="utf-8")
self.assertIn("#ifdef COMPANION_EXCLUSIVE_WIFI_BLE", source)
self.assertIn("TRANSPORT,", source)
self.assertIn('"Wi-Fi", wifi_active, wifi_selected', source)
self.assertIn('"WiFi", wifi_active, wifi_selected', source)
self.assertIn('"BLE", !wifi_active, !wifi_selected', source)
self.assertIn("display.fillRect(x, y, width, height);", source)
self.assertIn('"ACTIVE"', source)
self.assertIn('large_transport_text ? 2 : 1', source)
self.assertIn('large_transport_text ? 3 : 1', source)
self.assertIn("const bool show_status_label = height >= 44;", source)
self.assertIn('active ? "ACTIVE"', source)
self.assertIn('large_transport_text ? "NEXT" : "NEXT BOOT"', source)
@@ -181,6 +181,36 @@ TEST(DisplayDriver, IndicatorHomeSeparatesInfoAndPairingGeometry) {
layout.pairing, layout.pairing_value_y, 24));
}
TEST(DisplayDriver, NativeIndicatorExpandsHomeTypographyRegions) {
EXPECT_TRUE(mesh::ui::usesExpandedCompanionHomeTypography(
160, 160, 480, 480));
EXPECT_FALSE(mesh::ui::usesExpandedCompanionHomeTypography(
160, 160, 320, 320));
EXPECT_FALSE(mesh::ui::usesExpandedCompanionHomeTypography(
128, 64, 480, 480));
const mesh::ui::CompanionHomeLayout layout =
mesh::ui::makeLargeCompanionHomeLayout(160, 160, true);
EXPECT_EQ(2, layout.info.x);
EXPECT_EQ(51, layout.info.y);
EXPECT_EQ(156, layout.info.width);
EXPECT_EQ(46, layout.info.height);
EXPECT_EQ(8, layout.pairing.x);
EXPECT_EQ(100, layout.pairing.y);
EXPECT_EQ(144, layout.pairing.width);
EXPECT_EQ(58, layout.pairing.height);
EXPECT_FALSE(mesh::ui::displayRegionsOverlap(layout.info,
layout.pairing));
EXPECT_TRUE(mesh::ui::displayRegionContainsLine(
layout.info, layout.instruction_y, 20));
EXPECT_TRUE(mesh::ui::displayRegionContainsLine(
layout.info, layout.network_y, 20));
EXPECT_TRUE(mesh::ui::displayRegionContainsLine(
layout.pairing, layout.pairing_label_y, 20));
EXPECT_TRUE(mesh::ui::displayRegionContainsLine(
layout.pairing, layout.pairing_value_y, 30));
}
TEST(DisplayDriver, IndicatorPairingValuesFitAtRenderedTextSizes) {
// Model the fallback font's fixed six-logical-pixel cell. It is the wider
// of the two paths for CONNECTED; the profile test reads the recovered
+27 -2
View File
@@ -103,8 +103,13 @@ class IndicatorDisplayProfileTest(unittest.TestCase):
requested_size * coordinate_scale / native_scale
* profile_scale
)
width = sum(advances[ord(char)] for char in text)
height = max(heights[ord(char)] for char in text)
# Blank glyphs carry no bitmap record in the packed VLW. The
# checked-in font is monospaced with the documented 18px cell, so
# spaces still advance by one complete cell.
width = sum(
18 if char == " " else advances[ord(char)] for char in text
)
height = max(heights[ord(char)] for char in text if char != " ")
return (
int((width * render_scale + coordinate_scale - 1)
// coordinate_scale),
@@ -129,6 +134,26 @@ class IndicatorDisplayProfileTest(unittest.TestCase):
self.assertLessEqual(width, 144)
self.assertLessEqual(height, 30)
# Native 480 reflows the spacious home page instead of globally
# enlarging every dense UI row. Its prominent strings fit at their
# requested sizes, while a two-digit inbox count takes the deliberate
# size-2 fallback.
native_title = dimensions("INBOX 0", 3, 3, 1.2)
native_two_digit_title = dimensions("INBOX 10", 3, 3, 1.2)
native_two_digit_fallback = dimensions("INBOX 10", 2, 3, 1.2)
self.assertLessEqual(native_title[0], 156)
self.assertGreater(native_two_digit_title[0], 156)
self.assertLessEqual(native_two_digit_fallback[0], 156)
for text, region_width in (
("tap inbox", 156),
("WiFi: OFF", 156),
("BLE PIN", 144),
):
width, height = dimensions(text, 2, 3, 1.2)
self.assertLessEqual(width, region_width)
self.assertLessEqual(height, 20)
if __name__ == "__main__":
unittest.main()
@@ -153,6 +153,32 @@ TEST(TouchInput, SplitSelectorMapsTapHalvesToExplicitChoices) {
TouchAction::None);
}
TEST(TouchInput, SplitSelectorAcceptsQuickBoundedTapsOnly) {
TouchInput input(true, true, 70);
const TouchSplitSelector selector{2, 76, 82, 76, 36, 98};
input.update(true, 30, 100, 160, 160, false, &selector);
EXPECT_EQ(input.update(false, -1, -1, 160, 160, false, &selector),
TouchAction::None);
EXPECT_EQ(input.update(false, -1, -1, 160, 160, false, &selector),
TouchAction::SelectLeft);
input.update(true, 130, 100, 160, 160, false, &selector);
EXPECT_EQ(input.update(false, -1, -1, 160, 160, false, &selector),
TouchAction::None);
EXPECT_EQ(input.update(false, -1, -1, 160, 160, false, &selector),
TouchAction::SelectRight);
input.update(true, 80, 100, 160, 160, false, &selector);
EXPECT_EQ(input.update(false, -1, -1, 160, 160, false, &selector),
TouchAction::None);
EXPECT_EQ(input.update(false, -1, -1, 160, 160, false, &selector),
TouchAction::None);
input.update(true, 30, 100, 160, 160);
EXPECT_EQ(release(input, 160, 160), TouchAction::None);
}
TEST(TouchInput, SplitSelectorKeepsSwipesAsNavigation) {
TouchInput input(true, true, 70);
const TouchSplitSelector selector{8, 68, 84, 68, 38, 72};