From 9f59a942ef732d1ff2b0e6ea257800554d10d158 Mon Sep 17 00:00:00 2001 From: polymurph Date: Sat, 30 Oct 2021 16:15:39 +0200 Subject: [PATCH] added idea --- pin_stuff/pin.hpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 pin_stuff/pin.hpp diff --git a/pin_stuff/pin.hpp b/pin_stuff/pin.hpp new file mode 100644 index 0000000..56a19c6 --- /dev/null +++ b/pin_stuff/pin.hpp @@ -0,0 +1,57 @@ +#ifndef __PIN_HPP__ +#define __PIN_HPP__ + +#define NUMBER_OF_PINS + + +struct Pin +{ + Pin(pinNo_et pinNo); + + static _init_all() + { + for(uint8_t i = _index; i++) { + _list.init(); + } + } + + // implicit inline! + void write(bool state) + { + _write(id, state); + } + + void init() + { + + } + + protected: + + pinNo_et getID() + { + return id; + }; + + private: + + static void _registerPin(pinNo_et p) + { + // check for duplicates + for(uint8_t i = _index; i>0;i--) { + assert(_list[i]->getID() != p); + } + // register pin + _list[_index] = p; + _index++; + } + + static void _write(pinNo_et p, bool state); + static Pin* _list[NUMBER_OF_PINS]; + static _throwError(pinNo_t p); + static uint8_t _index; + pinNo_et id; +} + +#endif //__PIN_HPP__ +