Go Down

Topic: [FIXED][CapacitiveSensor] Can't compile with Due (port manipulation) (Read 2136 times) previous topic - next topic


I'm using the CapacitiveSensor library from here: http://playground.arduino.cc//Main/CapacitiveSensor
It works great with my Leonardo (AVR), but it can't compile with Due and here are the errors explained:

  • portOutputRegister(PIN) and portInputRegister(PIN) were returning a uint8_t and now they return RwReg.

  • portModeRegister(PIN) isn't available on the Due. (Arduino.h code is commented out)

Now my question is:
I changed the uint8_t registers to RwReg (compiler doesn't complain) and I replaced the use of portModeRegister(PIN) with simple pinMode(PIN, MODE) calls (it's slower but it works).

  • Do the RwReg need to be handled in a different way? (the code works but I'm not an expert)

  • Is there a faster way than using pinMode(PIN, MODE) on Due?

  • Should I care about clock cycles since the old arduino was 16MHz and Due is 84MHz? :P

I'm waiting some feedback, then I'm going to rewrite the whole code to be Due-compatible and release a patch.


I finally released my own version of this library and it works on Arduino Due. XD

I made a pull request to the only repository that I found about this library: https://github.com/arduino-libraries/CapacitiveSensor/pull/1

I hope that someone can optimize it because I'm just a beginner with Arduino. :smiley-red:

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131