led.h 421 B

123456789101112131415161718192021222324252627
  1. #pragma once
  2. // uint8_t
  3. #include <stdint.h>
  4. enum LedState {
  5. LS_Off = 0,
  6. LS_On = 1,
  7. };
  8. constexpr LedState operator~(LedState const state) noexcept {
  9. return state == LS_On ? LS_Off : LS_On;
  10. }
  11. class Led final {
  12. public:
  13. explicit Led(uint8_t pin);
  14. void init() noexcept;
  15. void setState(LedState state) noexcept;
  16. LedState getState() const noexcept;
  17. void toggleState() noexcept;
  18. private:
  19. uint8_t pin_;
  20. };