Added Inkplate Color
parent
db0b36129d
commit
ab74a78998
|
@ -0,0 +1,30 @@
|
|||
from inkplate6_COLOR import Inkplate
|
||||
from image import *
|
||||
import time
|
||||
|
||||
display = Inkplate()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Must be called before using, line in Arduino
|
||||
display.begin()
|
||||
|
||||
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.GREEN)
|
||||
display.drawCircle(200, 200, 30, display.BLUE)
|
||||
display.fillCircle(300, 300, 30, display.BLACK)
|
||||
display.drawFastHLine(20, 100, 50, display.BLACK)
|
||||
display.drawFastVLine(100, 20, 50, display.ORANGE)
|
||||
display.drawLine(100, 100, 400, 400, display.ORANGE)
|
||||
display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK)
|
||||
display.fillRoundRect(10, 100, 100, 100, 10, display.YELLOW)
|
||||
display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK)
|
||||
|
||||
# Draws image from bytearray
|
||||
display.setRotation(0)
|
||||
display.drawBitmap(10, 160, image, 576, 100, display.BLUE)
|
||||
display.display()
|
|
@ -0,0 +1,62 @@
|
|||
import network
|
||||
import time
|
||||
from inkplate6_COLOR 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()
|
||||
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()
|
|
@ -0,0 +1,15 @@
|
|||
import os
|
||||
import time
|
||||
from inkplate6_COLOR import Inkplate
|
||||
|
||||
display = Inkplate()
|
||||
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()
|
|
@ -0,0 +1,55 @@
|
|||
from inkplate6_COLOR import Inkplate
|
||||
from image import *
|
||||
|
||||
display = Inkplate()
|
||||
|
||||
circle_x = 300
|
||||
circle_y = 200
|
||||
circle_r = 40
|
||||
|
||||
# main function used by micropython
|
||||
if __name__ == "__main__":
|
||||
display.begin()
|
||||
|
||||
# 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(
|
||||
0, 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.display()
|
||||
|
||||
if touch3():
|
||||
circle_x += 40
|
||||
display.clearDisplay()
|
||||
topText()
|
||||
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
|
||||
display.display()
|
||||
|
||||
if touch2():
|
||||
circle_x = 300
|
||||
circle_y = 200
|
||||
circle_r = 40
|
||||
|
||||
display.clearDisplay()
|
||||
topText()
|
||||
display.drawCircle(circle_x, circle_y, circle_r, display.BLACK)
|
||||
display.display()
|
|
@ -0,0 +1,19 @@
|
|||
import machine
|
||||
import time
|
||||
from inkplate6_COLOR import Inkplate
|
||||
|
||||
|
||||
display = Inkplate()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Waking up")
|
||||
|
||||
display.begin()
|
||||
display.display()
|
||||
display.setPanelDeepSleepState(1)
|
||||
|
||||
time.sleep(5)
|
||||
display.begin()
|
||||
display.printText(100, 100, "aaaaa", Inkplate.BLACK)
|
||||
display.display()
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,301 @@
|
|||
Board Name FQBN
|
||||
AI Thinker ESP32-CAM esp32:esp32:esp32cam
|
||||
AI Thinker ESP32-CAM espressif:esp32:esp32cam
|
||||
ALKS ESP32 espressif:esp32:alksesp32
|
||||
ALKS ESP32 esp32:esp32:alksesp32
|
||||
ATMegaZero ESP32-S2 espressif:esp32:atmegazero_esp32s2
|
||||
ATMegaZero ESP32-S2 esp32:esp32:atmegazero_esp32s2
|
||||
ATtiny1634 (No bootloader) ATTinyCore:avr:attiny1634
|
||||
ATtiny1634 (Optiboot) ATTinyCore:avr:attiny1634opti
|
||||
ATtiny167 (Micronucleus / DigiSpark Pro) ATTinyCore:avr:attinyx7micr
|
||||
ATtiny167/87 (Optiboot) ATTinyCore:avr:attinyx7opti
|
||||
ATtiny2313(a)/4313 (No bootloader) ATTinyCore:avr:attinyx313
|
||||
ATtiny24/44/84(a) (No bootloader) ATTinyCore:avr:attinyx4
|
||||
ATtiny25/45/85 (No bootloader) ATTinyCore:avr:attinyx5
|
||||
ATtiny261/461/861(a) ATTinyCore:avr:attinyx61
|
||||
ATtiny43 (No bootloader) ATTinyCore:avr:attiny43
|
||||
ATtiny44/84(a) (Optiboot) ATTinyCore:avr:attinyx4opti
|
||||
ATtiny441/841 (No bootloader) ATTinyCore:avr:attinyx41
|
||||
ATtiny441/841 (Optiboot) ATTinyCore:avr:attinyx41opti
|
||||
ATtiny45/85 (Optiboot) ATTinyCore:avr:attinyx5opti
|
||||
ATtiny461/861(a) (Optiboot) ATTinyCore:avr:attinyx61opti
|
||||
ATtiny48/88 (No bootloader) ATTinyCore:avr:attinyx8
|
||||
ATtiny48/88 (Optiboot) ATTinyCore:avr:attinyx8opti
|
||||
ATtiny828 (No bootloader) ATTinyCore:avr:attiny828
|
||||
ATtiny828 (Optiboot) ATTinyCore:avr:attiny828opti
|
||||
ATtiny841 (Micronucleus / Wattuino) ATTinyCore:avr:attinyx41micr
|
||||
ATtiny84a (Micronucleus / California STEAM) ATTinyCore:avr:attinyx4micr
|
||||
ATtiny85 (Micronucleus / DigiSpark) ATTinyCore:avr:attinyx5micr
|
||||
ATtiny87/167 (No bootloader) ATTinyCore:avr:attinyx7
|
||||
ATtiny88 (Micronucleus, MH-ET t88 w/16MHz CLOCK) ATTinyCore:avr:attinyx8micr
|
||||
Adafruit Circuit Playground arduino:avr:circuitplay32u4cat
|
||||
Adafruit ESP32 Feather espressif:esp32:featheresp32
|
||||
Adafruit ESP32 Feather esp32:esp32:featheresp32
|
||||
Adafruit Feather ESP32-S2 espressif:esp32:adafruit_feather_esp32s2
|
||||
Adafruit Feather ESP32-S2 esp32:esp32:adafruit_feather_esp32s2
|
||||
Adafruit Feather ESP32-S2 TFT esp32:esp32:adafruit_feather_esp32s2_tft
|
||||
Adafruit Feather ESP32-S2 TFT espressif:esp32:adafruit_feather_esp32s2_tft
|
||||
Adafruit FunHouse espressif:esp32:adafruit_funhouse_esp32s2
|
||||
Adafruit FunHouse esp32:esp32:adafruit_funhouse_esp32s2
|
||||
Adafruit MagTag 2.9" esp32:esp32:adafruit_magtag29_esp32s2
|
||||
Adafruit MagTag 2.9" espressif:esp32:adafruit_magtag29_esp32s2
|
||||
Adafruit Metro ESP32-S2 esp32:esp32:adafruit_metro_esp32s2
|
||||
Adafruit Metro ESP32-S2 espressif:esp32:adafruit_metro_esp32s2
|
||||
Adafruit QT Py ESP32-S2 espressif:esp32:adafruit_qtpy_esp32s2
|
||||
Adafruit QT Py ESP32-S2 esp32:esp32:adafruit_qtpy_esp32s2
|
||||
Arduino BT arduino:avr:bt
|
||||
Arduino Duemilanove or Diecimila arduino:avr:diecimila
|
||||
Arduino Esplora arduino:avr:esplora
|
||||
Arduino Ethernet arduino:avr:ethernet
|
||||
Arduino Fio arduino:avr:fio
|
||||
Arduino Gemma arduino:avr:gemma
|
||||
Arduino Industrial 101 arduino:avr:chiwawa
|
||||
Arduino Leonardo arduino:avr:leonardo
|
||||
Arduino Leonardo ETH arduino:avr:leonardoeth
|
||||
Arduino Mega ADK arduino:avr:megaADK
|
||||
Arduino Mega or Mega 2560 arduino:avr:mega
|
||||
Arduino Micro arduino:avr:micro
|
||||
Arduino Mini arduino:avr:mini
|
||||
Arduino NG or older arduino:avr:atmegang
|
||||
Arduino Nano arduino:avr:nano
|
||||
Arduino Pro or Pro Mini arduino:avr:pro
|
||||
Arduino Robot Control arduino:avr:robotControl
|
||||
Arduino Robot Motor arduino:avr:robotMotor
|
||||
Arduino Uno arduino:avr:uno
|
||||
Arduino Uno Mini arduino:avr:unomini
|
||||
Arduino Uno WiFi arduino:avr:unowifi
|
||||
Arduino Yún arduino:avr:yun
|
||||
Arduino Yún Mini arduino:avr:yunmini
|
||||
BPI-BIT esp32:esp32:bpi-bit
|
||||
BPI-BIT espressif:esp32:bpi-bit
|
||||
D-duino-32 esp32:esp32:d-duino-32
|
||||
D-duino-32 espressif:esp32:d-duino-32
|
||||
DOIT ESP32 DEVKIT V1 espressif:esp32:esp32doit-devkit-v1
|
||||
DOIT ESP32 DEVKIT V1 esp32:esp32:esp32doit-devkit-v1
|
||||
DOIT ESPduino32 espressif:esp32:esp32doit-espduino
|
||||
DOIT ESPduino32 esp32:esp32:esp32doit-espduino
|
||||
DPU ESP32 esp32:esp32:dpu_esp32
|
||||
DPU ESP32 espressif:esp32:dpu_esp32
|
||||
Dasduino ConnectPlus (ESP32) Dasduino_Boards:esp32:connectplus
|
||||
Dasduino ConnectPlus LoRa ESP32 Dasduino_Boards:esp32:lora32
|
||||
Deneyap Kart espressif:esp32:deneyapkart
|
||||
Deneyap Kart esp32:esp32:deneyapkart
|
||||
Deneyap Mini espressif:esp32:deneyapmini
|
||||
Deneyap Mini esp32:esp32:deneyapmini
|
||||
Denky espressif:esp32:ch_denky
|
||||
Denky esp32:esp32:ch_denky
|
||||
Dongsen Tech Pocket 32 esp32:esp32:pocket_32
|
||||
Dongsen Tech Pocket 32 espressif:esp32:pocket_32
|
||||
ESP32 Dev Module espressif:esp32:esp32
|
||||
ESP32 Dev Module esp32:esp32:esp32
|
||||
ESP32 FM DevKit espressif:esp32:fm-devkit
|
||||
ESP32 FM DevKit esp32:esp32:fm-devkit
|
||||
ESP32 PICO-D4 espressif:esp32:pico32
|
||||
ESP32 PICO-D4 esp32:esp32:pico32
|
||||
ESP32 Wrover Kit (all versions) espressif:esp32:esp32wroverkit
|
||||
ESP32 Wrover Kit (all versions) esp32:esp32:esp32wroverkit
|
||||
ESP32 Wrover Module espressif:esp32:esp32wrover
|
||||
ESP32 Wrover Module esp32:esp32:esp32wrover
|
||||
ESP32C3 Dev Module esp32:esp32:esp32c3
|
||||
ESP32C3 Dev Module espressif:esp32:esp32c3
|
||||
ESP32S2 Dev Module esp32:esp32:esp32s2
|
||||
ESP32S2 Dev Module espressif:esp32:esp32s2
|
||||
ESP32S2 Native USB espressif:esp32:esp32s2usb
|
||||
ESP32S2 Native USB esp32:esp32:esp32s2usb
|
||||
ESP32vn IoT Uno espressif:esp32:esp32vn-iot-uno
|
||||
ESP32vn IoT Uno esp32:esp32:esp32vn-iot-uno
|
||||
ESPea32 esp32:esp32:espea32
|
||||
ESPea32 espressif:esp32:espea32
|
||||
ESPectro32 espressif:esp32:espectro32
|
||||
ESPectro32 esp32:esp32:espectro32
|
||||
ET-Board esp32:esp32:ET-Board
|
||||
ET-Board espressif:esp32:ET-Board
|
||||
Electronic SweetPeas - ESP320 espressif:esp32:esp320
|
||||
Electronic SweetPeas - ESP320 esp32:esp32:esp320
|
||||
FireBeetle-ESP32 espressif:esp32:firebeetle32
|
||||
FireBeetle-ESP32 esp32:esp32:firebeetle32
|
||||
Franzininho WiFi esp32:esp32:franzininho_wifi_esp32s2
|
||||
Franzininho WiFi espressif:esp32:franzininho_wifi_esp32s2
|
||||
Franzininho WiFi MSC esp32:esp32:franzininho_wifi_msc_esp32s2
|
||||
Franzininho WiFi MSC espressif:esp32:franzininho_wifi_msc_esp32s2
|
||||
Frog Board ESP32 esp32:esp32:frogboard
|
||||
Frog Board ESP32 espressif:esp32:frogboard
|
||||
HONEYLemon esp32:esp32:honeylemon
|
||||
HONEYLemon espressif:esp32:honeylemon
|
||||
Heltec WiFi Kit 32 espressif:esp32:heltec_wifi_kit_32
|
||||
Heltec WiFi Kit 32 esp32:esp32:heltec_wifi_kit_32
|
||||
Heltec WiFi LoRa 32 esp32:esp32:heltec_wifi_lora_32
|
||||
Heltec WiFi LoRa 32 espressif:esp32:heltec_wifi_lora_32
|
||||
Heltec WiFi LoRa 32(V2) esp32:esp32:heltec_wifi_lora_32_V2
|
||||
Heltec WiFi LoRa 32(V2) espressif:esp32:heltec_wifi_lora_32_V2
|
||||
Heltec Wireless Stick esp32:esp32:heltec_wireless_stick
|
||||
Heltec Wireless Stick espressif:esp32:heltec_wireless_stick
|
||||
Heltec Wireless Stick Lite espressif:esp32:heltec_wireless_stick_lite
|
||||
Heltec Wireless Stick Lite esp32:esp32:heltec_wireless_stick_lite
|
||||
Hornbill ESP32 Dev esp32:esp32:hornbill32dev
|
||||
Hornbill ESP32 Dev espressif:esp32:hornbill32dev
|
||||
Hornbill ESP32 Minima espressif:esp32:hornbill32minima
|
||||
Hornbill ESP32 Minima esp32:esp32:hornbill32minima
|
||||
IMBRIOS LOGSENS_V1P1 esp32:esp32:imbrios-logsens-v1p1
|
||||
IMBRIOS LOGSENS_V1P1 espressif:esp32:imbrios-logsens-v1p1
|
||||
INEX OpenKB esp32:esp32:OpenKB
|
||||
INEX OpenKB espressif:esp32:OpenKB
|
||||
Inkplate 10 (ESP32) Inkplate_Boards:esp32:Inkplate10
|
||||
Inkplate 5 (ESP32) Inkplate_Boards:esp32:Inkplate5
|
||||
Inkplate 6 (ESP32) Inkplate_Boards:esp32:Inkplate6
|
||||
Inkplate 6COLOR (ESP32) Inkplate_Boards:esp32:Inkplate6COLOR
|
||||
Inkplate 6PLUS (ESP32) Inkplate_Boards:esp32:Inkplate6plus
|
||||
IntoRobot Fig espressif:esp32:intorobot-fig
|
||||
IntoRobot Fig esp32:esp32:intorobot-fig
|
||||
KB32-FT espressif:esp32:kb32
|
||||
KB32-FT esp32:esp32:kb32
|
||||
KITS ESP32 EDU esp32:esp32:kits-edu
|
||||
KITS ESP32 EDU espressif:esp32:kits-edu
|
||||
LOLIN D32 espressif:esp32:d32
|
||||
LOLIN D32 esp32:esp32:d32
|
||||
LOLIN D32 PRO espressif:esp32:d32_pro
|
||||
LOLIN D32 PRO esp32:esp32:d32_pro
|
||||
Labplus mPython esp32:esp32:mPython
|
||||
Labplus mPython espressif:esp32:mPython
|
||||
LilyPad Arduino arduino:avr:lilypad
|
||||
LilyPad Arduino USB arduino:avr:LilyPadUSB
|
||||
Linino One arduino:avr:one
|
||||
LoPy espressif:esp32:lopy
|
||||
LoPy esp32:esp32:lopy
|
||||
LoPy4 espressif:esp32:lopy4
|
||||
LoPy4 esp32:esp32:lopy4
|
||||
M5Stack-ATOM espressif:esp32:m5stack-atom
|
||||
M5Stack-ATOM esp32:esp32:m5stack-atom
|
||||
M5Stack-Core-ESP32 espressif:esp32:m5stack-core-esp32
|
||||
M5Stack-Core-ESP32 esp32:esp32:m5stack-core-esp32
|
||||
M5Stack-Core2 espressif:esp32:m5stack-core2
|
||||
M5Stack-Core2 esp32:esp32:m5stack-core2
|
||||
M5Stack-CoreInk espressif:esp32:m5stack-coreink
|
||||
M5Stack-CoreInk esp32:esp32:m5stack-coreink
|
||||
M5Stack-FIRE espressif:esp32:m5stack-fire
|
||||
M5Stack-FIRE esp32:esp32:m5stack-fire
|
||||
M5Stack-Timer-CAM esp32:esp32:m5stack-timer-cam
|
||||
M5Stack-Timer-CAM espressif:esp32:m5stack-timer-cam
|
||||
M5Stick-C espressif:esp32:m5stick-c
|
||||
M5Stick-C esp32:esp32:m5stick-c
|
||||
MGBOT IOTIK 32A espressif:esp32:mgbot-iotik32a
|
||||
MGBOT IOTIK 32A esp32:esp32:mgbot-iotik32a
|
||||
MGBOT IOTIK 32B espressif:esp32:mgbot-iotik32b
|
||||
MGBOT IOTIK 32B esp32:esp32:mgbot-iotik32b
|
||||
MH ET LIVE ESP32DevKIT espressif:esp32:mhetesp32devkit
|
||||
MH ET LIVE ESP32DevKIT esp32:esp32:mhetesp32devkit
|
||||
MH ET LIVE ESP32MiniKit esp32:esp32:mhetesp32minikit
|
||||
MH ET LIVE ESP32MiniKit espressif:esp32:mhetesp32minikit
|
||||
MagicBit espressif:esp32:magicbit
|
||||
MagicBit esp32:esp32:magicbit
|
||||
Metro ESP-32 esp32:esp32:metro_esp-32
|
||||
Metro ESP-32 espressif:esp32:metro_esp-32
|
||||
Microduino-CoreESP32 espressif:esp32:CoreESP32
|
||||
Microduino-CoreESP32 esp32:esp32:CoreESP32
|
||||
Nano32 esp32:esp32:nano32
|
||||
Nano32 espressif:esp32:nano32
|
||||
Node32s espressif:esp32:node32s
|
||||
Node32s esp32:esp32:node32s
|
||||
NodeMCU-32S esp32:esp32:nodemcu-32s
|
||||
NodeMCU-32S espressif:esp32:nodemcu-32s
|
||||
Noduino Quantum esp32:esp32:quantum
|
||||
Noduino Quantum espressif:esp32:quantum
|
||||
ODROID ESP32 espressif:esp32:odroid_esp32
|
||||
ODROID ESP32 esp32:esp32:odroid_esp32
|
||||
OLIMEX ESP32-DevKit-LiPo espressif:esp32:esp32-DevKitLipo
|
||||
OLIMEX ESP32-DevKit-LiPo esp32:esp32:esp32-DevKitLipo
|
||||
OLIMEX ESP32-EVB esp32:esp32:esp32-evb
|
||||
OLIMEX ESP32-EVB espressif:esp32:esp32-evb
|
||||
OLIMEX ESP32-GATEWAY esp32:esp32:esp32-gateway
|
||||
OLIMEX ESP32-GATEWAY espressif:esp32:esp32-gateway
|
||||
OLIMEX ESP32-PoE esp32:esp32:esp32-poe
|
||||
OLIMEX ESP32-PoE espressif:esp32:esp32-poe
|
||||
OLIMEX ESP32-PoE-ISO esp32:esp32:esp32-poe-iso
|
||||
OLIMEX ESP32-PoE-ISO espressif:esp32:esp32-poe-iso
|
||||
OROCA EduBot espressif:esp32:oroca_edubot
|
||||
OROCA EduBot esp32:esp32:oroca_edubot
|
||||
Onehorse ESP32 Dev Module esp32:esp32:onehorse32dev
|
||||
Onehorse ESP32 Dev Module espressif:esp32:onehorse32dev
|
||||
Piranha ESP-32 espressif:esp32:piranha_esp-32
|
||||
Piranha ESP-32 esp32:esp32:piranha_esp-32
|
||||
ProtoCentral HealthyPi 4 esp32:esp32:healthypi4
|
||||
ProtoCentral HealthyPi 4 espressif:esp32:healthypi4
|
||||
Pycom GPy espressif:esp32:gpy
|
||||
Pycom GPy esp32:esp32:gpy
|
||||
S.ODI Ultra v1 esp32:esp32:S_ODI_Ultra
|
||||
S.ODI Ultra v1 espressif:esp32:S_ODI_Ultra
|
||||
Senses's WEIZEN esp32:esp32:sensesiot_weizen
|
||||
Senses's WEIZEN espressif:esp32:sensesiot_weizen
|
||||
Silicognition wESP32 esp32:esp32:wesp32
|
||||
Silicognition wESP32 espressif:esp32:wesp32
|
||||
Sonoff DUALR3 esp32:esp32:sonoff_dualr3
|
||||
Sonoff DUALR3 espressif:esp32:sonoff_dualr3
|
||||
SparkFun ESP32 MicroMod esp32:esp32:esp32micromod
|
||||
SparkFun ESP32 MicroMod espressif:esp32:esp32micromod
|
||||
SparkFun ESP32 Thing esp32:esp32:esp32thing
|
||||
SparkFun ESP32 Thing espressif:esp32:esp32thing
|
||||
SparkFun ESP32 Thing Plus esp32:esp32:esp32thing_plus
|
||||
SparkFun ESP32 Thing Plus espressif:esp32:esp32thing_plus
|
||||
SparkFun ESP32-S2 Thing Plus espressif:esp32:sparkfun_esp32s2_thing_plus
|
||||
SparkFun ESP32-S2 Thing Plus esp32:esp32:sparkfun_esp32s2_thing_plus
|
||||
SparkFun LoRa Gateway 1-Channel espressif:esp32:sparkfun_lora_gateway_1-channel
|
||||
SparkFun LoRa Gateway 1-Channel esp32:esp32:sparkfun_lora_gateway_1-channel
|
||||
T-Beam espressif:esp32:t-beam
|
||||
T-Beam esp32:esp32:t-beam
|
||||
TTGO LoRa32-OLED espressif:esp32:ttgo-lora32
|
||||
TTGO LoRa32-OLED esp32:esp32:ttgo-lora32
|
||||
TTGO T-OI PLUS RISC-V ESP32-C3 espressif:esp32:ttgo-t-oi-plus
|
||||
TTGO T-OI PLUS RISC-V ESP32-C3 esp32:esp32:ttgo-t-oi-plus
|
||||
TTGO T-Watch espressif:esp32:twatch
|
||||
TTGO T-Watch esp32:esp32:twatch
|
||||
TTGO T1 esp32:esp32:ttgo-t1
|
||||
TTGO T1 espressif:esp32:ttgo-t1
|
||||
TTGO T7 V1.3 Mini32 esp32:esp32:ttgo-t7-v13-mini32
|
||||
TTGO T7 V1.3 Mini32 espressif:esp32:ttgo-t7-v13-mini32
|
||||
TTGO T7 V1.4 Mini32 espressif:esp32:ttgo-t7-v14-mini32
|
||||
TTGO T7 V1.4 Mini32 esp32:esp32:ttgo-t7-v14-mini32
|
||||
ThaiEasyElec's ESPino32 esp32:esp32:espino32
|
||||
ThaiEasyElec's ESPino32 espressif:esp32:espino32
|
||||
Trueverit ESP32 Universal IoT Driver espressif:esp32:esp32-trueverit-iot-driver
|
||||
Trueverit ESP32 Universal IoT Driver esp32:esp32:esp32-trueverit-iot-driver
|
||||
Trueverit ESP32 Universal IoT Driver MK II espressif:esp32:esp32-trueverit-iot-driver-mkii
|
||||
Trueverit ESP32 Universal IoT Driver MK II esp32:esp32:esp32-trueverit-iot-driver-mkii
|
||||
Turta IoT Node esp32:esp32:turta_iot_node
|
||||
Turta IoT Node espressif:esp32:turta_iot_node
|
||||
UM FeatherS2 esp32:esp32:feathers2
|
||||
UM FeatherS2 espressif:esp32:feathers2
|
||||
UM FeatherS2 Neo esp32:esp32:feathers2neo
|
||||
UM FeatherS2 Neo espressif:esp32:feathers2neo
|
||||
UM TinyPICO esp32:esp32:tinypico
|
||||
UM TinyPICO espressif:esp32:tinypico
|
||||
UM TinyS2 esp32:esp32:tinys2
|
||||
UM TinyS2 espressif:esp32:tinys2
|
||||
VintLabs ESP32 Devkit esp32:esp32:vintlabs-devkit-v1
|
||||
VintLabs ESP32 Devkit espressif:esp32:vintlabs-devkit-v1
|
||||
WEMOS D1 MINI ESP32 esp32:esp32:d1_mini32
|
||||
WEMOS D1 MINI ESP32 espressif:esp32:d1_mini32
|
||||
WEMOS LOLIN32 esp32:esp32:lolin32
|
||||
WEMOS LOLIN32 espressif:esp32:lolin32
|
||||
WEMOS LOLIN32 Lite esp32:esp32:lolin32-lite
|
||||
WEMOS LOLIN32 Lite espressif:esp32:lolin32-lite
|
||||
WT32-ETH01 Ethernet Module espressif:esp32:wt32-eth01
|
||||
WT32-ETH01 Ethernet Module esp32:esp32:wt32-eth01
|
||||
WeMos WiFi&Bluetooth Battery esp32:esp32:WeMosBat
|
||||
WeMos WiFi&Bluetooth Battery espressif:esp32:WeMosBat
|
||||
WiFiduino32 esp32:esp32:wifiduino32
|
||||
WiFiduino32 espressif:esp32:wifiduino32
|
||||
WiPy 3.0 espressif:esp32:wipy3
|
||||
WiPy 3.0 esp32:esp32:wipy3
|
||||
Widora AIR espressif:esp32:widora-air
|
||||
Widora AIR esp32:esp32:widora-air
|
||||
XinaBox CW02 espressif:esp32:cw02
|
||||
XinaBox CW02 esp32:esp32:cw02
|
||||
microS2 esp32:esp32:micros2
|
||||
microS2 espressif:esp32:micros2
|
||||
u-blox NINA-W10 series (ESP32) esp32:esp32:nina_w10
|
||||
u-blox NINA-W10 series (ESP32) espressif:esp32:nina_w10
|
||||
uPesy ESP32 Wroom DevKit espressif:esp32:uPesy_wroom
|
||||
uPesy ESP32 Wroom DevKit esp32:esp32:uPesy_wroom
|
||||
uPesy ESP32 Wrover DevKit espressif:esp32:uPesy_wrover
|
||||
uPesy ESP32 Wrover DevKit esp32:esp32:uPesy_wrover
|
||||
|
9
gfx.py
9
gfx.py
|
@ -36,6 +36,8 @@ __version__ = "0.0.0-auto.0"
|
|||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_GFX.git"
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
|
||||
class GFX:
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
"""Create an instance of the GFX drawing class.
|
||||
|
@ -59,6 +61,7 @@ class GFX:
|
|||
The input shoudl be a properly formatted dict.
|
||||
"""
|
||||
# pylint: disable=too-many-arguments
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
width,
|
||||
|
@ -335,7 +338,8 @@ class GFX:
|
|||
self.hline(
|
||||
x0, y0 + height - radius + 1, width - 2 * radius + 1, *args, **kwargs
|
||||
) # bottom
|
||||
self.hline(x0, y0 - radius, width - 2 * radius + 1, *args, **kwargs) # top
|
||||
self.hline(x0, y0 - radius, width - 2 *
|
||||
radius + 1, *args, **kwargs) # top
|
||||
while x < y:
|
||||
if f >= 0:
|
||||
y -= 1
|
||||
|
@ -497,7 +501,8 @@ class GFX:
|
|||
|
||||
# make sure something is sent even if not in font dict
|
||||
try:
|
||||
self._place_char(x_roll, y_roll, char, size, *args, **kwargs)
|
||||
self._place_char(x_roll, y_roll, char,
|
||||
size, *args, **kwargs)
|
||||
except KeyError:
|
||||
self._place_char(
|
||||
x_roll, y_roll, "?CHAR?", size, *args, **kwargs
|
||||
|
|
|
@ -12,7 +12,7 @@ from shapes import Shapes
|
|||
from gfx import GFX
|
||||
from gfx_standard_font_01 import text_dict as std_font
|
||||
|
||||
#Raw display constants for Inkplate 10
|
||||
# Raw display constants for Inkplate 10
|
||||
D_ROWS = const(825)
|
||||
D_COLS = const(1200)
|
||||
|
||||
|
@ -868,7 +868,7 @@ class Inkplate:
|
|||
y -= h - 1
|
||||
(self.ipm.fill_rect if self.displayMode == self.INKPLATE_1BIT else self.ipg.fill_rect)(
|
||||
x, y, w, h, c
|
||||
)
|
||||
)
|
||||
|
||||
def writeFastVLine(self, x, y, h, c):
|
||||
if self.rotation in (1, 3):
|
||||
|
@ -882,7 +882,7 @@ class Inkplate:
|
|||
y -= h - 1
|
||||
(self.ipm.vline if self.displayMode == self.INKPLATE_1BIT else self.ipg.vline)(
|
||||
x, y, h, c
|
||||
)
|
||||
)
|
||||
|
||||
def writeFastHLine(self, x, y, w, c):
|
||||
if self.rotation in (1, 3):
|
||||
|
@ -896,7 +896,7 @@ class Inkplate:
|
|||
x -= w - 1
|
||||
(self.ipm.hline if self.displayMode == self.INKPLATE_1BIT else self.ipg.hline)(
|
||||
x, y, w, c
|
||||
)
|
||||
)
|
||||
|
||||
def writeLine(self, x0, y0, x1, y1, c):
|
||||
self.GFX.line(x0, y0, x1, y1, c)
|
||||
|
|
|
@ -22,7 +22,7 @@ D_COLS = const(800)
|
|||
# Meaning of values: 0=dischg, 1=black, 2=white, 3=skip
|
||||
# Uses "colors" 0 (black), 3, 5, and 7 (white) from 3-bit waveforms below
|
||||
|
||||
#add discharge to waveforms to try to fix them
|
||||
# add discharge to waveforms to try to fix them
|
||||
WAVE_2B = ( # original mpy driver for Ink 6, differs from arduino driver below
|
||||
(0, 0, 0, 0),
|
||||
(0, 0, 0, 0),
|
||||
|
@ -32,9 +32,9 @@ WAVE_2B = ( # original mpy driver for Ink 6, differs from arduino driver below
|
|||
(1, 1, 2, 0),
|
||||
(1, 2, 2, 2),
|
||||
)
|
||||
# Ink6 WAVEFORM3BIT from arduino driver
|
||||
# {{0,1,1,0,0,1,1,0},{0,1,2,1,1,2,1,0},{1,1,1,2,2,1,0,0},{0,0,0,1,1,1,2,0},
|
||||
# {2,1,1,1,2,1,2,0},{2,2,1,1,2,1,2,0},{1,1,1,2,1,2,2,0},{0,0,0,0,0,0,2,0}};
|
||||
# Ink6 WAVEFORM3BIT from arduino driver
|
||||
# {{0,1,1,0,0,1,1,0},{0,1,2,1,1,2,1,0},{1,1,1,2,2,1,0,0},{0,0,0,1,1,1,2,0},
|
||||
# {2,1,1,1,2,1,2,0},{2,2,1,1,2,1,2,0},{1,1,1,2,1,2,2,0},{0,0,0,0,0,0,2,0}};
|
||||
|
||||
TPS65186_addr = const(0x48) # I2C address
|
||||
|
||||
|
|
|
@ -0,0 +1,619 @@
|
|||
# Copyright © 2020 by Thorsten von Eicken.
|
||||
import time
|
||||
import os
|
||||
from machine import ADC, I2C, SPI, Pin, SDCard
|
||||
from micropython import const
|
||||
from shapes import Shapes
|
||||
from mcp23017 import MCP23017
|
||||
from machine import Pin as mPin
|
||||
from gfx import GFX
|
||||
from gfx_standard_font_01 import text_dict as std_font
|
||||
# ===== Constants that change between the Inkplate 6 and 10
|
||||
|
||||
# Connections between ESP32 and color Epaper
|
||||
EPAPER_RST_PIN = const(19)
|
||||
EPAPER_DC_PIN = const(33)
|
||||
EPAPER_CS_PIN = const(27)
|
||||
EPAPER_BUSY_PIN = const(32)
|
||||
EPAPER_CLK = const(18)
|
||||
EPAPER_DIN = const(23)
|
||||
|
||||
# Timeout for init of epaper(1.5 sec in this case)
|
||||
# INIT_TIMEOUT 1500
|
||||
|
||||
pixelMaskGLUT = [0xF, 0xF0]
|
||||
|
||||
# Epaper registers
|
||||
PANEL_SET_REGISTER = "\x00"
|
||||
POWER_SET_REGISTER = "\x01"
|
||||
POWER_OFF_SEQ_SET_REGISTER = "\x03"
|
||||
POWER_OFF_REGISTER = "\x04"
|
||||
BOOSTER_SOFTSTART_REGISTER = "\x06"
|
||||
DEEP_SLEEP_REGISTER = "\x07"
|
||||
DATA_START_TRANS_REGISTER = "\x10"
|
||||
DATA_STOP_REGISTER = "\x11"
|
||||
DISPLAY_REF_REGISTER = "\x12"
|
||||
IMAGE_PROCESS_REGISTER = "\x13"
|
||||
PLL_CONTROL_REGISTER = "\x30"
|
||||
TEMP_SENSOR_REGISTER = "\x40"
|
||||
TEMP_SENSOR_EN_REGISTER = "\x41"
|
||||
TEMP_SENSOR_WR_REGISTER = "\x42"
|
||||
TEMP_SENSOR_RD_REGISTER = "\x43"
|
||||
VCOM_DATA_INTERVAL_REGISTER = "\x50"
|
||||
LOW_POWER_DETECT_REGISTER = "\x51"
|
||||
RESOLUTION_SET_REGISTER = "\x61"
|
||||
STATUS_REGISTER = "\x71"
|
||||
VCOM_VALUE_REGISTER = "\x81"
|
||||
VCM_DC_SET_REGISTER = "\x02"
|
||||
|
||||
# Epaper resolution and colors
|
||||
D_COLS = const(600)
|
||||
D_ROWS = const(448)
|
||||
|
||||
MCP23017_INT_ADDR = const(0x20)
|
||||
MCP23017_EXT_ADDR = const(0x20)
|
||||
|
||||
MCP23017_INT_PORTA = const(0x00)
|
||||
MCP23017_INT_PORTB = const(0x01)
|
||||
MCP23017_INT_NO_MIRROR = False
|
||||
MCP23017_INT_MIRROR = True
|
||||
MCP23017_INT_PUSHPULL = False
|
||||
MCP23017_INT_OPENDRAIN = True
|
||||
MCP23017_INT_ACTLOW = False
|
||||
MCP23017_INT_ACTHIGH = True
|
||||
|
||||
MCP23017_IODIRA = const(0x00)
|
||||
MCP23017_IPOLA = const(0x02)
|
||||
MCP23017_GPINTENA = const(0x04)
|
||||
MCP23017_DEFVALA = const(0x06)
|
||||
MCP23017_INTCONA = const(0x08)
|
||||
MCP23017_IOCONA = const(0x0A)
|
||||
MCP23017_GPPUA = const(0x0C)
|
||||
MCP23017_INTFA = const(0x0E)
|
||||
MCP23017_INTCAPA = const(0x10)
|
||||
MCP23017_GPIOA = const(0x12)
|
||||
MCP23017_OLATA = const(0x14)
|
||||
|
||||
MCP23017_IODIRB = const(0x01)
|
||||
MCP23017_IPOLB = const(0x03)
|
||||
MCP23017_GPINTENB = const(0x05)
|
||||
MCP23017_DEFVALB = const(0x07)
|
||||
MCP23017_INTCONB = const(0x09)
|
||||
MCP23017_IOCONB = const(0x0B)
|
||||
MCP23017_GPPUB = const(0x0D)
|
||||
MCP23017_INTFB = const(0x0F)
|
||||
MCP23017_INTCAPB = const(0x11)
|
||||
MCP23017_GPIOB = const(0x13)
|
||||
MCP23017_OLATB = const(0x15)
|
||||
|
||||
# User pins on MCP for Inkplate COLOR
|
||||
MCP23017_PIN_A0 = const(0)
|
||||
MCP23017_PIN_A1 = const(1)
|
||||
MCP23017_PIN_A2 = const(2)
|
||||
MCP23017_PIN_A3 = const(3)
|
||||
MCP23017_PIN_A4 = const(4)
|
||||
MCP23017_PIN_A5 = const(5)
|
||||
MCP23017_PIN_A6 = const(6)
|
||||
MCP23017_PIN_A7 = const(7)
|
||||
|
||||
MCP23017_PIN_B0 = const(8)
|
||||
MCP23017_PIN_B1 = const(9)
|
||||
MCP23017_PIN_B2 = const(10)
|
||||
MCP23017_PIN_B3 = const(11)
|
||||
MCP23017_PIN_B4 = const(12)
|
||||
MCP23017_PIN_B5 = const(13)
|
||||
MCP23017_PIN_B6 = const(14)
|
||||
MCP23017_PIN_B7 = const(15)
|
||||
|
||||
|
||||
class Inkplate:
|
||||
BLACK = const(0b00000000)
|
||||
WHITE = const(0b00000001)
|
||||
GREEN = const(0b00000010)
|
||||
BLUE = const(0b00000011)
|
||||
RED = const(0b00000100)
|
||||
YELLOW = const(0b00000101)
|
||||
ORANGE = const(0b00000110)
|
||||
|
||||
_width = D_COLS
|
||||
_height = D_ROWS
|
||||
|
||||
rotation = 0
|
||||
textSize = 1
|
||||
|
||||
_panelState = False
|
||||
|
||||
_framebuf = bytearray([0x11] * (D_COLS * D_ROWS // 2))
|
||||
|
||||
@classmethod
|
||||
def __init__(self):
|
||||
try:
|
||||
os.mount(
|
||||
SDCard(
|
||||
slot=3,
|
||||
miso=Pin(12),
|
||||
mosi=Pin(13),
|
||||
sck=Pin(14),
|
||||
cs=Pin(15)),
|
||||
"/sd"
|
||||
)
|
||||
except:
|
||||
print("Sd card could not be read")
|
||||
|
||||
@classmethod
|
||||
def begin(self):
|
||||
self.wire = I2C(0, scl=Pin(22), sda=Pin(21))
|
||||
self._mcp23017 = MCP23017(self.wire)
|
||||
self.TOUCH1 = self._mcp23017.pin(10, Pin.IN)
|
||||
self.TOUCH2 = self._mcp23017.pin(11, Pin.IN)
|
||||
self.TOUCH3 = self._mcp23017.pin(12, Pin.IN)
|
||||
|
||||
self.spi = SPI(2)
|
||||
|
||||
self.spi.init(baudrate=2000000, firstbit=SPI.MSB, polarity=0, phase=0)
|
||||
|
||||
self.EPAPER_BUSY_PIN = Pin(EPAPER_BUSY_PIN, Pin.IN)
|
||||
self.EPAPER_RST_PIN = Pin(EPAPER_RST_PIN, Pin.OUT)
|
||||
self.EPAPER_DC_PIN = Pin(EPAPER_DC_PIN, Pin.OUT)
|
||||
self.EPAPER_CS_PIN = Pin(EPAPER_CS_PIN, Pin.OUT)
|
||||
|
||||
self.framebuf = bytearray(D_ROWS * D_COLS // 2)
|
||||
|
||||
self.GFX = GFX(
|
||||
D_COLS,
|
||||
D_ROWS,
|
||||
self.writePixel,
|
||||
self.writeFastHLine,
|
||||
self.writeFastVLine,
|
||||
self.writeFillRect,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
|
||||
self.resetPanel()
|
||||
|
||||
_timeout = time.ticks_ms()
|
||||
while not self.EPAPER_BUSY_PIN.value() and (time.ticks_ms() - _timeout) < 10000:
|
||||
pass
|
||||
|
||||
if not self.EPAPER_BUSY_PIN.value():
|
||||
return False
|
||||
|
||||
self.sendCommand(PANEL_SET_REGISTER)
|
||||
self.sendData(b"\xef\x08")
|
||||
self.sendCommand(POWER_SET_REGISTER)
|
||||
self.sendData(b"\x37\x00\x23\x23")
|
||||
self.sendCommand(POWER_OFF_SEQ_SET_REGISTER)
|
||||
self.sendData(b"\x00")
|
||||
self.sendCommand(BOOSTER_SOFTSTART_REGISTER)
|
||||
self.sendData(b"\xc7\xc7\x1d")
|
||||
self.sendCommand(PLL_CONTROL_REGISTER)
|
||||
self.sendData(b"\x3c")
|
||||
self.sendCommand(TEMP_SENSOR_REGISTER)
|
||||
self.sendData(b"\x00")
|
||||
self.sendCommand(VCOM_DATA_INTERVAL_REGISTER)
|
||||
self.sendData(b"\x37")
|
||||
self.sendCommand(b"\x60")
|
||||
self.sendData(b"\x20")
|
||||
self.sendCommand(RESOLUTION_SET_REGISTER)
|
||||
self.sendData(b"\x02\x58\x01\xc0")
|
||||
self.sendCommand(b"\xE3")
|
||||
self.sendData(b"\xaa")
|
||||
|
||||
time.sleep_ms(100)
|
||||
|
||||
self.sendCommand(b"\x50")
|
||||
self.sendData(b"\x37")
|
||||
|
||||
self.setMCPForLowPower()
|
||||
|
||||
self._panelState = True
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def setMCPForLowPower(self):
|
||||
self._mcp23017.pin(10, mode=mPin.IN)
|
||||
self._mcp23017.pin(11, mode=mPin.IN)
|
||||
self._mcp23017.pin(12, mode=mPin.IN)
|
||||
|
||||
self._mcp23017.pin(9, value=0, mode=mPin.OUT)
|
||||
|
||||
for x in range(8):
|
||||
self._mcp23017.pin(x, value=0, mode=mPin.OUT)
|
||||
self._mcp23017.pin(8, value=0, mode=mPin.OUT)
|
||||
self._mcp23017.pin(13, value=0, mode=mPin.OUT)
|
||||
self._mcp23017.pin(14, value=0, mode=mPin.OUT)
|
||||
self._mcp23017.pin(15, value=0, mode=mPin.OUT)
|
||||
|
||||
@classmethod
|
||||
def getPanelDeepSleepState(self):
|
||||
return self._panelState
|
||||
|
||||
@classmethod
|
||||
def setPanelDeepSleepState(self, state):
|
||||
_panelState = False if state == 0 else True
|
||||
|
||||
if _panelState:
|
||||
self.begin()
|
||||
else:
|
||||
time.sleep_ms(10)
|
||||
self.sendCommand(DEEP_SLEEP_REGISTER)
|
||||
self.sendData(b"\xA5")
|
||||
time.sleep_ms(100)
|
||||
EPAPER_RST_PIN.value(0)
|
||||
EPAPER_DC_PIN.value(0)
|
||||
EPAPER_CS_PIN.value(0)
|
||||
|
||||
@classmethod
|
||||
def resetPanel(self):
|
||||
self.EPAPER_RST_PIN.value(0)
|
||||
time.sleep_ms(1)
|
||||
self.EPAPER_RST_PIN.value(1)
|
||||
time.sleep_ms(1)
|
||||
|
||||
@classmethod
|
||||
def sendCommand(self, command):
|
||||
self.EPAPER_DC_PIN.value(0)
|
||||
self.EPAPER_CS_PIN.value(0)
|
||||
|
||||
self.spi.write(command)
|
||||
|
||||
self.EPAPER_CS_PIN.value(1)
|
||||
|
||||
@classmethod
|
||||
def sendData(self, data):
|
||||
self.EPAPER_DC_PIN.value(1)
|
||||
self.EPAPER_CS_PIN.value(0)
|
||||
|
||||
self.spi.write(data)
|
||||
|
||||
self.EPAPER_CS_PIN.value(1)
|
||||
|
||||
@classmethod
|
||||
def clearDisplay(self):
|
||||
self._framebuf = bytearray([0x11] * (D_COLS * D_ROWS // 2))
|
||||
|
||||
@classmethod
|
||||
def display(self):
|
||||
if not self._panelState:
|
||||
return
|
||||
|
||||
self.sendCommand(b"\x61")
|
||||
self.sendData(b"\x02\x58\x01\xc0")
|
||||
|
||||
self.sendCommand(b"\x10")
|
||||
|
||||
self.EPAPER_DC_PIN.value(1)
|
||||
self.EPAPER_CS_PIN.value(0)
|
||||
|
||||
self.spi.write(self._framebuf)
|
||||
|
||||
self.EPAPER_CS_PIN.value(1)
|
||||
|
||||
self.sendCommand(POWER_OFF_REGISTER)
|
||||
while not self.EPAPER_BUSY_PIN.value():
|
||||
pass
|
||||
|
||||
self.sendCommand(DISPLAY_REF_REGISTER)
|
||||
while not self.EPAPER_BUSY_PIN.value():
|
||||
pass
|
||||
|
||||
self.sendCommand(POWER_OFF_REGISTER)
|
||||
while self.EPAPER_BUSY_PIN.value():
|
||||
pass
|
||||
|
||||
time.sleep_ms(200)
|
||||
|
||||
@classmethod
|
||||
def clean(self):
|
||||
if not self._panelState:
|
||||
return
|
||||
|
||||
self.sendCommand(b"\x61")
|
||||
self.sendData(b"\x02\x58\x01\xc0")
|
||||
|
||||
self.sendCommand(b"\x10")
|
||||
|
||||
self.EPAPER_DC_PIN.value(1)
|
||||
self.EPAPER_CS_PIN.value(0)
|
||||
|
||||
self.spi.write(bytearray(0x11 for x in range(D_COLS * D_ROWS // 2)))
|
||||
|
||||
self.EPAPER_CS_PIN.value(1)
|
||||
|
||||
self.sendCommand(POWER_OFF_REGISTER)
|
||||
while not self.EPAPER_BUSY_PIN.value():
|
||||
pass
|
||||
|
||||
self.sendCommand(DISPLAY_REF_REGISTER)
|
||||
while not self.EPAPER_BUSY_PIN.value():
|
||||
pass
|
||||
|
||||
self.sendCommand(POWER_OFF_REGISTER)
|
||||
while self.EPAPER_BUSY_PIN.value():
|
||||
pass
|
||||
|
||||
time.sleep_ms(200)
|
||||
|
||||
@classmethod
|
||||
def width(self):
|
||||
return self._width
|
||||
|
||||
@classmethod
|
||||
def height(self):
|
||||
return self._height
|
||||
|
||||
# Arduino compatibility functions
|
||||
@classmethod
|
||||
def setRotation(self, x):
|
||||
self.rotation = x % 4
|
||||
if self.rotation == 0 or self.rotation == 2:
|
||||
self._width = D_COLS
|
||||
self._height = D_ROWS
|
||||
elif self.rotation == 1 or self.rotation == 3:
|
||||
self._width = D_ROWS
|
||||
self._height = D_COLS
|
||||
|
||||
@classmethod
|
||||
def getRotation(self):
|
||||
return self.rotation
|
||||
|
||||
@classmethod
|
||||
def drawPixel(self, x, y, c):
|
||||
self.startWrite()
|
||||
self.writePixel(x, y, c)
|
||||
self.endWrite()
|
||||
|
||||
@classmethod
|
||||
def startWrite(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def writePixel(self, x, y, c):
|
||||
if x > self.width() - 1 or y > self.height() - 1 or x < 0 or y < 0:
|
||||
return
|
||||
if self.rotation == 1:
|
||||
x, y = y, x
|
||||
x = self.height() - x - 1
|
||||
elif self.rotation == 0:
|
||||
x = self.width() - x - 1
|
||||
y = self.height() - y - 1
|
||||
elif self.rotation == 3:
|
||||
x, y = y, x
|
||||
y = self.width() - y - 1
|
||||
|
||||
_x = x // 2
|
||||
_x_sub = x % 2
|
||||
|
||||
temp = self._framebuf[D_COLS * y // 2 + _x]
|
||||
self._framebuf[D_COLS * y // 2 + _x] = (pixelMaskGLUT[_x_sub] & temp) |\
|
||||
(c if _x_sub else c << 4)
|
||||
|
||||
@classmethod
|
||||
def writeFillRect(self, x, y, w, h, c):
|
||||
for j in range(w):
|
||||
for i in range(h):
|
||||
self.writePixel(x + j, y + i, c)
|
||||
|
||||
@classmethod
|
||||
def writeFastVLine(self, x, y, h, c):
|
||||
for i in range(h):
|
||||
self.writePixel(x, y + i, c)
|
||||
|
||||
@classmethod
|
||||
def writeFastHLine(self, x, y, w, c):
|
||||
for i in range(w):
|
||||
self.writePixel(x + i, y, c)
|
||||
|
||||
@classmethod
|
||||
def writeLine(self, x0, y0, x1, y1, c):
|
||||
self.GFX.line(x0, y0, x1, y1, c)
|
||||
|
||||
@classmethod
|
||||
def endWrite(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def drawFastVLine(self, x, y, h, c):
|
||||
self.startWrite()
|
||||
self.writeFastVLine(x, y, h, c)
|
||||
self.endWrite()
|
||||
|
||||
@classmethod
|
||||
def drawFastHLine(self, x, y, w, c):
|
||||
self.startWrite()
|
||||
self.writeFastHLine(x, y, w, c)
|
||||
self.endWrite()
|
||||
|
||||
@classmethod
|
||||
def fillRect(self, x, y, w, h, c):
|
||||
self.startWrite()
|
||||
self.writeFillRect(x, y, w, h, c)
|
||||
self.endWrite()
|
||||
|
||||
@classmethod
|
||||
def fillScreen(self, c):
|
||||
self.fillRect(0, 0, self.width(), self.height(), c)
|
||||
|
||||
@classmethod
|
||||
def drawLine(self, x0, y0, x1, y1, c):
|
||||
self.startWrite()
|
||||
self.writeLine(x0, y0, x1, y1, c)
|
||||
self.endWrite()
|
||||
|
||||
@classmethod
|
||||
def drawRect(self, x, y, w, h, c):
|
||||
self.GFX.rect(x, y, w, h, c)
|
||||
|
||||
@classmethod
|
||||
def drawCircle(self, x, y, r, c):
|
||||
self.GFX.circle(x, y, r, c)
|
||||
|
||||
@classmethod
|
||||
def fillCircle(self, x, y, r, c):
|
||||
self.GFX.fill_circle(x, y, r, c)
|
||||
|
||||
@classmethod
|
||||
def drawTriangle(self, x0, y0, x1, y1, x2, y2, c):
|
||||
self.GFX.triangle(x0, y0, x1, y1, x2, y2, c)
|
||||
|
||||
@classmethod
|
||||
def fillTriangle(self, x0, y0, x1, y1, x2, y2, c):
|
||||
self.GFX.fill_triangle(x0, y0, x1, y1, x2, y2, c)
|
||||
|
||||
@classmethod
|
||||
def drawRoundRect(self, x, y, q, h, r, c):
|
||||
self.GFX.round_rect(x, y, q, h, r, c)
|
||||
|
||||
@classmethod
|
||||
def fillRoundRect(self, x, y, q, h, r, c):
|
||||
self.GFX.fill_round_rect(x, y, q, h, r, c)
|
||||
|
||||
@classmethod
|
||||
def setDisplayMode(self, mode):
|
||||
self.displayMode = mode
|
||||
|
||||
@classmethod
|
||||
def selectDisplayMode(self, mode):
|
||||
self.displayMode = mode
|
||||
|
||||
@classmethod
|
||||
def getDisplayMode(self):
|
||||
return self.displayMode
|
||||
|
||||
@classmethod
|
||||
def setTextSize(self, s):
|
||||
self.textSize = s
|
||||
|
||||
@classmethod
|
||||
def setFont(self, f):
|
||||
self.GFX.font = f
|
||||
|
||||
@classmethod
|
||||
def printText(self, x, y, s, c=BLACK):
|
||||
self.GFX._very_slow_text(x, y, s, self.textSize, c)
|
||||
|
||||
@classmethod
|
||||
def readBattery(self):
|
||||
self.VBAT_EN.value(0)
|
||||
# Probably don't need to delay since Micropython is slow, but we do it anyway
|
||||
time.sleep_ms(1)
|
||||
value = self.VBAT.read()
|
||||
self.VBAT_EN.value(1)
|
||||
result = (value / 4095.0) * 1.1 * 3.548133892 * 2
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def drawBitmap(self, x, y, data, w, h, c=BLACK):
|
||||
byteWidth = (w + 7) // 8
|
||||
byte = 0
|
||||
self.startWrite()
|
||||
for j in range(h):
|
||||
for i in range(w):
|
||||
if i & 7:
|
||||
byte <<= 1
|
||||
else:
|
||||
byte = data[j * byteWidth + i // 8]
|
||||
if byte & 0x80:
|
||||
self.writePixel(x + i, y + j, c)
|
||||
self.endWrite()
|
||||
|
||||
# @classmethod
|
||||
# def drawImageFile(self, x, y, path, invert=False):
|
||||
# with open(path, "rb") as f:
|
||||
# header14 = f.read(14)
|
||||
# if header14[0] != 0x42 or header14[1] != 0x4D:
|
||||
# return 0
|
||||
# header40 = f.read(40)
|
||||
|
||||
# w = int(
|
||||
# (header40[7] << 24)
|
||||
# + (header40[6] << 16)
|
||||
# + (header40[5] << 8)
|
||||
# + header40[4]
|
||||
# )
|
||||
# h = int(
|
||||
# (header40[11] << 24)
|
||||
# + (header40[10] << 16)
|
||||
# + (header40[9] << 8)
|
||||
# + header40[8]
|
||||
# )
|
||||
# dataStart = int((header14[11] << 8) + header14[10])
|
||||
|
||||
# depth = int((header40[15] << 8) + header40[14])
|
||||
# totalColors = int((header40[33] << 8) + header40[32])
|
||||
|
||||
# rowSize = 4 * ((depth * w + 31) // 32)
|
||||
|
||||
# if totalColors == 0:
|
||||
# totalColors = 1 << depth
|
||||
|
||||
# palette = None
|
||||
|
||||
# if depth <= 8:
|
||||
# palette = [0 for i in range(totalColors)]
|
||||
# p = f.read(totalColors * 4)
|
||||
# for i in range(totalColors):
|
||||
# palette[i] = (
|
||||
# 54 * p[i * 4] + 183 * p[i * 4 + 1] + 19 * p[i * 4 + 2]
|
||||
# ) >> 14
|
||||
# # print(palette)
|
||||
# f.seek(dataStart)
|
||||
# for j in range(h):
|
||||
# # print(100 * j // h, "% complete")
|
||||
# buffer = f.read(rowSize)
|
||||
# for i in range(w):
|
||||
# val = 0
|
||||
# if depth == 1:
|
||||
# px = int(
|
||||
# invert
|
||||
# ^ (palette[0] < palette[1])
|
||||
# ^ bool(buffer[i >> 3] & (1 << (7 - i & 7)))
|
||||
# )
|
||||
# val = palette[px]
|
||||
# elif depth == 4:
|
||||
# px = (buffer[i >> 1] & (0x0F if i & 1 == 1 else 0xF0)) >> (
|
||||
# 0 if i & 1 else 4
|
||||
# )
|
||||
# val = palette[px]
|
||||
# if invert:
|
||||
# val = 3 - val
|
||||
# elif depth == 8:
|
||||
# px = buffer[i]
|
||||
# val = palette[px]
|
||||
# if invert:
|
||||
# val = 3 - val
|
||||
# elif depth == 16:
|
||||
# px = (buffer[(i << 1) | 1] << 8) | buffer[(i << 1)]
|
||||
|
||||
# r = (px & 0x7C00) >> 7
|
||||
# g = (px & 0x3E0) >> 2
|
||||
# b = (px & 0x1F) << 3
|
||||
|
||||
# val = (54 * r + 183 * g + 19 * b) >> 14
|
||||
|
||||
# if invert:
|
||||
# val = 3 - val
|
||||
# elif depth == 24:
|
||||
# r = buffer[i * 3]
|
||||
# g = buffer[i * 3 + 1]
|
||||
# b = buffer[i * 3 + 2]
|
||||
|
||||
# val = (54 * r + 183 * g + 19 * b) >> 14
|
||||
|
||||
# if invert:
|
||||
# val = 3 - val
|
||||
# elif depth == 32:
|
||||
# r = buffer[i * 4]
|
||||
# g = buffer[i * 4 + 1]
|
||||
# b = buffer[i * 4 + 2]
|
||||
|
||||
# val = (54 * r + 183 * g + 19 * b) >> 14
|
||||
|
||||
# if invert:
|
||||
# val = 3 - val
|
||||
|
||||
# if self.getDisplayMode() == self.INKPLATE_1BIT:
|
||||
# val >>= 1
|
||||
|
||||
# self.drawPixel(x + i, y + h - j, val)
|
|
@ -0,0 +1,30 @@
|
|||
from inkplate6_COLOR import Inkplate
|
||||
from image import *
|
||||
import time
|
||||
|
||||
display = Inkplate()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Must be called before using, line in Arduino
|
||||
display.begin()
|
||||
|
||||
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.GREEN)
|
||||
display.drawCircle(200, 200, 30, display.BLUE)
|
||||
display.fillCircle(300, 300, 30, display.BLACK)
|
||||
display.drawFastHLine(20, 100, 50, display.BLACK)
|
||||
display.drawFastVLine(100, 20, 50, display.ORANGE)
|
||||
display.drawLine(100, 100, 400, 400, display.ORANGE)
|
||||
display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK)
|
||||
display.fillRoundRect(10, 100, 100, 100, 10, display.YELLOW)
|
||||
display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK)
|
||||
|
||||
# Draws image from bytearray
|
||||
display.setRotation(0)
|
||||
display.drawBitmap(10, 160, image, 576, 100, display.BLUE)
|
||||
display.display()
|
Loading…
Reference in New Issue