-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: general Fade(from, to, duration) method (#106)
* FadeOn/FadeOff now use generalized Breathe evaluator allowing us to get rid of classes formerly used for FadeOn/FadeOff * add generalized Fade(from,to,duration) function which internally configures the breathe-effect with min- and max-brightness correctly set up. * add fade from-to example * add pule example
- Loading branch information
1 parent
7bf7edc
commit 4f8de1f
Showing
7 changed files
with
136 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// JLed fade from-to example. Example randomly fades to a new level with | ||
// a random duration. | ||
// Copyright 2022 by Jan Delgado. All rights reserved. | ||
// https://github.com/jandelgado/jled | ||
#include <jled.h> | ||
|
||
auto led = JLed(5).On(1); // start with LED turned on | ||
|
||
void setup() {} | ||
|
||
void loop() { | ||
static uint8_t last_to = 255; | ||
|
||
if (!led.Update()) { | ||
// when effect is done (Update() returns false), | ||
// reconfigure fade effect using random values | ||
auto new_from = last_to; | ||
auto new_to = jled::rand8(); | ||
auto duration = 250 + jled::rand8() * 4; | ||
last_to = new_to; | ||
led.Fade(new_from, new_to, duration).Repeat(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters