Hi Everybody,
I want to contribute back to the community and released Arduino based library for very easy capacitive sense (MIT license).
I do not need 2 pins or any external components, 1 digital pin is enough (by combining an internal pull-up and VERY fast sampling).
See the 1 minute getting started video (sorry the comments on the video got disabled the moment I enabled that the video is kids friendly, but feel free to comment here on github):
https://www.youtube.com/watch?v=KwPeKHTvGJs
And read the Readme or download the project and try it yourself:
https://github.com/truhlikfredy/SinglePinCapacitiveSense
It's fast and pretty sensitive (the video is from the very first release which was not that fast and not that sensitive). Can do up to 4080 of continuous sampling at a rate of ~1.3 clocks per 1 sample at one go!
The first major advantage over generic libraries is that it's not runtime generic (only compile-time generic) and the compiler was able to optimize the instructions much better (mentioned it in the readme), thanks to C++ and templates. However the releases 2.0 and above are using handcrafted assembly, where I as able to use registers as a buffer and not having to test them for the majority of the time, which gave me such high sampling rate.
So even if you are not interested in the capacitive sense I would recommend to give it a look. I used plenty of comments in the code/assembly if anybody wants to have a look. Special fun is to make C++ template which can take arguments and feed them directly into the assembly as immediate values or addresses (even doing some offset calculation before). Links to my references are bundled in the code as well. Another very nice thing is that the inline assembly is C friendly so all inputs/outputs clobbers are defined and the C is much more safer and more aware what actually the assembly is doing to the CPU state (links are in readme in the reference and in the code as well).
And it has Travis CI builds done in the docker for each commit as well.
I hope some of this will be useful to somebody in some shape or form.