This repository was archived by the owner on Jul 25, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include " MCP23017Pin.hpp"
2
+ #include < MCP23017.h>
3
+
4
+ MCP23017Pin::MCP23017Pin (MCP23017 &ioExpander, std::uint8_t const pin) :ioExpander(ioExpander), pin(pin) {
5
+ }
6
+
7
+ MCP23017Pin::~MCP23017Pin () {
8
+ }
9
+
10
+ int MCP23017Pin::read () {
11
+ return ioExpander.digitalRead (pin);
12
+ }
13
+
14
+ void MCP23017Pin::setMode (std::uint8_t const mode) {
15
+ setMode (mode, false );
16
+ }
17
+
18
+ void MCP23017Pin::setMode (std::uint8_t const mode, bool const inverted) {
19
+ ioExpander.pinMode (pin, mode, inverted);
20
+ }
21
+
22
+ void MCP23017Pin::write (std::uint8_t const value) {
23
+ ioExpander.digitalWrite (pin, value);
24
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef MCP23017PIN_HPP_
2
+ #define MCP23017PIN_HPP_
3
+
4
+ #include " GpioInterface.hpp"
5
+
6
+ class MCP23017 ;
7
+
8
+ class MCP23017Pin : public GpioInterface {
9
+ public:
10
+ MCP23017Pin (MCP23017& ioExpander, const std::uint8_t pin);
11
+ virtual ~MCP23017Pin ();
12
+ virtual int read () override ;
13
+ virtual void setMode (const std::uint8_t mode) override ;
14
+ void setMode (const std::uint8_t mode, const bool inverted);
15
+ virtual void write (const std::uint8_t value) override ;
16
+ private:
17
+ MCP23017& ioExpander;
18
+ const std::uint8_t pin;
19
+ };
20
+
21
+ #endif /* MCP23017PIN_HPP_ */
You can’t perform that action at this time.
0 commit comments