luni
Well-known member
Here a (IMHO) nice supplement for the pinMode function utilizing 'modern' c++ features
file: pinModeEx.h (attached)
You can use it like this:
It of course doesn't touch the original pinMode function. Might be nice to have it in the core.
file: pinModeEx.h (attached)
Code:
#include <initializer_list>
#include "core_pins.h"
inline void pinMode(std::initializer_list<uint8_t> pins, uint8_t mode)
{
for (uint8_t pin : pins)
{
pinMode(pin, mode);
}
}
You can use it like this:
Code:
const int pinA = 3, pinB = 17, switch1 = 3, switch2 = 4;
void setup()
{
pinMode({pinA, pinB, 17, LED_BUILTIN}, OUTPUT); // set a bunch of pins to mode OUTPUT...
pinMode({switch1, switch2}, INPUT_PULLUP); // others to INPUT
}
It of course doesn't touch the original pinMode function. Might be nice to have it in the core.