MX682X/ptc_touch

Some simple fixes and a compile error

Closed this issue · 5 comments

Hi! trying to test this out, I have a series of boards that use 1 series attinies so an arduino library for ptc touch would be amazing. Found some simple problems which seemed like easy fixes but then ran into

First thing i ran into was a missing url:
I added this line to library.properties, url=https://github.com/MX682X/ptc_touch
and that seemed to work.

the example directory/file selfcap_with dedicated_shield seemed to be causing some trouble and I changed them to selfcap_with_dedicated_shield (there was accidental space instead of underscore i think) and that seems to have worked

I tried to compiling selfcap.ino example and received this error

Linking everything together...
"C:\\Users\\username\\AppData\\Local\\Arduino15\\packages\\DxCore\\tools\\avr-gcc\\7.3.0-atmel3.6.1-azduino6/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -Wl,--section-start=.text=0x0 -mrelax -mmcu=attiny1614 -o "C:\\Users\username\\AppData\\Local\\Temp\\arduino_build_445631/selfcap.ino.elf" "C:\\Users\\username\\AppData\\Local\\Temp\\arduino_build_445631\\sketch\\selfcap.ino.cpp.o" "C:\\Users\\username\\AppData\\Local\\Temp\\arduino_build_445631\\libraries\\ptc_touch-main\\ptc_touch.c.o" "C:\\Users\\username\\AppData\\Local\\Temp\\arduino_build_445631/core\\core.a" "-LC:\\Users\\username\\AppData\\Local\\Temp\\arduino_build_445631" -lm
C:\Users\username\AppData\Local\Temp\ccfzKFQa.ltrans0.ltrans.o: In function `ptc_process_measurement':
<artificial>:(.text+0x49a): undefined reference to `ptc_event_callback'
<artificial>:(.text+0x4ac): undefined reference to `ptc_event_callback'
<artificial>:(.text+0x50a): undefined reference to `ptc_event_callback'
<artificial>:(.text+0x5d6): undefined reference to `ptc_event_callback'
<artificial>:(.text+0x5f8): undefined reference to `ptc_event_callback'
C:\Users\martini\AppData\Local\Temp\ccfzKFQa.ltrans0.ltrans.o:<artificial>:(.text.startup+0x178): more undefined references to `ptc_event_callback' follow
collect2.exe: error: ld returned 1 exit status
Using library ptc_touch-main at version 0.1.0 in folder: C:\Users\username\Documents\Arduino\libraries\ptc_touch-main 
exit status 1
Error compiling for board ATtiny3224/1624/1614/1604/824/814/804/424/414/404/214/204.

I'm one of those not great at code people but still pokes around and tests out so I wish i could be more helpful as this is library is hugely useful so i'm just trying to help where i can.

MX682X commented

Finally someone who can test the library! Nice.
Thanks for the hints, I've already pushed the changed to the repository.
The reason why the ptc_event_callback reference is undefined is that I've changed the type of the event to an enum and forgot to update the other examples.
You basically have to change the function in the example to this:
void ptc_event_callback(const ptc_cb_event_t eventType, cap_sensor_t* node) (eventType was uint8_t before)

oh great! it's compiling and i'm testing it out. Running into some weird serial decoding issues which may be due to my hardware but it does seem to be recognizing touches! I'll report more as I try to figure things out.

the MCUs i'll be testing on: 3217, 1616. I have some fun custom boards that use them.

MX682X commented

Good to see that it works!
You can increase the sensitivity with the following function:
uint8_t ptc_node_set_gain(cap_sensor_t* node, uint8_t aGain, uint8_t dGain); (in setup, right after adding the nodes)
I don't know how exactly the analog gain works, the digital gain increases the oversampling (and right-shift). 0x00 and 0x04 are the defaults.
Next you can adjust the thresholds with
uint8_t ptc_node_set_thresholds (cap_sensor_t* node, int16_t th_in, int16_t th_out);
for debugging, you can use
inline int16_t ptc_get_node_delta(cap_sensor_t* node)
to see the measured value, the thresholds refer to the delta

Awesome! this library has been very exciting and seems to be working rather well. I was having some weird issues with my custom board that I think are just noise related. I have one of the dr. azzy breakouts for the 3217 and the library seems to be functioning just great. Do you want me to mark this issue closed? I can open a new issue if I have further questions but since the main problems have been fixed/addressed maybe a good idea to close this one.

https://chaos.social/@chipperdoodles/111089183199528518 additionally here's me testing it with my amulet board that uses a 1616. I used upped the analog gain to 130 and left digital gain the same. The copper for the touch pads are actually on the backside of this board hence cranking up the sensitivity. Very happy to see things working!!