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 MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
|
||||
#define MINBPM 20
|
||||
#define SCREEN_TIMEOUT 30000 //30 sec
|
||||
|
||||
#define INPUT_PIN 2 //needs to be an interrupt pin
|
||||
#define ENC_BTN_PIN 14
|
||||
@ -46,7 +47,7 @@ int channelPulseCount[6];
|
||||
int channelPulsesPerCycle[6];
|
||||
int playingModes[6]; //actual channel modes array updated from channels each beat
|
||||
|
||||
int pulsePeriod;
|
||||
unsigned int pulsePeriod;
|
||||
bool isPlaying = false;
|
||||
|
||||
bool pulseCounted = false;
|
||||
@ -59,9 +60,9 @@ bool externalPulseCounted = true;
|
||||
unsigned long lastExtPulseTime;
|
||||
unsigned long newExtPulseTime;
|
||||
|
||||
int displayTab = 0;
|
||||
int displayTabOld;
|
||||
int insideTab = 0;
|
||||
unsigned int displayTab = 0;
|
||||
unsigned int displayTabOld;
|
||||
unsigned int insideTab = 0;
|
||||
bool playBtnPushed = false;
|
||||
|
||||
int a1Input = 0;
|
||||
@ -72,6 +73,8 @@ unsigned long encPressedTime;
|
||||
unsigned long encReleasedTime;
|
||||
bool encPressRegistered;
|
||||
|
||||
unsigned long lastInteractionTime;
|
||||
|
||||
Adafruit_SSD1306 display(128, 64, &Wire, -1);
|
||||
RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
|
||||
|
||||
@ -134,6 +137,10 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
checkInputs();
|
||||
if ((millis() - lastInteractionTime) > SCREEN_TIMEOUT) {
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void clock() {
|
||||
@ -312,6 +319,7 @@ void checkInputs() {
|
||||
resetClocks();
|
||||
playBtnPushed = true;
|
||||
saveState();
|
||||
lastInteractionTime = millis();
|
||||
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
|
||||
playBtnPushed = false;
|
||||
}
|
||||
@ -324,6 +332,8 @@ void checkInputs() {
|
||||
void updateScreen() {
|
||||
display.clearDisplay();
|
||||
|
||||
lastInteractionTime = millis(); //not sure if it's a right place for this, but should do for now
|
||||
|
||||
//Tabs
|
||||
display.drawRect(0, 0, 128, 2, SSD1306_WHITE);
|
||||
display.setCursor(0,2);
|
||||
|
||||
Reference in New Issue
Block a user