encode

wayland/gps/encode

Parse NMEA data stream.
encode
@/encode
Parse NMEA data stream.
GPS@/gps-device
A gps-device.
UARTxod/uart/uart
Universal asynchronous receiver-transmitter interface.
Waitnumber
On each update (UPD), wait this number of milliseconds for data to arrive from GPS device (default=1000).
UPDpulse
Update.
encode
GPS
UART
Wait
UPD
Done
Donepulse
Pulse on completion.
To use the node in your project you should have the wayland/gps 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 evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {

    void evaluate(Context ctx) {
        if (!isInputDirty<input_UPD>(ctx))
            return;

        auto gps = getValue<input_GPS>(ctx);
        auto uart = getValue<input_UART>(ctx);
        auto wait = getValue<input_Wait>(ctx);

        // Ensure that gps instance is being fed. See smartDelay in:
        // https://github.com/mikalhart/TinyGPSPlus/blob/master/examples/FullExample/FullExample.ino
        uint8_t byte = 0x00;
        uint32_t start = millis(); 
        
        do {
            while (uart->available()) {
                uart->readByte(&byte);
                gps->encode(byte);
            }
        } while (millis() - start < wait);
        
        emitValue<output_Done>(ctx, 1);
    }
}