Skip to content
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

Fix setting a pixels slice #28

Merged
merged 1 commit into from
Aug 25, 2021
Merged

Fix setting a pixels slice #28

merged 1 commit into from
Aug 25, 2021

Conversation

Neradoc
Copy link
Contributor

@Neradoc Neradoc commented Aug 25, 2021

When setting the pixels with a slice, set the correct pixel to a value provided (not to the index).

This was discovered using adafruit_led_animation.animation.rainbow

from adafruit_led_animation.animation.rainbow import Rainbow
rainbow = Rainbow(macropad.pixels, speed=.1, period=2)
while True:
    rainbow.animate()

And tested with this (with all values of rotation)

from adafruit_macropad import MacroPad
import time

macropad = MacroPad(rotation=0)

macropad.pixels[:] = (
    (255,0,0), (128,255,0), (0,255,0), (0,255,128),
    (0,0,255), (128,0,255), (255,255,255), (0,0,0),
    (255,0,0), (128,255,0), (0,255,0), (0,255,128),
)
time.sleep(2)

for x in range(9):
    macropad.pixels.fill(0)
    macropad.pixels[x:x+4] = (
        (255,0,0), (0,255,0), (0,0,255), (255,255,255)
    )
    time.sleep(1)

When setting the pixels with a slice, set the correct pixel to a value provided (not to the index).

This was discovered using `adafruit_led_animation.animation.rainbow`
```py
from adafruit_led_animation.animation.rainbow import Rainbow
rainbow = Rainbow(macropad.pixels, speed=.1, period=2)
while True:
    rainbow.animate()
```
And tested with this (with all values of rotation)
```py
from adafruit_macropad import MacroPad
import time

macropad = MacroPad(rotation=0)

macropad.pixels[:] = (
    (255,0,0), (128,255,0), (0,255,0), (0,255,128),
    (0,0,255), (128,0,255), (255,255,255), (0,0,0),
    (255,0,0), (128,255,0), (0,255,0), (0,255,128),
)
time.sleep(2)

for x in range(9):
    macropad.pixels.fill(0)
    macropad.pixels[x:x+4] = (
        (255,0,0), (0,255,0), (0,0,255), (255,255,255)
    )
    time.sleep(1)
```
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit 59c2411 into adafruit:main Aug 25, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 27, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1106 to 1.2.0 from 1.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SH1106#5 from lesamouraipourpre/vertical-scroll

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1107 to 1.4.0 from 1.3.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SH1107#8 from lesamouraipourpre/vertical-scroll

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1305 to 1.3.0 from 1.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SSD1305#13 from lesamouraipourpre/vertical-scroll

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306 to 1.5.0 from 1.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306#23 from lesamouraipourpre/vertical-scroll

Updating https://github.com/adafruit/Adafruit_CircuitPython_OV2640 to 1.1.0 from 1.0.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_OV2640#12 from jerryneedell/jerryn_saola

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1322 to 1.2.0 from 1.1.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1322#12 from lesamouraipourpre/vertical-scroll

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1325 to 1.4.0 from 1.3.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1325#13 from lesamouraipourpre/vertical-scroll
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1325#12 from lesamouraipourpre/docs

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 8.0.3 from 8.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#132 from adafruit/dhalbert-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout to 1.12.0 from 1.11.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#47 from FoamyGuy/remove_dial_and_annotation

Updating https://github.com/adafruit/Adafruit_CircuitPython_HID to 5.1.1 from 5.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_HID#79 from adafruit/tannewt-patch-1
  > Merge pull request adafruit/Adafruit_CircuitPython_HID#76 from FoamyGuy/rename_gamepad_example

Updating https://github.com/adafruit/Adafruit_CircuitPython_MacroPad to 2.0.1 from 2.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_MacroPad#28 from Neradoc/patch-1
@Neradoc Neradoc deleted the patch-1 branch February 26, 2022 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants