~josealberto4444/arduino-quiz

1c0e82f4df40d98ac189499c0b4f792176ae5f0e — josealberto4444 2 years ago cf02a26
Add pause and resume functions
1 files changed, 20 insertions(+), 2 deletions(-)

M quiz/quiz.ino
M quiz/quiz.ino => quiz/quiz.ino +20 -2
@@ 48,7 48,7 @@ bool welcomeScreenState = false;  // Is the welcome screen playing?


// Timing variables
const unsigned short secondsToInactive = 30;
const unsigned short secondsToInactive = 7;
volatile unsigned long prevActiveMillis = 0;
unsigned long prevToneMillis = 0;
unsigned long prevScreenMillis = 0;


@@ 59,6 59,11 @@ byte toneCounter = 0;
byte screenCounter = 0;


// Remote-command variabes
const unsigned long remoteSwitchScroll = 0x1fe48b7;
const unsigned long remotePause = 0x1fee817;


// Scrolling class
class Scroller {
  // Receive a message and scroll it through the screen


@@ 142,6 147,14 @@ class Scroller {
      lcd.print(spaceFilling);
    }
  }
  
  void pauseOrResume () {
    if (isUpperCase(direct)) {
      direct |= B00100000; // To lower-case.
    } else {
      direct &= ~(B00100000); // To upper-case.
    }
  }
};




@@ 242,8 255,13 @@ void loop() {
      aMessage.Update();
      if (irrecv.decode(&results)) {
        switch (results.value) {
          case 0x1fe48b7:
          case remoteSwitchScroll:
            aMessage.switchDirection();
            prevActiveMillis = millis();
            break;
          case remotePause:
            aMessage.pauseOrResume();
            prevActiveMillis = millis();
            break;
        }
        irrecv.resume();