Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1016 B

  1. /*
  2. Part of the MCP23S08 MODULE
  3. Copyright (C) 2020 by Eddi De Pieri <eddi at depieri dot com>
  4. Adapted from https://github.com/kmpelectronics/Arduino
  5. Copyright (C) 2016 Plamen Kovandjiev <p.kovandiev@kmpelectronics.eu> & Dimitar Antonov <d.antonov@kmpelectronics.eu>
  6. (ref. https://github.com/kmpelectronics/Arduino/blob/master/ProDinoWiFiEsp/src/PRODINoESP8266/src/KMPDinoWiFiESP.cpp)
  7. */
  8. #pragma once
  9. #include "libs/BasePin.h"
  10. #include "mcp23s08.h"
  11. class McpGpioPin final : public BasePin {
  12. public:
  13. explicit McpGpioPin(unsigned char pin) :
  14. BasePin(pin)
  15. {}
  16. void pinMode(int8_t mode) override {
  17. ::MCP23S08SetDirection(this->pin, mode);
  18. }
  19. void digitalWrite(int8_t val) override {
  20. ::MCP23S08SetPin(this->pin, val);
  21. }
  22. int digitalRead() override {
  23. return ::MCP23S08GetPin(this->pin);
  24. }
  25. String description() const override {
  26. static String desc(String(F("McpGpioPin @ GPIO")) + static_cast<int>(pin));
  27. return desc;
  28. }
  29. };