gpslocaltime

ivanmason/gps-receiver/gpslocaltime

No description
gpslocaltime
@/gpslocaltime
DEV@/neo6mv2-device
LTCnumber
UPDpulse
gpslocaltime
HOUR
MIN
SEC
DAY
MONTH
YEAR
WDAY
DEV
LTC
UPD
WDAYnumber
YEARnumber
MONTHnumber
DAYnumber
SECnumber
MINnumber
HOURnumber
To use the node in your project you should have the ivanmason/gps-receiver library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD require "https://github.com/PaulStoffregen/Time"

// Include C++ library:
{{#global}}
#include <TimeLib.h>
{{/global}}

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    
    byte last_second, Second, Minute, Hour, Day, Month;
    int Year; 
    
     if (!isInputDirty<input_UPD>(ctx))
        return;
    
    auto gps = getValue<input_DEV>(ctx);
    TinyGPSTime time = gps->time;
    TinyGPSDate date = gps->date;
    auto time_offset = getValue<input_LTC>(ctx) * 3600;
    
     if (time.isValid())
      {
        Minute = time.minute();
        Second = time.second();
        Hour   = time.hour();
      }
 
      // get date drom GPS module
      if (date.isValid())
      {
        Day   = date.day();
        Month = date.month();
        Year  = date.year();
      }
 
      if(last_second != time.second())  // if time has changed
      {
        last_second = time.second();
 
        // set current UTC time
        setTime(Hour, Minute, Second, Day, Month, Year);
        // add the offset to get local time
        adjustTime(time_offset);
        emitValue<output_HOUR>(ctx, hour());
        emitValue<output_MIN>(ctx, minute());
        emitValue<output_SEC>(ctx, second());
        emitValue<output_DAY>(ctx, day());
        emitValue<output_MONTH>(ctx, month());
        emitValue<output_YEAR>(ctx, year());
        emitValue<output_WDAY>(ctx, weekday());
      }
                    

}