These are chat archives for Makuna/NeoPixelBus

21st
Jun 2015
sticilface
@sticilface
Jun 21 2015 15:22
so been using the lib for a few days, and it is working really well. I'm wondering, if it would be worth converting things to uint_16. there is quite a lot of stepping, during animations if the difference is not that much but the time is... if that makes sense. ie... stepping from 20 - 40, over 10 seconds, does not give much fine control?
Michael Miller
@Makuna
Jun 21 2015 15:56
For hsl? Have you tried to turn on the float mode and see how it looks? Just modify the hslcolor.h, at the top make sure to uncomment the float define.
sticilface
@sticilface
Jun 21 2015 16:28
i've not tried yet to be honest! i'm in the process of trying to get all my effects working.... BUT you have a point.. it is early days yet.. so things might change.. i all give it a go...
i also thought you have this method... void StopAnimation(uint16_t n); do you think you could add a void StopAnimation(); so that you can effectively just pause all animations at once
sticilface
@sticilface
Jun 21 2015 16:44
although to get them going again would require generating a new callback i guess... how about a PauseAnimations();.... and ResumeAnimations();
Michael Miller
@Makuna
Jun 21 2015 17:51
it into look will, I usefull soundPause and Resume
Wow, I am using my Android tablet to type that, Gitter changed something and this last week Chrome doesn't like it, my words get inserted into a strange order, as the keyboard hides the edit box.
sticilface
@sticilface
Jun 21 2015 17:58
hahah i thought you were intentionally typing star wars
something is not quite right with the floats... and i also meant to say that i get back max values of 255 for brightness.. (not 127)...
I'm just checking now what is going on
ok.. so this is using ints... ( original Lightness, progress, new lightness ) with a BLACK pixel
Original HSL = 0: 0.01 --> 0
Original HSL = 0: 0.02 --> 0
Original HSL = 0: 0.04 --> 0
Original HSL = 0: 0.05 --> 0
Original HSL = 0: 0.07 --> 0
Original HSL = 0: 0.08 --> 0
Original HSL = 0: 0.10 --> 0
Original HSL = 0: 0.11 --> 0
Original HSL = 0: 0.13 --> 0
Original HSL = 0: 0.15 --> 0
Original HSL = 0: 0.16 --> 0
Original HSL = 0: 0.18 --> 0
Original HSL = 0: 0.19 --> 0
Original HSL = 0: 0.21 --> 0
Original HSL = 0: 0.22 --> 0
Original HSL = 0: 0.24 --> 0
Original HSL = 0: 0.25 --> 0
Original HSL = 0: 0.27 --> 0
Original HSL = 0: 0.28 --> 0
Original HSL = 0: 0.30 --> 0
Original HSL = 0: 0.32 --> 0
Original HSL = 0: 0.33 --> 0
Original HSL = 0: 0.35 --> 0
Original HSL = 0: 0.36 --> 0
Original HSL = 0: 0.38 --> 0
Original HSL = 0: 0.39 --> 0
Original HSL = 0: 0.41 --> 0
Original HSL = 0: 0.42 --> 0
Original HSL = 0: 0.44 --> 0
Original HSL = 0: 0.46 --> 0
Original HSL = 0: 0.47 --> 0
Original HSL = 0: 0.49 --> 0
Original HSL = 0: 0.50 --> 0
Original HSL = 0: 0.52 --> 0
Original HSL = 0: 0.53 --> 0
Original HSL = 0: 0.55 --> 0
Original HSL = 0: 0.56 --> 0
Original HSL = 0: 0.58 --> 0
Original HSL = 0: 0.60 --> 0
Original HSL = 0: 0.61 --> 0
Original HSL = 0: 0.63 --> 0
Original HSL = 0: 0.64 --> 0
Original HSL = 0: 0.66 --> 0
Original HSL = 0: 0.67 --> 0
Original HSL = 0: 0.69 --> 0
Original HSL = 0: 0.70 --> 0
Original HSL = 0: 0.72 --> 0
Original HSL = 0: 0.73 --> 0
Original HSL = 0: 0.75 --> 0
Original HSL = 0: 0.77 --> 0
Original HSL = 0: 0.78 --> 0
Original HSL = 0: 0.80 --> 0
Original HSL = 0: 0.81 --> 0
Original HSL = 0: 0.83 --> 0
Original HSL = 0: 0.84 --> 0
Original HSL = 0: 0.86 --> 0
Original HSL = 0: 0.87 --> 0
Original HSL = 0: 0.89 --> 0
Original HSL = 0: 0.90 --> 0
Original HSL = 0: 0.92 --> 0
Original HSL = 0: 0.94 --> 0
Original HSL = 0: 0.95 --> 0
Original HSL = 0: 0.97 --> 0
Original HSL = 0: 0.98 --> 0
Original HSL = 0: 1.00 --> 0
Original HSL = 0: 1.00 --> 0
WHITE PIXEL
Original HSL = 255: 0.02 --> 251
Original HSL = 255: 0.03 --> 247
Original HSL = 255: 0.05 --> 243
Original HSL = 255: 0.06 --> 239
Original HSL = 255: 0.08 --> 235
Original HSL = 255: 0.09 --> 231
Original HSL = 255: 0.11 --> 227
Original HSL = 255: 0.12 --> 223
Original HSL = 255: 0.14 --> 219
Original HSL = 255: 0.16 --> 215
Original HSL = 255: 0.17 --> 211
Original HSL = 255: 0.19 --> 207
Original HSL = 255: 0.20 --> 203
Original HSL = 255: 0.22 --> 199
Original HSL = 255: 0.23 --> 195
Original HSL = 255: 0.25 --> 191
Original HSL = 255: 0.26 --> 187
Original HSL = 255: 0.28 --> 183
Original HSL = 255: 0.29 --> 179
Original HSL = 255: 0.31 --> 175
Original HSL = 255: 0.33 --> 171
Original HSL = 255: 0.34 --> 168
Original HSL = 255: 0.36 --> 164
Original HSL = 255: 0.37 --> 160
Original HSL = 255: 0.39 --> 156
Original HSL = 255: 0.40 --> 152
Original HSL = 255: 0.42 --> 148
Original HSL = 255: 0.43 --> 144
Original HSL = 255: 0.45 --> 140
Original HSL = 255: 0.47 --> 136
Original HSL = 255: 0.48 --> 132
Original HSL = 255: 0.50 --> 128
Original HSL = 255: 0.51 --> 124
Original HSL = 255: 0.53 --> 120
Original HSL = 255: 0.54 --> 116
Original HSL = 255: 0.56 --> 112
Original HSL = 255: 0.57 --> 108
Original HSL = 255: 0.59 --> 104
Original HSL = 255: 0.60 --> 100
Original HSL = 255: 0.62 --> 96
Original HSL = 255: 0.64 --> 92
Original HSL = 255: 0.65 --> 88
Original HSL = 255: 0.67 --> 85
Original HSL = 255: 0.68 --> 81
Original HSL = 255: 0.70 --> 77
Original HSL = 255: 0.71 --> 73
Original HSL = 255: 0.73 --> 69
Original HSL = 255: 0.74 --> 65
Original HSL = 255: 0.76 --> 61
Original HSL = 255: 0.77 --> 57
Original HSL = 255: 0.79 --> 53
Original HSL = 255: 0.81 --> 49
Original HSL = 255: 0.82 --> 45
Original HSL = 255: 0.84 --> 41
Original HSL = 255: 0.85 --> 37
Original HSL = 255: 0.87 --> 33
Original HSL = 255: 0.88 --> 29
Original HSL = 255: 0.90 --> 25
Original HSL = 255: 0.91 --> 21
Original HSL = 255: 0.93 --> 17
Original HSL = 255: 0.95 --> 13
Original HSL = 255: 0.96 --> 9
Original HSL = 255: 0.98 --> 5
Original HSL = 255: 0.99 --> 2
Original HSL = 255: 1.00 --> 0
so this is working... a L of 255 gets faded to 0, over progress from 0 - 1
sticilface
@sticilface
Jun 21 2015 18:13
This is a black pixel... using floats...
Original HSL = 2.49: 0.01 --> 2.49
Original HSL = 2.36: 0.02 --> 2.36
Original HSL = 1.98: 0.04 --> 1.98
Original HSL = 1.35: 0.05 --> 1.35
Original HSL = 0.48: 0.07 --> 0.48
Original HSL = -0.63: 0.08 --> -0.63
Original HSL = -1.99: 0.10 --> -1.99
Original HSL = -3.60: 0.12 --> -3.60
Original HSL = -5.44: 0.13 --> -5.44
Original HSL = -7.54: 0.15 --> -7.54
Original HSL = -9.87: 0.16 --> -9.87
Original HSL = -12.45: 0.18 --> -12.45
Original HSL = -15.28: 0.19 --> -15.28
Original HSL = -0.42: 0.21 --> -0.42
Original HSL = -0.45: 0.22 --> -0.45
Original HSL = -3.61: 0.24 --> -3.61
Original HSL = -6.98: 0.25 --> -6.98
Original HSL = -10.57: 0.27 --> -10.57
Original HSL = -14.38: 0.29 --> -14.38
Original HSL = -18.41: 0.30 --> -18.41
Original HSL = -22.65: 0.32 --> -22.65
Original HSL = -27.11: 0.33 --> -27.11
Original HSL = -31.79: 0.35 --> -31.79
Original HSL = -36.68: 0.36 --> -36.68
Original HSL = -41.79: 0.38 --> -41.79
Original HSL = -47.12: 0.39 --> -47.12
Original HSL = -52.66: 0.41 --> -52.66
Original HSL = -58.42: 0.43 --> -58.42
Original HSL = -64.40: 0.44 --> -64.40
Original HSL = -70.59: 0.46 --> -70.59
Original HSL = -77.00: 0.47 --> -77.00
Original HSL = -83.63: 0.49 --> -83.63
Original HSL = -90.48: 0.50 --> -90.48
Original HSL = -97.54: 0.52 --> -97.54
Original HSL = -104.82: 0.53 --> -104.82
Original HSL = -112.32: 0.55 --> -112.32
Original HSL = -120.03: 0.56 --> -120.03
Original HSL = -127.96: 0.58 --> -127.96
Original HSL = -136.10: 0.60 --> -136.10
Original HSL = -144.47: 0.61 --> -144.47
Original HSL = -153.05: 0.63 --> -153.05
Original HSL = -161.85: 0.64 --> -161.85
Original HSL = -170.86: 0.66 --> -170.86
Original HSL = 0.64: 0.67 --> 0.64
Original HSL = -8.80: 0.69 --> -8.80
Original HSL = -18.47: 0.70 --> -18.47
Original HSL = -28.35: 0.72 --> -28.35
Original HSL = -38.45: 0.74 --> -38.45
Original HSL = 0.49: 0.75 --> 0.49
Original HSL = -10.04: 0.77 --> -10.04
Original HSL = -20.79: 0.78 --> -20.79
Original HSL = -31.76: 0.80 --> -31.76
Original HSL = -42.94: 0.81 --> -42.94
Original HSL = -54.34: 0.83 --> -54.34
Original HSL = -65.96: 0.84 --> -65.96
Original HSL = -77.79: 0.86 --> -77.79
Original HSL = -89.84: 0.87 --> -89.84
Original HSL = -102.11: 0.89 --> -102.11
Original HSL = -114.59: 0.91 --> -114.59
Original HSL = -127.29: 0.92 --> -127.29
Original HSL = -140.21: 0.94 --> -140.21
Original HSL = -153.35: 0.95 --> -153.35
Original HSL = -166.70: 0.97 --> -166.70
Original HSL = -180.27: 0.98 --> -180.27
Original HSL = -194.05: 1.00 --> -194.05
Original HSL = -208.03: 1.00 --> -208.03
here is the code Im using...
#ifdef HSL_FLOAT
            float NewLIG = ( (HslColor(original)).L - ((HslColor(original)).L  * progress) ); 
            RgbColor updatedColor = RgbColor(HslColor( (HslColor(original)).H, (HslColor(original)).S, NewLIG  ))  ; 

#else
            uint8_t NewLIG = (uint8_t) ( HslColor(original).L - (HslColor(original).L  * progress) ); 
            RgbColor updatedColor = RgbColor(HslColor( HslColor(original).H, HslColor(original).S, NewLIG  ))  ;    

#endif
So what I don't understand is that when I'm using ints... the original colour stays the same. When i use floats the original colour is lost! and it changes continuously...
sticilface
@sticilface
Jun 21 2015 19:18
Right... if u use HslColor.H .S .L .... for white... in int mode i get 0,0,255 in float mode i get 1.9,0,0
Michael Miller
@Makuna
Jun 21 2015 19:20
Could you include more code around your last example, I don't think its right. Is Original a RgbColor? You don't want to convert it so much, cache it.
HslColor hslOriginal = HslColor(original);
float NewLIG = ( hslOriginal.L - (hslOriginal.L  * progress) ); 
            RgbColor updatedColor = RgbColor(HslColor( hslOriginal.H, hslOriginal .S, NewLIG  ))  ;
Your new L value calculation doesn't seem right. What are you trying to do?
Normally, you calc the delta between the original and where you want it to be, multiply this by the progress, and then add that to the original.
float NewLIG = (hslTarget.L - hslOriginal.L) * progress + hstOriginal.L;
BTW, you can call strip.SetPixelColor() with a hslColor, it will auto convert for you.
sticilface
@sticilface
Jun 21 2015 19:36
ah ok... that will help
i think there is a bug somewhere...
bingo.. found it... unless #define HSL_FLOAT is included IN the Hslcolor.cpp file it returns the int
that is why nothing has been working
sticilface
@sticilface
Jun 21 2015 19:42
i had it in my main.ino which does work... but then i used your debug code.. and i was getting int for H S L when they should have been the floats.... even with #define HSL_FLOAT in the HslColor.p file it doesn't work
here it is with HSL_FLOAT in the cpp file
RGB picker command: 17FF45
0.37, 1.00, 0.55 = 0.37, 1.00, 0.55
0.37, 1.00, 0.55 = 0.37, 1.00, 0.55
0.37, 1.00, 0.55 = 0.37, 1.00, 0.55
HSL components (float): 0.37,1.00,0.55
RGB components: 23,255,69
RGB picker command: 17FF45
correct
Michael Miller
@Makuna
Jun 21 2015 19:43
At the top of HslColor.h, there should be a commented out define, just uncomment it and it will work.
sticilface
@sticilface
Jun 21 2015 19:44
yes i think I'm barking up the wrong tree
ah... a noob mistake... i thought i could get away with putting the #define in MY ino and it would propagate... but it doesn't... is there anyway of passing from my sketch without editing the lib?
Michael Miller
@Makuna
Jun 21 2015 19:47
I think I am going to make HslColor float by default for now until I can figure out a way to get more color range out H, it can't be a uint8_t.
sticilface
@sticilface
Jun 21 2015 19:48
yeah this is what i was thinking... from my implementation!
when u say cache do you mean just assign it to a variable?
Michael Miller
@Makuna
Jun 21 2015 19:48
Unfortunately you can't do that with the Arduino IDE. Normally somewhere attached to the "sketch" or project, you can include symbols, you would just type the symbol in there and it would be applied to all files, they lack this in their IDE.
Yes, cache in the very general sense, capture the value into a variable. By what you were doing, it would run the code to convert from RGB to HSL every time to just get the L property that isn't changing.
sticilface
@sticilface
Jun 21 2015 19:56
so the floats are much smoother with the lightness as well.
Michael Miller
@Makuna
Jun 21 2015 19:58
I updated the animator branch to use float by default for hsl, and I added Pause() and Resume().
sticilface
@sticilface
Jun 21 2015 20:00

brilliant.. that is great...

so one more question for today?

how are you calculating the animation stepping?
Michael Miller
@Makuna
Jun 21 2015 20:00
I was doing calculations yesterday on Hsl that uses uint8_t and the math just can't work out. Not only is the H limited, but the way S and L are used, they can vary in their need for precision based on how mono-chromatic the color is. So there is no easy way to add a few bits to H by taking them from the others.
sticilface
@sticilface
Jun 21 2015 20:02
basically i've noticed that if an inturrupt goes.. or something like a web page fires then the animation will do a huge jump to catch up to where it thinks it should be.. it might be better to have (i don't even know if this is possible) but a relative approach.. where the time animating is kept constant even if it is interrupted.. not a biggie just wondering
Michael Miller
@Makuna
Jun 21 2015 20:05
standard "update" loop timing, check how much time has passed since the last time it was called, apply this delta to the individual animations time and then just calculate the delta from original time to the progress. (core code below)
                    pAnim->remaining -= delta;

                    float progress = (float)(pAnim->time - pAnim->remaining) / (float)pAnim->time;

                    pAnim->fnUpdate(progress);
Michael Miller
@Makuna
Jun 21 2015 20:10
You should try to keep the work within the interrupt (or web page service) to a small quantum. Most interrupts are already small by nature. The WiFi stuff actually is running another "thread" with the main app so we can't control it. But work you do to service the WiFi can be split into smaller pieces where you do the pieces over time. If you are interested in this sort of topic, look at my Task library on GitHub. It was meant to help you split work up. BUT....
sticilface
@sticilface
Jun 21 2015 20:10
ok, i guess that is the easiest way. it looks good with floats btw.. a lot better
can strip->GetPixelColor(pixel); return an Hsl does not look like it can?
Michael Miller
@Makuna
Jun 21 2015 20:11
I think what you really want is to say is to put a cap on the max amount of time that can progress. Such that if the time is less than 100ms, then use the real time, if its over 100ms, use 100ms no matter how much time went by.
No, GetPixelColor will always return a RGB, you will need to convert.
sticilface
@sticilface
Jun 21 2015 20:12
yes, that is much better way of saying it
Michael Miller
@Makuna
Jun 21 2015 20:25
ok, see the new UpdateAnimations() call, you can try passing 100 into it and it should make the animations have less jarring changes but will no longer match real time if the update takes longer than 100ms.
sticilface
@sticilface
Jun 21 2015 20:34
ah cool. thank you:) I will give it a go... still trying to get floats to work properly so there is a lot for me to test here:)
sticilface
@sticilface
Jun 21 2015 22:22
pause and resume work nicely.
not having any float troubles.