OK I know it is no recursion but it looked like it ...
analogRead() can be found in - ~\arduino-0021\hardware\arduino\cores\arduino\wiring_analog.c
If not then I may change the functions altogether to something like muxAnalogRead() etc which will keep them a lot more separate....
imho that will be far more clear for the users of the lib to have one clear name. If you want it to look and feel like the standard analogRead(int pin) you should only make the version with the parameter public. Keep the interface of the class as simple as possible, e.g. something like below (mux4051.cpp only)
// datasheet - http://pdf1.alldatasheet.com/datasheet-pdf/view/173652/UTC/4051.html
// S0, S1, S2 are the selection pins
// readPin is the analog pin from the Arduino to be multiplexed.
mux4051::mux4051(uint8_t S0, uint8_t S1, uint8_t S2, uint8_t readPin)
_S0 = S0;
_S1 = S1;
_S2 = S2;
_readPin = readPin;
int mux4051::analogRead(uint8_t pin)
// if (pin > 7) pin = 7;
digitalWrite(_S0, bitRead(pin, 0));
digitalWrite(_S1, bitRead(pin, 1));
digitalWrite(_S2, bitRead(pin, 2));
return analogRead( _readPin);
What do you think of this proposal ?
ps - demux likewise of course...