您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

45 行
1003 B

  1. #include "MainUnit.h"
  2. #include "Rtc.h"
  3. #include "Pins.h"
  4. #include "Debug.h"
  5. #define LOGGER_NAME "MainUnit"
  6. namespace mainunit {
  7. namespace details {
  8. void prepareSleep() {
  9. hardware::sim808::simSerial.end(); //avoid woke up by SoftwareSerial interrupt
  10. delay(5); //ensure message have been printed out
  11. }
  12. void wokeUp() {
  13. tmElements_t wokeUpTime;
  14. rtc::getTime(wokeUpTime);
  15. VERBOSE_FORMAT("wokeUp", "%d:%d:%d", wokeUpTime.Hour, wokeUpTime.Minute, wokeUpTime.Second);
  16. hardware::sim808::simSerial.listen();
  17. }
  18. }
  19. void interrupt() {
  20. detachInterrupt(digitalPinToInterrupt(RTC_WAKE));
  21. }
  22. void interruptIn(uint16_t seconds) {
  23. rtc::setAlarm(seconds);
  24. pinMode(RTC_WAKE, INPUT);
  25. attachInterrupt(digitalPinToInterrupt(RTC_WAKE), interrupt, FALLING);
  26. }
  27. void deepSleep(uint16_t seconds) {
  28. NOTICE_FORMAT("deepSleep", "%d seconds", seconds);
  29. interruptIn(seconds);
  30. details::prepareSleep();
  31. LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
  32. details::wokeUp();
  33. }
  34. }