Skip to content

Return from fade on "None" #53

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

Merged
merged 8 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ _build
# Virtual environment-specific files
.env
.venv
venv

# MacOS-specific files
*.DS_Store
Expand Down
15 changes: 10 additions & 5 deletions adafruit_is31fl3731/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Base library.

* Author(s): Tony DiCola, Melissa LeBlanc-Williams, David Glaude
* Author(s): Tony DiCola, Melissa LeBlanc-Williams, David Glaude, E. A. Graham Jr.

Implementation Notes
--------------------
Expand Down Expand Up @@ -202,13 +202,18 @@ def fade(self, fade_in=None, fade_out=None, pause=0):
"""
if fade_in is None and fade_out is None:
self._register(_CONFIG_BANK, _BREATH2_REGISTER, 0)
elif fade_in is None:
return
if fade_in is None:
fade_in = fade_out
elif fade_out is None:
fade_out = fade_in
fade_in = int(math.log(fade_in / 26, 2))
fade_out = int(math.log(fade_out / 26, 2))
pause = int(math.log(pause / 26, 2))

if fade_in != 0:
fade_in = int(math.log(fade_in / 26, 2))
if fade_out != 0:
fade_out = int(math.log(fade_out / 26, 2))
if pause != 0:
pause = int(math.log(pause / 26, 2))
if not 0 <= fade_in <= 7:
raise ValueError("Fade in out of range")
if not 0 <= fade_out <= 7:
Expand Down
24 changes: 24 additions & 0 deletions examples/is31fl3731_ledshim_fade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2023 E. A. Graham, Jr.
# SPDX-License-Identifier: MIT

import time
import board
import busio
from adafruit_is31fl3731.led_shim import LedShim as Display

i2c = busio.I2C(board.SCL, board.SDA)

# initial display if you are using Pimoroni LED SHIM
display = Display(i2c)

y = 1
for x in range(28):
display.pixel(x, y, 255)

display.fade(fade_in=104, pause=250)

try:
while True:
time.sleep(10)
except KeyboardInterrupt:
display.sleep(True)