added display timeout
This commit is contained in:
@ -11,6 +11,7 @@
|
|||||||
#define PULSE_LENGTH 12 //ms (with 12 ms you can't get higher than 208bpm)
|
#define PULSE_LENGTH 12 //ms (with 12 ms you can't get higher than 208bpm)
|
||||||
#define MAXBPM 200 //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 SCREEN_TIMEOUT 30000 //30 sec
|
||||||
|
|
||||||
#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
|
#define ENC_BTN_PIN 14
|
||||||
@ -46,7 +47,7 @@ int channelPulseCount[6];
|
|||||||
int channelPulsesPerCycle[6];
|
int channelPulsesPerCycle[6];
|
||||||
int playingModes[6]; //actual channel modes array updated from channels each beat
|
int playingModes[6]; //actual channel modes array updated from channels each beat
|
||||||
|
|
||||||
int pulsePeriod;
|
unsigned int pulsePeriod;
|
||||||
bool isPlaying = false;
|
bool isPlaying = false;
|
||||||
|
|
||||||
bool pulseCounted = false;
|
bool pulseCounted = false;
|
||||||
@ -59,9 +60,9 @@ bool externalPulseCounted = true;
|
|||||||
unsigned long lastExtPulseTime;
|
unsigned long lastExtPulseTime;
|
||||||
unsigned long newExtPulseTime;
|
unsigned long newExtPulseTime;
|
||||||
|
|
||||||
int displayTab = 0;
|
unsigned int displayTab = 0;
|
||||||
int displayTabOld;
|
unsigned int displayTabOld;
|
||||||
int insideTab = 0;
|
unsigned int insideTab = 0;
|
||||||
bool playBtnPushed = false;
|
bool playBtnPushed = false;
|
||||||
|
|
||||||
int a1Input = 0;
|
int a1Input = 0;
|
||||||
@ -72,6 +73,8 @@ unsigned long encPressedTime;
|
|||||||
unsigned long encReleasedTime;
|
unsigned long encReleasedTime;
|
||||||
bool encPressRegistered;
|
bool encPressRegistered;
|
||||||
|
|
||||||
|
unsigned long lastInteractionTime;
|
||||||
|
|
||||||
Adafruit_SSD1306 display(128, 64, &Wire, -1);
|
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);
|
||||||
|
|
||||||
@ -134,6 +137,10 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
checkInputs();
|
checkInputs();
|
||||||
|
if ((millis() - lastInteractionTime) > SCREEN_TIMEOUT) {
|
||||||
|
display.clearDisplay();
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clock() {
|
void clock() {
|
||||||
@ -312,6 +319,7 @@ void checkInputs() {
|
|||||||
resetClocks();
|
resetClocks();
|
||||||
playBtnPushed = true;
|
playBtnPushed = true;
|
||||||
saveState();
|
saveState();
|
||||||
|
lastInteractionTime = millis();
|
||||||
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
|
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
|
||||||
playBtnPushed = false;
|
playBtnPushed = false;
|
||||||
}
|
}
|
||||||
@ -324,6 +332,8 @@ void checkInputs() {
|
|||||||
void updateScreen() {
|
void updateScreen() {
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
|
|
||||||
|
lastInteractionTime = millis(); //not sure if it's a right place for this, but should do for now
|
||||||
|
|
||||||
//Tabs
|
//Tabs
|
||||||
display.drawRect(0, 0, 128, 2, SSD1306_WHITE);
|
display.drawRect(0, 0, 128, 2, SSD1306_WHITE);
|
||||||
display.setCursor(0,2);
|
display.setCursor(0,2);
|
||||||
|
|||||||
Reference in New Issue
Block a user