Skip to content

Feature/character set improvements#147

Open
oligazar wants to merge 3 commits intojoeycastillo:mainfrom
oligazar:feature/character-set-improvements
Open

Feature/character set improvements#147
oligazar wants to merge 3 commits intojoeycastillo:mainfrom
oligazar:feature/character-set-improvements

Conversation

@oligazar
Copy link

@oligazar oligazar commented Nov 14, 2025

Character Set Face Improvements

This PR adds bidirectional navigation and refactors the character set face for improved code quality and
efficiency.

New Features

Bidirectional Navigation

  • Forward navigation (existing):
    • ALARM short press: advance one character
    • ALARM long press: fast scroll forward at 8Hz
  • Backward navigation (new):
    • LIGHT short press: go back one character
    • LIGHT long press: fast scroll backward at 8Hz

Characters wrap around between space (0x20) and DEL (0x7F) in both directions.

Code Quality Improvements

  1. Extract Display Update to Helper Function
  • Eliminated code duplication (4 identical display update blocks → 1 function)
  • Created _character_set_face_update_display() helper function
  • Improves maintainability and reduces code size
  1. Use memset() Instead of sprintf()

Before:
sprintf(buf, "%c%c%c%c%c%c", c, c, c, c, c, c); // 6 repeated arguments

After:
memset(buf, c, 6); // Clean and efficient
buf[6] = '\0';

More efficient and much more readable.

  1. Use WATCH_POSITION_TOP Instead of Separate Calls

Before:
watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, buf, buf);
watch_display_text_with_fallback(WATCH_POSITION_TOP_RIGHT, buf, buf);
watch_display_text_with_fallback(WATCH_POSITION_BOTTOM, buf, buf);

After:
watch_display_text_with_fallback(WATCH_POSITION_TOP, buf, buf);
watch_display_text_with_fallback(WATCH_POSITION_BOTTOM, buf, buf);

WATCH_POSITION_TOP handles the entire top line (2 chars on classic LCD, 5 chars on custom LCD) automatically.

Implementation Details

  • Fast scroll uses 8Hz tick frequency for smooth scrolling
  • Fast scroll automatically stops when button is released
  • State tracking via quick_ticks_running flag
  • Character range: 0x20 (space) to 0x7F (DEL)

Commits

  1. cfe2f1d - feat: add fast scroll to character set face
  2. 52b6109 - refactor: simplify character set face display update
  3. 1a2eaae - refactor: use WATCH_POSITION_TOP instead of separate left/right
  4. 1b5b212 - test: add character_set_face to test refactored code

- Add bidirectional navigation with LIGHT button (backwards)
- Add fast scroll with long press on ALARM (forward) and LIGHT (backward)
- Implement 8Hz tick frequency for smooth fast scrolling
- Add proper state management with character_set_state_t
- Auto-stop fast scroll when button released

Controls:
- ALARM short press: advance one character forward
- ALARM long press: fast scroll forward (8Hz)
- LIGHT short press: go back one character
- LIGHT long press: fast scroll backward (8Hz)
@oligazar oligazar force-pushed the feature/character-set-improvements branch from 3727ee9 to cfe2f1d Compare November 14, 2025 21:39
- Extract repetitive display code into helper function
- Use memset instead of sprintf with 6 repeated arguments
- Eliminate code duplication (4 identical display update blocks)
- Remove unused buf variable from main loop
- Improve code readability and maintainability
WATCH_POSITION_TOP handles the entire top line (2 chars on classic, 5 on custom),
so there's no need to call TOP_LEFT and TOP_RIGHT separately.
@oligazar oligazar marked this pull request as draft November 15, 2025 09:31
@oligazar oligazar marked this pull request as ready for review November 15, 2025 10:02
@oligazar oligazar force-pushed the feature/character-set-improvements branch from 1b5b212 to 1a2eaae Compare November 15, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant