arduino project liquid crystal

Calum122

Member +
No, but I've used the SSD1306 OLED screens to do similar things for having a real time clock on the Starlet.


index.php
 

Calum122

Member +
It was mainly because my car is always switched off via a kill switch in the boot and I didn't want to faff about setting the clock all the time.

So now when it boots, it gets the time from GPS and parses the time out of the payload packets. Takes a few minutes to acquire the signal etc but it's a fire & forget solution. Eventually it'll acquire the signal and extract the time value.

C:
#define EXPECTED_FIELDS 12
#define GPRMC "$GPRMC"
#define BUF_SIZE        512

struct gprmc {
    char timestamp[GPRMC_BUF],
         validity,
         latatitude[GPRMC_BUF],
         longitude[GPRMC_BUF],
         norSou,
         easWes,
         speed[GPRMC_BUF],
         course[GPRMC_BUF],
         date[GPRMC_BUF],
         variation[GPRMC_BUF],
         moreEastWest,
         checkSum[GPRMC_BUF];
    bool succcess;
};
/*
 * @brief Process the $GPRMC line
 *
 * @param  gprmc - The struct used to house everything
 * @return success - A flag used to indicate the success of the subroutine
 */
static struct gprmc parseLine(char *line) {
    struct gprmc gps = { { 0 }, 0, { 0 }, { 0 }, 0, 0, { 0 }, { 0 }, { 0 }, { 0 }, 0, { 0 }, 0 };
    int  fields  = 0;

    fields = sscanf(line, "$GPRMC,%[^,],%c,%[^,],%c,%[^,],%c,%[^,],%[^,],%[^,],%[^,],%c,%[^,]\n", gps.timestamp, &gps.validity, gps.latatitude, &gps.norSou, gps.longitude, &gps.easWes, gps.speed, gps.course, gps.date, gps.variation, &gps.moreEastWest, gps.checkSum);

    if(EXPECTED_FIELDS == fields)
        gps.success = true;

    return gps;
} /* End of parseLine */

/*
 * @brief Search through the GPS looking for the line $GPRMC
 * And extract it.
 *
 * @param  file - The file where the GPS information can be found
 * @param  line - The buffer to place to the contents in to
 * @return found - A flag indicating whether or not the contents could be found
 */
static bool yankLine(FILE *fp, char *line) {
    bool found = false;

    int loopCounter = 0;

    char buff[BUF_SIZE] = { 0 }, *offset = NULL;

    while(false == found || LOOP_MAX == loopCounter) {
        fgets(buff, BUF_SIZE, fp);
        
        if(NULL != buff) {
            offset = strstr(buff, GPRMC);

            /* Date Found */
            if(NULL != offset) {
                memcpy(line, buff, BUF_SIZE);
                found = true;
            }

        }

        memset(buff, '\0', BUF_SIZE);
        ++loopCounter;
    }

    return found;
} /* End of yankLine */

I just had a serial USB GPS device which could be opened using a FILE descriptor. Then just read the data into a fixed buffer and keep reading each line until you find the GPMRC line at which you can parse it...in case anyone was wondering.
 

SKINY

Lifer
Is the adafruit library not just pictures of blokes wearing skinny jeans standing beside shitvics ?
 
Top