forked from jandelgado/jled
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optionally return last brightness value from Update() (jandelgado#131)
add new example examples/last_brightness
- Loading branch information
1 parent
41e5276
commit f6ccd9d
Showing
12 changed files
with
313 additions
and
134 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"packages": [ | ||
"python@3.11", | ||
"python@3.13", | ||
"[email protected]", | ||
"pipx", | ||
"[email protected]" | ||
], | ||
"shell": { | ||
"init_hook": [ | ||
"echo 'Welcome to devbox!' > /dev/null" | ||
"init_hook": [ | ||
". $VENV_DIR/bin/activate" | ||
], | ||
"scripts": { | ||
"test": [ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Stops an effect when a button is pressed (and hold). When the button is | ||
// released, the LED will fade to off with starting the brightness value it had | ||
// when the effect was stopped. | ||
// | ||
// dependency: arduinogetstarted/[email protected] to control the button | ||
// | ||
// Copyright 2024 by Jan Delgado. All rights reserved. | ||
// https://github.com/jandelgado/jled | ||
// | ||
#include <ezButton.h> // arduinogetstarted/[email protected] | ||
#include <jled.h> | ||
|
||
constexpr auto LED_PIN = 16; | ||
constexpr auto BUTTON_PIN = 18; | ||
|
||
auto button = ezButton(BUTTON_PIN); | ||
|
||
// start with a pulse effect | ||
auto led = | ||
JLed(LED_PIN).DelayBefore(1000).Breathe(2000).Forever().MinBrightness(25); | ||
|
||
void setup() {} | ||
|
||
void loop() { | ||
static int16_t lastBrightness = 0; | ||
|
||
button.loop(); | ||
led.Update(&lastBrightness); | ||
|
||
if (button.isPressed()) { | ||
// when the button is pressed, stop the effect on led, but keep the LED | ||
// on with it's current brightness ... | ||
led.Stop(JLed::KEEP_CURRENT); | ||
} else if (button.isReleased()) { | ||
// when the button is released, fade from the last brightness to 0 | ||
led = JLed(LED_PIN).Fade(lastBrightness, 0, 1000); | ||
} | ||
} |
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
Oops, something went wrong.