25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
527 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::setAlarm(seconds);
  10. pinMode(RTC_WAKE, INPUT);
  11. attachInterrupt(digitalPinToInterrupt(RTC_WAKE), interrupt, FALLING);
  12. }
  13. void sleep(period_t period) {
  14. LowPower.powerDown(period, ADC_OFF, BOD_OFF);
  15. }
  16. void deepSleep(uint16_t seconds) {
  17. interruptIn(seconds);
  18. LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
  19. }
  20. }