CapacitiveSensor library

Please do not post requests
Post Reply
Posts: 1
Joined: Mon Jul 03, 2017 1:38 pm

CapacitiveSensor library

Post by uli96 » Sat Jul 15, 2017 5:47 pm
(8.83 KiB) Downloaded 12 times

this is my first post to this forum, hello to everyone!

I needed the CapacitiveSensor library for one of my projects and the CapacitiveSense library didn't compile for my Maple Mine (Baite) project. The definitions for STM32F1 where missing and I took them from the OneWire_STM libray and added those to CapacitiveSensor.h:

Code: Select all

#elif defined(__arm__) && defined(__STM32F1__)
#define PIN_TO_BASEREG(pin)            (0) 
#define PIN_TO_BITMASK(pin)            ( pin ) 
#define IO_REG_TYPE unsigned int
#define IO_REG_ASM             
#define DIRECT_READ(base, pin)       digitalRead(pin)
#define DIRECT_WRITE_LOW(base, pin)  digitalWrite(pin, LOW)
#define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH)
#define DIRECT_MODE_INPUT(base, pin) pinMode(pin,INPUT)
#define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin,OUTPUT)
#warning "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture."
The library seems to work now, just wanted to share this. I used Paul Stoffregen's version from here


User avatar
Posts: 567
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: CapacitiveSensor library

Post by zoomx » Mon Jul 17, 2017 7:46 am

Thanks for sharing.
Some STM32 MCU have native support for touch sensors but not the STM32F1x family.

STM32F0 Series, STM32F3 Series, STM32L0 Series, STM32L1 Series, STM32L4 Series, STM8L Series, STM8AL Series have touch sensors native support ... 087990.pdf ... h-lib.html

The first link has also guidelines to build good touch sensors

Post Reply