This initializes the screen (it’ll show the REPL if you hit STOP in Thonny)
from fourwire import FourWire
from adafruit_ili9341 import ILI9341 # https://circuitpython.org/libraries
from busio import SPI
import digitalio
spi = SPI(clock=board.GP10, MOSI=board.GP11, MISO=board.GP12)
if not spi.try_lock():
print("Failed to lock SPI bus")
return
spi.configure(baudrate=40000000)
spi.unlock()
tft_cs = board.GP13
tft_dc = board.GP14
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs,reset=board.GP15)
fb_display = ILI9341(display_bus, width=320, height=320, rotation=270)
That comes from:
import board
from gc import collect as free
from terminalio import FONT
from displayio import (
Bitmap,
Group,
OnDiskBitmap,
Palette,
TileGrid,
release_displays,
) # https://circuitpython.org/libraries - add to the /lib folder
from adafruit_display_text.bitmap_label import (
Label,
) # https://circuitpython.org/libraries - add to the /lib folder
from adafruit_imageload import (
load as load_image,
) # https://circuitpython.org/libraries - add to the /lib folder
This file has been truncated. show original
I wish I saw this like 4 hours ago I ran into the same keyboard issue, which to my current understanding is a bit odd because a similar I2C setup in micropython works just fine.
CircuitPython seems better for memory management and I love its file system, but honestly, the Adafruit libraries (mainly the graphic ones) aren’t that good compared to the MicroPython ones.
I also see that some developers have already created some MicroPython drivers for the PicoCalc so I’m discontinuing CircuitPython support in Picoware for now.
If anyone figures out the keyboard in the future, certainly tag me
Here’s a Draw class that handles graphics:
import board
from gc import collect as free
from terminalio import FONT
from displayio import (
Bitmap,
Group,
OnDiskBitmap,
Palette,
TileGrid,
release_displays,
) # https://circuitpython.org/libraries - add to the /lib folder
from adafruit_display_text.bitmap_label import (
Label,
) # https://circuitpython.org/libraries - add to the /lib folder
from adafruit_imageload import (
load as load_image,
) # https://circuitpython.org/libraries - add to the /lib folder
This file has been truncated. show original
Image class
from sys import byteorder as sys_byteorder
from gc import collect as free
from displayio import release_displays
from framebufferio import FramebufferDisplay
from adafruit_framebuf import (
FrameBuffer,
RGB565,
) # https://circuitpython.org/libraries - add to the /lib folder
from .vector import Vector
SEEK_CUR = 1
class Image:
"""
Represents an image. On CircuitPython this uses adafruit_framebuf.FrameBuffer
for pixel manipulation, and displayio + framebufferio to put it on-screen.
"""
This file has been truncated. show original
Keyboard
import time
from board import GP7, GP6
from busio import I2C
from collections import deque
from micropython import const
_REG_CFG = const(0x02) # config
_REG_KEY = const(0x04) # key status
_REG_BKL = const(0x05) # backlight
_REG_RST = const(0x08) # reset
_REG_FIF = const(0x09) # fifo
_REG_BK2 = const(0x0A) # backlight 2
_REG_BAT = const(0x0B) # battery
_KEY_COUNT_MASK = const(0x1F)
_WRITE_MASK = const(1 << 7)
_StatePress = const(1)
_StateLongPress = const(2)
class Keyboard:
This file has been truncated. show original
1 Like