Explorar el Código

Fixed rtc might be powered off when calling interruptIn

tags/v1.2.0
Bertrand Lemasle hace 7 años
padre
commit
8b6c9088e0
Se han modificado 5 ficheros con 21 adiciones y 5 borrados
  1. +1
    -1
      GpsTracker/GpsTracker.ino
  2. +2
    -0
      GpsTracker/Hardware.cpp
  3. +2
    -0
      GpsTracker/MainUnit.cpp
  4. +2
    -2
      GpsTracker/Time2.cpp
  5. +14
    -2
      GpsTracker/Time2.h

+ 1
- 1
GpsTracker/GpsTracker.ino Ver fichero

@@ -32,5 +32,5 @@ void loop() {
positions::send();
}

mainunit::deepSleep(10); //duration TBD
mainunit::deepSleep(10); //TODO : duration
}

+ 2
- 0
GpsTracker/Hardware.cpp Ver fichero

@@ -73,6 +73,8 @@ namespace hardware {
uint8_t powered = 0;

void powerOn() {
if (powered > 0) return;

digitalWrite(I2C_PWR, HIGH);
pinMode(I2C_PWR, OUTPUT);



+ 2
- 0
GpsTracker/MainUnit.cpp Ver fichero

@@ -9,7 +9,9 @@ namespace mainunit {
}

void interruptIn(uint16_t seconds) {
rtc::powerOn();
rtc::setAlarm(seconds);
rtc::powerOff();

pinMode(RTC_WAKE, INPUT);
attachInterrupt(digitalPinToInterrupt(RTC_WAKE), interrupt, FALLING);


+ 2
- 2
GpsTracker/Time2.cpp Ver fichero

@@ -38,7 +38,7 @@
static const uint8_t monthDays[] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; // API starts months from 1, this array starts from 0

__attribute__((__optimize__("O2")))
void breakTime(timestamp_t timeInput, tmElements_t &tm) {
void breakTime(const timestamp_t timeInput, tmElements_t &tm) {
// break the given timestamp_t into time components
// this is a more compact version of the C library localtime function
// note that year is offset from 1970 !!!
@@ -95,7 +95,7 @@ void breakTime(timestamp_t timeInput, tmElements_t &tm) {
}

__attribute__((__optimize__("O2")))
timestamp_t makeTime(tmElements_t &tm) {
timestamp_t makeTime(const tmElements_t &tm) {
// assemble time elements into timestamp_t
// note year argument is offset from 1970 (see macros in time.h to convert to other formats)
// previous version used full four digit year (or digits since 2000),i.e. 2009 was 2009 or 9


+ 14
- 2
GpsTracker/Time2.h Ver fichero

@@ -23,5 +23,17 @@
} tmElements_t, TimeElements, *tmElementsPtr_t;

/* low level functions to convert to and from system time */
void breakTime(timestamp_t time, tmElements_t &tm); // break timestamp_t into elements
timestamp_t makeTime(tmElements_t &tm); // convert time elements into timestamp_t
void breakTime(const timestamp_t time, tmElements_t &tm); // break timestamp_t into elements
timestamp_t makeTime(const tmElements_t &tm); // convert time elements into timestamp_t

tmElements_t operator += (const timestamp_t b) {

}

tmElements_t operator + (const tmElements_t a, const timestamp_t b) {
tmElements_t result;
timestamp_t aTimestamp = makeTime(a);
breakTime(aTimestamp + b, result);

return result;
}

Cargando…
Cancelar
Guardar