adafruit / adafruit_circuitpython_ra8875 Goto Github PK
View Code? Open in Web Editor NEWCircuitPython library for the RA8875 TFT driver board
License: MIT License
CircuitPython library for the RA8875 TFT driver board
License: MIT License
The width and height parameters are not actually the width and the height of the window. If you set them both to 0 the windows is actually 1 pixel wide by 1 pixel high.
I believe either the description should be changed or the math should subtract 1 from the width and height when writing to the HEAW0 and VEAW0 respectively.
Tested with latest stable CircuitPython and got this error:
Traceback (most recent call last):
File "code.py", line 34, in <module>
File "/lib/adafruit_ra8875/ra8875.py", line 588, in fill
File "/lib/adafruit_ra8875/ra8875.py", line 812, in _rect_helper
File "/lib/adafruit_ra8875/ra8875.py", line 190, in write_reg
File "/lib/adafruit_ra8875/ra8875.py", line 212, in write_data
File "/lib/adafruit_ra8875/ra8875.py", line 212, in write_data
OverflowError: value must fit in 1 byte(s)
First, the RA8875 driver board and library helped me complete my project, and I sincerely appreciate the effort that went into both.
I discovered that the parameter names for the _rect_helper
method of the RA8875
class are inconsistent with the actual drawing behavior. The method signature is:
_rect_helper(self, x, y, width, height, color, filled)
However, the width
and height
parameters should really be the x- and y-coordinate of the endpoint--they are a second absolute x-y screen coordinate, rather than a width and height offset applied to the first screen coordinate. Page 120 of the RA8875 datasheet that is linked from the Adafruit product page confirms the registers written by this method are an endpoint coordinate, not width/height.
This parameter mislabeling carries through to the public methods of the same class that rely on the _rect_helper
method, including at least the rect
and fill_rect
methods (but possibly others...these are just the ones I happened to use with confusing results).
I would suggest that the signature of the _rect_helper
method be changed to be consistent with other methods like _triangle_helper
:
_rect_helper(self, x1, y1, x2, y2, color, filled)
I would then suggest that the parameters and documentation for other methods like rect
and fill_rect
that currently specify a width/height be updated accordingly. By changing the parameter names and documentation, existing code (including the examples) that relies on the existing behavior will not be broken.
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:
This is the first time I've run it on the Raspberry Pi and it works mostly, but was a little laggy (SPI bus speed maybe) and output this error at the end:
Traceback (most recent call last):
File "ra8875_simpletest.py", line 66, in <module>
display.txt_write("Player Score: " + str(testvar))
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_ra8875/ra8875.py", line 475, in txt_write
self._write_data(char, True)
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_ra8875/ra8875.py", line 225, in _write_data
spi.write(data if raw else bytearray([data & 0xFF])) # pylint: disable=no-member
File "/home/pi/.local/lib/python3.7/site-packages/busio.py", line 170, in write
return self._spi.write(buf, start, end)
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 61, in write
self._spi.writebytes2(buf[start:end])
TypeError: Non-Int/Long value in arguments: b6687160.
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.