limited value ranges
This commit is contained in:
@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
#define SCREEN_ADDRESS 0x3C
|
#define SCREEN_ADDRESS 0x3C
|
||||||
|
|
||||||
#define PPQN 24 //24 is good for triplets. each pulse is 1/512th note
|
#define PPQN 24 //24 is a standart for midi
|
||||||
#define PULSE_LENGTH 5
|
#define PULSE_LENGTH 5
|
||||||
|
#define MAXBPM 250 //250 at 24ppqn 5ms pulse will be 50/50 square wave
|
||||||
|
#define MINBPM 20
|
||||||
|
|
||||||
#define INPUT_CONNECTED_PIN 12
|
#define INPUT_CONNECTED_PIN 12
|
||||||
#define INPUT_PIN 2
|
#define INPUT_PIN 2
|
||||||
@ -30,7 +32,7 @@ bool clockModeOld;
|
|||||||
int inputMode; //clock, reset, start/stop
|
int inputMode; //clock, reset, start/stop
|
||||||
int clockCount = 0;
|
int clockCount = 0;
|
||||||
|
|
||||||
int bpm = 30;
|
int bpm = 130;
|
||||||
int pulseClockCount = 0;
|
int pulseClockCount = 0;
|
||||||
int pulseCount = 0;
|
int pulseCount = 0;
|
||||||
int pulsePeriod;
|
int pulsePeriod;
|
||||||
@ -206,9 +208,19 @@ void checkInputs() {
|
|||||||
int change = encPositionOld - encPosition;
|
int change = encPositionOld - encPosition;
|
||||||
if (displayTab == 0) {
|
if (displayTab == 0) {
|
||||||
bpm = bpm + change;
|
bpm = bpm + change;
|
||||||
|
if (bpm > MAXBPM) {
|
||||||
|
bpm = MAXBPM;
|
||||||
|
} else if (bpm < MINBPM) {
|
||||||
|
bpm = MINBPM;
|
||||||
|
}
|
||||||
updatePeriod();
|
updatePeriod();
|
||||||
} else {
|
} else {
|
||||||
outsModeIndex[displayTab-1] = outsModeIndex[displayTab-1] + change;
|
outsModeIndex[displayTab-1] = outsModeIndex[displayTab-1] + change;
|
||||||
|
if (outsModeIndex[displayTab-1] < 0) {
|
||||||
|
outsModeIndex[displayTab-1] = 0;
|
||||||
|
} else if (outsModeIndex[displayTab-1] > (sizeof(outsModes)/sizeof(int)) - 1) {
|
||||||
|
outsModeIndex[displayTab-1] = (sizeof(outsModes)/sizeof(int)) - 1;
|
||||||
|
}
|
||||||
needToResetChannel = displayTab-1;
|
needToResetChannel = displayTab-1;
|
||||||
}
|
}
|
||||||
updateScreen();
|
updateScreen();
|
||||||
|
|||||||
Reference in New Issue
Block a user