Pages: [1]   Go Down
Author Topic: Calling pinMode from within a class that has its own version...  (Read 433 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone

Been messing about with Arduino for years, more of a hardware bod than anything but try hard with software.

I'm developing an MPR121 library that's a nice neat class and very feature complete. Will give you proper access to the digital input, output and PWM capabilities as well as all the touch stuff. Also going to be releasing a nice partner GUI plotter for the touch electrodes to ease calibration and debugging. This is all for a neat little touch board that will be released very soon - can't give you all the details yet but will post the Kickstarter link when it goes live (should be next week).

Anyway, the problem I have is this:

In implementing all of the DIO functions of the MPR121 I wanted to give it a very Arduino feel. That is to say that I have implemented an MPR121.pinMode(unsigned char pin) method.

Sadly, in another method within the class, I want to call the normal Arduino pinMode() function in order to set up the interrupt pin for the MPR121 on the Atmega. Obviously I could do this with direct register manipulation but I want to use pinMode() if at all possible to aid portability.

So how do I do this? If I call pinMode() from within my class it will call the method within the class itself preferentially. How do I force it to use the Arduino pinMode() function? I know how to force it to go the other way - I can use this->pinMode() to be sure I call inside the class, but how do I break free?

Happy to post examples if that helps. All help gratefully received - the code generated is coming back to the community so please help if you can.

Stefan
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried ::pinMode(...); ?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You, Sir (or Madam), are a smart cookie! Thanks, works perfectly.

So that I understand better, what am I actually doing here, syntactically? I understand something like namespace::function() as similar syntax (and had actually guessed around looking for an Arduino namespace). What does the double colon do without a namespace prefix?

In any case, thank you very much. Code will be released soon smiley

All the best

Stefan
Logged

Pages: [1]   Go Up
Jump to: