Pārlūkot izejas kodu

Introduced speed timing variations based on time of the day

tags/v1.2.0
Bertrand Lemasle pirms 7 gadiem
vecāks
revīzija
1b8e898a9b
6 mainītis faili ar 40 papildinājumiem un 21 dzēšanām
  1. +18
    -18
      GpsTracker/Config.h
  2. +10
    -1
      GpsTracker/Core.cpp
  3. +1
    -1
      GpsTracker/Debug.cpp
  4. +1
    -1
      GpsTracker/GpsTracker.ino
  5. +9
    -0
      GpsTracker/Rtc.cpp
  6. +1
    -0
      GpsTracker/Rtc.h

+ 18
- 18
GpsTracker/Config.h Parādīt failu

@@ -35,8 +35,14 @@

#pragma endregion

#define SLEEP_TIMING_TIME(hours, minutes) hours * 60 + minutes
#define SLEEP_TIMING_MIN SLEEP_TIMING_TIME(0, 0)
#define SLEEP_TIMING_MAX SLEEP_TIMING_TIME(23, 59)

struct sleepTimings_t {
uint8_t speed;
uint16_t timeMin;
uint16_t timeMax;
uint16_t seconds;
};

@@ -53,25 +59,19 @@ struct config_t {
namespace config {

static const sleepTimings_t defaultSleepTimings[] PROGMEM = {
/*{ 5, SLEEP_DEFAULT_TIME_SECONDS },
{ 10, 1200 },
{ 20, 600 },
{ 30, 540 },
{ 50, 480 },
{ 80, 240 },
{ 100, 210 },
{ 180, 180 },
};*/
{ 3, 1800 },
{ 5, 900 },
{ 10, 600 },
{ 20, 600 },
{ 30, 540 },
{ 50, 480 },
{ 80, 240 },
{ 100, 210 },
{ 180, 180 },
{ 3, SLEEP_TIMING_TIME(16, 00), SLEEP_TIMING_TIME(8, 30), SLEEP_DEFAULT_TIME_SECONDS },
{ 3, SLEEP_TIMING_MIN, SLEEP_TIMING_TIME(15, 59), 10800 },
{ 3, SLEEP_TIMING_TIME(8, 29), SLEEP_TIMING_MAX, 10800 },

{ 5, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 900 },
{ 20, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 600 },
{ 30, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 540 },
{ 50, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 480 },
{ 80, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 240 },
{ 100, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 210 },
{ 180, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 180 },
};

namespace main {
extern config_t value;



+ 10
- 1
GpsTracker/Core.cpp Parādīt failu

@@ -39,13 +39,22 @@ namespace core {

uint16_t computeSleepTime(uint8_t velocity) {
uint16_t result;
uint16_t currentTime = 0xFFFF;
if (rtc::isAccurate()) {
tmElements_t time;
rtc::getTime(time);

currentTime = SLEEP_TIMING_TIME(time.Hour, time.Minute);
}
for (uint8_t i = 0; i < flash::getArraySize(config::defaultSleepTimings); i++) {
sleepTimings_t timing;
flash::read(&config::defaultSleepTimings[i], timing);

if (velocity > timing.speed) continue;
if (currentTime != 0xFFFF && (currentTime < timing.timeMin || currentTime > timing.timeMax)) continue;

result = timing.seconds;
break;
}


+ 1
- 1
GpsTracker/Debug.cpp Parādīt failu

@@ -7,7 +7,7 @@

#define MENU_ENTRY(name, text) const char MENU_##name[] PROGMEM = text

const char FAKE_GPS_ENTRY[] PROGMEM = "1,1,20170924184842.000,49.454862,1.144537,71.900,67.99,172.6,1,,1.3,2.2,1.8,,11,7,,,37,,";
const char FAKE_GPS_ENTRY[] PROGMEM = "1,1,20170924184842.000,49.454862,1.144537,71.900,2.70,172.6,1,,1.3,2.2,1.8,,11,7,,,37,,";

MENU_ENTRY(HEADER, "========================\n-- Menu --");
MENU_ENTRY(SEPARATOR, "----");


+ 1
- 1
GpsTracker/GpsTracker.ino Parādīt failu

@@ -4,7 +4,7 @@
#if _DEBUG
#define MENU_DEFAULT_TIMEOUT 0
#else
#define MENU_DEFAULT_TIMEOUT 5000
#define MENU_DEFAULT_TIMEOUT 10000

#endif
bool bypassMenu = false;


+ 9
- 0
GpsTracker/Rtc.cpp Parādīt failu

@@ -31,6 +31,14 @@ namespace rtc {
return temperature;
}

bool isAccurate() {
hardware::i2c::powerOn();
bool accurate = RTC.status(DS3231_HALTED_FLAG) == DS3231_OFF;
hardware::i2c::powerOff();

return accurate;
}

timestamp_t getTime() {
tmElements_t time;
getTime(time);
@@ -50,6 +58,7 @@ namespace rtc {

hardware::i2c::powerOn();
RTC.writeTime(time);
RTC.control(DS3231_HALTED_FLAG, DS3231_OFF);
hardware::i2c::powerOff();
}



+ 1
- 0
GpsTracker/Rtc.h Parādīt failu

@@ -7,6 +7,7 @@ namespace rtc {

float getTemperature();

bool isAccurate();
timestamp_t getTime();
void getTime(tmElements_t &time);
void setTime(const tmElements_t &time);


Notiek ielāde…
Atcelt
Saglabāt