27 _offset = pins[0].getOffset();
28 _PIN = pins[0].getPIN();
29 _PORT = pins[0].getPORT();
30 _DDR = pins[0].getDDR();
31 _numbers[0] = pins[0].getNumber();
34 for (
int i = 1; i < N; i++) {
35 if (_DDR != pins[i].
getDDR()) {
38 _offset |= pins[i].getOffset();
39 _numbers[i] = pins[i].getNumber();
52 uint8_t status = *_PIN;
53 if ((status & _offset) == _offset) {
54 return (value == HIGH);
55 }
else if ((status | _ioffset) == _ioffset) {
56 return (value == LOW);
70 uint8_t status = *_PIN;
71 if ((status & _offset) == _offset) {
72 return (value == LOW);
73 }
else if ((status | _ioffset) == _ioffset) {
74 return (value == HIGH);
86 uint8_t oldSREG = SREG;
158 uint8_t status = *_DDR;
159 if ((status & _offset) == _offset) {
161 }
else if ((status | _ioffset) == _ioffset) {
174 uint8_t status = *_PORT;
175 if ((status & _offset) == _offset) {
177 }
else if ((status | _ioffset) == _ioffset) {
190 uint8_t status = *_PIN;
191 if ((status & _offset) == _offset) {
193 }
else if ((status | _ioffset) == _ioffset) {
215 void set(uint8_t mode, uint8_t state) {
216 uint8_t oldSREG = SREG;
237 uint8_t oldSREG = SREG;
253 uint8_t oldSREG = SREG;
267 uint8_t oldSREG = SREG;
277 uint8_t oldSREG = SREG;
287 uint8_t oldSREG = SREG;
297 uint8_t oldSREG = SREG;
308 uint8_t oldSREG = SREG;
319 uint8_t oldSREG = SREG;
329 uint8_t oldSREG = SREG;
339 uint8_t oldSREG = SREG;
349 uint8_t oldSREG = SREG;
360 uint8_t oldSREG = SREG;
371 uint8_t oldSREG = SREG;
381 uint8_t oldSREG = SREG;
392 volatile uint8_t* _PIN;
393 volatile uint8_t* _PORT;
394 volatile uint8_t* _DDR;
Fast operations on Arduino I/O pins.
#define DDR_HIGH
Set the DDR register to HIGH for the pin.
#define PORT_LOW
Set the PORT register to LOW for the pin.
#define PORT_HIGH
Set the PORT register to HIGH for the pin.
#define DDR_TOGGLE
Set the DDR register to the inverse for the pin.
#define PORT_TOGGLE
Set the PORT register to the inverse for the pin.
#define DDR_LOW
Set the DDR register to LOW for the pin.
Class for simultaneous operations on Arduino I/O pins.
void setOutputLow()
Set the pin mode to output and the pin output to LOW.
PinGroup & operator=(uint8_t state)
Set the pin state.
void toggleState()
Toggle the pin state (HIGH -> LOW, LOW -> HIGH)
void setOutput()
Set the pin mode to output.
void setInput()
Set the pin mode to input.
void set(uint8_t mode, uint8_t state)
Set the pin mode and pin state.
void setLow()
Set the pin output to LOW.
uint8_t getOffset()
Get the pin offset.
uint8_t getMode()
Get the mode of the pin from the DDR register.
void setInputPullupOff()
Set the pin mode to input and the pin pullup resistor to off.
void setPullupOff()
Set the pin pullup resistor to off.
volatile uint8_t * getPORT()
Get a pointer to the PORT register.
void setState(uint8_t state)
Set the pin state.
void setHigh()
Set the pin output to HIGH.
volatile uint8_t * getPIN()
Get a pointer to the PIN register.
uint8_t * getNumbers()
Get the pin numbers.
uint8_t getInverseOffset()
Get the inverse pin offset.
PinGroup(Pin(&pins)[N])
Default constructor.
volatile uint8_t * getDDR()
Get a pointer to the DDR register.
bool operator!=(uint8_t value)
Compare the value of the pin.
void toggleMode()
Toggle the pin mode (OUTPUT -> INPUT, INPUT -> OUTPUT)
void setOutputHigh()
Set the pin mode to output and the pin output to HIGH.
void setInputPullupOn()
Set the pin mode to input and the pin pullup resistor to on.
uint8_t getState()
Get the state of the pin from the PORT register.
bool operator==(uint8_t value)
Compare the value of the pin.
void setPullupOn()
Set the pin pullup resistor to on.
uint8_t getValue()
Get the value of the pin from the PIN register.
void setMode(uint8_t mode)
Set the pin mode.
bool isValid()
Check the group to ensure all pins use the same registers.
Class for fast operations on Arduino I/O pins.