def runExample(): # These three lines of code are all you need to initialize the # OLED and print the splash screen. # Before you can start using the OLED, call begin() to init # all of the pins and configure the OLED. print("\nSparkFun Micro OLED Hello Example\n") myOLED = qwiic_micro_oled.QwiicMicroOled() if not myOLED.connected: print("The Qwiic Micro OLED device isn't connected to the system. Please check your connection", \ file=sys.stderr) return myOLED.begin() # clear(ALL) will clear out the OLED's graphic memory. # clear(PAGE) will clear the Arduino's display buffer. myOLED.clear( myOLED.ALL) # Clear the display's memory (gets rid of artifacts) # To actually draw anything on the display, you must call the # display() function. myOLED.display() time.sleep(2) myOLED.clear(myOLED.PAGE) # Clear the display's buffer myOLED.print("Hello World") # Add "Hello World" to buffer # To actually draw anything on the display, you must call the display() function. myOLED.display()
def __init__(self): self.myOLED = qwiic_micro_oled.QwiicMicroOled() if not self.myOLED.connected: errStr = "The Qwiic Micro OLED device isn't connected to the system. Please check your connection" raise Exception(errStr) self.myOLED.begin()
def display_coords(coords): """For testing. Displays GPS latitude and logitude on OLED.""" oled = qwiic_micro_oled.QwiicMicroOled() oled.clear(oled.ALL) oled.clear(oled.PAGE) oled.set_font_type(0) oled.set_cursor(0, 0) oled.print("Latitude: " + "%0.3f" % coords.lat) oled.set_cursor(0, 24) oled.print("Longitude: " + "%0.3f" % coords.lon) oled.display()
def display_plot(coord_list): """Take list of flight coordinates and display on OLED. Currently, output is mirrored vertically.""" buffer = plot.copy() for coord in coord_list: location = 64 * (coord[0] // 8) + coord[1] buffer[location] = buffer[location] | num_to_bit(coord[0] % 8) oled = qwiic_micro_oled.QwiicMicroOled() oled.clear(oled.ALL) oled.clear(oled.PAGE) oled.draw_bitmap(buffer) oled.display()
def get_ip(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) ip_addr = s.getsockname()[0] s.close() return ip_addr if __name__ == '__main__': ip = get_ip() ipstr = ip.split('.') oled = qwiic_micro_oled.QwiicMicroOled() oled.begin() oled.clear(oled.ALL) oled.display() time.sleep(1) oled.set_font_type(1) oled.clear(oled.PAGE) oled.set_cursor(0, 0) oled.print("IP Address:") oled.set_cursor(0, 16) oled.print(ipstr[0]) oled.print(":")
def oled_setup(): """Run on startup. Prepares OLED for use.""" oled = qwiic_micro_oled.QwiicMicroOled() oled.begin() oled.clear(oled.ALL) oled.clear(oled.PAGE)