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

89 行
2.4 KiB

  1. #include "GpsTracker.h"
  2. #include "Positions.h"
  3. bool bypassMenu = false;
  4. void setup() {
  5. #ifdef _DEBUG
  6. debug::waitForSerial();
  7. Log.begin(LOG_LEVEL_VERBOSE, &Serial);
  8. #else
  9. if(Serial) Log.begin(LOG_LEVEL_NOTICE, &Serial);
  10. #endif
  11. if (Serial) Serial.println(F("============================="));
  12. config::main::setup();
  13. rtc::setup();
  14. hardware::sim808::setup();
  15. positions::setup();
  16. }
  17. void loop() {
  18. debug::GPSTRACKER_DEBUG_COMMAND command = debug::GPSTRACKER_DEBUG_COMMAND::RUN;
  19. if(!bypassMenu) command = debug::menu();
  20. bypassMenu = command == debug::GPSTRACKER_DEBUG_COMMAND::RUN;
  21. switch (command) {
  22. case debug::GPSTRACKER_DEBUG_COMMAND::RUN:
  23. case debug::GPSTRACKER_DEBUG_COMMAND::ONCE:
  24. core::main();
  25. break;
  26. case debug::GPSTRACKER_DEBUG_COMMAND::RAM:
  27. debug::displayFreeRam();
  28. break;
  29. case debug::GPSTRACKER_DEBUG_COMMAND::BATTERY:
  30. debug::getAndDisplayBattery();
  31. break;
  32. case debug::GPSTRACKER_DEBUG_COMMAND::GPS_ON:
  33. gps::powerOn();
  34. break;
  35. case debug::GPSTRACKER_DEBUG_COMMAND::GPS_OFF:
  36. gps::powerOff();
  37. break;
  38. case debug::GPSTRACKER_DEBUG_COMMAND::GPS_GET:
  39. debug::getAndDisplayGpsPosition();
  40. break;
  41. case debug::GPSTRACKER_DEBUG_COMMAND::GPS_SET:
  42. debug::setFakeGpsPosition();
  43. break;
  44. case debug::GPSTRACKER_DEBUG_COMMAND::RTC_GET:
  45. debug::getAndDisplayRtcTime();
  46. break;
  47. case debug::GPSTRACKER_DEBUG_COMMAND::RTC_SET:
  48. debug::setRtcTime();
  49. break;
  50. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_CONFIG:
  51. debug::getAndDisplayEepromConfig();
  52. break;
  53. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_RESET_CONFIG:
  54. config::main::reset();
  55. break;
  56. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_CONTENT:
  57. debug::getAndDisplayEepromContent();
  58. break;
  59. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_ENTRIES:
  60. debug::getAndDisplayEepromPositions();
  61. break;
  62. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_LAST_ENTRY:
  63. debug::getAndDisplayEepromLastPosition();
  64. break;
  65. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_ADD_ENTRY:
  66. debug::addLastPositionToEeprom();
  67. break;
  68. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_BACKUP_ENTRIES:
  69. positions::doBackup();
  70. break;
  71. case debug::GPSTRACKER_DEBUG_COMMAND::SLEEP:
  72. mainunit::sleep(period_t::SLEEP_8S);
  73. break;
  74. case debug::GPSTRACKER_DEBUG_COMMAND::SLEEP_DEEP:
  75. mainunit::deepSleep(10);
  76. break;
  77. case debug::GPSTRACKER_DEBUG_COMMAND::SD_WRITE_TEST:
  78. default:
  79. NOTICE_MSG("loop", "Unsupported");
  80. }
  81. }