Open joshcorn opened 2 years ago
Hi,
Somehow I missed this issue when you opened it last year. Sorry about that. Did you ever get it to work or was it still having problems?
Hi I have same problem,
I use only keys 0-7,
when I tap on key 7 I have with touch_sensor.touched(status, key)
active also 7,8,9,10,11 keys
can I disable 8-11 keys ?
I didn't have a ton of time to create a fix for this at the time so I ended up writing my own function that read the specific registers, returned the combined keys and then could do a bitRead on that:
uint16_t AT42QT2120::keysStatus()
{
uint8_t keys1;
uint8_t keys2;
read(RegisterAddresses::AT42QT2120::KEY1,keys1);
read(RegisterAddresses::AT42QT2120::KEY2,keys2);
uint16_t combined = (keys2 << 8) | keys1;
return combined;
}
I am still curious why this library works on my hardware, but not on either of yours. Which microcontrollers are you using?
For the status, I am using a union of a struct and a uint32_t. I suppose that could fail if a compiler did not order the bytes in the same way or did not closely pack the bytes.
I could simply add this function that you wrote to the library if that would be helpful, but I would like to fix the problem properly if possible.
Perhaps using unions with structs and bitfields are just not a portable way to access registers.
I was using an ATTINY3227 running megaTinyCore's version of Arduino.
I using ATmega4809 arduino uno wifi rev2 board simulator via this programer: https://github.com/MCUdude/microUPDI?fbclid=IwAR0npGFdrOgD4wNyM3k7belUS7QPdJLjBXEROFgv2UP_xv9pzodmOSSnH6I
Interesting, you both are using AVR while I am testing this on an ARM. I am not sure what would cause it to work on one, but not the other. I would like to figure it out though.
On Oct 4, 2023, at 14:59, Dusan Hudak @.***> wrote:
ATmega4809
Maybe I need to add something like:struct attribute((packed))Using the GNU Compiler Collection (GCC)gcc.gnu.orgAlthough I am not sure that works for Arduino.Is it possible for one of you to add that to the status struct and see if it works for your board?On Oct 4, 2023, at 15:24, Peter Polidoro @.> wrote:Interesting, you both are using AVR while I am testing this on an ARM. I am not sure what would cause it to work on one, but not the other. I would like to figure it out though.On Oct 4, 2023, at 14:59, Dusan Hudak @.> wrote:ATmega4809
Maybe I need to add something like:struct attribute((packed))Using the GNU Compiler Collection (GCC)gcc.gnu.orgAlthough I am not sure that works for Arduino.Is it possible for one of you to add that to the status struct and see if it works for your board?On Oct 4, 2023, at 15:24, Peter Polidoro @.> wrote:Interesting, you both are using AVR while I am testing this on an ARM. I am not sure what would cause it to work on one, but not the other. I would like to figure it out though.On Oct 4, 2023, at 14:59, Dusan Hudak @.> wrote:ATmega4809
I don't quite understand what you expect, if you send me the code I can try it.
I just added a git branch named "packed" that shows what I meant.
If you are able to clone this repository and switch to the packed branch can you please test if this does anything different on your hardware? Thanks!
I just added a git branch named "packed" that shows what I meant.
If you are able to clone this repository and switch to the packed branch can you please test if this does anything different on your hardware? Thanks!
I changed it, not help
Hi, any Idea?
Keys 0-6 all trigger correctly when touched on the AT42QT2120 but when touching key 7, keys 8-11 are shown as being touched in status.keys. Also, touching keys 8-11 doesn't register as touches. Maybe it has something to do with the key status registers as keys 8-11 are at a different address?