These are chat archives for Makuna/NeoPixelBus

23rd
Mar 2016
Michael Miller
@Makuna
Mar 23 2016 01:32
@marksev1 Their HSL to RGB is EXACTLY the same as mine.
@marksev1 Their HSV to RGB is VERY CLOSE to the same as my HSB to RGB, the only difference is when S = 0.0
marksev1
@marksev1
Mar 23 2016 10:17
but I need RGB to HSB right
marksev1
@marksev1
Mar 23 2016 10:24
green (0,255,0) red (255,0,0) blue (0,0,255) https://github.com/mjackson/mjijackson.github.com/blob/master/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript.txt so can I use this code to convert to something that that sketch that i have currently will accept?
marksev1
@marksev1
Mar 23 2016 10:48
so I think its outputting red-green-blue right?
marksev1
@marksev1
Mar 23 2016 15:38
now I did the conversion and for green rgb 0 255 0 i get hsl h 0.3333333 s 1 and l 0.5 does it look legit?
Aditya Tannu
@AdySan
Mar 23 2016 15:39
I think so, thats 100% green
marksev1
@marksev1
Mar 23 2016 15:42
no I think i'm gonna have to modify your code a bit right
remove the /100
brightness = (myMessage.toFloat())/100;
this one came out as 0.5 does that mean its already a float
do i have to remove .toFloat()
and do i have to remove /100
Aditya Tannu
@AdySan
Mar 23 2016 15:45
yes to all of those
marksev1
@marksev1
Mar 23 2016 15:46
so then its brightness = (myMessage);
Aditya Tannu
@AdySan
Mar 23 2016 15:47
oh so you're doing the conversion in JS
marksev1
@marksev1
Mar 23 2016 15:48
yes do u want the code
Aditya Tannu
@AdySan
Mar 23 2016 15:48
I think the way I'm using MQTT, it's just sending plain text, that's why I had to use .toFloat()
marksev1
@marksev1
Mar 23 2016 15:48
its directly usable in the "function" node in node-red
Aditya Tannu
@AdySan
Mar 23 2016 15:48
hence on the esp8266/arduino side, I had to convert the text to a float
marksev1
@marksev1
Mar 23 2016 15:49
hmm I think I need to leave that
Aditya Tannu
@AdySan
Mar 23 2016 15:49
yeah
marksev1
@marksev1
Mar 23 2016 15:49
because one value came as 1
which could be an integer
hmm hue you are converthing to integer?
hue = myMessage.toInt();
I don't get hue as always an integer
marksev1
@marksev1
Mar 23 2016 15:54
so I think I need to convert it to float right
Aditya Tannu
@AdySan
Mar 23 2016 15:55
yes, the HSC converson I'm using uses a value of 0-360 for Hue https://gist.github.com/AdySan/edbd96ad1c0e5990f78c#file-adafruit_neopixel-cpp-L1206
hence I just use the value from HomeKit as it is, just converting text to Int
marksev1
@marksev1
Mar 23 2016 15:56
aha its because of the library right
Aditya Tannu
@AdySan
Mar 23 2016 15:56
yes
marksev1
@marksev1
Mar 23 2016 15:56
so I need to probably change that for Makuna's library
Aditya Tannu
@AdySan
Mar 23 2016 15:56
yeah I think this library expects 0-1
marksev1
@marksev1
Mar 23 2016 16:10
with decimals inbetween?
Aditya Tannu
@AdySan
Mar 23 2016 16:13
yes, hence you need to convert to float
marksev1
@marksev1
Mar 23 2016 16:14
yup
hue = myMessage.toFloat(); without the outer () since I don't do any devision or something right
sorry for my noobness
Aditya Tannu
@AdySan
Mar 23 2016 16:18
yes looks right
its kinda funny how these days people are more comfortable in node.js rather than c/c++
marksev1
@marksev1
Mar 23 2016 16:19
I'm in neither :D
I have good people like your guys everywhere around to help :D
thank you guys you are awesome!
Aditya Tannu
@AdySan
Mar 23 2016 16:20
me neither, but as for Node.Js I'm only capable of copy-paste from stack exchange
or GitHub
marksev1
@marksev1
Mar 23 2016 16:21
but now that I went reading through it, i do think some simple js or simple python is more readable than c/c++, for a noob non-coder like me
Aditya Tannu
@AdySan
Mar 23 2016 16:22
i agree, but on a fundamental level, I really dont know what exactly NodeJS is...
marksev1
@marksev1
Mar 23 2016 16:23
yeah, me neither. I'm a pharmacist :D
I need to learn tho', started with python first since they say its easiest, but now I'm at some more advanced topics which I don't understand alot lol
:D
Aditya Tannu
@AdySan
Mar 23 2016 16:23
NeoPixels attract all sorts of people
marksev1
@marksev1
Mar 23 2016 16:25
yup i like those colorful lights, so much possibilities :D
especially if used with node-red
for example alarm mode they could all turn red :D
or like weather notification if weather is forecasted good then show yellow lights if its forecasted bad show blue lights
if someone is infront of the door also change color :D
etc
marksev1
@marksev1
Mar 23 2016 17:42
Cool maybe now I could start expandimg the sketch for animations
But I need to wait also for Makuna so that both u guys inspect the sketch and values
Michael Miller
@Makuna
Mar 23 2016 17:47
Did you update the sketch? I gave feedback on something yesterday or was it the day before that.
marksev1
@marksev1
Mar 23 2016 17:49
Yes i did
Ill pastebin it or something
Just a sec
Michael Miller
@Makuna
Mar 23 2016 17:49
Do me @makuna with link 😃
marksev1
@marksev1
Mar 23 2016 17:50
a pm?
Michael Miller
@Makuna
Mar 23 2016 17:50
No, just here, it marks it in the history so I can find it easier.
marksev1
@marksev1
Mar 23 2016 17:51
@Makuna http://pastebin.com/zczMnL30 I just pasted it for 1 day :D
Can you also feedback this question-> now I did the conversion and for green rgb 0 255 0 i get hsl h 0.3333333 s 1 and l 0.5 does it look legit?
I didn't update yet with animations if you were asking that
I just update it to the values I'm getting from node-red color picker
Michael Miller
@Makuna
Mar 23 2016 17:54
That looks legit, red is hue 0.0, green is 0.33, and blue is 0.66. If full bright is 0.5, then you are looking at a HSL value here.
marksev1
@marksev1
Mar 23 2016 17:56
cool so job done on node-red side :)
Michael Miller
@Makuna
Mar 23 2016 17:56
It looks like all the color numerous corrections are moved out of your sketch, you are no longer dividing by 360 or 100.
marksev1
@marksev1
Mar 23 2016 17:56
yes
because i get the value already with a comma from node-red
so I don't need to divide like adysan did
right, looks legit?
Michael Miller
@Makuna
Mar 23 2016 17:57
If the value comes in between 0.0 and 1.0, then no need to divide.
marksev1
@marksev1
Mar 23 2016 17:58
where do i divide
I think I don't :), and I need to convert all to float since I think with mqtt they come as strings
Michael Miller
@Makuna
Mar 23 2016 18:00
If the value for hue at line 87 comes in at what range?
(sorry for typos, on a mobile device)
marksev1
@marksev1
Mar 23 2016 18:02
from 0-1 I believe
Michael Miller
@Makuna
Mar 23 2016 18:02
Got to go, if there is anything specific you need to get my attentiin, use the @makuna and I will see it.
marksev1
@marksev1
Mar 23 2016 18:02
cool
cya
Michael Miller
@Makuna
Mar 23 2016 18:02
Ok, then it looks good.
marksev1
@marksev1
Mar 23 2016 18:03
Assumes r, g, and b are contained in the set [0, 255] and
 * returns h, s, and l in the set [0, 1].
so I think its legit
marksev1
@marksev1
Mar 23 2016 18:24
@AdySan need to ask you again something lol - for off state in your sketch you are not expiclitly sending and off mqtt comannd. So how frequent does then the on command need to be sent for the light to remain turned on. How is it with the duration of shown color light? And how is it in my slightly modified sketch :), I can send you pastebin if you will look at it within 24h then this link is valid - http://pastebin.com/zczMnL30
marksev1
@marksev1
Mar 23 2016 18:36
@Makuna there isn't any strip.Stop() function right? http://pastebin.com/zczMnL30 I'm curious about the on and off state here, since its off when else is true, which means when mqtt on is not sent, but then at what time frequency does mqtt message sent need to be sent for the lights to remain on. Same goes for the HSL values. Hope you get me what I want to ask
Michael Miller
@Makuna
Mar 23 2016 18:39
The lights will stay at what ever state you last set them to. They do not automatically turn off. So when you call 'show()' they will remain at that color until you call 'show ()' again or they are powered off.
marksev1
@marksev1
Mar 23 2016 18:40
but how will then the else statement be evaluated
if I don't send any state there
Michael Miller
@Makuna
Mar 23 2016 18:42
What else statementioned (line number please)
marksev1
@marksev1
Mar 23 2016 18:42
60
which represents turned off i think since they are all zeros, now I added also a bunch of else if's in betweens and bunch of other present colors
Michael Miller
@Makuna
Mar 23 2016 18:44
That means if you are sent any other command, turn them off. This should probably be in a check for "off" instead.
marksev1
@marksev1
Mar 23 2016 18:46
I don't get it currently :), lets continue tommorrow, I don't want to bug you if you don't have much time today.
Michael Miller
@Makuna
Mar 23 2016 22:05
Back, that else is t9 this statement,
' if(pub.payload_string() == "on")', so if any other payload than "on" comes through, you set all the pixels to black or off. I don't think this is correct, you should only turn them off if you get an "off" command.
Aditya Tannu
@AdySan
Mar 23 2016 22:08
well than mqtt topic is only meant for on/off
HGL have separate topics for each of them
HSL
Michael Miller
@Makuna
Mar 23 2016 22:09
Just above that if, you put a serial.println( pub.payload_string ()) this would confirm what commands you are being sent.
Also, the on and off, should the be changing the color or just turning it on and off?
Aditya Tannu
@AdySan
Mar 23 2016 22:13
well for the Hue clone I wasnt sure what exactly on does, so I just set it to white
HomeKit doesnt send HSL values for this case, jsut a single on command
Michael Miller
@Makuna
Mar 23 2016 22:15
That would suggest that you should retain the color and set it again, further would you ever get a hue command when it was off? shold you then turn on? I don't know their standards.
Right now off and on modifies the last color, this seems suspect after knowing on can be sent without color information.
Aditya Tannu
@AdySan
Mar 23 2016 22:24
well i dont think anyone cares how hue does it
not sure what his nodered interface looks like
might not even need an on/off