Skip to content

fix(t-deck): restore CALIBRATE_TOUCH so the touch panel is calibrated - #11349

Open
merocle wants to merge 1 commit into
meshtastic:masterfrom
merocle:fix/t-deck-restore-touch-calibration
Open

fix(t-deck): restore CALIBRATE_TOUCH so the touch panel is calibrated#11349
merocle wants to merge 1 commit into
meshtastic:masterfrom
merocle:fix/t-deck-restore-touch-calibration

Conversation

@merocle

@merocle merocle commented Aug 3, 2026

Copy link
Copy Markdown

Problem

The T-Deck touch panel is uncalibrated on the MUI build (t-deck-tft): a touch registers off by the 320/240 ratio — stretched by about 1.33 on X, compressed by about 0.8 on Y — accurate only near the bottom-left corner and worse with distance from it.

Cause

device-ui ships calibration parameters for this board and applies them in include/graphics/driver/LGFXDriver.h:

uint16_t parameters[8] = {0, 2, 0, 314, 223, 5, 224, 314};   // T_DECK
...
lgfx->setTouchCalibrate(parameters);

The whole block is behind #ifdef CALIBRATE_TOUCH. That flag was active for t-deck-tft until 8ae05f6 ("MUI: defcon tft display size definitions", #7142, 2025-06-26) commented it out while adding LGFX_SCREEN_WIDTH / LGFX_SCREEN_HEIGHT:

-  -D CALIBRATE_TOUCH=0
+;  -D CALIBRATE_TOUCH=0
+  -D LGFX_SCREEN_WIDTH=240
+  -D LGFX_SCREEN_HEIGHT=320

Neither that PR's description nor its discussion mentions touch, so this looks unintended. With the flag gone no calibration is applied at all and the panel runs on raw LovyanGFX values.

Fix

Uncomment the line. CALIBRATE_TOUCH=0 applies the stored parameters; =1 would run interactive calibration, which does not persist yet — there is a FIXME in device-ui about reading it back from storage.

Testing

Built t-deck-tft at v2.7.26.54e0d8d with this change and flashed app0 on a T-Deck Plus (868 MHz). Touch is accurate across the whole screen afterwards; before the change it missed as described above. LoRa, keyboard and trackball unaffected.

Not addressed here

t-deck is the only variant that sets CALIBRATE_TOUCH, so the calibration block in device-ui is currently dead code for every board, even though it also carries parameters for WT32_SC01, T_HMI, ESP32_2432S022, ESP32_2432S028RV1, UNPHONE, NODEMCU_32S and SENSECAP_INDICATOR. I do not have those boards, so this PR touches one line rather than all of them.

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other

I have a T-Deck Plus and a Heltec V4 only. The change is scoped to the t-deck variant's build flags, so other boards cannot be affected.

The T-Deck touch panel has been uncalibrated on the MUI build since meshtastic#7142.

device-ui carries calibration parameters for this board and applies them in
LGFXDriver.h, but the whole block is behind `#ifdef CALIBRATE_TOUCH`. That flag
was active for t-deck-tft until 8ae05f6 ("MUI: defcon tft display size
definitions", meshtastic#7142) commented it out while adding LGFX_SCREEN_WIDTH and
LGFX_SCREEN_HEIGHT. Neither that PR's description nor its discussion mentions
touch, so the change looks unintended.

Without the flag no calibration is applied at all and the panel runs on raw
LovyanGFX values: a touch lands off by the 320/240 ratio, stretched by about
1.33 on X and compressed by about 0.8 on Y, accurate only near the bottom-left
corner and worse with distance from it. Restoring the line makes touch accurate
across the screen.

CALIBRATE_TOUCH=0 applies the stored parameters; 1 would run interactive
calibration, which does not persist yet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@merocle, Welcome to Meshtastic!

Thanks for opening your first pull request. We really appreciate it.

We discuss work as a team in discord, please join us in the #firmware channel.
There's a big backlog of patches at the moment. If you have time,
please help us with some code review and testing of other PRs!

Welcome to the team 😄

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ae7a299-5850-49bc-b95c-b55fea308b00

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@NomDeTom

NomDeTom commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Please retarget this change to develop

@vidplace7
vidplace7 requested a review from mverch67 August 3, 2026 23:35
@caveman99
caveman99 changed the base branch from master to develop August 4, 2026 09:40
@caveman99
caveman99 changed the base branch from develop to master August 4, 2026 09:41

@mverch67 mverch67 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Display calibration may be individual for each display, that's why there's a calibration function in Settings->Screen Calibration. Though I agree that some default values may be better than nothing, especially if the lovyanGFX default is so far off that the settings button cannot be reached.
Upon startup these default values are overwritten with the stored values (from the last screen calibration) in NodeDB.

@caveman99 caveman99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please rebase this onto develop

@vidplace7

Copy link
Copy Markdown
Member

Display calibration may be individual for each display, that's why there's a calibration function in Settings->Screen Calibration. Though I agree that some default values may be better than nothing, especially if the lovyanGFX default is so far off that the settings button cannot be reached. Upon startup these default values are overwritten with the stored values (from the last screen calibration) in NodeDB.

@mverch67 Alternatively. Can we prompt for screen calibration upon firstboot? (If a previous calibration is not already stored).

@mverch67

mverch67 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

@mverch67 Alternatively. Can we prompt for screen calibration upon firstboot? (If a previous calibration is not already stored).

that's also possible, yes. But there's already another prompt in place to set username / region. So we'd had two prompts (and for sure could think about having even more prompts), lol.

@caveman99

Copy link
Copy Markdown
Member

@merocle last request to rebase this one liner onto develop, or i will do it myself and close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants