fixed deviders switching going to min after max

This commit is contained in:
2023-03-17 01:03:49 +02:00
parent 52906c8a6b
commit c4b3d717e3

View File

@ -8,14 +8,14 @@
#define SCREEN_ADDRESS 0x3C #define SCREEN_ADDRESS 0x3C
#define PPQN 24 #define PPQN 24
#define PULSE_LENGTH 15 //ms #define PULSE_LENGTH 12 //ms (with 12 ms you can't get higher than 208bpm)
#define MAXBPM 250 //250 at 24ppqn with 5ms pulse will be 50/50 square wave #define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
#define MINBPM 20 #define MINBPM 20
#define INPUT_PIN 2 //needs to be an interrupt pin #define INPUT_PIN 2 //needs to be an interrupt pin
#define ENC_BTN_PIN 14 //3 //21 #define ENC_BTN_PIN 14
#define ENC_D1_PIN 17 //12 //20 #define ENC_D1_PIN 17
#define ENC_D2_PIN 4 //4 //17 #define ENC_D2_PIN 4
#define START_STOP_BTN_PIN 5 #define START_STOP_BTN_PIN 5
#define ANALOGUE_INPUT_1_PIN A2 #define ANALOGUE_INPUT_1_PIN A2
#define ANALOGUE_INPUT_2_PIN A1 #define ANALOGUE_INPUT_2_PIN A1
@ -74,7 +74,7 @@ Adafruit_SSD1306 display(128, 64, &Wire, -1);
RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03); RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
void setup() { void setup() {
//Serial.begin(9600); Serial.begin(9600);
//check last bit of eeprom to know if settings were stored //check last bit of eeprom to know if settings were stored
if (EEPROM.read(1023) == 'H') { if (EEPROM.read(1023) == 'H') {
@ -259,8 +259,8 @@ void checkInputs() {
updateTiming(); updateTiming();
} else if (displayTab != 0 && insideTab == 0) { } else if (displayTab != 0 && insideTab == 0) {
channels[displayTab-1].mode = channels[displayTab-1].mode - change; channels[displayTab-1].mode = channels[displayTab-1].mode - change;
if (channels[displayTab-1].mode < 0) { if (channels[displayTab-1].mode == 65535) { //65535 is 0-1 for unsigned vars
channels[displayTab-1].mode = 0; channels[displayTab-1].mode = 0;
} else if (channels[displayTab-1].mode > (sizeof(clockModes)/sizeof(int)) - 1) { } else if (channels[displayTab-1].mode > (sizeof(clockModes)/sizeof(int)) - 1) {
channels[displayTab-1].mode = (sizeof(clockModes)/sizeof(int)) - 1; channels[displayTab-1].mode = (sizeof(clockModes)/sizeof(int)) - 1;
} }