Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/inkplate10/battery_and_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# Drawing or printing text will have no effect on the display itself before you call this function
inkplate.display()

# Get the battery reading as a string
battery = str(inkplate.read_battery())
# Get the battery reading as a string, rounded to two decimals
battery = "{:.2f}".format(inkplate.read_battery())

# Set text size to double from the original size, so we can see the text better
inkplate.set_text_size(2)
Expand All @@ -29,8 +29,8 @@
# Show it on the display
inkplate.partial_update()

# Get the temperature reading, also as a string
temperature = str(inkplate.read_temperature())
# Get the temperature reading, also as a string, rounded to one decimal
temperature = "{:.1f}".format(inkplate.read_temperature())

# Print the text at coordinates 100, 150, and also add the measurement unit
inkplate.print_text(350, 400, "Temperature: " + temperature + "C")
Expand Down
33 changes: 25 additions & 8 deletions examples/inkplate10/example_network.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
"""Connect to WiFi and fetch data from the internet."""

# Include needed libraries
import time
from inkplate10 import Inkplate

# Enter your WiFi credentials here
ssid = "ENTER_SSID_HERE"
password = "ENTER_PASSWORD_HERE"

# Create and initialize our Inkplate object in 1-bit mode
inkplate = Inkplate(Inkplate.INKPLATE_1BIT)
inkplate.begin()

# Start from a clean screen
inkplate.clear_display()
inkplate.display()

# Text twice the size of the built-in font for the progress messages
inkplate.set_text_size(2)

# Function which connects to WiFi

# Function which connects to WiFi and shows the progress on the screen
# More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html
def do_connect():
import network

sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print("connecting to network...")
inkplate.print("Connecting to " + ssid)
inkplate.partial_update()
sta_if.active(True)
sta_if.connect(ssid, password)
while not sta_if.isconnected():
pass
# One dot a second, so you can see the board is alive
time.sleep(1)
inkplate.print(".")
inkplate.partial_update()
print("network config:", sta_if.ifconfig())
inkplate.print(" connected")
inkplate.partial_update()


# This function does a HTTP GET request
Expand Down Expand Up @@ -51,14 +70,12 @@ def http_get(url):
# If you were to do a GET request to a different page/resource, change the URL here
response = http_get("http://micropython.org/ks/test.html")

# Create and initialize our Inkplate object in 1-bit mode
inkplate = Inkplate(Inkplate.INKPLATE_1BIT)
inkplate.begin()

# Set text size to double from the original size, so we can see the text better
# Clear the progress messages and use the normal text size, so more of the answer fits
inkplate.clear_display()
inkplate.set_cursor(0, 0)
inkplate.set_text_size(1)

# Print response line by line
# Print the whole answer
inkplate.print(response)

# Display image from buffer in full refresh
Expand Down
2 changes: 1 addition & 1 deletion examples/inkplate10/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from inkplate10 import Inkplate # Include the Inkplate module

inkplate = Inkplate(Inkplate.INKPLATE_1BIT) # Create a display instance (8-level grayscale)
inkplate = Inkplate(Inkplate.INKPLATE_1BIT) # Create a display instance (1-bit, black and white)

inkplate.begin() # Initialize the display

Expand Down
Loading