Skip to content

fix(button): stop phantom NORVI operation-mode switches - #181

Merged
stritti merged 6 commits into
mainfrom
fix/mode-source-logging
Aug 16, 2026
Merged

stritti merged 6 commits into
mainfrom
fix/mode-source-logging

Conversation

@stritti

@stritti stritti commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Problem

The NORVI AE01-R front panel repeatedly switched the operation mode without any button being pressed. Log analysis showed [MODE_CHANGED] ... source=button:S3/menu events firing spontaneously.

Root cause

The front-panel buttons are read via a resistor ladder on ADC GPIO32 that pulls the signal UP toward VCC on press. Live measurements (via /api/logs debug capture):

State ADC level
No press (resting) ~2610–2990 (oscillates)
Button 1 ~3275–3456
Button 2 ~3579–3765
Button 3 ~4095 (full scale)

The old thresholds (B3_MIN=2700, NO_PRESS=3800) sat inside the resting oscillation, so the resting level itself crossed the Button-3 boundary and each S3 press/release pair (open menu + confirm, menu defaults to MODE) cycled the operation mode.

Changes

  • fix(logging) — trace operation mode command sources (b41fc17), enabling diagnosis
  • 8 × debounce fixes (0fee59b…74ea4c3) — fast-attack filter, stability windows, release debouncing, long-press evaluation
  • Threshold calibration — B1 3100–3520, B2 3520–3880, B3 3880–4095, no-press 4096 (no-op, S3 reads full scale); midpoints between measured levels
  • Configurable thresholds (new) — the 7 ADC thresholds are now stored in NVS via ConfigManager (defaults = calibrated values) and editable in the web UI Pool settings tab, so future ADC drift (resting level rose ~2445 → ~2700 over weeks) can be corrected without a firmware reflash

Verification

  • pio run -e norvi_ae01_r SUCCESS (Flash 97.1%)
  • ✅ Native tests: 109 suites / 202 assertions / 0 failures
  • ✅ OTA deployed to the live device; boot verified, no mode changes since
  • ✅ New settings exposed via /api/config (btn1_minbtn_no_press)

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ ACTION actionlint 8 0 0 0.54s
✅ BASH bash-exec 1 0 0 0.43s
✅ BASH shellcheck 1 0 0 0.43s
✅ BASH shfmt 1 0 0 0.01s
✅ C clang-format 1 0 0 0.04s
✅ C cppcheck 1 0 0 0.02s
✅ C cpplint 1 0 0 0.21s
✅ CPP clang-format 79 0 0 0.38s
✅ CPP cppcheck 79 0 0 4.15s
✅ CPP cpplint 79 0 0 5.0s
✅ EDITORCONFIG editorconfig-checker 256 0 0 0.48s
✅ JSON jsonlint 6 0 0 0.11s
✅ JSON v8r 6 0 0 3.27s
⚠️ MARKDOWN markdownlint 101 2 0 2.77s
✅ YAML yamllint 25 0 0 0.63s

Detailed Issues

⚠️ MARKDOWN / markdownlint - 2 errors
.opencode/skills/web-ui/SKILL.md:34 error MD028/no-blanks-blockquote Blank line inside blockquote
docs/superpowers/plans/2026-08-10-olimex-c6-local-ui-implementation.md:106:401 error MD013/line-length Line length [Expected: 400; Actual: 452]

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: MAKEFILE, MAKEFILE_CHECKMAKE, MARKDOWN_MARKDOWN_LINK_CHECK. See Removed linters to find their replacements.

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.0.0 --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,BASH_EXEC,BASH_SHELLCHECK,BASH_SHFMT,C_CPPCHECK,C_CPPLINT,C_CLANG_FORMAT,CPP_CPPCHECK,CPP_CPPLINT,CPP_CLANG_FORMAT,EDITORCONFIG_EDITORCONFIG_CHECKER,JSON_JSONLINT,JSON_V8R,MARKDOWN_MARKDOWNLINT,YAML_YAMLLINT

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

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

Copy link
Copy Markdown

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: 5dbdfabc7d

ℹ️ 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".

Comment thread src/WebPortal.cpp
Comment thread data/web/app.js
Measured ADC levels on the NORVI AE01-R: no press ~2610-2990 (oscillates),
S1 ~3275-3456, S2 ~3579-3765, S3 ~4095 (full scale). The old 2700/3800
boundaries sat inside the resting oscillation, so phantom S3 presses
repeatedly switched the operation mode.

- Calibrate thresholds to measured levels (B1 3100-3520, B2 3520-3880,
  B3 3880-4095, no-press 4096 as no-op since S3 reads full scale)
- Make thresholds configurable via NVS (ConfigManager) with the calibrated
  values as defaults, editable in the web UI Pool settings tab
The settings handler updated ConfigManager but NorviButtonHandler only
copied the thresholds in begin(), so changes required a reboot. Add
NorviButtonHandler::applySettings() and call it after saving settings.

Addresses PR #181 review comment.
Empty or out-of-range threshold fields were stored as 0 by toInt(),
reintroducing phantom presses. Validate presence, 0-4095 range, and
coherent non-overlapping min/max ranges before saving.

Addresses PR #181 review comment.
The native test build defines NORVI_AE01_R but did not compile
NorviButtonHandler.cpp, so the new applySettings() call failed to link.
Add it to SERVICE_SOURCES and extend the mock Settings struct with the
button threshold fields. Align ConfigManager field comments per
clang-format (MegaLinter).
@stritti
stritti force-pushed the fix/mode-source-logging branch from 5dbdfab to b45aebe Compare August 16, 2026 19:28
@github-actions

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 34.3%
Branch Coverage 72.8%
Lines Hit/Total 298/870
Branches Hit/Total 123/169

Report from native unit tests (ASan + gcov).

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

Copy link
Copy Markdown

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: b45aebe1a6

ℹ️ 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".

Comment thread data/web/index.html Outdated
@stritti
stritti force-pushed the fix/mode-source-logging branch from ff9b93a to 3a137e0 Compare August 16, 2026 19:47
@github-actions

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 34.3%
Branch Coverage 72.8%
Lines Hit/Total 298/870
Branches Hit/Total 123/169

Report from native unit tests (ASan + gcov).

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

Copy link
Copy Markdown

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: ff9b93ad9c

ℹ️ 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".

Comment thread data/web/app.js
@github-actions

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 34.3%
Branch Coverage 72.8%
Lines Hit/Total 298/870
Branches Hit/Total 123/169

Report from native unit tests (ASan + gcov).

@stritti
stritti merged commit cdf4083 into main Aug 16, 2026
15 checks passed
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