Skip to content

Firmware, LCD UI makeup.#542

Open
nk25719 wants to merge 7 commits intoPubInv:mainfrom
nk25719:main
Open

Firmware, LCD UI makeup.#542
nk25719 wants to merge 7 commits intoPubInv:mainfrom
nk25719:main

Conversation

@nk25719
Copy link
Copy Markdown
Collaborator

@nk25719 nk25719 commented May 9, 2026

Summary

The LCD system was redesigned to:

  • create a cleaner and more modern 20x4 UI
  • improve encoder navigation
  • separate alarm display from settings/status
  • make the UI responsive and non-blocking
  • integrate WiFi/MQTT status visually
  • reduce stale/unnecessary LCD redraws
  • improve maintainability

New LCD Architecture

Added UI State System

Introduced dedicated UI states instead of mixed menu logic:

UI_MAIN_PAGE
UI_ICON_FOCUS
UI_SETTINGS_MENU
UI_ALARM_ACTION_SELECT
UI_ACTION_FEEDBACK
UI_INFO
UI_WIFI
UI_BROKER
UI_VOLUME
UI_MUTE
UI_COM_SETUP
UI_RESET_CONFIRM

This removed:

  • stuck navigation
  • mixed encoder behavior
  • menu lockups
  • stale screens

Main Screen Redesign

New Main Layout

Row 0

Alarm queue + compact right-side status icons

Example:

Q:+ NEXT        W B M ⚙

Where:

  • W = WiFi
  • B = Broker/MQTT
  • M = Mute
  • ⚙ = Settings

Icons are aligned to the far right.


Row 1

Primary alarm title/type

Example:

CRIT Pump Failure

Row 2

Alarm details / ID

Example:

ID:123 Temp High

Row 3

Normally empty.

Only used dynamically for:

  • alarm actions
  • feedback messages

Examples:

Ack Dismiss Shelve

or

Alarm dismissed

This removed the old stale MAC row problem.


Alarm Interaction Improvements

Encoder Alarm Actions

When alarm is active:

  • rotating encoder opens action selection

  • user can select:

    • Acknowledge
    • Dismiss
    • Shelve

Pressing encoder:

  • executes selected action
  • publishes MQTT/GPAP response
  • shows confirmation feedback

Example:

Alarm acknowledged

Encoder Navigation Refactor

Fixed Rotation Direction

Corrected encoder sense:

  • Clockwise = DOWN/NEXT
  • Counter-clockwise = UP/PREVIOUS

Fixed Menu Selection Bug

Resolved issues where:

  • menu editing stopped working
  • encoder presses were ignored
  • navigation became stuck

Main causes fixed:

  • incorrect event routing
  • running_menu remaining true
  • UI mode not resetting
  • ArduinoMenu consuming all encoder events

Always-Accessible Icon Navigation

Main page encoder behavior now:

  • always allows icon selection

  • never blocks on the dashboard

  • supports navigating between:

    • WiFi
    • Broker
    • Mute
    • Settings

Fallback routing was added to prevent dead states.


Settings Refactor

Added Full Settings Navigation

Settings now include:

  1. Info
  2. WiFi
  3. Broker
  4. Volume
  5. Mute Duration
  6. COM Setup
  7. Reset Device
  8. Back

Added Back Navigation Everywhere

Every submenu now includes:

  • Back
  • safe return handling
  • automatic return to main dashboard

Info Screen

Moved device info out of the main dashboard.

Now accessible through:

Settings → Info

Displays:

  • IP address
  • MAC address
  • SSID
  • MQTT status

This removed:

  • stale MAC row rendering
  • cluttered alarm pages

WiFi Refactor

LCD WiFi Behavior Changed

WiFi is no longer configured directly from the LCD.

Instead:

  • LCD displays:

    • SSID
    • IP
    • AP portal info
  • user is guided to configure WiFi through Web UI

Example:

WiFi Setup
Open Web UI
192.168.4.1
Back

Broker Refactor

Added Broker Selection Screen

Broker menu now lists:

  • Krake PubInv
  • Public Shiftr
  • Local Broker
  • Back

Selecting a broker:

  • updates MQTT configuration
  • reconnects automatically
  • saves preference

Added Persistent MQTT Connection Logic

Goal:
Krake should never remain disconnected unnecessarily.

Added:

  • non-blocking reconnect loop
  • retry timer
  • optional broker failover
  • automatic reconnect handling

LCD Rendering Improvements

Dirty-Flag Rendering

Added:

lcdNeedsRefresh

LCD now:

  • updates only when needed
  • refreshes max every 150–250 ms
  • avoids repeated lcd.clear()

This improved:

  • responsiveness
  • MQTT timing
  • encoder responsiveness
  • reduced flicker

Performance Improvements

Reduced Blocking Behavior

Removed heavy operations from:

  • MQTT callbacks
  • encoder callbacks
  • frequent loop paths

Queued or deferred:

  • LCD updates
  • DFPlayer actions
  • feedback rendering

String / Memory Improvements

Reduced runtime String usage:

  • replaced with char[]
  • snprintf
  • fixed buffers

This reduced:

  • heap fragmentation
  • MQTT latency risk
  • instability over long uptime

Cleanup and Debugging Improvements

Added:

  • debug macros
  • feature flags
  • structured event routing

Prepared codebase for:

  • removing stale code
  • removing duplicated menu paths
  • removing duplicate UART/DFPlayer handling
  • future modularization

Overall Result

The LCD/UI system evolved from:

  • a mostly static/debug-oriented LCD
  • mixed menu/navigation logic
  • stale rows
  • blocking behavior

into:

  • a responsive dashboard UI
  • dynamic alarm interaction system
  • icon-based navigation
  • structured settings system
  • non-blocking event-driven LCD architecture
  • cleaner MQTT/WiFi integration
  • more maintainable firmware structure

@nk25719
Copy link
Copy Markdown
Collaborator Author

nk25719 commented May 9, 2026

to review:

git fetch origin pull/542/head:pr-542
git checkout pr-542

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