8000 esp32/boards: Add INKPLATE6 board. by mattytrentini · Pull Request #8493 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

esp32/boards: Add INKPLATE6 board. #8493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
20 changes: 20 additions & 0 deletions ports/esp32/boards/INKPLATE6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# MicroPython for the Inkplate6

![](https://www.crowdsupply.com/img/040a/inkplate-6-angle-01_png_project-main.jpg)

Inkplate is a powerful, Wi-Fi enabled ESP32 based e-paper display – recycled from a Kindle e-reader. Learn more about Inkplate on [official website](https://inkplate.io/). Inkplate6 was crowdfunded on [Crowd Supply Inkplate 6](https://www.crowdsupply.com/e-radionica/inkplate-6).

This board definition was based on [e-radionica/Inkplate-micropython](https://github.com/e-radionicacom/Inkplate-micropython) though the original software effort was by [tve](https://github.com/tve/micropython-inkplate6).

### Features

- Simple graphics class for monochrome use of the e-paper display
- Simple graphics class for 2 bits per pixel greyscale use of the e-paper display
- Support for partial updates
- Access to touch sensors
- Everything in pure python with screen updates virtually as fast as the Arduino C driver
- Bitmap drawing, although really slow

### Getting started with MicroPython on Inkplate

Download and flash the MicroPython firmware for the [INKPLATE6](https://micropython.org/download/inkplate6/) board.
27 changes: 27 additions & 0 deletions ports/esp32/boards/INKPLATE6/board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"BLE",
"WiFi",
"Display",
"e-ink",
"Micro USB",
"MicroSD",
"SPIRAM"
],
"id": "inkplate6",
"images": [
"inkplate6.jpg"
],
"mcu": "esp32",
"product": "ESP32",
"thumbnail": "",
"url": "https://inkplate.io/",
"variants": {
"idf3": "Compiled with IDF 3.x"
},
"vendor": "e-radonica"
}
1 change: 1 addition & 0 deletions ports/esp32/boards/INKPLATE6/board.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The following files are daily firmware builds for the Inkplate6.
17 changes: 17 additions & 0 deletions ports/esp32/boards/INKPLATE6/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Examples

These examples, originally from [e-radionica/Inkplate/Examples/Inkplate6](https://github.com/e-radionicacom/Inkplate-micropython/tree/master/Examples/Inkplate6) are _not_ frozen into the board firmware; they're here for reference. Execute them on your Inkplate to try them out.

- basicBW.py -> demonstrates basic drawing capabilities, as well as drawing some images.
- basicGrayscale.py -> demonstrates basic drawing capabilities, as well as drawing some images.
- exampleNetwork.py -> demonstrates connection to WiFi network while drawing the HTTP request response on the screen.
- exampleSd.py -> demonstrates reading files and images from SD card.
- batteryAndTemperatureRead.py -> demonstrates how to read temperature and voltage from internal sensors.
- touchpads.py -> demonstrates how to use built in touchpads.

## To execute the examples
The recommended way to execute the examples is with `mpremote`. Install `mpremote` with `pipx` (`pipx install mpremote`) then run a script on the Inkplate, eg:

```bash
> mpremote connect [SERIALPORT] run basicBW.py
```
39 changes: 39 additions & 0 deletions ports/esp32/boards/INKPLATE6/examples/basicBW.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from inkplate6 import Inkplate
from image import *
import time

display = Inkplate(Inkplate.INKPLATE_1BIT)

if __name__ == "__main__":
# Must be called before using, line in Arduino
display.begin()
display.clearDisplay()
display.display()

for r in range(4):
# Sets the screen rotation
display.setRotation(r)

# All drawing functions
display.drawPixel(100, 100, display.BLACK)
display.drawRect(50, 50, 75, 75, display.BLACK)
display.drawCircle(200, 200, 30, display.BLACK)
display.fillCircle(300, 300, 30, display.BLACK)
display.drawFastHLine(20, 100, 50, display.BLACK)
display.drawFastVLine(100, 20, 50, display.BLACK)
display.drawLine(100, 100, 400, 400, display.BLACK)
display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK)
display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK)
display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK)

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()
33 changes: 33 additions & 0 deletions ports/esp32/boards/INKPLATE6/examples/basicGrayscale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Include needed libraries

from inkplate6 import Inkplate
from image import *
import time


# Initialize inkplate display
display = Inkplate(Inkplate.INKPLATE_2BIT)


# Main function, you can make infinite while loop inside this to run code indefinitely
if __name__ == "__main__":
# Must be called before using, line in Arduino
display.begin()
display.clearDisplay()
display.display()

# Draw palet of posible colors
#use color values 0, 1, 2, 3
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)

display.display()
time.sleep(3)

# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
display.display()
time.sleep(10)
22 changes: 22 additions & 0 deletions ports/esp32/boards/INKPLATE6/examples/batteryAndTemperatureRead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from inkplate6 import Inkplate
from image import *

display = Inkplate(Inkplate.INKPLATE_1BIT)

if __name__ == "__main__":
display.begin()
display.clearDisplay()
display.display()

battery = str(display.readBattery())

display.setTextSize(2)
display.printText(100, 100, "batt: " + battery + "V")
display.display()


temperature = str(display.readTemperature())

display.setTextSize(2)
display.printText(100, 150, "TEMP: " + temperature + "C")
display.display()
60 changes: 60 additions & 0 deletions ports/esp32/boards/INKPLATE6/examples/exampleNetwork.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import network
import time
from inkplate6 import Inkplate

ssid = "e-radionica.com"
password = "croduino"

# 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...")
sta_if.active(True)
sta_if.connect(ssid, password)
while not sta_if.isconnected():
pass
print("network config:", sta_if.ifconfig())


# 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]
s = socket.socket()
s.connect(addr)
s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8"))
while True:
data = s.recv(100)
if data:
res += str(data, "utf8")
else:
break
s.close()

return res


# Calling functions defined above
do_connect()
response = http_get("http://micropython.org/ks/test.html")

# Initialise our Inkplate object
display = Inkplate(Inkplate.INKPLATE_1BIT)
display.begin()

# 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

# Display image from buffer
display.display()
21 changes: 21 additions & 0 deletions ports/esp32/boards/INKPLATE6/examples/exampleSd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os, time
from inkplate6 import Inkplate

display = Inkplate(Inkplate.INKPLATE_2BIT)
display.begin()

# This prints all the files on card
print(os.listdir("/sd"))

f = open("sd/text.txt", "r")

# Print file contents
print(f.read())
f.close()

time.sleep(5)

# Utterly slow, can take minutes :(
display.drawImageFile(0, 0, "sd/1.bmp")

display.display()
57 changes: 57 additions & 0 deletions ports/esp32/boards/INKPLATE6/examples/touchpads.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from inkplate6 import Inkplate
from image import *

display = Inkplate(Inkplate.INKPLATE_1BIT)

circle_x = 400
circle_y = 300
circle_r = 40

#main function used by micropython
if __name__ == "__main__":
display.begin()
display.clearDisplay()
display.display()

# function to show text at the top of the screen
# need to be called every time we clear display
def topText():
display.setTextSize(2)
display.printText(100, 10, "TOUCHPADS EXAMPLE! 1, 3 TO MOVE CIRCLE, 2 TO RESET")

topText()

# Touchpads definitions
touch1, touch2, touch3 = display.TOUCH1, display.TOUCH2, display.TOUCH3

#draw initial circle for touchpad demonstration
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
display.display()

#Main loop that will run forever or until battery is dead
while True:
#check if touchpad is pressed
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()
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
display.partialUpdate()

if touch2():
circle_x = 400
circle_y = 300
circle_r = 40

display.clearDisplay()
topText()
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
display.partialUpdate()

2 changes: 2 additions & 0 deletions ports/esp32/boards/INKPLATE6/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include("$(PORT_DIR)/boards/manifest.py")
freeze("modules")
Loading
0