diyhue / Lights

DIY lights with support for diyHue
https://diyhue.org/
172 stars 99 forks source link

Dividable lights (pixels) and other changes #84

Closed dobby5 closed 4 years ago

dobby5 commented 4 years ago

Hello,

I would like to present a few changes to the "Generic_WS2812_Strip".

Because some functions were missing or others made the handling unnecessarily difficult I have improved some features or made small changes to make the handling easier.

These changes are designed for my private needs. But maybe others will find the changes helpful as well.

Let's get to the biggest change in the subdivision of the lights. Previously, the lights were only ever divided with factor 2 and could not be individually subdivided. The rewritten light engine and interface now makes this possible. Furthermore it is automatically calculated how many pixels are still available. When adding a new lamp, a new field is added and automatically calculated how many pixels it could have, which must be confirmed once. These changes are working in normal mode as well as with the entertainment mode (transition light also works).

Now the small changes:

...

An update of the lights to the new version is possible - there is no data loss.

And finally screenshots

https://imgur.com/a/0OytePC

In case of a possible merge please change the diyhue.js link.

I would be happy for testings and feedback. Thank you :)

mariusmotea commented 4 years ago

It sound nice, please let me test your changes first

Ro4cHii commented 4 years ago

Wow, I was just looking for something like this and am thrilled to try this out :)

One question: will there also be the possibility to have an offset i.e. "move the lights along the stripe"?

E.g.: I have 20 LEDs in total which are split into 4 lights à 5 LEDs and need the individual lights to be as follows: 1st light: LED 2-6 2nd light: LED 7-11 3rd light: LED 12-16 4th light: LED 17-20 and 1

Is this possible with your adaptions or can it be implemented somehow?

dobby5 commented 4 years ago

Thank you, but currently it is not possible to use an offset and for time reasons it is not planned to add this feature.

But it is not excluded that this function might be added later.

dobby5 commented 4 years ago

Wow, I was just looking for something like this and am thrilled to try this out :)

One question: will there also be the possibility to have an offset i.e. "move the lights along the stripe"?

E.g.: I have 20 LEDs in total which are split into 4 lights à 5 LEDs and need the individual lights to be as follows: 1st light: LED 2-6 2nd light: LED 7-11 3rd light: LED 12-16 4th light: LED 17-20 and 1

Is this possible with your adaptions or can it be implemented somehow?

I finally found some time and made a prototype. But you have to enter the offset in the arduino code manualy. Please test everything intensively and let me know if everything is working (not only the offset general please) then I will make changes to the web interface.

https://github.com/dobby5/Lights/tree/offset

GitHub
dobby5/Lights
DIY lights with support for diyHue. Contribute to dobby5/Lights development by creating an account on GitHub.
Ro4cHii commented 4 years ago

Wow, that was quick! Thank you sooooo much! :)

I did not have the time yet to do a complete check, but the quick test I did worked like charm.


Edit: I did some more checking with pixelCount = 216, lightsCount = 4, pixelOffset = 3, transitionLeds = 0 and there still seems to be a little bug.

The 3 offset pixels are recognized but they do not change when I choose a different color for my 4th light. However, (if I remember correctly) when I change the brightness of light nr 1 then the 3 offset pixels also take the color of light nr 1 (whereas I would expect them to always have the color of light nr 4).

https://imgur.com/a/bFXg8ey

Is this something you can fix or would that be too hard? :/

dobby5 commented 4 years ago

Jo there is something wrong when the offset jumps over to the other lamps :D We should get that fixed, though. I have a little more time today. I'm gonna take care of this problem.

And big thanks for the good error description with pictures and numbering etc. This helps enormously in the analysis.

dobby5 commented 4 years ago

So @Ro4cHii, the changes from my side are in so far finished, my first tests are done. I would also like you to take a few tests and tell me if everything works as requested. Seeing four eyes makes more than two :)

The changes can be found as usual in the branch 'offset'. Of course, you don't have to set the offset in the code anymore, you can do this conveniently in the web interface.

Ro4cHii commented 4 years ago

Thank you for the quick adaptions, @dobby5! :) Unfortunately, it is still not working as expected.

I posted the new results here: https://imgur.com/a/vt9AqBL The settings I used:

The offset seems to be working in general. However, the LEDs 1 to [offset value - 1] still behave strangely, i.e.:

When changing light 1, 2 or 3 I did not notice any change in the 14 offset LEDs.

One more thing I noticed: LED nr 14 seems to be the first LED of light nr 1. When I did my test yesterday I used an offset of 3 and the first LED of light nr 1 was LED nr 4. Did you change this and how is this supposed to be: [offset value] = nr of LED that the 1st light starts with or amount of LEDs that belong to the last light?

Imgur
Imgur
Post with 0 views.
dobby5 commented 4 years ago

I'm going to check it out, the transition's giving me a bit of a problem. It might not work for the time being, if an offset is set, to reconstruct the problem exactly I need the number of pixels from the lights 1-4.

And two things you really have the latest version it? I uploaded a fix not so long ago, that's why the question. Because the problem with switching on and off light flicker should be solved by the last update.

And how do you update? Through the http updater or do you do a complete clean up and upload via Arduino? Sometimes it helps to do that one.

Ro4cHii commented 4 years ago

I can imagine. I tried implementing an offset myself before I discovered your work and not even in that I have been successful.

I update exclusively through the http updater since OTA via Arduino IDE is not working for me (I know that it had worked in the past but I don't know if it is possible with this project?) and updating via USB would be too much effort since every time I would need to hang down the painting and so on.

However, your last commit 618477d from 13 hours ago seems to have done the trick. So far, I have tested color, brightness, scene and effect changes and everything is working just as it's supposed to :)

Again, thank you sooo much for your efforts!

Ro4cHii commented 4 years ago

I think the Transition LEDs are still not working entirely correct. I just did a quick test with transitionLeds=10 and then again another with transitionLeds=8 and both times I was only able to spot 3 transition LEDs if any at all.

For me personally, this shouldn't be a problem since I don't really use them but I just wanted to let you know :)

dobby5 commented 4 years ago

I was very happy to do that. I am glad that you like my work and that we were able to develop a new feature for the lamps together. If you need help with the update via usb, you are welcome to contact me - otherwise, http is much more comfortable. The fix should now also support ota normally again.

I will work on the transitionLed sometime later, but for me they never made much sense, because the light reflection also creates a natural transition. But there are some applications where it is a useful function.

If you should miss anything else or notice any bugs, please contact me.

Thank you very much and have fun with your light system :)

Ro4cHii commented 4 years ago

I'm glad to hear so! I think there are quite some people who could make use of the new features.

The http updater is totally fine for me but thanks for the offer :)

Regarding the transitions I absolutely agree with you. Also, the natural transitions look smoother in my opinion (at least in my projects).

Since the painting project is finished now, I am currently working on my next project (rear-illuminated mirror) and this time, I indeed face another difficultly that is not working yet: negative offsets.

Regardless of the fact whether I use -1 or [pixelCount-1] as offset, the whole LED strip behaves strangely. I figure that it is not working anymore from the point where the offset becomes greater than the amount of pixels of the smallest light. However, I am not entirely sure about this since I did only a brief test because it was around 2am ^^

Unfortunately, I cannot provide any pictures for now either since I need to rework some of the electronics (the setup is a little tricky since I have attached multiple PIR sensors and lots of cables). If it helps, I can take some in 2-3 days I guess.

Best regards

Ro4cHii commented 4 years ago

I have reworked the electronics for my second project now and wanted to provide some pictures. However, another problem occurred in the meantime that hinders me from doing so.

The web interface is not working correctly anymore. This has suddenly happened for both my projects (although I haven't really touched the first one since I got it all working). The tab navigation is not working anymore, the tabs seem mixed up and all fields are either empty or showing 'null'.

When I flash the original sketch from diyHue main project, everything is working as expected. With your adapted SW however, I am not able to control anything via web interface. Lamp recognition and control in Hue Essentials App is still working however.

https://imgur.com/a/zR2J76Y

Any idea?

Cheers

Imgur
diyHue comparison
Post with 0 views. diyHue comparison
dobby5 commented 4 years ago

My server is down, due to technical problems, so the diyhue script is not loaded and the interface does not work. I will try to fix it as soon as possible.

Sorry for the inconvenience.

Ro4cHii commented 4 years ago

Your server ... ? What do you mean? Why does the interface need your server? I am confused.

dobby5 commented 4 years ago

image

It is only a javascript that is hosted on my server. I dont get any data from you.

Server is online

Ro4cHii commented 4 years ago

Oh okay :D I was quite confused why that would be connected to your server. I guess embedding the CSS into the HTML is not really feasible, is it?

Regarding the offset, I made some tests: https://imgur.com/a/sJ3xuAM Unfortunately, not as detailed as last time but I hope it helps.

Cheers

Mevel commented 4 years ago

@dobby5 can host the js on the diyhue server as a cdn. already in use for other UI components

dobby5 commented 4 years ago

@Ro4cHii sorry I have only little time to work on the desired function at the moment. I have to see when I can get to it next time. The offset function was designed to work with positive values and not negative ones. Because of that, this one does not work either.

dobby5 commented 4 years ago

@Mevel you mean that we host it about https://cerny.in like the nouislider script? I dont have access to this server.

Ro4cHii commented 4 years ago

Don't worry, I am glad that you even did all the adaptions that you have done so far. Using negative offset would indeed help me but it's just cosmetics.

Cheers

alexyao2015 commented 4 years ago

I believe github can host files like the js which would make it easier to update as well.

dobby5 commented 4 years ago

@alexyao2015 The data are now hosted by GitHub

dobby5 commented 4 years ago

@mariusmotea All changes have been fully implemented. The PR is final, if further testing is necessary, the links must be changed back to my server. This is not necessary if the PR is merged, because the links are set to the main repo.

Ro4cHii commented 11 months ago

Hello @dobby5 and @alexyao2015,

I hope you're well!

It's been three years and the other day I noticed that some WS2812 lights are behaving strangely in Home Assistant (e. g. status not always updating correctly) so I decided it's time that I could switch to the newest firmware (https://github.com/diyhue/Lights/blob/master/ESP8266/Generic_WS2812_Strip/Generic_WS2812_Strip.ino).

Unfortunately, the feature "pixel offset" vanished completely. I looked through your forked project (https://github.com/dobby5/Lights/tree/offset/Arduino) but I was not able to find the modification regarding the offset feature.

Would it be possible to re-merge these adaptations into the diyhue master branch?