Skip to content

Commit

Permalink
counter data type was too small for new binary division choices > 256…
Browse files Browse the repository at this point in the history
…. Reset counter when changing a division to avoid going out of phase.
  • Loading branch information
awonak committed Jan 30, 2024
1 parent 8cc3860 commit d48ab93
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions A-RYTH-MATIK/TimeBandit/TimeBandit.ino
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ClockDivision {
// Declare A-RYTH-MATIK hardware variable.
Arythmatik hw;
ClockDivision clockDiv[OUTPUT_COUNT];
byte counter;
int counter;
byte mode; // Normal, Select Output, Edit.
byte selected_out = 0;
bool update_display = true;
Expand Down Expand Up @@ -130,12 +130,18 @@ void UpdateParameter(Encoder::Direction dir) {
int division = clockDiv[selected_out].division;
switch (dir) {
case Encoder::DIRECTION_DECREMENT:
if (division > 1) clockDiv[selected_out].division = division >> 1;
update_display = true;
if (division > 1) {
clockDiv[selected_out].division = division >> 1;
counter = 0;
update_display = true;
}
break;
case Encoder::DIRECTION_INCREMENT:
if (division < 4096) clockDiv[selected_out].division = division << 1;
update_display = true;
if (division < 4096) {
clockDiv[selected_out].division = division << 1;
counter = 0;
update_display = true;
}
break;
}
}
Expand Down

0 comments on commit d48ab93

Please sign in to comment.