Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/MF_Analog/MFAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ void MFAnalog::attach(uint8_t pin, const char *name, uint8_t sensitivity)
_sensitivity = sensitivity;
_pin = pin;
_name = name;
#if defined(ARDUINO_AVR_PROMICRO16)
// ProMicro has a special pin assignment for analog pins
// therefore reading from A6 and A7 does not work
// via "digital" pins. See also pins_arduino.h
if (_pin == 4)
_pin = A6;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could have mapped the label A6 in the boards.json file, no?
That would leave this special treatment out here. My first thought was, that special handling for certain variants is not so great. i know we have done it for Pico, but that's an entirely different platform.

else if (_pin == 6)
_pin = A7;
#endif
pinMode(_pin, INPUT_PULLUP); // set pin to input. Could use OUTPUT for analog, but shows the intention :-)
// Fill averaging buffers with initial reading
for (uint8_t i = 0; i < ADC_MAX_AVERAGE; i++) {
Expand Down