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

69 lines
1.7 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
2021-11-13 09:19:09 -05:00
// AUTHOR: Rob Tillaart
2021-12-23 12:59:45 -05:00
// VERSION: 0.1.6
2020-05-20 03:53:04 -04:00
// DATE: 2017-04-26
2017-08-20 16:11:38 -04:00
// PURPOSE: PinOutGroup library for Arduino
2021-01-29 06:31:58 -05:00
// URL: https://github.com/RobTillaart/PinOutGroup
2017-08-20 16:11:38 -04:00
//
2020-05-20 03:53:04 -04:00
2021-01-29 06:31:58 -05:00
2017-08-20 16:11:38 -04:00
#include "Arduino.h"
2021-01-29 06:31:58 -05:00
2021-12-23 12:59:45 -05:00
#define PINOUTGROUP_LIB_VERSION (F("0.1.6"))
2021-01-29 06:31:58 -05:00
2020-05-20 03:53:04 -04:00
// smaller MAXSIZE will reduce memory footprint with ditto bytes.
#ifndef PINOUTGROUP_MAXSIZE
2021-12-23 12:59:45 -05:00
#define PINOUTGROUP_MAXSIZE 16
2020-05-20 03:53:04 -04:00
#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)
2021-11-13 09:19:09 -05:00
uint8_t add(uint8_t size, uint8_t* pinArray, uint8_t value = LOW);
2017-08-20 16:11:38 -04:00
// adds a single pin to the PinOutGroup, default to LOW.
2021-01-29 06:31:58 -05:00
uint8_t add(uint8_t pin, uint8_t value = LOW);
// returns count of pin in the group => only 0 or 1 makes sense
uint8_t isInGroup(uint8_t pin);
2017-08-20 16:11:38 -04:00
// 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
2021-11-13 09:19:09 -05:00
uint8_t write(uint8_t index, uint8_t value);
2021-01-29 06:31:58 -05:00
void allLOW();
void allHIGH();
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; };
// check how many free "slots" there are...
2021-01-29 06:31:58 -05:00
uint8_t available() { return PINOUTGROUP_MAXSIZE - _size; };
2021-11-13 09:19:09 -05:00
uint8_t getMaxSize() { return PINOUTGROUP_MAXSIZE; };
2021-01-29 06:31:58 -05:00
2021-11-13 09:19:09 -05:00
uint8_t getPin(uint8_t index);
uint8_t getIndex(uint8_t pin);
uint8_t getIdx(uint8_t pin) { return getIndex(pin); }; // will be obsolete in 0.2.0
2021-01-29 06:31:58 -05:00
2017-08-20 16:11:38 -04:00
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
2021-12-23 12:59:45 -05:00
2020-05-20 03:53:04 -04:00
// -- END OF FILE --
2021-12-23 12:59:45 -05:00