Skip to content

Commit e6aeacf

Browse files
committed
read inputs at same time
1 parent 460411d commit e6aeacf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/firmware.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ void loop() {
8686

8787
if(initd) {
8888
// encoder -------------------
89-
state = (state << 1) | digitalRead(ClockPin) | 0xe000;
89+
auto c = digitalRead(ClockPin);
90+
auto d = digitalRead(DataPin);
91+
state = (state << 1) | c | 0xe000;
92+
9093
if(state == 0xf000) {
91-
if(digitalRead(DataPin))
92-
++encoderIdx;
94+
if(d) ++encoderIdx;
9395
else --encoderIdx;
9496

9597
state = 0;

0 commit comments

Comments
 (0)