-
Notifications
You must be signed in to change notification settings - Fork 53
added pylint to project and update code #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Started testing library. ST7735R fails.
adafruit_rgb_display/st7735.py
Outdated
def __init__(self, spi, dc, cs, rst=None, width=128, height=128): | ||
super().__init__(spi, dc, cs, rst, width, height) | ||
# def __init__(self, spi, dc, cs, rst=None, width=1, height=1, baudrate=1000000, | ||
# polarity=0, phase=0) | ||
|
||
|
||
class ST7735R(ST7735): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with ST7735R display, shows bars and multicolored pixellation across the display. Tried with example code included at beginning of file, as well as other code. Both of my examples run with the current version (if I change the last line to self.write
in the current version as well) - using PR version of rgb.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SSD1351 testing failed.
@@ -1,5 +1,6 @@ | |||
"""A simple driver for the SSD1351-based displays.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing with SSD1351 display fails - results in static looking pixellation using example in code.. Tested successfully with current version of this file with same example - using PR version of rgb.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kattni thanks for testing this. I trusted pylint too much and deleted some important __init__ code. put it back in the two you have identified and several others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also notice the internal identifiers were only in the rgb.py file but also should be in all .py files. So I added those required lines.
Since travis checks were failing, i fixed some more error that my pylint did not find.
Ready to re-review. |
adafruit_rgb_display/hx8353.py
Outdated
|
||
>>> import busio | ||
>>> import digitalio | ||
>>> import board | ||
>>> from adafruit_rgb_display import color565 | ||
>>> import adafruit_rgb_display.hx8353 as hx8353 | ||
>>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO) | ||
>>> display = hx8353.HX8383(spi, cs=digitalio.DigitalInOut(board.GPIO0), dc=digitalio.DigitalInOut(board.GPIO15)) | ||
>>> display = hx8353.HX8383(spi, cs=digitalio.DigitalInOut(board.GPIO0), | ||
dc=digitalio.DigitalInOut(board.GPIO15)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing "..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -1,10 +1,15 @@ | |||
"""A simple driver for the ILI9341/ILI9340-based displays.""" | |||
|
|||
try: | |||
import struct | |||
except ImportError: | |||
import ustruct as struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed, CircuitPython always has "struct".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, sorry, old CircuitPython still uses ustruct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got ya, ignored
adafruit_rgb_display/ili9341.py
Outdated
@@ -16,7 +21,8 @@ class ILI9341(DisplaySPI): | |||
>>> from adafruit_rgb_display import color565 | |||
>>> import adafruit_rgb_display.ili9341 as ili9341 | |||
>>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO) | |||
>>> display = ili9341.ILI9341(spi, cs=digitalio.DigitalInOut(board.GPIO0), dc=digitalio.DigitalInOut(board.GPIO15)) | |||
>>> display = ili9341.ILI9341(spi, cs=digitalio.DigitalInOut(board.GPIO0), | |||
dc=digitalio.DigitalInOut(board.GPIO15)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing "..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
adafruit_rgb_display/ili9341.py
Outdated
|
||
def scroll(self, dy=None): | ||
if dy is None: | ||
def scroll(self, delta_y=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is "dy" not "delta y" or "δy". It's a common notation in math.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted to dy
pass | ||
|
||
def high(self): | ||
"""Dummy high Pin method""" | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole class needs to be rewritten for CircuitPython, as it has a completely different gpio pin API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am inclined to remove dummy pin for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should move it to simpleio, but that would be a separate pull request. Please ignore this comment for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
adafruit_rgb_display/s6d02a1.py
Outdated
|
||
>>> import busio | ||
>>> import digitalio | ||
>>> import board | ||
>>> from adafruit_rgb_display import color565 | ||
>>> import adafruit_rgb_display.s6d02a1 as s6d02a1 | ||
>>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO) | ||
>>> display = s6d02a1.S6D02A1(spi, cs=digitalio.DigitalInOut(board.GPIO0), dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) | ||
>>> display = s6d02a1.S6D02A1(spi, cs=digitalio.DigitalInOut(board.GPIO0), | ||
dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing "..."
adafruit_rgb_display/ssd1331.py
Outdated
@@ -43,7 +48,8 @@ class SSD1331(DisplaySPI): | |||
>>> from adafruit_rgb_display import color565 | |||
>>> import adafruit_rgb_display.ssd1331 as ssd1331 | |||
>>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO) | |||
>>> display = ssd1331.SSD1331(spi, cs=digitalio.DigitalInOut(board.GPIO0), dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) | |||
>>> display = ssd1331.SSD1331(spi, cs=digitalio.DigitalInOut(board.GPIO0), | |||
dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing "...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
adafruit_rgb_display/ssd1331.py
Outdated
# (_CONTRASTA, b'\x91'), #//0xEF - 0x91 | ||
# (_CONTRASTB, b'\x50'), #;//0x11 - 0x50 | ||
# (_CONTRASTC, b'\x7d'), #;//0x48 - 0x7D | ||
# (_DISPLAYON, b''), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DISPLAYON is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added _DISPLAYON
adafruit_rgb_display/ssd1351.py
Outdated
@@ -44,7 +48,8 @@ class SSD1351(DisplaySPI): | |||
>>> from adafruit_rgb_display import color565 | |||
>>> import adafruit_rgb_display.ssd1351 as ssd1351 | |||
>>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO) | |||
>>> display = ssd1351.SSD1351(spi, cs=digitalio.DigitalInOut(board.GPIO0), dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) | |||
>>> display = ssd1351.SSD1351(spi, cs=digitalio.DigitalInOut(board.GPIO0), | |||
dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing "..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
adafruit_rgb_display/st7735.py
Outdated
@@ -62,7 +67,8 @@ class ST7735(DisplaySPI): | |||
>>> 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.ST7735(spi, cs=digitalio.DigitalInOut(board.GPIO0), dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) | |||
>>> display = st7735.ST7735(spi, cs=digitalio.DigitalInOut(board.GPIO0), | |||
dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing "..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
ok, i am done with the 2nd round of testing. does the _DISPLAYON missing explain @kattni problem with drivers? |
adafruit_rgb_display/rgb.py
Outdated
@@ -70,9 +70,9 @@ def _block(self, xpos0, ypos0, xpos1, ypos1, data=None): | |||
return None | |||
#pylint: enable-msg=too-many-arguments | |||
|
|||
def _encode_pos(self, avalue, bvalue): | |||
def _encode_pos(self, x, y): #pylint: disable-msg=invalid-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the impression that pylint has those names added to exceptions in its configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That change got made after i created my template project from cookiecutter. I have updated the .pylintrc and remove the redundant #pylint lines
adafruit_rgb_display/__init__.py
Outdated
@@ -1 +1,2 @@ | |||
"""import class color565""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string here is a bit confusing. First, it's a module-level docstring, so it should be describing the module, rather than commenting the code. Second, color565 is a function, not a class. And finally I'm not sure we need to explain what the "import" statement does.
adafruit_rgb_display/rgb.py
Outdated
|
||
def read(self, command, count): | ||
"""Derived class must implement this""" | ||
raise NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advise against dummy methods raising NotImplementedError
. Not only they waste memory, but they also make it very hard to use super()
properly. I think that AttributeError
in case something tries to call this is good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe pylint has smarts around recognizing unimplemented methods like this and validating that suubclasses define them. The memory hit won't be so large that it isn't worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The real problem is when you use this class in any multiple inheritance scenario, where you have to use super()
to make sure all the methods are properly called, but this will also call this method and raise a NotImplementedError
. That's why this is an anti-pattern. I understand that with CircuitPython we run a much lower risk for this, but it's still a bad habit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting! What would you recommend in this case? Would you mind opening an issue for us to make the drivers consistent on how to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way to do this in normal Python is to use @abc.abstractmethod
, but CircuitPython doesn't have the abc
module. Personally I'm inclined to just leaving this out completely, and just mentioning in the comments that the subclasses need to implement those methods. This is not something the user of the library should ever see or need anyways.
I think so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SSD1331 test fails.
adafruit_rgb_display/ssd1331.py
Outdated
@@ -1,4 +1,9 @@ | |||
"""A simple driver for the SSD1331-based displays.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing with SSD1331 failed. However I get the same results with the current version of the driver as well. Multicolor pixellation and a single vertical line that turns the color that the code attempts to fill the entire display. That 1-pixel-wide line will change color if I change the fill
color in the code. The line is close to the left side, if that matters.
@kattni what does your main.py look like? |
@mrmcwethy The following:
|
I got the SSD1331 display to work after this library was forked from mine. If you look at the MicroPython library, you will see the fixed setup code there: https://github.com/adafruit/micropython-adafruit-rgb-display/blob/master/ssd1331.py#L52-L75 However, I believe that this would be a separate issue and a separate pull request. |
I have the SSD1331 working. I'm going to make a separate PR to resolve it since it's an issue with the current version of the driver as well. |
Now that i have removed the "abstract functions" can this be merged? Also resolved conflicts to SSD1331.py |
I am happy to commit resolved conflicts. If someone else does it, take the "lint" changes over master. |
Current testing status: the ILI9341 and the ST7735 (non-R version) still need to be tested. All other displays have been successfully tested. |
Adafruit does not carry the ST7735, only the ST7735R. ILI9341 tested successfully. That's everything! Great job! |
Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.0.0 from 2.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#10 from mrmcwethy/lint > Update to SSD1331 driver (adafruit/Adafruit_CircuitPython_RGB_Display#11) > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#9 from deshipu/fix-small-buffer > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#8 from deshipu/fix-readinto
Lint all the libraries! #475
Not tested