From 0e913498b37712bae1bfd55b7087129f436479ee Mon Sep 17 00:00:00 2001 From: --global <--global> Date: Mon, 8 May 2023 01:00:07 +0300 Subject: [PATCH] added display timeout --- software/GToE/GToE.ino | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/software/GToE/GToE.ino b/software/GToE/GToE.ino index 5c27dc5..44fe527 100644 --- a/software/GToE/GToE.ino +++ b/software/GToE/GToE.ino @@ -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);