Done with reformatting of examples and library, needs testing

master
Robert Sorić 2023-08-23 13:15:05 +02:00
parent 888f73a413
commit 1f83efe404
31 changed files with 648 additions and 234 deletions

View File

@ -18,9 +18,9 @@ if __name__ == "__main__":
display.begin()
# pin = display.gpioExpanderPin(gpioExpander,pin,mode)
# Supported gpio expanders on Soldered Inkplate 6: 1, 2 (internal, external)
# Supported gpio expanders on Soldered Inkplate 10: 1, 2 (internal, external)
# Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT
# Supported pins on Soldered Inkplate 6 are listed below
# The pins are listed below
# Declare all the available pins as output:

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

View File

@ -0,0 +1,9 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit.
Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus.
Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae.
Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta.
Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas.

View File

@ -1,15 +1,32 @@
# This example will show you how to draw shapes and text in black, white and red
# Also, it will draw a bitmap of the Soldered logo in the middle
# Include needed libraries
from inkplate4 import Inkplate
from soldered_logo import *
import time
# Create Inkplate object
display = Inkplate()
# Main function
if __name__ == "__main__":
# Must be called before using the display, like in Arduino
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# Let's draw some shapes!
# This example will draw shapes around the upper left corner, and then rotate the screen
# This creates a symmetrical-looking pattern of various shapes
for r in range(4):
# Sets the screen rotation
display.setRotation(r)
@ -26,13 +43,21 @@ if __name__ == "__main__":
display.fillRoundRect(150, 70, 60, 15, 10, display.RED)
display.drawTriangle(5, 196, 60, 196, 33, 149, display.RED)
# Show on the display!
# This function must be called in order for the display to update
display.display()
# Wait 5 seconds
time.sleep(5)
# Draws image from bytearray
# Reset the rotation
display.setRotation(0)
# Let's draw the Soldered logo right in the middle
# First, fill the background of the image white
display.fillRect(94, 128, 211, 44, display.WHITE) # Draw white background
# Now, draw the logo
display.drawBitmap(94, 128, soldered_logo, 211, 44, display.RED)
# Use display.partialUpdate instead of display.display() to draw only updated pixels
# Show on the display
display.display()

View File

@ -1,15 +1,34 @@
from inkplate4 import Inkplate
from image import *
# This example will show you how to read the voltage of the battery
# and also print it on the screen
# Include needed libraries
from inkplate4 import Inkplate
import time
# Create Inkplate object
display = Inkplate()
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
#display.clearDisplay()
#display.display()
battery = str(display.read_battery())
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# Get the battery reading as a string
battery = str(display.readBattery())
# Set text size to double from the original size, so we can see the text better
display.setTextSize(2)
display.printText(100, 100, "batt: " + battery + "V")
# Print the text at coordinates 50, 50 (from the upper left corner)
display.printText(50, 50, "Battery voltage: " + battery + "V")
# Show it on the display
display.display()

View File

@ -1,7 +1,12 @@
# This example will show you how to connect to WiFi
# get data from the internet and then print it
# Include needed libraries
import network
import time
from inkplate4 import Inkplate
# Enter your WiFi credentials here
ssid = ""
password = ""
@ -9,8 +14,6 @@ password = ""
# More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html
def do_connect():
import network
# Connect to WiFi
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print("connecting to network...")
@ -20,7 +23,7 @@ def do_connect():
pass
print("network config:", sta_if.ifconfig())
# Does a HTTP GET request
# This function does a HTTP GET request
# More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html
def http_get(url):
import socket
@ -37,28 +40,32 @@ def http_get(url):
else:
break
s.close()
return res
# Main function
if __name__ == "__main__":
# Calling functions defined above
do_connect()
# First, connect
do_connect()
# Do a GET request to the micropython test page
# If you were to do a GET request to a different page, change the URL here
response = http_get("http://micropython.org/ks/test.html")
# Do a GET request to the micropython test page
# 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")
# Initialise our Inkplate object
display = Inkplate()
display.begin()
# Create and initialize our Inkplate object
display = Inkplate()
display.begin()
# Print the GET response in lines
cnt = 0
for x in response.split("\n"):
display.printText(
10, 10 + cnt, x.upper()
) # Default font has only upper case letters
cnt += 10
# Set text size to double from the original size, so we can see the text better
display.setTextSize(2)
# Display image from buffer
display.display()
# Print response line by line
cnt = 0
for x in response.split("\n"):
display.printText(
10, 20 + cnt, x.upper()
) # Default font has only upper case letters
cnt += 20
# Display image from buffer
display.display()

View File

@ -1,29 +1,42 @@
# For this example, copy the files from the directory "Sd_card_example_files"
# to an empty microSD card's root folder and then insert it into Inkplate
# Include required libraries
import os, time
from inkplate4 import Inkplate
# Create Inkplate object
display = Inkplate()
display.begin()
# SD Card must be initialised with this function
display.initSDCard()
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
# This prints all the files on card
print(os.listdir("/sd"))
# SD Card must be initialised with this function
display.initSDCard()
f = open("sd/text.txt", "r")
# This prints all the files on card
print(os.listdir("/sd"))
# Print file contents
print(f.read())
f.close()
# Open the file text.txt in read only mode and print it's contents
f = open("sd/text.txt", "r")
print(f.read()) # This should print 5 lines of "Lorem Ipsum"
f.close() # Close the file
time.sleep(5)
# Wait 5 seconds
time.sleep(5)
# Draw the image titled "1.bmp"
display.drawImageFile(0, 0, "sd/1.bmp")
# Draw the image titled "1.bmp"
# Warning, this takes quite a while
# It's faster with smaller images
display.drawImageFile(0, 0, "sd/1.bmp")
# You can turn off the power to the SD card to save power
display.SDCardSleep()
# To turn it back on, use:
# display.SDCardWake()
# You can turn off the power to the SD card to save power
display.SDCardSleep()
# To turn it back on, use:
# display.SDCardWake()
display.display()
# Show the image from the buffer
display.display()

View File

@ -11,51 +11,32 @@ if __name__ == "__main__":
display.begin()
# pin = display.gpioExpanderPin(gpioExpander,pin,mode)
# Supported gpio expanders on Soldered Inkplate 6: 1, 2
# Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT
# Supported pins on Soldered Inkplate 6 are listed below
# Supported pins on Soldered Inkplate 4 are listed below
expander1_P0_0 = display.gpioExpanderPin(0, modeOUTPUT)
expander1_P0_1 = display.gpioExpanderPin(1, modeOUTPUT)
expander1_P0_2 = display.gpioExpanderPin(2, modeOUTPUT)
expander1_P0_3 = display.gpioExpanderPin(3, modeOUTPUT)
expander1_P0_4 = display.gpioExpanderPin(4, modeOUTPUT)
expander1_P0_5 = display.gpioExpanderPin(5, modeOUTPUT)
expander1_P0_6 = display.gpioExpanderPin(6, modeOUTPUT)
expander1_P0_7 = display.gpioExpanderPin(7, modeOUTPUT)
expander_P0_0 = display.gpioExpanderPin(0, modeOUTPUT)
expander_P0_1 = display.gpioExpanderPin(1, modeOUTPUT)
expander_P0_2 = display.gpioExpanderPin(2, modeOUTPUT)
expander_P0_3 = display.gpioExpanderPin(3, modeOUTPUT)
expander_P0_4 = display.gpioExpanderPin(4, modeOUTPUT)
expander_P0_5 = display.gpioExpanderPin(5, modeOUTPUT)
expander_P0_6 = display.gpioExpanderPin(6, modeOUTPUT)
expander_P0_7 = display.gpioExpanderPin(7, modeOUTPUT)
expander1_P1_0 = display.gpioExpanderPin(8, modeOUTPUT)
expander1_P1_1 = display.gpioExpanderPin(9, modeOUTPUT)
expander1_P1_2 = display.gpioExpanderPin(10, modeOUTPUT)
expander1_P1_3 = display.gpioExpanderPin(11, modeOUTPUT)
expander1_P1_4 = display.gpioExpanderPin(12, modeOUTPUT)
expander1_P1_5 = display.gpioExpanderPin(13, modeOUTPUT)
expander1_P1_6 = display.gpioExpanderPin(14, modeOUTPUT)
expander1_P1_7 = display.gpioExpanderPin(15, modeOUTPUT)
pins = (expander1_P0_0,
expander1_P0_1,
expander1_P0_2,
expander1_P0_3,
expander1_P0_4,
expander1_P0_5,
expander1_P0_6,
expander1_P0_7,
expander1_P1_0,
expander1_P1_1,
expander1_P1_2,
expander1_P1_3,
expander1_P1_4,
expander1_P1_5,
expander1_P1_6,
expander1_P1_7,
)
# This example writes a 0.2s pulse on the pins consecutively to test the output
expander_P1_0 = display.gpioExpanderPin(8, modeOUTPUT)
expander_P1_1 = display.gpioExpanderPin(9, modeOUTPUT)
expander_P1_2 = display.gpioExpanderPin(10, modeOUTPUT)
expander_P1_3 = display.gpioExpanderPin(11, modeOUTPUT)
expander_P1_4 = display.gpioExpanderPin(12, modeOUTPUT)
expander_P1_5 = display.gpioExpanderPin(13, modeOUTPUT)
expander_P1_6 = display.gpioExpanderPin(14, modeOUTPUT)
expander_P1_7 = display.gpioExpanderPin(15, modeOUTPUT)
# Take the previously declared pin 1_5 and blink it
# To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND
while (1):
for pin in pins:
pin.digitalWrite(1)
time.sleep(0.2)
pin.digitalWrite(0)
time.sleep(0.2)
expander_P1_5.digitalWrite(1)
time.sleep(0.5)
expander_P1_5.digitalWrite(0)
time.sleep(0.5)
# Infinite loop, this goes on forever

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@ -0,0 +1,9 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit.
Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus.
Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae.
Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta.
Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas.

View File

@ -1,16 +1,33 @@
# This example will show you how to draw basic black and white shapes
# Also, it will draw a bitmap of the Soldered logo in the middle
# Include all the required libraries
from inkplate5 import Inkplate
from soldered_logo import *
import time
# Create Inkplate object in 1-bit mode, black and white colors only
# For 2-bit grayscale, see basicGrayscale.py
display = Inkplate(Inkplate.INKPLATE_1BIT)
# Main function
if __name__ == "__main__":
# Must be called before using, like in Arduino
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# Let's draw some shapes!
# This example will draw shapes around the upper left corner, and then rotate the screen
# This creates a symmetrical-looking pattern of various shapes
for r in range(4):
# Sets the screen rotation
display.setRotation(r)
@ -26,17 +43,25 @@ if __name__ == "__main__":
display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK)
display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK)
print("rotation "+str(r))
# If it's rotation 0 or 2, also add this filled triangle
if display.rotation % 2 == 0:
display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK)
display.display()
# Show on the display!
# Use display.partialUpdate instead of display.display() to draw only updated pixels
# This makes for a faster update
# IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display()
# This ensures the image retains it's quality
display.partialUpdate()
# Wait 5 seconds
time.sleep(5)
# Reset the rotation
display.setRotation(0)
# Draws image from bytearray
# Parameters are X position, Y position, the byte array, and the exact dimensions of the image (width, height)
# We've drawn the pattern, now let's draw the Soldered logo right in the middle
display.drawBitmap(374, 248, soldered_logo, 211, 44)
#Use display.partialUpdate instead of display.display() to draw only updated pixels
display.partialUpdate()
# Show on the display
display.display()

View File

@ -1,34 +1,40 @@
# Include needed libraries
# This example will show you how to draw different shades of gray using grayscale mode
# Include needed libraries
from inkplate5 import Inkplate
from soldered_logo import *
import time
# Initialize inkplate display
# Create Inkplate object in 2-bit grayscale mode
display = Inkplate(Inkplate.INKPLATE_2BIT)
# Main function, you can make infinite while loop inside this to run code indefinitely
# Main function
if __name__ == "__main__":
# Must be called before using, line in Arduino
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# Draw palet of posible colors
#use color values 0, 1, 2, 3
# Draw pallet of posible shades
# 0 being the lightest (white), 3 being the darkest
display.writeFillRect(0, 0, 25, 600, 3)
display.writeFillRect(25, 0, 25, 600, 2)
display.writeFillRect(50, 0, 25, 600, 1)
display.writeFillRect(75, 0, 25, 600, 0)
# Show on the display
display.display()
# Wait 3 seconds
time.sleep(3)
display.setRotation(0)
# Draws image from bytearray
# Parameters are X position, Y position, the byte array, and the exact dimensions of the image (width, height)
# Let's draw the Soldered logo and show it on the display
display.drawBitmap(374, 248, soldered_logo, 211, 44)
display.display()
time.sleep(10)

View File

@ -1,21 +1,47 @@
from inkplate5 import Inkplate
from image import *
# This example will show you how to read the voltage of the battery
# and also the temperature from the TPS and print it on the screen
# Include needed libraries
from inkplate5 import Inkplate
import time
# Create Inkplate object in 1-bit mode, black and white colors only
# For 2-bit grayscale, see basicGrayscale.py
display = Inkplate(Inkplate.INKPLATE_1BIT)
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# Get the battery reading as a string
battery = str(display.readBattery())
# Set text size to double from the original size, so we can see the text better
display.setTextSize(2)
display.printText(100, 100, "batt: " + battery + "V")
# Print the text at coordinates 100,100 (from the upper left corner)
display.printText(100, 100, "Battery voltage: " + battery + "V")
# Show it on the display
display.display()
# Wait 5 seconds
time.sleep(5)
# Get the temperature reading, also as a string
temperature = str(display.readTemperature())
display.setTextSize(2)
display.printText(100, 150, "TEMP: " + temperature + "C")
# Print the text at coordinates 100, 150, and also add the measurement unit
display.printText(100, 150, "Temperature: " + temperature + "C")
# Show it on the display
display.display()

View File

@ -1,25 +1,44 @@
# This example shows how to draw a grayscale image from the SD card
# Copy the image from Sd_card_example_files and place it on the microSD card
# NOTE: This takes quite a while as MicroPython can be a bit slow
# Include needed libraries
from inkplate5 import Inkplate
import os, time
# Init display in 2bit mode, important
display = Inkplate(Inkplate.INKPLATE_2BIT)
# Main function
if __name__ == "__main__":
# Must be called before using, line in Arduino
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# SD Card must be initialised with this function
display.initSDCard()
# Wait one second so we're totally sure it's initialized
time.sleep(1)
# Wake the SD
# Wake the SD (power ON)
display.SDCardWake()
# Draw image in grayscale and display it
# Also print a message before and after
print("Starting to draw image from file!")
display.drawImageFile(0, 0, "sd/1.bmp", False)
display.display()
print("Finished drawing image from file!")
# Put the SD card to sleep
# Put the SD card back to sleep to save power
display.SDCardSleep()
# To turn it back on, use:
# display.SDCardWake()

View File

@ -1,29 +1,42 @@
# For this example, copy the files from the directory "Sd_card_example_files"
# to an empty microSD card's root folder and then insert it into Inkplate
# Include required libraries
import os, time
from inkplate5 import Inkplate
# Create Inkplate object in 2-bit (grayscale) mode
display = Inkplate(Inkplate.INKPLATE_2BIT)
display.begin()
# SD Card must be initialised with this function
display.initSDCard()
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
# This prints all the files on card
print(os.listdir("/sd"))
# SD Card must be initialised with this function
display.initSDCard()
f = open("sd/text.txt", "r")
# This prints all the files on card
print(os.listdir("/sd"))
# Print file contents
print(f.read())
f.close()
# Open the file text.txt in read only mode and print it's contents
f = open("sd/text.txt", "r")
print(f.read()) # This should print 5 lines of "Lorem Ipsum"
f.close() # Close the file
time.sleep(5)
# Wait 5 seconds
time.sleep(5)
# Utterly slow, can take minutes :(
display.drawImageFile(0, 0, "sd/1.bmp")
# Draw the image titled "1.bmp"
# Warning, this takes quite a while
# It's faster with smaller images or in 1-bit mode
display.drawImageFile(0, 0, "sd/1.bmp")
# You can turn off the power to the SD card to save power
display.SDCardSleep()
# To turn it back on, use:
# display.SDCardWake()
# You can turn off the power to the SD card to save power
display.SDCardSleep()
# To turn it back on, use:
# display.SDCardWake()
display.display()
# Show the image from the buffer
display.display()

View File

@ -0,0 +1,39 @@
# This example shows you how to use the GPIO expander's pins
# See below which pins are available
# Include needed libraries
import time
from PCAL6416A import *
from inkplate5 import Inkplate
# Create Inkplate object
display = Inkplate()
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
# pin = display.gpioExpanderPin(gpioExpander,pin,mode)
# Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT
# Supported pins on Soldered Inkplate 5 are listed below
# Declare all the available pins as output:
expander_P1_1 = display.gpioExpanderPin(9, modeOUTPUT)
expander_P1_2 = display.gpioExpanderPin(10, modeOUTPUT)
expander_P1_3 = display.gpioExpanderPin(11, modeOUTPUT)
expander_P1_4 = display.gpioExpanderPin(12, modeOUTPUT)
expander_P1_5 = display.gpioExpanderPin(13, modeOUTPUT)
expander_P1_6 = display.gpioExpanderPin(14, modeOUTPUT)
expander_P1_7 = display.gpioExpanderPin(15, modeOUTPUT)
# Take the previously declared pin 1_5 and blink it
# To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND
while (1):
expander_P1_5.digitalWrite(1)
time.sleep(0.5)
expander_P1_5.digitalWrite(0)
time.sleep(0.5)
# Infinite loop, this goes on forever

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -0,0 +1,9 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit.
Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus.
Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae.
Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta.
Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas.

View File

@ -1,20 +1,37 @@
# This example will show you how to draw basic black and white shapes
# Also, it will draw a bitmap of the Soldered logo in the middle
# Include all the required libraries
from inkplate6 import Inkplate
from image import *
from soldered_logo import *
import time
# Create Inkplate object in 1-bit mode, black and white colors only
# For 2-bit grayscale, see basicGrayscale.py
display = Inkplate(Inkplate.INKPLATE_1BIT)
# Main function
if __name__ == "__main__":
# Must be called before using, line in Arduino
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# Let's draw some shapes!
# This example will draw shapes around the upper left corner, and then rotate the screen
# This creates a symmetrical-looking pattern of various shapes
for r in range(4):
# Sets the screen rotation
display.setRotation(r)
# All drawing functions
# All the drawing functions
display.drawPixel(100, 100, display.BLACK)
display.drawRect(50, 50, 75, 75, display.BLACK)
display.drawCircle(200, 200, 30, display.BLACK)
@ -26,14 +43,25 @@ if __name__ == "__main__":
display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK)
display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK)
# If it's rotation 0 or 2, also add this filled triangle
if display.rotation % 2 == 0:
display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK)
display.display()
time.sleep(5)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
#Use display.partialUpdate instead of display.display() to draw only updated pixels
display.partialUpdate()
# Show on the display!
# Use display.partialUpdate instead of display.display() to draw only updated pixels
# This makes for a faster update
# IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display()
# This ensures the image retains it's quality
display.partialUpdate()
# Wait 5 seconds
time.sleep(5)
# Reset the rotation
display.setRotation(0)
# We've drawn the pattern, now let's draw the Soldered logo right in the middle
display.drawBitmap(294, 20, soldered_logo, 211, 44)
# Show on the display
display.display()

View File

@ -1,33 +1,39 @@
# Include needed libraries
# This example will show you how to draw different shades of gray using grayscale mode
# Include needed libraries
from inkplate6 import Inkplate
from image import *
from soldered_logo import *
import time
# Initialize inkplate display
# Create Inkplate object in 2-bit grayscale mode
display = Inkplate(Inkplate.INKPLATE_2BIT)
# Main function, you can make infinite while loop inside this to run code indefinitely
# Main function
if __name__ == "__main__":
# Must be called before using, line in Arduino
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# Draw palet of posible colors
#use color values 0, 1, 2, 3
# Draw pallet of posible shades
# 0 being the lightest (white), 3 being the darkest
display.writeFillRect(0, 0, 25, 600, 3)
display.writeFillRect(25, 0, 25, 600, 2)
display.writeFillRect(50, 0, 25, 600, 1)
display.writeFillRect(75, 0, 25, 600, 0)
# Show on the display
display.display()
# Wait 3 seconds
time.sleep(3)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
display.display()
time.sleep(10)
# Let's draw the Soldered logo and show it on the display
display.drawBitmap(294, 278, soldered_logo, 211, 44)
display.display()

View File

@ -1,21 +1,47 @@
from inkplate6 import Inkplate
from image import *
# This example will show you how to read the voltage of the battery
# and also the temperature from the TPS and print it on the screen
# Include needed libraries
from inkplate6 import Inkplate
import time
# Create Inkplate object in 1-bit mode, black and white colors only
# For 2-bit grayscale, see basicGrayscale.py
display = Inkplate(Inkplate.INKPLATE_1BIT)
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# Get the battery reading as a string
battery = str(display.readBattery())
# Set text size to double from the original size, so we can see the text better
display.setTextSize(2)
display.printText(100, 100, "batt: " + battery + "V")
# Print the text at coordinates 100,100 (from the upper left corner)
display.printText(100, 100, "Battery voltage: " + battery + "V")
# Show it on the display
display.display()
# Wait 5 seconds
time.sleep(5)
# Get the temperature reading, also as a string
temperature = str(display.readTemperature())
display.setTextSize(2)
display.printText(100, 150, "TEMP: " + temperature + "C")
# Print the text at coordinates 100, 150, and also add the measurement unit
display.printText(100, 150, "Temperature: " + temperature + "C")
# Show it on the display
display.display()

View File

@ -0,0 +1,44 @@
# This example shows how to draw a grayscale image from the SD card
# Copy the image from Sd_card_example_files and place it on the microSD card
# NOTE: This takes quite a while as MicroPython can be a bit slow
# Include needed libraries
from inkplate6 import Inkplate
import os, time
# Init display in 2bit mode, important
display = Inkplate(Inkplate.INKPLATE_2BIT)
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# SD Card must be initialised with this function
display.initSDCard()
# Wait one second so we're totally sure it's initialized
time.sleep(1)
# Wake the SD (power ON)
display.SDCardWake()
# Draw image in grayscale and display it
# Also print a message before and after
print("Starting to draw image from file!")
display.drawImageFile(0, 0, "sd/1.bmp", False)
display.display()
print("Finished drawing image from file!")
# Put the SD card back to sleep to save power
display.SDCardSleep()
# To turn it back on, use:
# display.SDCardWake()

View File

@ -1,14 +1,19 @@
# This example will show you how to connect to WiFi
# get data from the internet and then print it
# Include needed libraries
import network
import time
from inkplate6 import Inkplate
from soldered_inkplate6 import Inkplate
# Enter your WiFi credentials here
ssid = ""
password = ""
# Function which connects to WiFi
# 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...")
@ -18,11 +23,10 @@ def do_connect():
pass
print("network config:", sta_if.ifconfig())
# This function does a HTTP GET request
# More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html
def http_get(url):
import socket
res = ""
_, _, host, path = url.split("/", 3)
addr = socket.getaddrinfo(host, 80)[0][-1]
@ -36,25 +40,32 @@ def http_get(url):
else:
break
s.close()
return res
# Main function
if __name__ == "__main__":
# Calling functions defined above
do_connect()
response = http_get("http://micropython.org/ks/test.html")
# First, connect
do_connect()
# Initialise our Inkplate object
display = Inkplate(Inkplate.INKPLATE_1BIT)
display.begin()
# Do a GET request to the micropython test page
# 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")
# Print response in lines
cnt = 0
for x in response.split("\n"):
display.printText(
10, 10 + cnt, x.upper()
) # Default font has only upper case letters
cnt += 10
# Create and initialize our Inkplate object in 1-bit mode
display = Inkplate(Inkplate.INKPLATE_1BIT)
display.begin()
# Display image from buffer
display.display()
# Set text size to double from the original size, so we can see the text better
display.setTextSize(2)
# Print response line by line
cnt = 0
for x in response.split("\n"):
display.printText(
10, 20 + cnt, x.upper()
) # Default font has only upper case letters
cnt += 20
# Display image from buffer in full refresh
display.display()

View File

@ -1,21 +1,42 @@
# For this example, copy the files from the directory "Sd_card_example_files"
# to an empty microSD card's root folder and then insert it into Inkplate
# Include required libraries
import os, time
from inkplate6 import Inkplate
# Create Inkplate object in 2-bit (grayscale) mode
display = Inkplate(Inkplate.INKPLATE_2BIT)
display.begin()
# This prints all the files on card
print(os.listdir("/sd"))
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
f = open("sd/text.txt", "r")
# SD Card must be initialised with this function
display.initSDCard()
# Print file contents
print(f.read())
f.close()
# This prints all the files on card
print(os.listdir("/sd"))
time.sleep(5)
# Open the file text.txt in read only mode and print it's contents
f = open("sd/text.txt", "r")
print(f.read()) # This should print 5 lines of "Lorem Ipsum"
f.close() # Close the file
# Utterly slow, can take minutes :(
display.drawImageFile(0, 0, "sd/1.bmp")
# Wait 5 seconds
time.sleep(5)
display.display()
# Draw the image titled "1.bmp"
# Warning, this takes quite a while
# It's faster with smaller images or in 1-bit mode
display.drawImageFile(0, 0, "sd/1.bmp")
# You can turn off the power to the SD card to save power
display.SDCardSleep()
# To turn it back on, use:
# display.SDCardWake()
# Show the image from the buffer
display.display()

View File

@ -0,0 +1,60 @@
# This example shows you how to use the GPIO expander's pins
# Soldered Inkplate6 has an internal and external GPIO expander
# See below which pins are available
# Include needed libraries
import time
from PCAL6416A import *
from soldered_inkplate6 import Inkplate
# Create Inkplate object in 1-bit mode, black and white colors only
# For 2-bit grayscale, see basicGrayscale.py
display = Inkplate(Inkplate.INKPLATE_1BIT)
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
# pin = display.gpioExpanderPin(gpioExpander,pin,mode)
# Supported gpio expanders on Inkplate 6: 1, 2 (internal, external)
# Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT
# Supported pins on Inkplate 6 are listed below
# Declare all the available pins as output:
expander1_P1_1 = display.gpioExpanderPin(1, 9, modeOUTPUT)
expander1_P1_2 = display.gpioExpanderPin(1, 10, modeOUTPUT)
expander1_P1_3 = display.gpioExpanderPin(1, 11, modeOUTPUT)
expander1_P1_4 = display.gpioExpanderPin(1, 12, modeOUTPUT)
expander1_P1_5 = display.gpioExpanderPin(1, 13, modeOUTPUT)
expander1_P1_6 = display.gpioExpanderPin(1, 14, modeOUTPUT)
expander1_P1_7 = display.gpioExpanderPin(1, 15, modeOUTPUT)
expander2_P0_0 = display.gpioExpanderPin(2, 0, modeOUTPUT)
expander2_P0_1 = display.gpioExpanderPin(2, 1, modeOUTPUT)
expander2_P0_2 = display.gpioExpanderPin(2, 2, modeOUTPUT)
expander2_P0_3 = display.gpioExpanderPin(2, 3, modeOUTPUT)
expander2_P0_4 = display.gpioExpanderPin(2, 4, modeOUTPUT)
expander2_P0_5 = display.gpioExpanderPin(2, 5, modeOUTPUT)
expander2_P0_6 = display.gpioExpanderPin(2, 6, modeOUTPUT)
expander2_P0_7 = display.gpioExpanderPin(2, 7, modeOUTPUT)
expander2_P1_0 = display.gpioExpanderPin(2, 8, modeOUTPUT)
expander2_P1_1 = display.gpioExpanderPin(2, 9, modeOUTPUT)
expander2_P1_2 = display.gpioExpanderPin(2, 10, modeOUTPUT)
expander2_P1_3 = display.gpioExpanderPin(2, 11, modeOUTPUT)
expander2_P1_4 = display.gpioExpanderPin(2, 12, modeOUTPUT)
expander2_P1_5 = display.gpioExpanderPin(2, 13, modeOUTPUT)
expander2_P1_6 = display.gpioExpanderPin(2, 14, modeOUTPUT)
expander2_P1_7 = display.gpioExpanderPin(2, 15, modeOUTPUT)
# Take the previously declared pin 1_5 on expander 2 and blink it
# To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND
while (1):
expander2_P1_5.digitalWrite(1)
time.sleep(0.5)
expander2_P1_5.digitalWrite(0)
time.sleep(0.5)
# Infinite loop, this goes on forever

View File

@ -1,57 +1,79 @@
from inkplate6 import Inkplate
from image import *
# This example shows you how to use the touchpads
# Only older models of Inkplate10 (e-Radionica Inkplate 10) have them
# Include required libraries
from inkplate6 import Inkplate
# Create Inkplate object in 1-bit mode, black and white colors only
# For 2-bit grayscale, see basicGrayscale.py
display = Inkplate(Inkplate.INKPLATE_1BIT)
# Create some coordinates and a radius for drawing a circle
circle_x = 400
circle_y = 300
circle_r = 40
#main function used by micropython
# Main function
if __name__ == "__main__":
# Initialize the display, needs to be called only once
display.begin()
# Clear the frame buffer
display.clearDisplay()
# This has to be called every time you want to update the screen
# Drawing or printing text will have no effect on the display itself before you call this function
display.display()
# function to show text at the top of the screen
# need to be called every time we clear display
def topText():
# Function to show text at the top of the screen
# Needs to be called every time we clear the display to re-draw the text
def draw_top_text():
display.setTextSize(2)
display.printText(100, 10, "TOUCHPADS EXAMPLE! 1, 3 TO MOVE CIRCLE, 2 TO RESET")
topText()
# Call it
draw_top_text()
# Touchpads definitions
touch1, touch2, touch3 = display.TOUCH1, display.TOUCH2, display.TOUCH3
#draw initial circle for touchpad demonstration
# Draw the initial circle for touchpad demonstration
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
# Show everything on the display
display.display()
#Main loop that will run forever or until battery is dead
# Start infinite loop
while True:
#check if touchpad is pressed
# If a touchpad is pressed, move the circle and redraw everything
# Touch 1 moves the circle to the left
if touch1():
circle_x -= 40
display.clearDisplay()
topText()
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
display.partialUpdate()
if touch3():
circle_x += 40
display.clearDisplay()
topText()
draw_top_text()
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
# Show on the display!
# Use display.partialUpdate instead of display.display() to draw only updated pixels
# This makes for a faster update
# IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display()
# This ensures the image retains it's quality
display.partialUpdate()
# Touch 2 will reset the position of the circle
if touch2():
circle_x = 400
circle_y = 300
circle_r = 40
display.clearDisplay()
topText()
draw_top_text()
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
display.partialUpdate()
display.display() # Do a full refresh also
# Touch 3 will move the circle to the right
if touch3():
circle_x += 40
display.clearDisplay()
draw_top_text()
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
display.partialUpdate()

View File

@ -4,7 +4,7 @@
# Include needed libraries
import network
import time
from inkplate2 import Inkplate
from inkplate7 import Inkplate
# Enter your WiFi credentials here
ssid = ""

View File

@ -16,7 +16,6 @@ if __name__ == "__main__":
display.begin()
# pin = display.gpioExpanderPin(gpioExpander,pin,mode)
# Supported gpio expanders on Soldered Inkplate 6: 1, 2 (internal, external)
# Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT
# Supported pins on Soldered Inkplate 7 are listed below

View File

@ -17,9 +17,9 @@ if __name__ == "__main__":
display.begin()
# pin = display.gpioExpanderPin(gpioExpander,pin,mode)
# Supported gpio expanders on Soldered Inkplate 6: 1, 2 (internal, external)
# Supported gpio expanders on Soldered Inkplate 10: 1, 2 (internal, external)
# Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT
# Supported pins on Soldered Inkplate 6 are listed below
# Supported pins on Soldered Inkplate 10 are listed below
# Declare all the available pins as output:

View File

@ -64,4 +64,4 @@ if __name__ == "__main__":
display.drawBitmap(294, 20, soldered_logo, 211, 44)
# Show on the display
display.display()
display.display()

View File

@ -18,19 +18,16 @@ if __name__ == "__main__":
display.begin()
# pin = display.gpioExpanderPin(gpioExpander,pin,mode)
# Supported gpio expanders on Soldered Inkplate 6: 1, 2 (internal, external)
# Supported gpio expanders on Soldered Inkplate 6PLUS: 1, 2 (internal, external)
# Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT
# Supported pins on Soldered Inkplate 6 are listed below
# Supported pins on Soldered Inkplate 6PLUS are listed below
# Declare all the available pins as output:
expander1_P1_1 = display.gpioExpanderPin(1, 9, modeOUTPUT)
expander1_P1_2 = display.gpioExpanderPin(1, 10, modeOUTPUT)
expander1_P1_3 = display.gpioExpanderPin(1, 11, modeOUTPUT)
expander1_P1_4 = display.gpioExpanderPin(1, 12, modeOUTPUT)
expander1_P1_5 = display.gpioExpanderPin(1, 13, modeOUTPUT)
expander1_P1_6 = display.gpioExpanderPin(1, 14, modeOUTPUT)
expander1_P1_7 = display.gpioExpanderPin(1, 15, modeOUTPUT)
expander2_P0_1 = display.gpioExpanderPin(1, 1, modeOUTPUT)
expander2_P0_5 = display.gpioExpanderPin(2, 5, modeOUTPUT)
expander2_P0_6 = display.gpioExpanderPin(2, 6, modeOUTPUT)
expander2_P0_7 = display.gpioExpanderPin(2, 7, modeOUTPUT)
expander2_P0_0 = display.gpioExpanderPin(2, 0, modeOUTPUT)
expander2_P0_1 = display.gpioExpanderPin(2, 1, modeOUTPUT)