Skip to content

Commit

Permalink
Added additional "Breathe" example.
Browse files Browse the repository at this point in the history
  • Loading branch information
freefoote authored Sep 4, 2023
1 parent 3be7894 commit 96fde0d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/Berry_Addressable-LED.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,40 @@ var r = Rainbow_stripes(strip, 1.0)
r.start()
```

And here is another example that "breathes" the LED strip with a hardcoded colour:

``` python
class Breathe : Leds_animator
var brightness
var colour

# duration in seconds
def init(strip, duration)
super(self).init(strip)
self.brightness = 0
self.colour = 0xFFFFFF
self.add_anim(animate.back_forth(def(v) self.brightness = v end, 0, 100, int(duration * 1000)))
end

def animate()
var i = 0
while i < self.pixel_count # doing a loop rather than a `for` prevents from allocating a new object
self.strip.set_pixel_color(i, self.colour, self.brightness)
i += 1
end
self.strip.show()
end
end
```

And to use this one:

``` python
var strip = Leds(5,5, gpio.pin(gpio.WS2812, 1))
var r = Breathe(strip, 2.0)
r.start()
```

## Advanced features

### Hardware `RMT` channels
Expand Down

0 comments on commit 96fde0d

Please sign in to comment.