Probably a simple question, can anyone show me the basic style code to light an LED red when battery is below 50%
If you want to have other effects, just add this layer to existing style.
AlphaL<Red,IsLessThan<BatteryLevel,Int<16384>>>
If you just want the LED to only do this just add a Black base layer like so:
Layers<Black,AlphaL<Red,IsLessThan<BatteryLevel,Int<16384>>>>
If itâs a single color LED, replace âRedâ with âWhiteâ as White is full power on a single color LED, Red would be 33% power.
One Note, BatteryLevel isnât exactly linear so 16384 may not actually be 50% of your battery. It could be more and it could be less.
awesome cheers, what value is theoretically 100%? 32768?
32768 is full value
Sorry quick tweak to that, how would I make it blink red if over 16384 and orange if below it?
There are several ways depending on EXACTLY what you want.
Blink the same but change color below value? Should it fade from Red to Orange or just a swap?
Change blinking and color below value? Gradual or instant?
Etc?
The more specific you can be on behavior the easier it is to choose best approach.
Basically just blinking red but if battery below 50ish % that it changes to blinking orange.
If I can get that basic functionality working I can probably fiddle etc to get any fades
Layers<
AlphaL<Blinking<Orange,Black,1000,500>,Int<32768>>,
AlphaL<Blinking<Red,Black,1000,500>,IsGreaterThan<BatteryLevel,Int<16384>>>
>
Itâs simply covering (hiding) the orange based layer with the Red one when the conditions are right.
The âbasicâ would vary per what youâre trying to do, NoSloppyâs just covers one layer with another, you canât get any fade on that type of approach. If his is all you need you can probably make it more efficient by just swapping out the color with a function in one layer versus duplicating the full style in two layers, but again if you wanted it to fade or transition then Iâd go a completely different approach. If the above is good then no need for more, but if youâre trying to do more youâll be limited with above in which case more specifics on what youâre wanting will make it easier to give direction.
I used this
StylePtr<Layers<
AlphaL<Blinking<Orange,Black,1000,500>,Int<32768>>,
AlphaL<Blinking<Red,Black,1000,500>,IsGreaterThan<BatteryLevel,Int<16384>>>
>>(),
But get this error when uploading
could not convert â((StyleHelper<RGBA_nod>*)this)->StyleHelper<RGBA_nod>::getColor2(i)â from âRGBA_nodâ to âOverDriveColorâ
oh yeah duh. remove the alpha from the base layer like
StylePtr<Layers<
Blinking<Orange,Black,1000,500>,
AlphaL<Blinking<Red,Black,1000,500>,IsGreaterThan<BatteryLevel,Int<16384>>>
>>(),
sorted
tx