Skip to content

Commit

Permalink
Merge pull request #53 from EAGrahamJr/fade_52
Browse files Browse the repository at this point in the history
Return from fade on "None"
  • Loading branch information
tannewt authored Feb 22, 2023
2 parents 97eb72a + 701cb11 commit 5433ba3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
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)

0 comments on commit 5433ba3

Please sign in to comment.