Skip to content

Commit

Permalink
Change polarity/re-trigger control to toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
qiemem committed Aug 5, 2020
1 parent 3834589 commit a4115a9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions stages/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,12 @@ void Ui::Poll() {
if (pot_when_pressed_[i] == -1.0f) {
pot_when_pressed_[i] = pot;
} else if(
changing_pot_prop_ >> i & 1 // in the middle of change, so keep changing
|| fabs(pot_when_pressed_[i] - pot) > 0.1f) {
!(changing_pot_prop_ >> i & 1) // This is a toggle, so don't change if we've changed.
&& fabs(pot_when_pressed_[i] - pot) > 0.1f) {

changing_pot_prop_ |= 1 << i;
if (pot < 0.5f) {
seg_config[i] &= ~0b00001000;
} else {
seg_config[i] |= 0b00001000;
}
// toggle polarity
seg_config[i] ^= 0b00001000;
}
dirty = dirty || seg_config[i] != old_flags;
} else {
Expand Down

0 comments on commit a4115a9

Please sign in to comment.