Skip to content

Conversation

Workshopshed
Copy link

@Workshopshed Workshopshed commented Aug 1, 2025

Description

A driver for interacting with the XPT2046 resistive touch screen.

Motivation and Context

The SPI protocol used by this driver is quite complex and typical developers just want the X and Y values of the touch.
Created by referring to the datasheet and drivers in other languages.
Based the API on other touch controllers already in the repo such as the CHSC6540 and Ft6xx6x

How Has This Been Tested?

Ran this on an ESP32 based board which has a touch screen built in. Ensured that different touches produced outputs that were proportional to the position.

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

Summary by CodeRabbit

  • Chores
    • Added device category information for XPT2046.
    • Introduced versioning and release configuration for XPT2046.

DESKTOP-I0P6LF2\owner and others added 5 commits June 13, 2025 09:38
Readme and versioning

Example code copied from FT6xx6x driver
Driver work in progress
@nfbot
Copy link
Member

nfbot commented Aug 1, 2025

@Workshopshed I've fixed the checklist for you.
FYI, the correct format is [x], no spaces inside brackets, no other chars.

@nfbot nfbot added the Type: enhancement New feature or request label Aug 1, 2025
Copy link

coderabbitai bot commented Aug 1, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • README.md is excluded by !**/*.md and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

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

Walkthrough

Two new files were added under the devices/XPT2046 directory. The category.txt file lists the device categories as "proximity" and "touch". The version.json file introduces versioning and release configuration using the NerdBank.GitVersioning schema, specifying version details and branch rules for releases.

Changes

Cohort / File(s) Change Summary
Device Category Metadata
devices/XPT2046/category.txt
Added a text file listing the device categories as "proximity" and "touch".
Versioning Configuration
devices/XPT2046/version.json
Added a JSON file with versioning and release configuration for the device using NerdBank.GitVersioning.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Workshopshed
Copy link
Author

@dotnet-policy-service agree

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39a0daf and cca77ce.

⛔ Files ignored due to path filters (13)
  • README.md is excluded by !**/*.md and included by none
  • devices/XPT2046/Point.cs is excluded by none and included by none
  • devices/XPT2046/Properties/AssemblyInfo.cs is excluded by none and included by none
  • devices/XPT2046/README.md is excluded by !**/*.md and included by none
  • devices/XPT2046/TouchDemo/Program.cs is excluded by none and included by none
  • devices/XPT2046/TouchDemo/TouchDemo.nfproj is excluded by none and included by none
  • devices/XPT2046/TouchDemo/TouchDemo.sln is excluded by none and included by none
  • devices/XPT2046/TouchDemo/packages.config is excluded by none and included by none
  • devices/XPT2046/XPT2046.cs is excluded by none and included by none
  • devices/XPT2046/XPT2046.nfproj is excluded by none and included by none
  • devices/XPT2046/XPT2046.nuspec is excluded by none and included by none
  • devices/XPT2046/XPT2046.sln is excluded by none and included by none
  • devices/XPT2046/packages.config is excluded by none and included by none
📒 Files selected for processing (2)
  • devices/XPT2046/category.txt (1 hunks)
  • devices/XPT2046/version.json (1 hunks)
🔇 Additional comments (1)
devices/XPT2046/category.txt (1)

1-3: Re-evaluate the “proximity” classification

The XPT2046 is strictly a resistive-touch controller; it does not provide proximity-sensing capabilities. Keeping an incorrect category may confuse consumers of the metadata and mis-categorise NuGet search results.

-proximity
 touch
+touch

Please confirm with the repo’s category taxonomy and drop the inaccurate entry (or justify its presence).

Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

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

just a quick review to start as once those adjusted, it will be faster for the rest. Thank you!

DESKTOP-I0P6LF2\owner and others added 3 commits August 2, 2025 12:29
Added StyleCop to the project and followed recommendations.
Changed PowerMode constants to binary to be consistent with other constants.
Bumped version to 1
@josesimoes
Copy link
Member

All the packaging and publishing is handled by the pipeline. This has to be signed before distribution. Plus only authorized accounts can publish nugets for the nanoFramework org.

@Ellerbach
Copy link
Member

azp /run

@josesimoes
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Workshopshed
Copy link
Author

One warning from the build, guessing it doesn't apply to this specific build?

The windows-latest label will migrate from Windows Server 2022 to Windows Server 2025 beginning September 2, 2025. For more information see actions/runner-images#12677

@Workshopshed
Copy link
Author

Just checking if anything is outstanding for me to fix?

@Ellerbach
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Workshopshed
Copy link
Author

Many thanks for the feedback, will get those sorted

@josesimoes josesimoes changed the title XPT2046 Driver and Example [XPT2046] Add new binding and sample Sep 1, 2025
Move sample into samples folder
Moved namespace
Added assembly info for sample
Move sample to top level code for simplicity
Added package lock files
@Ellerbach
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

/// <summary>
/// A touch point.
/// </summary>
public struct Point
Copy link
Member

Choose a reason for hiding this comment

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

sorry for seen this but we do have the nanoFramework.Graphics.Core nuget which implements the points: https://github.com/nanoframework/nanoFramework.Graphics/blob/main/nanoFramework.Graphics.Core/System/Drawing/Point.cs

Please use that one instead of your own struct. That will allow to use it properly with the screens and have more flexibility. So, it's about adding this nuget, removing this file and adding the import in your code. It should just work transparently! As a bonus, you get all the point operations and more!

Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

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

couple of more comments

@Workshopshed
Copy link
Author

Workshopshed commented Sep 4, 2025

Build error seems to related to RestorePackagesWithLockFile = true which I don't think is used in VSCode so I've taken that out. Lets see if that fixes it.

NU1004: The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Run restore without using restore locked mode to update the lock file.

Tidy gitignore
Rename Point as it's not the same as the point in nanoFramework.Graphics
Tidy comments
Remove restore with lock as it breaks the pipeline
@josesimoes
Copy link
Member

Build error seems to related to true which I don't think is used in VSCode so I've taken that out. Lets see if that fixes it.

NU1004: The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Run restore without using restore locked mode to update the lock file.

Manually delete the lock file so it can be recreated by nuget.

Magic string .NETnanoFramework,Version=v1.0
@Workshopshed
Copy link
Author

Workshopshed commented Sep 5, 2025

Build error seems to related to true which I don't think is used in VSCode so I've taken that out. Lets see if that fixes it.
NU1004: The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Run restore without using restore locked mode to update the lock file.

Manually delete the lock file so it can be recreated by nuget.

I did cross check the files and the versions are the same between the lock file and the packages file.

Deleted the file.
Ran

nuget restore -forceEvaluate
nuget restore -UseLockFile

Identical file is generated. Git tells me there is nothing to commit.

Looking at another recent device Adc128D818. There's a difference in the top of the lock file.

{
  "version": 1,
  "dependencies": {
    ".NETnanoFramework,Version=v1.0": {
      "nanoFramework.CoreLibrary": {
{
  "version": 1,
  "dependencies": {
    "Any,Version=v0.0": {
      "nanoFramework.CoreLibrary": {      

So I've manually added that into my file. I'm guessing you are using a slightly different process to generate your lock files.

Also spotted a different in the project file. Mine had the Nerdbank.GitVersioning declared at both the beginning and end of the file. So I've made it same as per Adc128D818 example.

Doesn't seem to make a difference but consistent with other devices
@josesimoes
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@josesimoes
Copy link
Member

@Workshopshed you should be good with copy/paste from any of the other bindings or libraries. The patterns used everywhere are always the same. 😉

As for the lock file, I don't have any problems with those... Are you using VS Code or full VS? If it's VS Code, that can explain it...

@Workshopshed
Copy link
Author

Workshopshed commented Sep 5, 2025

Just checked it on the work laptop and it generates a lockfile with .NETnanoFramework. Using nuget version 6.13.2.1

nuget restore XPT2046.sln

Nuget at home is version 6.14.0.116

Upgraded work machine (with Visual Studio) recreated the file, still has added NETnanoFramework.

So agree seems to be a VS vs VSCode issue.

@Workshopshed
Copy link
Author

Just checking in that everything is now covered. As mentioned, the graphic POINT doesn't meet the requirements. But otherwise I've made all the requested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants