Git Product home page Git Product logo

adafruit_circuitpython_ra8875's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_circuitpython_ra8875's Issues

The arguments for set_window in RA8875Display class do not work as described.

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.

OverflowError: value must fit in 1 byte

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)

Incorrect parameter names and docstrings

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.

Missing Type Annotations

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:

  • adafruit_ra8875/ra8875.py:44
  • adafruit_ra8875/ra8875.py:63
  • adafruit_ra8875/ra8875.py:105
  • adafruit_ra8875/ra8875.py:180
  • adafruit_ra8875/ra8875.py:192
  • adafruit_ra8875/ra8875.py:205
  • adafruit_ra8875/ra8875.py:215
  • adafruit_ra8875/ra8875.py:231
  • adafruit_ra8875/ra8875.py:255
  • adafruit_ra8875/ra8875.py:275
  • adafruit_ra8875/ra8875.py:299
  • adafruit_ra8875/ra8875.py:309
  • adafruit_ra8875/ra8875.py:313
  • adafruit_ra8875/ra8875.py:324
  • adafruit_ra8875/ra8875.py:332
  • adafruit_ra8875/ra8875.py:345
  • adafruit_ra8875/ra8875.py:429
  • adafruit_ra8875/ra8875.py:445
  • adafruit_ra8875/ra8875.py:458
  • adafruit_ra8875/ra8875.py:469
  • adafruit_ra8875/ra8875.py:479
  • adafruit_ra8875/ra8875.py:491
  • adafruit_ra8875/ra8875.py:505
  • adafruit_ra8875/ra8875.py:518
  • adafruit_ra8875/ra8875.py:528
  • adafruit_ra8875/ra8875.py:539
  • adafruit_ra8875/ra8875.py:552
  • adafruit_ra8875/ra8875.py:562
  • adafruit_ra8875/ra8875.py:594
  • adafruit_ra8875/ra8875.py:606
  • adafruit_ra8875/ra8875.py:618
  • adafruit_ra8875/ra8875.py:626
  • adafruit_ra8875/ra8875.py:637
  • adafruit_ra8875/ra8875.py:648
  • adafruit_ra8875/ra8875.py:660
  • adafruit_ra8875/ra8875.py:672
  • adafruit_ra8875/ra8875.py:686
  • adafruit_ra8875/ra8875.py:700
  • adafruit_ra8875/ra8875.py:714
  • adafruit_ra8875/ra8875.py:728
  • adafruit_ra8875/ra8875.py:739
  • adafruit_ra8875/ra8875.py:750
  • adafruit_ra8875/ra8875.py:776
  • adafruit_ra8875/ra8875.py:803
  • adafruit_ra8875/ra8875.py:832
  • adafruit_ra8875/ra8875.py:849
  • adafruit_ra8875/ra8875.py:867
  • adafruit_ra8875/ra8875.py:885
  • adafruit_ra8875/ra8875.py:905

TypeError when running simpletest on Raspberry Pi

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.