Skip to content

Xpt2046 correct alignment - #44

Open
johnlr wants to merge 3 commits into
rdagger:masterfrom
johnlr:xpt2046-correct-alignment
Open

Xpt2046 correct alignment#44
johnlr wants to merge 3 commits into
rdagger:masterfrom
johnlr:xpt2046-correct-alignment

Conversation

@johnlr

@johnlr johnlr commented Aug 3, 2026

Copy link
Copy Markdown

The bitshifts for the xpt2046 are off. The values from the touch were very noisy because they have been accidentally including the busy bit in their value. You should find you need much less averaging to get a useful result.

Regards,
John

johnlr added 3 commits July 11, 2023 16:38
    The first bit of the result bytes is not used.
    So, for a 12 bit result, the high 7 bits come from rx_buf[1]
    and 5 low bits come from rx_buf[0].
The fixed bitshift means we should double the defaults for x_max and x_min
@rdagger

rdagger commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Sorry for the slow response. The original code intentionally scales the XPT2046’s 12-bit ADC output down to 11 bits by discarding the least-significant bit, reducing the raw range from roughly 0–4095 to 0–2047. For a 240×320 resistive touchscreen, that still provides far more coordinate resolution than the display can use, while also filtering out the noisiest, least-significant ADC bit and reducing small fluctuations in touch readings.

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.

2 participants