-
Notifications
You must be signed in to change notification settings - Fork 10
Initial release #1
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
Tested on Hollowing with invalid file present on board. |
adafruit_slideshow.py
Outdated
self._file_list = self._get_filenames() | ||
if self._order == SlideShow.RANDOM: | ||
self._file_list = sorted(self._file_list, key=lambda x: random.random()) | ||
self._images = self._get_next_image() |
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.
Unindent. Shouldn't be in the if
. Looks like that was my bad. I only tested random. :(
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 was testing it with alphabetical and it seemed to be working so I didn't think anything of it. On closer investigation it was only mostly working. Fixed.
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.
Couple small things.
With regards to type-checking for arguments, there are a couple more spots you could check (dwell
is int
), but I think they'll fail with standard exceptions anyway.
adafruit_slideshow.py
Outdated
FADE_IN = 0 | ||
SHOW_IMG = 1 | ||
FADE_OUT = 2 | ||
LOAD_IMG = 3 |
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.
These are all internal variables. Should start with _
? (_FADE_IN
)
Also, now that I read further down...these should also move outside of the SlideShow()
class. The variables themselves don't change, the self._current_state
does, so you don't need to recreate them for every instance of the class. Calls to self.FADE_IN
etc will also need to change after that.
return self._order | ||
|
||
@order.setter | ||
def order(self, order): |
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.
If there are only 2 options, I would check that the supplied argument meets one of them:
def order(self, order):
if not order in [ALPHA, RANDOM]:
raise ValueError("Order must be either 'RANDOM' or 'ALPHA'")
This should also be checked in __init__
.
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.
__init__
can do self.order = order
to call the setter instead of setting _order directly.
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.
So every instance of _order
gets changed to order
then?
Added ability to choose whether slideshow will automatically cycle through the images or whether you would like to specify an input to manually cycle through the slideshow. Added backlight brightness level control. Added ability to cycle forwards or backwards through image list. Added ability to turn off the fade in/out effects during image transition - this means the redraw effect of the image changing is visible, but it also means you can advance more quickly through the list if you choose to. Documentation updated. Various linting fixes.
I found a minor bug in the slideshow_simpletest.py:
|
@jerryneedell I already found that and updated it. Thanks for catching it though! Travis failed on it for me. |
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.
Found a few minor things.
adafruit_slideshow.py
Outdated
while slideshow.update(): | ||
pass | ||
|
||
Example code for Hollowing Express. Sets ``dwell`` to 0 seconds, turns ``auto_advance`` off, |
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.
s/Hollowing/Hallowing
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.
:face_palm: Thank you for catching this.
adafruit_slideshow.py
Outdated
|
||
**Hardware:** | ||
|
||
* `Adafruit Hollowing M0 Express <https://www.adafruit.com/product/3900>`_ |
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.
s/Hollowing/Hallowing
adafruit_slideshow.py
Outdated
if slideshow should auto play, ``False`` if you want to control advancement | ||
manually. Default is ``True``. | ||
|
||
Example code for Hollowing Express. With this example, the slideshow will play through once |
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.
s/Hollowing/Hallowing
docs/index.rst
Outdated
.. toctree:: | ||
:caption: Related Products | ||
|
||
Adafruit Hollowing M0 Express <https://www.adafruit.com/product/3900> |
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.
s/Hollowing/Hallowing
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.
These internals are more complicated than they need to be. In particular:
- There aren't really 5 states, there are two: waiting or advancing. That way you only need to track the time.
- You don't need a generator. Instead, just save the current index on self.
I've gone through and reworked this PR and PRed to it (so meta!) here: kattni#1 The PR also includes fixes for these inline comments.
Overall the API looked really good! I only changed how brightness works. Thanks for getting it this far! All the knobs are nice!
adafruit_slideshow.py
Outdated
|
||
# pylint: disable=too-many-arguments | ||
def __init__(self, folder="/", order=PlayBackMode.RANDOM, loop=True, dwell=3, fade_effect=True, | ||
auto_advance=True): |
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.
How about adding *,
after self to force these as kwargs? Otherwise things can get confusing with the multiple boolean options.
adafruit_slideshow.py
Outdated
if self.order == PlayBackMode.RANDOM: | ||
self._file_list = sorted(self._file_list, key=lambda x: random.random()) | ||
|
||
def backlight_level_up(self, step=16): |
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.
Why not have a max_brightness
property instead? That way you can just += to change it.
adafruit_slideshow.py
Outdated
except ValueError as error: | ||
print("Incompatible image:", imagename, str(error)) | ||
|
||
return True |
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.
Why return anything?
adafruit_slideshow.py
Outdated
self._show_bmp(imagename) | ||
self._current_state = _FADE_IN | ||
except ValueError as error: | ||
print("Incompatible image:", imagename, str(error)) |
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.
Its weird to print from within a library. I'd suggest either now catching the exception or silently passing.
adafruit_slideshow.py
Outdated
odb = displayio.OnDiskBitmap(image) | ||
face = displayio.Sprite(odb, pixel_shader=displayio.ColorConverter(), position=(0, 0)) | ||
self._group.append(face) | ||
board.DISPLAY.wait_for_frame() |
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 will close the image file too early. It should be open until the sprite is popped from the group. We don't check this currently but it should check and throw an error.
examples/slideshow_simpletest.py
Outdated
slideshow.loop = False | ||
|
||
# Set the order to alphabetical. | ||
slideshow.order = PlayBackMode.ALPHA |
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.
Why don't the examples use the constructor arguments instead? I'd only expect the properties to be used when changing from within the loop.
time.sleep(0.01) | ||
|
||
def update(self): | ||
"""Updates the slideshow to the next image.""" |
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 change this comment because it won't always go to the next image.
The extra states jumped out at me because each |
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.
Looks good! Thanks for taking my changes
In commit |
No description provided.