Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snoozeblock overwritten when using multiple SnoozeBlocks in script #100

Open
daanvV opened this issue Apr 15, 2021 · 0 comments
Open

Snoozeblock overwritten when using multiple SnoozeBlocks in script #100

daanvV opened this issue Apr 15, 2021 · 0 comments

Comments

@daanvV
Copy link

daanvV commented Apr 15, 2021

Hello!

I am trying to implement multiple snoozeblocks on a Teensy 3.2.

With the code below I would expect to see the following sequence of events happen:

  • Teensy goes to sleep for 5 seconds
  • LED blinks
  • Teensy goes to sleep for 10 seconds
  • LED blinks
  • 30 seconds delay
  • Teensy goes to sleep for 5 seconds
  • etc. etc.

What is actually happening is this:

  • Teensy goes to sleep for 10 seconds
  • LED blinks
  • Teensy goes to sleep for 10 seconds
  • LED blinks
  • 30 seconds delay
  • Teensy goes to sleep for 10 seconds
  • etc etc.

I get the impression that the command to hibernate with "config1" gets changed to "config2". In fact, even if I change both of the hibernate commands to "Snooze.hibernate(config1);", the Teensy still sleeps for 10 seconds on end, meaning that in the definition of the snoozeblocks, the second SnoozeBlock is probably overwriting the first SnoozeBlock. I'm guessing this is a bug, right? Does anyone know a solution? Many thanks! 🙄🚀

#include <Snooze.h>


#define LED_PIN LED_BUILTIN

// Load drivers
SnoozeTimer timer1;
SnoozeTimer timer2; 

SnoozeBlock config1(timer1); 
SnoozeBlock config2(timer2); 


void setup() {

  pinMode(LED_PIN, OUTPUT); 
  timer1.setTimer(5000);// milli seconds

  timer2.setTimer(10000);


}

void loop() {
  int who = Snooze.hibernate(config1);
  blinkLED();
  blinkLED();
  blinkLED();
  blinkLED(); 
  
  int who2 = Snooze.hibernate(config2);  
  blinkLED();
  blinkLED();
  blinkLED();
  blinkLED(); 

 delay(30000);    

 
}


void blinkLED(void) {
  digitalWrite(LED_PIN, HIGH);
  delay(80);
  digitalWrite(LED_PIN, LOW);
  delay(80);
  digitalWrite(LED_PIN, HIGH);
  delay(80);
  digitalWrite(LED_PIN, LOW);
}

@daanvV daanvV changed the title Snoozeblock overwritten when using Multiple SnoozeBlocks in script Snoozeblock overwritten when using multiple SnoozeBlocks in script Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant