-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
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
Extend RGB LED with Printer Events #6240
Extend RGB LED with Printer Events #6240
Conversation
84b9c24
to
2416037
Compare
Marlin/Marlin_main.cpp
Outdated
r = 255; | ||
g = 0; | ||
set_led_color(r, g, b); | ||
set_led_color(255, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@boweeble I assume this is the correct fix?
90a0b3c
to
684384c
Compare
f82ebf0
to
b396486
Compare
The RGB strip does not have to be pwm pins. The TIP's don't care. Can be digital, but transitions won't happen. |
I just got through testing this. Brings back memories of the issues I worked through on this. |
Right, PWM is truly optional. I'll modify the notes. |
I'm curious. Why submit a new feature that needs work when getting ready for a release? |
b396486
to
daae9df
Compare
@Tannoo I was using this as an example while working on a video explaining how to use git for the developers of Marlin. So, then I've been trying to polish it up since. And actually, it doesn't amount to a new feature after all. It's ending up being more like just changing the notes on the existing I don't know if this would get merged before the release. Do you think it looks innocuous enough to merge? How's things with you? Working on anything interesting lately? |
I would not merge this as it is incomplete and doesn't doo all of what's advertised. I am ok. Currently trying to track down something I noticed this afternoon on my display. Not sure if it's something I did or not. I've gone back several of my backups ago and it's still the same. So, I'm not sure when that broke. |
I will dig into it more in the am. |
I generally agree. All it now amounts to is This PR doesn't need to worry about PWM versus non-PWM, since both will work with the right pins. Obviously we can't prevent someone hooking up an LED strip wrong (without power MOSFETs) so I think the warnings are enough in support of LED Strips. The only thing really left to do with this is to make sure the |
I'll flash the latest |
Yes. Reprap full graphic. |
daae9df
to
0fa0fab
Compare
I already have the led things working on mine. Printer events for homing, leveling, printing, filament change events, and done homing. I have tested it with a single rgb led, an rgb strip, an rgbw strip, and an addressable rgb strip. The only thing I couldn't test yet is the blinkm. |
0fa0fab
to
bd96806
Compare
|
b04afcb
to
b79bafe
Compare
I'm not sure if I need the |
The initial color setting in this PR is guaranteed by the initialized values of |
You know, I may have just run into pure luck that it's been working for me. lol I will change it to something that is guaranteed. |
That was my working assumption. 😉 |
I will have to test what you have done here without my minglings.
I have been trying to implement this into mine, and all I get is a slower flashing of red and purple. |
Marlin/Marlin_main.cpp
Outdated
@@ -6195,11 +6251,16 @@ inline void gcode_M109() { | |||
|
|||
target_extruder = active_extruder; // for print_heaterstates | |||
|
|||
#if ENABLED(PRINTER_EVENT_LEDS) | |||
const float start_temp = thermalManager.degTargetBed(); | |||
uint8_t old_red = 255; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const float start_temp = thermalManager.degBed();
const uint8_t old_red = 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right… thermalManager.degBed
is better!
Since old_red
is altered below, it can't be const
. And it should be 255 to start, because this ensures the color will be set on the first iteration (because the initial red will be closer to 0).
Marlin/Marlin_main.cpp
Outdated
bool wants_to_cool = false; | ||
wait_for_heatup = true; | ||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0; | ||
|
||
KEEPALIVE_STATE(NOT_BUSY); | ||
|
||
#if ENABLED(PRINTER_EVENT_LEDS) | ||
const float start_temp = thermalManager.degTargetHotend(target_extruder); | ||
uint8_t old_blue = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const float start_temp = thermalManager.degHotend(target_extruder);
const uint8_t old_blue = 255
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right… thermalManager.degHotend
is better!
Since old_blue
is altered below, it can't be const
. And it should be 0 to start, because this ensures the color will be set on the first iteration (because the initial blue will be closer to 255).
I got a copy of your repo and got this to compile, then got the transitions working. |
Simple changes and not that many to make it work. I'll just comment them in the code. |
const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0); | ||
if (blue != old_blue) set_led_color(255, 0, (old_blue = blue)); | ||
} | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if ENABLED(PRINTER_EVENT_LEDS)
// Gradually change LED strip from violet to red as nozzle heats up
if (wait_for_heatup && !wants_to_cool) {
const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0);
if (blue == old_blue) set_led_color(255, 0, 255); //Purple to start
if (blue != old_blue) set_led_color(255, 0, blue); //Start transitioning to Red
}
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd generally reduce those two lines down to one:
set_led_color(255, 0, blue == old_blue ? 255 : blue);
…but they are incorrect. First of all, old_blue
is not being set to blue
when it differs. Secondly, with that correction made, blue == old_blue
will evaluate true most of the time.
if (red != old_red) set_led_color((old_red = red), 0, 255); | ||
} | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if ENABLED(PRINTER_EVENT_LEDS)
// Gradually change LED strip from blue to violet as bed heats up
if (wait_for_heatup && !wants_to_cool) {
const uint8_t red = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 0, 255);
if (red == old_red) set_led_color(0, 0, 255); //Blue to start
if (red != old_red) set_led_color(red, 0, 255); //Start transitioning to Purple
}
#endif
It works fine with those changes. |
Trying from the web interface or from Github Desktop? It should be easier from the web interface. If you open your fork's page, the link to create a PR will be at the top. |
1cac42b
to
e7746ff
Compare
Only by kismet. The code you pasted will simply always pass the test Yep, I do dream in code. I started programming in 1978 in Sinclair BASIC. By 1984 I was programming 6502 Assembler. In 1988 I was programming 680x0 Assembler, writing Amiga games. But I must admit, I didn't start programming in C++ until around 1997. Of course, now I eat new languages for breakfast. 😜 |
I presume that for an RGBW LED we just need to add one more pin and treat all gray values as varying intensities of white. For example, if the color given is |
|
That's the idea. |
It's back to flickering again....WTH? I think it's due to your code is too efficient and it's executing too fast. |
So, no ws2812b support as of now? :'( |
Not officially, yet. Although, my branch has it currently working. |
Rebase and squash of #5395 by @boweeble
RGB_LED_STRIP
was not needed as a separate feature. The only difference was that the led strip "required" PWM pins, whileRGB_LED
would work with either PWM or 5V digital.It is still possible to add software PWM for those cases where one or more pins isn't hardware-PWM-capable, but we need a way to determine at compile-time that a pin is PWM capable (and available for use because it's not associated with a timer).