diff options
Diffstat (limited to 'examples/Blink3rdPartyLib/Toggle')
| -rw-r--r-- | examples/Blink3rdPartyLib/Toggle/Makefile | 14 | ||||
| -rw-r--r-- | examples/Blink3rdPartyLib/Toggle/TogglePin.cpp | 27 | ||||
| -rw-r--r-- | examples/Blink3rdPartyLib/Toggle/TogglePin.h | 19 |
3 files changed, 60 insertions, 0 deletions
diff --git a/examples/Blink3rdPartyLib/Toggle/Makefile b/examples/Blink3rdPartyLib/Toggle/Makefile new file mode 100644 index 0000000..a6234f6 --- /dev/null +++ b/examples/Blink3rdPartyLib/Toggle/Makefile @@ -0,0 +1,14 @@ +# This program is free software and is licensed under the same conditions as +# describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt + +# This is an example Makefile, that is being used to build an archive +# from locally compiled objects. +# +# All source files in this directory will automatically get compiled +# and archived into the build-$(BOARD_TAG)/libtoggle.a target. + +include ../board.mk +include ../../../Arduino.mk + +build-$(BOARD_TAG)/libtoggle.a: $(LOCAL_OBJS) + $(AR) rcs $@ $(LOCAL_OBJS) diff --git a/examples/Blink3rdPartyLib/Toggle/TogglePin.cpp b/examples/Blink3rdPartyLib/Toggle/TogglePin.cpp new file mode 100644 index 0000000..fd6925d --- /dev/null +++ b/examples/Blink3rdPartyLib/Toggle/TogglePin.cpp @@ -0,0 +1,27 @@ +// This program is free software and is licensed under the same conditions as +// describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt + +#include "TogglePin.h" + +#ifdef ARDUINO +#if ARDUINO >= 100 +#include "Arduino.h" +#else +#include "WProgram.h" +#endif +#endif // ARDUINO + +TogglePin::TogglePin(int pinNumber, bool state) + : _pinNumber(pinNumber), _state(state) +{ + pinMode(_pinNumber, OUTPUT); + digitalWrite(_pinNumber, _state ? HIGH : LOW); +} + +bool +TogglePin::toggle() +{ + _state = !_state; + digitalWrite(_pinNumber, _state ? HIGH : LOW); + return _state; +} diff --git a/examples/Blink3rdPartyLib/Toggle/TogglePin.h b/examples/Blink3rdPartyLib/Toggle/TogglePin.h new file mode 100644 index 0000000..5a7e32c --- /dev/null +++ b/examples/Blink3rdPartyLib/Toggle/TogglePin.h @@ -0,0 +1,19 @@ +// This program is free software and is licensed under the same conditions as +// describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt + +#ifndef TOGGLEPIN_H_ +#define TOGGLEPIN_H_ + +class TogglePin +{ + public: + TogglePin(int pinNumber, bool state); + + bool toggle(); + + private: + const int _pinNumber; + bool _state; +}; + +#endif |
