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 {
105
105
public:
106
106
ModulinoButtons (uint8_t address = 0xFF )
107
107
: 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 () {
109
112
uint8_t buf[3 ];
110
113
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 ];
118
118
return ret;
119
119
}
120
- void set (bool a, bool b, bool c) {
120
+ void setLeds (bool a, bool b, bool c) {
121
121
uint8_t buf[3 ];
122
122
buf[0 ] = a;
123
123
buf[1 ] = b;
@@ -133,7 +133,7 @@ class ModulinoButtons : public Module {
133
133
}
134
134
}
135
135
private:
136
- bool last_a, last_b, last_c ;
136
+ bool last_status[ 3 ] ;
137
137
protected:
138
138
std::vector<uint8_t > match = { 0x7C }; // same as fw main.c
139
139
};
You can’t perform that action at this time.
0 commit comments