GY-63_MS5611/libraries/PinOutGroup/PinOutGroup.h

56 lines
1.3 KiB
C
Raw Normal View History

2020-05-20 03:53:04 -04:00
#pragma once
2017-08-20 16:11:38 -04:00
// FILE: PinOutGroup.h
// AUTHOR: Rob dot Tillaart at gmail dot com
2020-05-20 03:53:04 -04:00
// VERSION: 0.1.1
// DATE: 2017-04-26
2017-08-20 16:11:38 -04:00
// PURPOSE: PinOutGroup library for Arduino
2020-05-20 03:53:04 -04:00
// HISTORY: See PinOutGroup.cpp
2017-08-20 16:11:38 -04:00
//
2020-05-20 03:53:04 -04:00
2017-08-20 16:11:38 -04:00
#include "Arduino.h"
2020-05-20 03:53:04 -04:00
#define PINOUTGROUP_LIB_VERSION "0.1.1"
// smaller MAXSIZE will reduce memory footprint with ditto bytes.
#ifndef PINOUTGROUP_MAXSIZE
#define PINOUTGROUP_MAXSIZE 16
#endif
2017-08-20 16:11:38 -04:00
class PinOutGroup
{
public:
PinOutGroup();
2020-05-20 03:53:04 -04:00
// enables one to reset at he pinGroup and repopulate it
void clear();
// adds a predefined array of pin numbers to the PinOutGroup
2017-08-20 16:11:38 -04:00
// sets all to (LOW, HIGH)
2020-05-20 03:53:04 -04:00
bool add(uint8_t sz, uint8_t* ar, uint8_t value = LOW);
2017-08-20 16:11:38 -04:00
// adds a single pin to the PinOutGroup, default to LOW.
bool add(uint8_t pin, uint8_t value = LOW);
// set up to 16 pins "simultaneously" in one call.
2020-05-20 03:53:04 -04:00
uint8_t write(uint16_t value);
// write to a single pin while maintaining internal admin
uint8_t write(uint8_t idx, uint8_t value);
2017-08-20 16:11:38 -04:00
// retrieve the last set value
2020-05-20 03:53:04 -04:00
uint16_t read() { return _lastValue; };
2017-08-20 16:11:38 -04:00
uint8_t size() { return _size; };
2020-05-20 03:53:04 -04:00
2017-08-20 16:11:38 -04:00
// check how many free "slots" there are...
uint8_t free() { return PINOUTGROUP_MAXSIZE - _size; };
private:
uint16_t _lastValue = 0;
2020-05-20 03:53:04 -04:00
uint8_t _pins[PINOUTGROUP_MAXSIZE];
2017-08-20 16:11:38 -04:00
uint8_t _size = 0;
};
2020-05-20 03:53:04 -04:00
// -- END OF FILE --