Skip to content

Added runtime debug levels selectable via LCD menu and serial command#509

Open
Yukti007 wants to merge 3 commits intomainfrom
feature/390-firmware-make-debug-levels-selectable-at-run-time-through-lcd-menu-rev-047
Open

Added runtime debug levels selectable via LCD menu and serial command#509
Yukti007 wants to merge 3 commits intomainfrom
feature/390-firmware-make-debug-levels-selectable-at-run-time-through-lcd-menu-rev-047

Conversation

@Yukti007
Copy link
Copy Markdown
Collaborator

Links

What & Why

  • Replaced two competing compile-time #define DEBUG values (one in GPAD_API.ino set to 1, one in GPAD_HAL.cpp set to 0) with a single global gpad_debug_level variable in a new gpad_debug.h / gpad_debug.cpp module
  • Converted all 17 #if (DEBUG > N) preprocessor guards across GPAD_API.ino, GPAD_HAL.cpp, and WiFiManagerOTA.cpp to runtime if (gpad_debug_level > N) checks so debug output can be toggled without recompiling or reflashing
  • Added a Debug Lvl FIELD (0–3) to the Krake LCD menu so debug level can be changed on the device itself using the rotary encoder
  • Added a d0–d3 serial command so debug level can be changed live from the Serial Monitor without touching the device

Validation / How to Verify

  • Flash firmware, open Serial Monitor, send d1 — device should immediately start printing basic debug info (MAC address, WiFi start, UART setup) without reboot
  • Open Krake Menu via rotary encoder, navigate to Debug Lvl, rotate to 2, press button — verbose output (RSSI, MQTT topics) should appear on Serial Monitor in real time

Artifacts (attach if relevant)

  • Screenshots / PDFs / STLs
  • Logs

Checklist

  • Only related changes : gpad_debug.h , gpad_debug.cpp, GPAD_API.ino, GPAD_HAL.cpp ,GPAD_menu.cpp ,WiFiManagerOTA.cpp
  • Folder structure respected, work directory : Firmware/GPAD_API/GPAD_API
  • Validation steps written

@Yukti007
Copy link
Copy Markdown
Collaborator Author

What was done

Replaced the scattered compile-time #define DEBUG values across the firmware with a single global gpad_debug_level variable. All debug print guards were converted from #if preprocessor checks (which required a recompile) to runtime if checks, so the level can be changed while the device is running.

How to use

Via LCD menu: Open Krake Menu with the rotary encoder → navigate to Debug Lvl → rotate to pick a value → press button to confirm

Via Serial Monitor: Type d0, d1, d2, or d3 and press enter

Debug levels

  • 0 — off, normal production mode
  • 1 — basic: MAC address, WiFi start, UART setup, MQTT payload echo
  • 2 — verbose: RSSI values, MQTT topic verification, HAL setup trace
  • 3 — trace: SPI raw packets, per-message level and content details

Files changed

  • gpad_debug.h / gpad_debug.cpp — new module, single source of truth for the debug level
  • GPAD_API.ino — removed #define DEBUG 1, converted 7 guards to runtime
  • GPAD_HAL.cpp — removed local #define DEBUG 0, converted 8 guards, added d0–d3 serial command
  • GPAD_menu.cpp — added Debug Lvl field to Krake Menu
  • WiFiManagerOTA.cpp — converted 1 orphaned guard to runtime

@Yukti007 Yukti007 requested a review from nk25719 April 29, 2026 21:49
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f291db7158

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1,3 @@
#include "gpad_debug.h"

int gpad_debug_level = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Initialize debug level before boot-time logging

Setting gpad_debug_level to 0 by default disables every debug print in setup() and GPAD_HAL_setup(), but the new mechanisms that change this value (interpretBuffer() serial command and the LCD FIELD) only run after setup has completed. In practice, sending d1 after boot cannot expose startup diagnostics like MAC/Wi-Fi/UART logs, so boot-time debugging regresses compared with the previous default (DEBUG 1 in GPAD_API.ino).

Useful? React with 👍 / 👎.

@nk25719
Copy link
Copy Markdown
Collaborator

nk25719 commented May 3, 2026

GPAD_API v0.054

Image

levels 1, 2 and 3 report the same :


online, RSSI:-62.00|
| online, RSSI:-48.00|
| online, RSSI:-65.00|
Publish RSSI: -48.00

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.

Firmware, Make Debug Levels Selectable at Run Time. Through LCD Menu, Rev 0.47

2 participants