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

67 lines
1.6 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
2021-01-29 06:31:58 -05:00
// VERSION: 0.1.4
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
#define PINOUTGROUP_LIB_VERSION (F("0.1.4"))
2020-05-20 03:53:04 -04:00
// smaller MAXSIZE will reduce memory footprint with ditto bytes.
#ifndef PINOUTGROUP_MAXSIZE
2021-01-29 06:31:58 -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-01-29 06:31:58 -05:00
uint8_t 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.
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
uint8_t write(uint8_t idx, 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; };
2020-05-20 03:53:04 -04:00
2017-08-20 16:11:38 -04:00
// check how many free "slots" there are...
2021-01-29 06:31:58 -05:00
uint8_t available() { return PINOUTGROUP_MAXSIZE - _size; };
uint8_t getPin(uint8_t idx);
uint8_t getIdx(uint8_t pin);
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
// -- END OF FILE --