File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -105,19 +105,19 @@ class ModulinoButtons : public Module {
105105public:
106106 ModulinoButtons (uint8_t address = 0xFF )
107107 : Module(address, " BUTTONS" ) {}
108- bool get (bool & a, bool & b, bool & c) {
108+ PinStatus isPressed (int index) {
109+ return last_status[index] ? HIGH : LOW;
110+ }
111+ bool update () {
109112 uint8_t buf[3 ];
110113 auto res = read ((uint8_t *)buf, 3 );
111- a = buf[0 ];
112- b = buf[1 ];
113- c = buf[2 ];
114- auto ret = res && (a != last_a || b != last_b || c != last_c);
115- last_a = a;
116- last_b = b;
117- last_c = c;
114+ auto ret = res && (buf[0 ] != last_status[0 ] || buf[1 ] != last_status[1 ] || buf[2 ] != last_status[2 ]);
115+ last_status[0 ] = buf[0 ];
116+ last_status[1 ] = buf[1 ];
117+ last_status[2 ] = buf[2 ];
118118 return ret;
119119 }
120- void set (bool a, bool b, bool c) {
120+ void setLeds (bool a, bool b, bool c) {
121121 uint8_t buf[3 ];
122122 buf[0 ] = a;
123123 buf[1 ] = b;
@@ -133,7 +133,7 @@ class ModulinoButtons : public Module {
133133 }
134134 }
135135private:
136- bool last_a, last_b, last_c ;
136+ bool last_status[ 3 ] ;
137137protected:
138138 std::vector<uint8_t > match = { 0x7C }; // same as fw main.c
139139};
You can’t perform that action at this time.
0 commit comments