-
Notifications
You must be signed in to change notification settings - Fork 55
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
FadeOn and stay on forever #88
Comments
How often is the |
On demand, i.e. triggered remotely, but never anywhere close to intervals shorter than |
I think you need to change to something like: #include <jled.h>
#define LASER_PIN 21
#define FRONTLIGHT_PIN 22
#define FADESLOW 3000
JLed pwm_pins[] = {JLed(LASER_PIN).Breathe(255).Forever(), JLed(FRONTLIGHT_PIN).Off()};
void setup() {
Serial.begin(9600);
}
void laser_fade_in_slow(int brightness) {
if (brightness){
Serial.print("Set to FadeOn with brightness=");
Serial.println(brightness);
pwm_pins[0].FadeOn(FADESLOW).MaxBrightness(brightness).Repeat(1).Reset();
} else {
Serial.println("Set to FadeOff");
pwm_pins[0].FadeOff(FADESLOW).Repeat(1).Reset();
}
}
void loop() {
static unsigned long last_change_time_ = 0;
pwm_pins[0].Update();
pwm_pins[1].Update();
delay(1);
// simulation: every 5s call laser_fade_in_slow with a new random brightness
if (millis() - last_change_time_ > 5000) {
last_change_time_ = millis();
const auto brightness= random(0, 255);
if (brightness < 100) {
laser_fade_in_slow(0);
} else {
laser_fade_in_slow(brightness);
}
}
} Otherwise, the effect for pwn_pins[0] will run |
Okay... so say I do this for both pins: #include <jled.h>
#define LASER_PIN 21
#define FRONTLIGHT_PIN 22
#define FADESLOW 3000
JLed pwm_pins[] = {JLed(LASER_PIN).Breathe(255).Forever(), JLed(FRONTLIGHT_PIN).Off()};
void laser_fade_in_slow(int brightness, int what) {
if (brightness){
Serial.print("Set to FadeOn with brightness=");
Serial.println(brightness);
pwm_pins[what].FadeOn(FADESLOW).MaxBrightness(brightness).Repeat(1).Reset();
} else {
Serial.println("Set to FadeOff");
pwm_pins[what].FadeOff(FADESLOW).Repeat(1).Reset();
}
} Note that Then, when I call |
I modified the example to call your #include <jled.h>
#define LASER_PIN 21
#define FRONTLIGHT_PIN 22
#define FADESLOW 3000
#define LASER_PIN 21
#define FRONTLIGHT_PIN 22
#define FADESLOW 3000
JLed pwm_pins[] = {JLed(LASER_PIN).Breathe(255).Forever(),
JLed(FRONTLIGHT_PIN).Off()};
void laser_fade_in_slow(int brightness, int what) {
Serial.print("For LED=");
Serial.print(what);
if (brightness) {
Serial.print(", set to FadeOn with brightness=");
Serial.println(brightness);
pwm_pins[what]
.FadeOn(FADESLOW)
.MaxBrightness(brightness)
.Repeat(1)
.Reset();
} else {
Serial.println(", set to FadeOff");
pwm_pins[what].FadeOff(FADESLOW).Repeat(1).Reset();
}
}
void setup() {
Serial.begin(9600);
}
void loop() {
static unsigned long last_change_time_ = 0;
pwm_pins[0].Update();
pwm_pins[1].Update();
delay(1);
// every 5s call laser_fade_in_slow with a new random brightness
if (millis() - last_change_time_ > 5000) {
last_change_time_ = millis();
const auto brightness = random(0, 255);
const auto what = random(0, 2);
if (brightness < 100) {
laser_fade_in_slow(0, what);
} else {
laser_fade_in_slow(brightness, what);
}
}
} |
Hi! Sorry for not answering for a while. I didn't have the time to test this part until now. TL;DR
Step 1. Adding Step 2. Adding Step 3. I saw in your code that you perform |
Regarding the
In your case also once the sequence "is done", it will not re-start when you reset the contained LEDs. The |
Hi,
Thank you for this fantastic library. I am working with it on a SAMD21 M0 (Feather RFM69) with the following code:
One of the packets received on the radio, triggers the following:
I am sure I am missing something, but I am unable to figure out how to make it stay on at the desired
brightness
level forever, only getting a loop with the same FadeOn.Could you give some guidance?
Thanks in advance
The text was updated successfully, but these errors were encountered: