def displayLocation(apiData, fieldLengths): # build a time header at the top of the screen timeHeader = buildDateTimeHeader() #build gps location data data = {} data["latitude"] = format(apiData['location']['lat'], '.6f') data["longitude"] = format(apiData['location']['lng'], '.6f') # build header header = {} header['lat'] = "latitude " header['lng'] = "longitude " # create a list of rows of text # include gps data on 2nd line screenOutput = [ timeHeader, " ", header['lat'] + data["latitude"].rjust(oled.getMaxCharacters() - len(header['lat'])), header['lng'] + data["longitude"].rjust(oled.getMaxCharacters() - len(header['lng'])) ] oled.clear() oled.writeLines(screenOutput)
def displayNetworks(networks, fieldLengths): # build a time header at the top of the screen timeHeader = buildDateTimeHeader() # create a list of rows of text # include gps data on 2nd line screenOutput = [ timeHeader, ] # add the network entries for i in range(0, len(networks)): entry = networks[i]["ssid"].ljust(fieldLengths["ssid"]) + (networks[i]["signalStrength"] + "%").rjust(fieldLengths["signalStrength"]) screenOutput.append(entry) oled.clear() oled.writeLines(screenOutput)
def displayLocation(gps, fieldLengths): # build a time header at the top of the screen timeHeader = buildDateTimeHeader() #build gps location data gps_json = json.loads(gps) data = {} data["latitude"] = str(gps_json['location']['lat']) data["longitude"] = str(gps_json['location']['lng']) # create a list of rows of text # include gps data on 2nd line screenOutput = [ timeHeader, "latittude " + data["latitude"].ljust(fieldLengths["Latitude"]), "longitude " + data["longitude"].ljust(fieldLengths["Longitude"]) ] oled.clear() oled.writeLines(screenOutput)
def displayError(message): screenOutput = ["ERROR", message] oled.clear() oled.writeLines(screenOutput)