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.

53 line
2.6 KiB

  1. /**
  2. * Controls how and when the device goes to sleep.
  3. */
  4. #pragma once
  5. #define SLEEP_TIMING_TIME(hours, minutes) hours * 60 + minutes
  6. #define SLEEP_TIME_SECONDS 1800 ///< Default sleep time
  7. #define SLEEP_TIMING_MIN_MOVING_VELOCITY 5 ///< Speed under which to consider the tracker as not moving
  8. #define SLEEP_PAUSING_TIME_SECONDS 270 ///< Sleep time to use when not moving
  9. #define SLEEP_STOPPED_THRESHOLD 5 ///< Number of successive positions acquired as not moving before considering the tracker as stopped
  10. #define SLEEP_TIMING_MIN SLEEP_TIMING_TIME(0, 0)
  11. #define SLEEP_TIMING_MAX SLEEP_TIMING_TIME(23, 59)
  12. /**
  13. * Represents a single entry in a larger parametization
  14. * of how long the tracker will go the sleep based on its speed
  15. * and the time of the day.
  16. */
  17. struct sleepTimings_t {
  18. uint8_t speed; ///< Minimum speed (NOT maximum, the logic is reversed for code efficiency)
  19. uint16_t timeMin; ///< Minimum time of the day (UTC)
  20. uint16_t timeMax; ///< Maximum time of the day (UTC)
  21. uint16_t seconds; ///< Sleep duration in seconds
  22. };
  23. namespace config {
  24. /**
  25. * Describes for how long the tracker should sleep before the next position
  26. * acquisition based on the sleepTimings_t structure
  27. */
  28. static const sleepTimings_t defaultSleepTimings[] PROGMEM = {
  29. // Sleep timings when not moving
  30. { 0, SLEEP_TIMING_TIME(16, 00), SLEEP_TIMING_TIME(19, 59), 3600 }, ///< 1 hour between 16:00 and 20:00 UTC (04:00 to 08:00 UTC+12)
  31. { 0, SLEEP_TIMING_TIME(20, 00), SLEEP_TIMING_MAX, SLEEP_TIME_SECONDS }, ///< default (30 minutes) between 20:00 and 00:00 UTC (08:00 to 12:00 UTC+12)
  32. { 0, SLEEP_TIMING_MIN, SLEEP_TIMING_TIME(8, 29), SLEEP_TIME_SECONDS }, ///< default (30 minutes) between 00:00 and 8:30 UTC (12:00 to 20:30 UTC+12)
  33. { 0, SLEEP_TIMING_TIME(8, 30), SLEEP_TIMING_TIME(15, 59), 10800 }, ///< 3 hours between 20:30 and 16:00 UTC (20:30 to 04:00 UTC+12)
  34. // Sleep timings while moving
  35. { SLEEP_TIMING_MIN_MOVING_VELOCITY, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 540 }, ///< 540 seconds when speed > SLEEP_TIMING_MIN_MOVING_VELOCITY (5km/h)
  36. { 10, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 270 }, ///< 270 seconds when speed > 10 km/h
  37. { 20, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 225 }, ///< 225 seconds when speed > 20 km/h
  38. { 30, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 240 }, ///< 240 seconds when speed > 30 km/h
  39. { 45, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 280 }, ///< 280 seconds when speed > 45 km/h
  40. { 65, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 276 }, ///< 276 seconds when speed > 65 km/h
  41. { 85, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 225 } ///< 2225 seconds when speed > 85 km/h
  42. };
  43. }