Merge branch 'dev'

master
Robert Sorić 2023-06-07 12:40:03 +02:00
commit 1db0e2bcb4
24 changed files with 123 additions and 81 deletions

View File

@ -1,5 +1,5 @@
from inkplate5 import Inkplate
from image import *
from soldered_logo import *
import time
display = Inkplate(Inkplate.INKPLATE_1BIT)
@ -33,9 +33,10 @@ if __name__ == "__main__":
display.display()
time.sleep(5)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(250, 420, image, 576, 100)
# Draws image from bytearray
# Parameters are X position, Y position, the byte array, and the exact dimensions of the image (width, height)
display.drawBitmap(374, 248, soldered_logo, 211, 44)
#Use display.partialUpdate instead of display.display() to draw only updated pixels
display.partialUpdate()

View File

@ -1,7 +1,7 @@
# Include needed libraries
from inkplate5 import Inkplate
from image import *
from soldered_logo import *
import time
@ -26,8 +26,9 @@ if __name__ == "__main__":
display.display()
time.sleep(3)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
# Draws image from bytearray
# Parameters are X position, Y position, the byte array, and the exact dimensions of the image (width, height)
display.drawBitmap(374, 248, soldered_logo, 211, 44)
display.display()
time.sleep(10)

View File

@ -14,7 +14,6 @@ if __name__ == "__main__":
display.printText(100, 100, "batt: " + battery + "V")
display.display()
temperature = str(display.readTemperature())
display.setTextSize(2)

View File

@ -4,6 +4,9 @@ from inkplate5 import Inkplate
display = Inkplate(Inkplate.INKPLATE_2BIT)
display.begin()
# SD Card must be initialised with this function
display.initSDCard()
# This prints all the files on card
print(os.listdir("/sd"))
@ -18,4 +21,9 @@ time.sleep(5)
# Utterly slow, can take minutes :(
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()
display.display()

View File

@ -14,7 +14,6 @@ if __name__ == "__main__":
display.printText(100, 100, "batt: " + battery + "V")
display.display()
temperature = str(display.readTemperature())
display.setTextSize(2)

View File

@ -2,8 +2,8 @@ import network
import time
from inkplate6 import Inkplate
ssid = "e-radionica.com"
password = "croduino"
ssid = ""
password = ""
# More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html
def do_connect():

View File

@ -1,5 +1,5 @@
from soldered_inkplate10 import Inkplate
from image import *
from soldered_logo import *
import time
display = Inkplate(Inkplate.INKPLATE_1BIT)
@ -28,12 +28,13 @@ if __name__ == "__main__":
if display.rotation % 2 == 0:
display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK)
display.display()
time.sleep(5)
display.display()
time.sleep(5)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
display.drawBitmap(494, 391, soldered_logo, 211, 44)
#Use display.partialUpdate instead of display.display() to draw only updated pixels
display.partialUpdate()
# Use display.partialUpdate instead of display.display() to draw only updated pixels
display.partialUpdate()

View File

@ -1,7 +1,5 @@
# Include needed libraries
from soldered_inkplate10 import Inkplate
from image import *
from soldered_logo import *
import time
# Initialize inkplate display
@ -17,16 +15,16 @@ if __name__ == "__main__":
# 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.writeFillRect(0, 0, 25, 825, 3)
display.writeFillRect(25, 0, 25, 825, 2)
display.writeFillRect(50, 0, 25, 825, 1)
display.writeFillRect(75, 0, 25, 825, 0)
display.display()
time.sleep(3)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
display.drawBitmap(248, 391, soldered_logo, 211, 44)
display.display()
time.sleep(10)

View File

@ -1,5 +1,4 @@
from soldered_inkplate10 import Inkplate
from image import *
display = Inkplate(Inkplate.INKPLATE_1BIT)

View File

@ -2,9 +2,10 @@ import network
import time
from soldered_inkplate10 import Inkplate
ssid = "e-radionica.com"
password = "croduino"
ssid = "Soldered"
password = "dasduino"
# Function which connects to WiFi
# More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html
def do_connect():
import network
@ -18,7 +19,7 @@ def do_connect():
pass
print("network config:", sta_if.ifconfig())
# 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
@ -42,19 +43,24 @@ def http_get(url):
# Calling functions defined above
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")
# Initialise our Inkplate object
display = Inkplate(Inkplate.INKPLATE_1BIT)
display.begin()
display.setTextSize(3)
# Print response in lines
cnt = 0
for x in response.split("\n"):
display.printText(
10, 10 + cnt, x.upper()
10, 28 + cnt, x.upper()
) # Default font has only upper case letters
cnt += 10
cnt += 28
# Display image from buffer
display.display()

View File

@ -18,6 +18,7 @@ f.close()
time.sleep(5)
# Draw the image titled "1.bmp"
display.drawImageFile(0, 0, "sd/1.bmp")
# You can turn off the power to the SD card to save power

View File

@ -1,5 +1,5 @@
from soldered_inkplate6 import Inkplate
from image import *
from soldered_logo import *
import time
display = Inkplate(Inkplate.INKPLATE_1BIT)
@ -28,12 +28,13 @@ if __name__ == "__main__":
if display.rotation % 2 == 0:
display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK)
display.display()
time.sleep(5)
display.display()
time.sleep(5)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
display.drawBitmap(294, 20, soldered_logo, 211, 44)
#Use display.partialUpdate instead of display.display() to draw only updated pixels
display.partialUpdate()
# Use display.partialUpdate instead of display.display() to draw only updated pixels
display.partialUpdate()

View File

@ -1,7 +1,7 @@
# Include needed libraries
from soldered_inkplate6 import Inkplate
from image import *
from soldered_logo import *
import time
@ -28,6 +28,6 @@ if __name__ == "__main__":
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
display.drawBitmap(294, 278, soldered_logo, 211, 44)
display.display()
time.sleep(10)

View File

@ -5,6 +5,7 @@ from soldered_inkplate6 import Inkplate
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
@ -18,7 +19,7 @@ def do_connect():
pass
print("network config:", sta_if.ifconfig())
# 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
@ -42,19 +43,24 @@ def http_get(url):
# Calling functions defined above
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")
# Initialise our Inkplate object
display = Inkplate(Inkplate.INKPLATE_1BIT)
display.begin()
display.setTextSize(2)
# Print response in lines
cnt = 0
for x in response.split("\n"):
display.printText(
10, 10 + cnt, x.upper()
10, 20 + cnt, x.upper()
) # Default font has only upper case letters
cnt += 10
cnt += 20
# Display image from buffer
display.display()

View File

@ -18,6 +18,7 @@ f.close()
time.sleep(5)
# Draw the image titled "1.bmp"
display.drawImageFile(0, 0, "sd/1.bmp")
# You can turn off the power to the SD card to save power

View File

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

View File

@ -1,5 +1,5 @@
from soldered_inkplate6_PLUS import Inkplate
from image import *
from soldered_logo import *
import time
display = Inkplate(Inkplate.INKPLATE_1BIT)
@ -28,12 +28,13 @@ if __name__ == "__main__":
if display.rotation % 2 == 0:
display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK)
display.display()
time.sleep(5)
display.display()
time.sleep(5)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
display.drawBitmap(406, 357, soldered_logo, 211, 44)
#Use display.partialUpdate instead of display.display() to draw only updated pixels
display.partialUpdate()

View File

@ -1,7 +1,5 @@
# Include needed libraries
from soldered_inkplate6_PLUS import Inkplate
from image import *
from soldered_logo import *
import time
@ -16,18 +14,19 @@ if __name__ == "__main__":
display.clearDisplay()
display.display()
# Draw palet of posible colors
# Draw pallet 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.writeFillRect(0, 0, 25, 758, 3)
display.writeFillRect(25, 0, 25, 758, 2)
display.writeFillRect(50, 0, 25, 758, 1)
display.writeFillRect(75, 0, 25, 758, 0)
display.display()
time.sleep(3)
# Draws image from bytearray
display.setRotation(0)
display.drawBitmap(120, 200, image, 576, 100)
display.drawBitmap(184, 357, soldered_logo, 211, 44)
display.display()
time.sleep(10)

View File

@ -5,6 +5,7 @@ from soldered_inkplate6_PLUS import Inkplate
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
@ -19,6 +20,7 @@ def do_connect():
print("network config:", sta_if.ifconfig())
# 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
@ -42,19 +44,24 @@ def http_get(url):
# Calling functions defined above
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")
# Initialise our Inkplate object
display = Inkplate(Inkplate.INKPLATE_1BIT)
display.begin()
display.setTextSize(2)
# Print response in lines
cnt = 0
for x in response.split("\n"):
display.printText(
10, 10 + cnt, x.upper()
10, 20 + cnt, x.upper()
) # Default font has only upper case letters
cnt += 10
cnt += 20
# Display image from buffer
display.display()

View File

@ -18,6 +18,7 @@ f.close()
time.sleep(5)
# Draw the image titled "1.bmp"
display.drawImageFile(0, 0, "sd/1.bmp")
# You can turn off the power to the SD card to save power

View File

@ -12,9 +12,9 @@ if __name__ == "__main__":
display.begin()
# pin = display.gpioExpanderPin(gpioExpander,pin,mode)
# Supported gpio expanders on Soldered Inkplate 10: 1, 2
# Supported gpio expanders on Soldered Inkplate 6 PLUS: 1, 2
# Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT
# Supported pins on Soldered Inkplate 10 are listed below
# Supported pins are listed below
expander1_P1_1 = display.gpioExpanderPin(1, 9, modeOUTPUT)
expander1_P1_5 = display.gpioExpanderPin(1, 13, modeOUTPUT)
@ -40,8 +40,6 @@ if __name__ == "__main__":
expander2_P1_7 = display.gpioExpanderPin(2, 15, modeOUTPUT)
pins = (expander1_P1_1,
expander1_P1_2,
expander1_P1_3,
expander1_P1_5,
expander1_P1_6,
expander1_P1_7,

View File

@ -32,7 +32,7 @@ Now it's possible to flash MicroPython firmware. Do so by running this command:
```
//Linux/Mac
python3 esptool.py --chip esp32 --port /dev/cu.usbserial-1420 write_flash -z 0x1000 esp32spiram-20220117-v1.18.bin
// If you're having problems on Mac, use a slower baud rate with the flag "-b 112500"
// If you're having problems on Mac, use a slower baud rate with the flag "-b 115200"
//Windows
python esptool.py --chip esp32 --port COM5 write_flash -z 0x1000 esp32spiram-20220117-v1.18.bin
@ -48,10 +48,10 @@ python3 pyboard.py --device /dev/ttyUSB0 -f cp mcp23017.py inkplate6.py image.py
//Windows
//This one might need to be started twice
python pyboard.py --device COM5 -f cp inkplate6.py gfx.py gfx_standard_font_01.py mcp23017.py image.py shapes.py :
python pyboard.py --device COM5 -f cp inkplate6.py gfx.py gfx_standard_font_01.py mcp23017.py PCAL6416A.py image.py shapes.py :
```
**NOTE:** here you need to again change the serial port to the one you're using and the main driver of the board to the one made specifically for your Inkplate board. Here it's inkplate6.py for Inkplate 6. If you have a newer version of Inkplate 6 (Soldered Inkplate 6) then copy soldered_inkplate6.py instead. inkplate2.py for Inkplate 2, and so on.
**NOTE:** here you need to again change the serial port to the one you're using and the main driver of the board to the one made specifically for your Inkplate board. Here it's inkplate6.py for Inkplate 6. If you have a newer version of Inkplate 6 (Soldered Inkplate 6) then copy soldered_inkplate6.py instead. inkplate2.py for Inkplate 2, and so on. Older Inkplate boards use 'mcp23017.py' for the IO expander and the new ones use PCAL6416A.py, so you only need to copy one of them. Check the driver file for your Inkplate board to see which one it requires.
In this command you also need to include all the files your Python script uses (external images, files with extenral functions you're including and so on) so it can run on your board!

View File

@ -156,8 +156,9 @@ class _Inkplate:
def read_battery(cls):
cls.VBAT_EN.digitalWrite(0)
# Probably don't need to delay since Micropython is slow, but we do it anyway
time.sleep_ms(1)
time.sleep_ms(5)
value = cls.VBAT.read()
print(value)
cls.VBAT_EN.digitalWrite(1)
result = (value / 4095.0) * 1.1 * 3.548133892 * 2
return result

View File

@ -22,7 +22,7 @@ D_COLS = const(1024)
# 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),
@ -105,8 +105,6 @@ class _Inkplate:
cls.TPS_INT = gpioPin(cls._PCAL6416A_1, 6, modeINPUT)
cls.TPS_PWR_GOOD = gpioPin(cls._PCAL6416A_1, 7, modeINPUT)
# Misc
cls.GPIO0_PUP = gpioPin(cls._PCAL6416A_1, 8, modeOUTPUT)
cls.GPIO0_PUP.digitalWrite(0)
@ -116,15 +114,15 @@ class _Inkplate:
cls.VBAT.atten(ADC.ATTN_11DB)
cls.VBAT.width(ADC.WIDTH_12BIT)
#Toucscreen
# Toucscreen
cls._tsXResolution = 0
cls._tsYResolution = 0
cls.touchX = 0
cls.touchY = 0
cls._xPos = [0,0]
cls._yPos = [0,0]
cls.xraw = [0,0]
cls.yraw = [0,0]
cls._xPos = [0, 0]
cls._yPos = [0, 0]
cls.xraw = [0, 0]
cls.yraw = [0, 0]
cls.SD_ENABLE = gpioPin(cls._PCAL6416A_1, 13, modeOUTPUT)
@ -151,7 +149,6 @@ class _Inkplate:
None,
None,
)
@classmethod
def clearDisplay(self):
@ -182,7 +179,7 @@ class _Inkplate:
result = (value / 4095.0) * 1.1 * 3.548133892 * 2
return result
#Touchscreen
# Touchscreen
@classmethod
def touchInArea(cls, x, y, width, height):
x2 = x+width
@ -194,9 +191,20 @@ class _Inkplate:
cls.touchX = cls._xPos[0]
cls.touchY = cls._yPos[0]
if(cls.touchX > x and cls.touchX < x2) and (cls.touchY > y and cls.touchY < y2):
if (cls.touchX > x and cls.touchX < x2) and (cls.touchY > y and cls.touchY < y2):
return True
return False
return False
# This function was a contributio by Evan Brynne
# For more info, see https://github.com/SolderedElectronics/Inkplate-micropython/issues/24
@classmethod
def activeTouch(cls):
if cls.tsAvailable():
fingers = cls.tsGetData()
if fingers > 0:
cls.touchX = cls._xPos[0]
cls.touchY = cls._yPos[0]
return (cls.touchX, cls.touchY)
@classmethod
def tsWriteRegs(cls, addr, buff):
@ -1282,3 +1290,9 @@ class Inkplate:
def tsShutdown(self):
_Inkplate.tsShutdown()
# This function was a contributio by Evan Brynne
# For more info, see https://github.com/SolderedElectronics/Inkplate-micropython/issues/24
def activeTouch(cls):
return _Inkplate.activeTouch()