1234567891011121314151617181920212223 |
- #include "led.h"
- #include <Arduino.h>
- Led::Led(uint8_t const pin)
- : pin_{ pin } {
- }
- void Led::init() noexcept {
- pinMode(pin_, OUTPUT);
- }
- void Led::setState(LedState const state) noexcept {
- digitalWrite(pin_, static_cast<uint8_t>(state));
- }
- LedState Led::getState() const noexcept {
- return static_cast<LedState>(digitalRead(pin_));
- }
- void Led::toggleState() noexcept {
- return setState(~getState());
- }
|