Code Monkey home page Code Monkey logo

arduino_tsc2004's People

Contributors

arturo182 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

arduino_tsc2004's Issues

touched() returns incorrect bool

Running on my Adafruit Feather M0, my loop() was always blocking on readData(). I believe the problem is that touched() was returning 'true' even when no touch was detected (and thus no data for readData()).

If I am reading the datasheet correctly, I believe a "touch detected" is signalled by bit15 being set in CRF0. The current touched() code returns true whenever CRF0 is non-zero, which happens frequently even when no touch was detected.

I believe touched() should be something like:

 return readRegister16(_REG_CFR0) & (CFR0_PENMODE | CFR0_STATUS) >>15;

I was able to workaround the problem in my test code, by adding a TOUCHED_DETECTED macro that tests bit15 only

 #define _REG_CFR0       (0xC << 3)
 #define CFR0_STATUS             (1 << 14)
 #define CFR0_PENMODE            (1 << 15)
 #define TOUCH_DETECTED(t)   (bool) (((t).readRegister16(_REG_CFR0) & (CFR0_PENMODE | CFR0_STATUS) ) >> 15)

Z (pressure) value is always zero

Lines 138 & 139 in TSC2004.cpp should read:

*z = *x * (z2/z1 - 1);                             // per page 15 of the datasheet
*z = *z * _RESISTOR_VAL / 4096;

Yeah, I know that *z *= should work but the compiler optimizes out the first line if the 2nd line isn't changed, and you still get only zero.

Make these 2 changes and it returns non-zero values. Note that it returns lower values for lighter touches, contrary to what I expected, but this is reasonable since resistance will decrease with higher pressure.

This version includes my touched() fix, referenced in the other issue, as well.

TSC2004.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.