diff --git a/README.md b/README.md index 9c11b71..73a8cda 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Objective arduino pins like: - `DigitalPulledPin` - pulled input - `DigitalOutputPin` - output - `AnalogInputPin` - analog input -- `ScopedOn` - RAII switch that turns off when out of scope +- `ScopedOn/Off` - RAII switch that turns off/on when out of scope ## Configuration Library requires c++14 or greater. diff --git a/keywords.txt b/keywords.txt index f537289..7963bf2 100644 --- a/keywords.txt +++ b/keywords.txt @@ -5,6 +5,7 @@ DigitalPulledPin KEYWORD1 DigitalOutputPin KEYWORD1 AnalogInputPin KEYWORD1 ScopedOn KEYWORD1 +ScopedOff KEYWORD1 # Methods and Functions (KEYWORD2) on KEYWORD2 diff --git a/library.json b/library.json index 535b994..bb38813 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ArduinoPin", - "version": "1.0.0", + "version": "1.1.0", "description": "Objective arduino pin", "keywords": "objective, digital, analog, pin", "repository": @@ -24,7 +24,7 @@ ], "license": "MIT", "homepage": "https://github.com/vovagorodok/ArduinoPin", - "headers": ["ArduinoPin.h", "DigitalPin.h", "AnalogPin.h", "ScopedOn.h"], + "headers": ["ArduinoPin.h", "DigitalPin.h", "AnalogPin.h", "ScopedSwitch.h"], "frameworks": "arduino", "platforms": ["*"] } \ No newline at end of file diff --git a/library.properties b/library.properties index 4b6f5ef..f577277 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=vovagorodok_ArduinoPin -version=1.0.0 +version=1.1.0 author=vovagorodok maintainer=vovagorodok sentence=Objective arduino pin paragraph=Objective arduino pin category=Hardware url=https://github.com/vovagorodok/ArduinoPin -includes=ArduinoPin.h, DigitalPin.h, AnalogPin.h, ScopedOn.h +includes=ArduinoPin.h, DigitalPin.h, AnalogPin.h, ScopedSwitch.h architectures=* diff --git a/src/ArduinoPin.h b/src/ArduinoPin.h index cb39faf..1aa8b02 100644 --- a/src/ArduinoPin.h +++ b/src/ArduinoPin.h @@ -1,4 +1,4 @@ #pragma once #include #include -#include \ No newline at end of file +#include \ No newline at end of file diff --git a/src/ScopedOn.h b/src/ScopedOn.h deleted file mode 100644 index 7225d7f..0000000 --- a/src/ScopedOn.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -template -class ScopedOn -{ -public: - inline ScopedOn(SwitchT& sw) : ref(sw) - { ref.on(); } - inline ~ScopedOn() - { ref.off(); } - -private: - SwitchT& ref; -}; \ No newline at end of file diff --git a/src/ScopedSwitch.h b/src/ScopedSwitch.h new file mode 100644 index 0000000..d4be5bc --- /dev/null +++ b/src/ScopedSwitch.h @@ -0,0 +1,25 @@ +#pragma once + +template +class ScopedOn +{ +public: + inline ScopedOn(T& sw) : ref(sw) + { ref.on(); } + inline ~ScopedOn() + { ref.off(); } +private: + T& ref; +}; + +template +class ScopedOff +{ +public: + inline ScopedOff(T& sw) : ref(sw) + { ref.off(); } + inline ~ScopedOff() + { ref.on(); } +private: + T& ref; +}; \ No newline at end of file