adafruit / adafruit_circuitpython_rgb_display Goto Github PK
View Code? Open in Web Editor NEWDrivers for RGB displays for Adafruit CircuitPython.
License: MIT License
Drivers for RGB displays for Adafruit CircuitPython.
License: MIT License
The examples all start with rgbdisplay_
and should begin with rgb_display_
. Examples need to be renamed to match CircuitPython library standards.
The lines including this file name in the docs/examples.rst
file must also be updated to reflect the name change, e.g.:
.. literalinclude:: ../examples/current_file_name.py
:caption: examples/current_file_name.py
:linenos:
would be updated to:
.. literalinclude:: ../examples/current_file_name_changed.py
:caption: examples/current_file_name_changed.py
:linenos:
administrator@raspberrypi:~ $ python3 rgb_display_ili9341test.py
Traceback (most recent call last):
File "/home/administrator/rgb_display_ili9341test.py", line 25, in
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 365, in init
self._spi = _SPI(portId)
File "/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 25, in init
self._spi = spi.SPI(device=(portid, 0))
File "/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/spi.py", line 149, in init
raise IOError(f"{device} does not exist")
OSError: /dev/spidev0.0 does not exist
Whats wrong here?
Hi
I am getting this GPIO error when trying to setup a pitft 240x240.
I am trying to install on a pi zero docker with python 3.6, 3.7, 3.8 so far.
Can you tell me what versions of linux and python work with this PiTFT?
I've tried all this stuff:
https://stackoverflow.com/questions/70697888/rpi-gpio-modulenotfounderror-no-module-named-rpi-gpio
Am I missing something? Thanks for any help!!!
Here's all the stuff getting installed:
RUN apt-get update && apt-get install build-essential \
apt-utils \
fonts-dejavu \
python3-dev \
python3-rpi.gpio
RUN pip3 install adafruit-circuitpython-rgb-display RPi.GPIO
RUN pip3 install --upgrade --force-reinstall spidev
Logs] [4/9/2022, 4:43:15 AM] [main] File "rgb_display_minipitfttest.py", line 4, in <module>
[Logs] [4/9/2022, 4:43:15 AM] [main] import digitalio
[Logs] [4/9/2022, 4:43:15 AM] [main] File "/usr/local/lib/python3.8/site-packages/digitalio.py", line 18, in <module>
[Logs] [4/9/2022, 4:43:15 AM] [main] from adafruit_blinka.microcontroller.bcm283x.pin import Pin
[Logs] [4/9/2022, 4:43:15 AM] [main] File "/usr/local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 5, in <module>
[Logs] [4/9/2022, 4:43:15 AM] [main] from RPi import GPIO
[Logs] [4/9/2022, 4:43:15 AM] [main] File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 23, in <module>
[Logs] [4/9/2022, 4:43:15 AM] [main] from RPi._GPIO import *
[Logs] [4/9/2022, 4:43:15 AM] [main] ModuleNotFoundError: No module named 'RPi._GPIO'
Thanks!!
When my LCD powers on and initializes, it shows garbage data on the screen for a moment. Here is the example codes I was following:
import digitalio
import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import
# Configuration for CS and DC pins (these are PiTFT defaults):
cs_pin = digitalio.DigitalInOut(board.CE0)
reset_pin = digitalio.DigitalInOut(board.D24)
dc_pin = digitalio.DigitalInOut(board.D25)
# Config for display baudrate (default max is 24mhz):
BAUDRATE = 24000000
# Setup SPI bus using hardware SPI:
spi = board.SPI()
# Create the display:
disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789
cs=cs_pin,
dc=dc_pin,
rst=reset_pin,
baudrate=BAUDRATE,
)
This is what appears on the LCD screen:
Traceback (most recent call last):
File "rgb_display_minipitfttest.py", line 14, in <module>
board.SPI(),
File "/usr/local/lib/python3.7/dist-packages/board.py", line 186, in SPI
return busio.SPI(SCLK, MOSI, MISO)
File "/usr/local/lib/python3.7/dist-packages/busio.py", line 186, in __init__
self._spi = _SPI(portId)
File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 22, in __init__
self._spi = spi.SPI(device=(portid, 0))
File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 165, in __init__
raise IOError("{} does not exist".format(device))
OSError: /dev/spidev0.0 does not exist
running rgb_display_minipitfttest.py after installing adafruit-circuitpython-rgb-display, spidev, ttf-dejavu, python3-numpy
please help
Hi, I'm trying to control two 2.2 TFT screens, both on SPI 0 using the two chip selects (CE0 and CE1).
Whenever I display to the first screen on CE0, it's fine (i.e. only displays on the first screen), but displaying to the second screen (CE1) pushes the same image to both screens. I can't seem to figure out why. Trying to manually throw CE0 high hasn't appeared to work.
Here's the implementation (adjusted from the sample code):
import digitalio
import board
from PIL import Image, ImageDraw, ImageFont
import adafruit_rgb_display.ili9341 as ili9341
import time
# First define some constants to allow easy resizing of shapes.
BORDER = 0
FONTSIZE = 24
# Configuration for CS and DC pins (these are PiTFT defaults):
cs_pin = digitalio.DigitalInOut(board.CE0)
cs2_pin = digitalio.DigitalInOut(board.CE1)
dc_pin = digitalio.DigitalInOut(board.D25)
dc2_pin = digitalio.DigitalInOut(board.D25)
reset_pin = digitalio.DigitalInOut(board.D24)
reset_pin2 = digitalio.DigitalInOut(board.D24)
# Config for display baudrate (default max is 24mhz):
BAUDRATE = 24000000
# Setup SPI bus using hardware SPI:
spi = board.SPI()
print('spi set up')
# pylint: disable=line-too-long
# Create the display:
disp = ili9341.ILI9341(
spi,
rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341
cs=cs_pin,
dc=dc_pin,
rst=reset_pin,
baudrate=BAUDRATE,
)
disp2 = ili9341.ILI9341(
spi,
rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341
cs=cs2_pin,
dc=dc2_pin,
rst=reset_pin2,
baudrate=BAUDRATE,
)
# pylint: enable=line-too-long
# Create blank image for drawing.
# Make sure to create image with mode 'RGB' for full color.
if disp.rotation % 180 == 90:
height = disp.width # we swap height/width to rotate it to landscape!
width = disp.height
else:
width = disp.width # we swap height/width to rotate it to landscape!
height = disp.height
image = Image.new("RGB", (width, height))
if disp2.rotation % 180 == 90:
height2 = disp2.width # we swap height/width to rotate it to landscape!
width2 = disp2.height
else:
width2 = disp2.width # we swap height/width to rotate it to landscape!
height2 = disp2.height
image2 = Image.new("RGB", (width2, height2))
print('width2:', width2, 'height2:', height2)
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
draw2 = ImageDraw.Draw(image2)
# Draw a white filled box as the background
draw.rectangle((00, 0, disp.width+100, disp.height+100), fill=(225, 225, 225))
disp.image(image)
input('draw blue box on second screen only')
#Draw a blue box only on the second screen
draw2.rectangle((0, 0, disp2.width+100, disp2.height+100), fill=(0, 225, 225))
disp2.image(image2)
Essentially the blue box appears on both screens instead of just the second one!
I'm not sure if I'm doing something wrong with the chip selects/setup, or if this library just can't support multiple SPI devices.
I have attached an SPI TFT display as per the following connection. all i get is a white screen nothing else.
the code loop runs without errors.
The original Adafruit_ILI9341 library was using Numpy to speed up the conversion from pixels to an SPI-conformant byte array (see here).
The new library in this repository uses the following loop
# Iterate through the pixels
for x in range(self.width): # yes this double loop is slow,
for y in range(self.height): # but these displays are small!
pix = color565(img.getpixel((x, y)))
pixels[2*(y * self.width + x)] = pix >> 8
pixels[2*(y * self.width + x) + 1] = pix & 0xFF
The comment about slowness is no understatement indeed. On a Raspberry Pi Zero, drawing a black image with a single line of text takes 8 seconds in my testing.
When I used the old code
pixelbytes = list(image_to_data(image))
self.display._block(0, 0, self.display.width-1, self.display.height - 1, pixelbytes)
with
def image_to_data(image):
"""Generator function to convert a PIL image to 16-bit 565 RGB bytes."""
#NumPy is much faster at doing this. NumPy code provided by:
#Keith (https://www.blogger.com/profile/02555547344016007163)
pb = np.array(image.convert('RGB')).astype('uint16')
color = ((pb[:,:,0] & 0xF8) << 8) | ((pb[:,:,1] & 0xFC) << 3) | (pb[:,:,2] >> 3)
return np.dstack(((color >> 8) & 0xFF, color & 0xFF)).flatten().tolist()
the time consumed drops down to below half a second. Unless there was a technical reason not to depend on Numpy, I think it'd be worth to bring back the old code. 8 seconds for a screen update puts an end to a lot of use cases.
The ST7735 display comes in two versions, referred to at Adafruit as "green tab" and "red tab" for some reason (even though the "green tab" ones often come with black tabs, and "red tab" ones often have green tabs). Those two kinds require different initialization code.
The MicroPython driver has a separate class for this, called ST7735R. Not sure how it would be best handled here.
Discovered corruption on two sides while testing the 1.44" TFT display with ST7735R. When I tested using Arduino, no issues were seen.
Looking at the Arduino Library code (Adafruit-ST7735), _rowstart and _colstart are being set in the function Adafruit_ST7735::initR for the different displays. These offsets are then used to adjust the start and end points when writing data in the function Adafruit_ST77xx::setAddrWindow. This is not being done in the CircuitPython code and is causing corruption along two edges of the screen.
I assume the offsets are the same, so it should be a simple matter of adding them to the rgb and st7735 modules.
What would it take to add touch support to this library?
I'm trying to run the examples/rgb_display_minipitftstats.py and I get the following error:
Traceback (most recent call last):
File "/home/pi/src/picam3-minipitft/button.py", line 11, in <module>
cs_pin = digitalio.DigitalInOut(board.CE0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 191, in __init__
self.direction = Direction.INPUT
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 221, in direction
self._pin.init(mode=Pin.IN)
File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 40, in init
GPIO.setup(self.id, GPIO.IN)
File "/home/pi/.local/lib/python3.11/site-packages/RPi/GPIO/__init__.py", line 696, in setup
_check(lgpio.gpio_claim_input(_chip, gpio, {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 755, in gpio_claim_input
return _u2i(_lgpio._gpio_claim_input(handle&0xffff, lFlags, gpio))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
raise error(error_text(v))
lgpio.error: 'GPIO busy'
I was able to get the requirements loaded with the following:
sudo pip3 install --break-system-packages adafruit-circuitpython-rgb-display
sudo pip3 install --break-system-packages spidev
sudo pip3 install --break-system-packages --upgrade adafruit-python-shell click setuptools
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.py
sudo python3 libgpiod.py
Are there any updates or instructions to get the minipitft board working with a Pi5/Bookworm? This does work on a Pi4/Bookworm.
Would it be feasible to provide backlight control through those interfaces?
I know it's just some PWM on a specific pin, but it would make things easier.
Thanks.
This line fails when I try importing this library.
I setup pi-hole on a pi zero w and that all works fine and is running properly. i just can't get the screen working yet.
I am NOT using the OLED kit, I'm using the Mini PiTFT.
I'm following the guide for the kit i bought here: https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w?view=all
when i type the command "sudo python3 ~pi/stats.py" it just returns
Traceback (most recent call last):
File "/home/pi/stats.py", line 16, in
import adafruit_rgb_display.st7789 as st7789
ModuleNotFoundError: No module named 'adafruit_rgb_display'
I assume I must be missing a step but i don't know what.
I would really appreciate the help I am new to the raspberry pi world
Consider that you will often write data bytes without a command byte, but will almost never write a command byte without data bytes. For example, after setting up the display and issuing commands to set the write window and ram write mode, an application might then simply start continuously writing frames. Or even internally, look at the fill_rectangle() command.
As an optimization, consider leaving self.dc_pin.value = 1 as the default state, and only changing it to 0 and then back to 1 when ever a command byte is being written.
I believe the changes for this would trivial and isolated to the write() and read() methods. And to be extra safe, possibly setting it to 1 at the end of init().
Trying to use DummyPin
for CS that I have pulled down permanently on this breakout (because Trinket M0 doesn't have enough pins to handle CS), I get:
>>> cs = DummyPin()
>>> display = st7735.ST7735(spi, cs=cs, dc=dc, rst=rst)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_rgb_display/st7735.py", line 98, in __init__
File "adafruit_rgb_display/rgb.py", line 104, in __init__
File "adafruit_bus_device/spi_device.py", line 59, in __init__
AttributeError: 'DummyPin' object has no attribute 'switch_to_output'
Can I use adafruit_rgb_display.ssd1351 to control SSD1357 driver?
We need to make sure all files from cookiecutter are here and that the README matches the template.
For instructions on cookiecutter see here.
I'm trying to use adafruit-circuitpython-display-text
in combination with this repo.
I found the following code in this video
import board
import displayio
from st7735r import ST7735R
spi = board.SPI()
cs = board.D11
dc = board.D10
displayio.release_displays()
display_bus = displayio.FourWire(spi, command=dc, chip_select=cs, reset=board.D9)
display = ST7735R(display_bus, width=128, height=160)
Is something like this possible? Or should I use this repo instead?
I tried using the code, but I can't import displayio
and I have no idea what pip package provides displayio
.
What does it take to add LVGL support to this library?
I mostly want to list ideas here for performance improvement ideas. The first idea I had is taking the image loading time into account for the delay. At the moment it loads the images, then does a delay. This change should have a significant impact.
Since this library is an alternative to displayio, it doesn't make sense to be loading displayio because those examples will not run on Blinka.
I have a simple application that updates a screen (Adafruit 1.14" 240x135 Color TFT Display + MicroSD Card Breakout - ST7789 Product ID: 4383) from a Pi Zero W 2, every 1/2 to 1 second, rendering moving 'eyes'. It consists of a main program (face_test.py) and a threaded class (face.py). The updating is done from a thread. The eyes are transparent PNG files that are enumerated from a text file and loaded at startup. In the thread, the code creates a green background, pastes the 'eyes' onto it, and then displays the image to the screen. This part appears to work fine. The main program can call a method on the class that tells it which PNG it should be using. At random times, this part appears to be resetting the screen, as it goes black and doesn't display anything else for the remainder of the run. I've attached all files, with the Python files as txt files.
The main program:
import os
import time
import face
def main():
face_animate = face.FaceAnimate()
face_animate.start()
for x in range(100):
time.sleep(2)
face_animate.set_face("squint")
time.sleep(2)
face_animate.set_face("regular")
face_animate.stop()
face_animate.join()
if __name__ == "__main__":
main()
The threaded class:
import os
import threading
import random
import time
import digitalio
import board
from PIL import Image, ImageDraw
from adafruit_rgb_display import st7789
# Configuration for CS and DC pins (these are PiTFT defaults):
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = digitalio.DigitalInOut(board.D24)
# Config for display baudrate (default max is 24mhz):
BAUDRATE = 24000000
# Setup SPI bus using hardware SPI:
spi = board.SPI()
disp = st7789.ST7789(spi,
rotation=270,
width=135,
height=240,
x_offset=53,
y_offset=40, # 1.14" ST7789
cs=cs_pin,
dc=dc_pin,
rst=reset_pin,
baudrate=BAUDRATE,
)
if disp.rotation % 180 == 90:
height = disp.width # we swap height/width to rotate it to landscape!
width = disp.height
else:
width = disp.width # we swap height/width to rotate it to landscape!
height = disp.height
class FaceAnimate(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.face_offset_x = 0
self.face_offset_y = 0
self.images = {}
self.load_images(os.getcwd() + "/images.txt")
self.face_key = list(self.images.keys())[0]
self.face = self.images[self.face_key]
self.running = True
random.seed()
def load_images(self, file_list_path):
try:
with open(file_list_path, 'r') as file:
for line in file:
image_filename = line.strip()
key = image_filename.split('.')[0]
image = Image.open(os.getcwd() + "/" + image_filename)
self.images[key] = image
except Exception as e:
print(f"{e}")
def run(self):
while self.running:
time.sleep(random.uniform(.5, 1))
self.face_offset_x = random.randint(-5, 5)
self.face_offset_y = random.randint(-5, 5)
self.show_face()
def set_face(self, face_name):
self.face = self.images[face_name]
self.show_face()
def get_background(self, R, G, B):
image = Image.new("RGB", (width, height))
draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, width, height), outline=0, fill=(R, G, B))
return image
def show_face(self):
background = self.get_background(int("6B", 16), int("8E", 16), int("23",16))
background.paste(self.face, (self.face_offset_x, self.face_offset_y), self.face)
disp.image(background)
def stop(self):
self.running = False
Hello, I am new to hardware. I am trying to configure the Mini PiTFT 135x240 on a Pi Zero W (https://learn.adafruit.com/adafruit-mini-pitft-135x240-color-tft-add-on-for-raspberry-pi/python-setup), and when I run the rgb_display_minipitfttest.py script, I get the following error:
Could not open SPI device - check if SPI is enabled in kernel!
Traceback (most recent call last):
File "rgb_display_minipitfttest.py", line 14, in
width=135, height=240, x_offset=53, y_offset=40)
File "/usr/local/lib/python3.7/dist-packages/adafruit_rgb_display/st7789.py", line 120, in init
x_offset=x_offset, y_offset=y_offset, rotation=rotation)
File "/usr/local/lib/python3.7/dist-packages/adafruit_rgb_display/rgb.py", line 250, in init
super().init(width, height, rotation)
File "/usr/local/lib/python3.7/dist-packages/adafruit_rgb_display/rgb.py", line 126, in init
self.init()
File "/usr/local/lib/python3.7/dist-packages/adafruit_rgb_display/st7789.py", line 123, in init
super().init()
File "/usr/local/lib/python3.7/dist-packages/adafruit_rgb_display/rgb.py", line 131, in init
self.write(command, data)
File "/usr/local/lib/python3.7/dist-packages/adafruit_rgb_display/rgb.py", line 266, in write
spi.write(bytearray([command]))
File "/usr/local/lib/python3.7/dist-packages/busio.py", line 170, in write
return self._spi.write(buf, start, end)
File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 49, in write
self._spi.open(self._port, 0)
FileNotFoundError: [Errno 2] No such file or directory
I have gone back through the CircuitPython on Linux and Raspberry Pi guide, and done every step, and the "blinka test" passed on all fronts. The only red flag was that the output from /dev/spi* did not include spidev0.0, only 0.1
Can you offer any guidance?
There are missing type annotations for some functions in this library.
The typing
module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:
try:
from typing import List, Tuple
except ImportError:
pass
Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:
def wrap_text_to_pixels(
string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:
If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github
There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: Sharing docs on ReadTheDocs
and Check your code with pre-commit
contain the tools to install and commands to run locally to run the checks.
If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @FoamyGuy and @kattni or reach out to us on Discord: https://adafru.it/discord in the #circuitpython-dev
channel.
The following locations are reported by mypy to be missing type annotations:
Following instructions at,
https://learn.adafruit.com/adafruit-1-3-and-1-54-240-x-240-wide-angle-tft-lcd-displays/python-wiring-and-setup
Resulted in,
Traceback (most recent call last):
File "/home/pi/./direwatch.py", line 305, in
disp.image(image)
File "/usr/local/lib/python3.11/dist-packages/adafruit_rgb_display/rgb.py", line 230, in image
pix = color565(img.getpixel((i, j)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/adafruit_rgb_display/rgb.py", line 58, in color565
red, g, b = r
^^^^^^^^^
ValueError: too many values to unpack (expected 3)
Raspberry Pi OS Bookworm/12
curiously,
-craig
Hi, Is Raspberry pi zero w with 1.14 inch st7789 LCD supported?
I pip installed adafruit-blinka and adafruit-circuitpython-rgb-display, but when I tried the rgb_display_simpletest.py example, I got 'No module named displayio' Error, and I can't pip install
adafruit-circuitpython-displayio
How to translate the pin definitions of Raspberry Pi? I want to change sides dc and rst.But I don't know how to compare the pins of the raspberr pi of the board. For example, in the Raspberry Pi ZERO W, does GPIO6 correspond to D6 or what?
When using a PITFT 2.8" TFT 320X240 + CAPACITIVE ( https://www.adafruit.com/product/1983 ), colors are inverted.
disp.fill(color565(255, 0, 0)) # red => Fills the screen with blue (cyan)
disp.fill(color565(0, 0, 255)) # blue => Fills with Yellow
disp.fill(color565(0, 255, 0)) # green => Magenta
It's probably just and initialization issue, but I don't know enough to fix it myself (besides manually inverting colors).
The display is initialized with
disp = ili9341.ILI9341(
spi,
rotation=270, # 2.2", 2.4", 2.8", 3.2" ILI9341
cs=cs_pin,
dc=dc_pin,
rst=reset_pin,
baudrate=BAUDRATE,
)
otherwise it's just the sample from https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display#22-24-28-32-tft
When using the sample AnimatedGif the images look inverted as well.
Thanks.
Hello!
I have two ST7789 lcds sharing the same SPI bus and I can draw on one or another screen but not on both at the same time (specifically, after I create another ST7789 object, previous one stops working).
Here is my code
display1 = ST7789(spi, rotation=0, width=240, height=240, x_offset=0, y_offset=80, baudrate=BAUDRATE,
cs=cs1_pin,
dc=dc_pin,
rst=rs_pin)
display1.fill(color565(255, 0, 0))
time.sleep(2)
display2 = ST7789(spi, rotation=0, width=240, height=240, x_offset=0, y_offset=80, baudrate=BAUDRATE,
cs=cs2_pin,
dc=dc_pin,
rst=rs_pin)
display2.fill(color565(0, 255, 0))
When I run this code, the first screen displays red (actually, yellow. I think its because both CS are enabled by default until I initialized driver?), then after 2 sec the first screen goes black and then the second screen shows green.
I am willing to have something drawn on both screens at the same time, and not just on one or another?
Originally posted by @BioRyajenka in #95 (comment)
Many of the examples/
use PIL or otherwise assume they're running under CPython, not CircuitPython.
A user was confused: https://forums.adafruit.com/viewtopic.php?f=60&t=167277
The line
Running a ST7735R on a Feather M0 Basic, and when it should display red - IE, color565(255,0,0) - it displays blue instead, and the reverse is also true.
The super simple code I am using:
import busio
import digitalio
import board
import time
from adafruit_rgb_display import color565
import adafruit_rgb_display.st7735 as st7735
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
display = st7735.ST7735R(spi, cs=digitalio.DigitalInOut(board.D9), dc=digitalio.DigitalInOut(board.D10), rst=digitalio.DigitalInOut(board.D11))
while True:
time.sleep(2.5)
print("RED")
display.fill(color565(255,0,0))
time.sleep(2.5)
print("BLUE")
display.fill(color565(0,0,255))
for completeness sake, I've removed the other driver files (hx8353, ili9341, etc) from the folder to save on space, as the M0 basic has almost none.
The image
method currently only allows to redraw the whole screen.
def image(self, img, rotation=None):
...
imwidth, imheight = img.size
if imwidth != self.width or imheight != self.height:
raise ValueError(...
...
self._block(0, 0, self.width-1, self.height - 1, pixels)
Especially on lower end boards it seems advantageous to be able to draw smaller images in part of the screen only without having to refresh the whole screen.
I would like to suggest to add two new arguments to the method for specifying the origin
def draw(self, image, x0=0, y0=0):
to drop the if imwidth != self.width or imheight != self.height:
check and to adapt the call to _block
so that the image's size is passed in instead of the screen size.
self.display._block(x0, y0, x0 + imwidth - 1, y0 + imheight - 1, pixels)
Instead of removing the size check, one could also replace it with a check to ensure that the image is not bigger than the screen size.
Happy to submit a pull request if this makes sense.
Hello,
I've been messing with this library for a while now and when I import Image.Draw text it displays on my ST7789 screen but it comes out inverted. I tried messing with ST7789.py and noticed an option called "_INVON" and I thought maybe this had something to do with it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.