We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Display Formatted GPS Info on OLED



  • This post is deleted!


  • Here is a raw example
    {
    "age": 0,
    "latitude": "38.1234",
    "longitude": "-80.1234",
    "elevation": "123.4",
    "course": "",
    "speed": "N"
    }

    Or with the -S
    {"age": 0,"latitude": "38.1234","longitude": "-80.1234","elevation": "123.4","course": "","speed": "N"}



  • Update - the script is now working correctly (it was not pulling in the GPS at all, actually)

    '#!/bin/sh
    oled-exp -c
    oled-exp invert on

    VAR=$(ubus -S call gps info)

    if [ $VAR != '{"signal":false}' ]
    then
    oled-exp write $VAR
    else
    oled-exp write "No or Weak GPS Signal"
    fi
    exit 0

    the above script actually writes the GPS info to the OLED. I just dont know how to parse the text to show it in the format I wish. It currently looks like this on the OLED

    {"age":174,"latitude"
    :"38.3541","longitude
    ":"-85.5559","elevati
    on":"194.7","course":
    "","speed":"N"}

    Below is how I wish the text to be displayed, but I dont know how to do that. I realize the coding in the OGPS package has the Speed and Course interchanged.

    Current Location
    Latitude: 12.3456
    Longitude: -65.4321
    Elevation: 123.4
    Course: N
    Speed: 12


  • administrators

    @Brad-Buskey You can modify the $VAR variable before you display it on the OLED.
    Try looking up the sed and awk commands for string manipulation



  • I am wondering if I should use Python instead? I was looking into SED and AWK and my head spun. Use the shell script to create a txt file with the information and then the oledExp functions in python to write the lines exactly how I want them. Or, is it possible to pull the "ubus call gps info" from python into a variable and do everything within python? Or is there even a GPS module for python?

    This is probably going to only really show my own journey trying to figure out string manipulation.



  • Python may be the answer. I can now run a shell script that writes the GPS data to a file and then runs a python script that reads that file and outputs the data to the OLED. Now, I just have to figure out how to pull different bits of data from the string and get it on the correct lines.



  • OK, new scripts have been created, I can now get the screen set up the way I want. All I have to do now is to read in the file and separate the data into the variables. I'm getting there, but slowly.

    {"age":6357,"latitude":"38.1234","longitude":"-80.1234","elevation":"1234.5","course":"12.34","speed":"N"}

    needs to be split so that I get back

    lat="38.1234"
    lon="-80.1234"
    elv="1234.5"
    cou="12.34"
    spd="N"



Looks like your connection to Community was lost, please wait while we try to reconnect.