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

92 行
2.5 KiB

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