You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 rivejä
564 B

  1. #include "MainUnit.h"
  2. #include "Rtc.h"
  3. #include "Pins.h"
  4. namespace mainunit {
  5. void interrupt() {
  6. detachInterrupt(digitalPinToInterrupt(RTC_WAKE));
  7. }
  8. void interruptIn(uint16_t seconds) {
  9. rtc::powerOn();
  10. rtc::setAlarm(seconds);
  11. rtc::powerOff();
  12. pinMode(RTC_WAKE, INPUT);
  13. attachInterrupt(digitalPinToInterrupt(RTC_WAKE), interrupt, FALLING);
  14. }
  15. void sleep(period_t period) {
  16. LowPower.powerDown(period, ADC_OFF, BOD_OFF);
  17. }
  18. void deepSleep(uint16_t seconds) {
  19. interruptIn(seconds);
  20. LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
  21. }
  22. }