toblum / McLighting

The ESP8266 based multi-client lighting gadget
MIT License
1.05k stars 291 forks source link

Question: [RGB-W] Can you the SK6812 fork integrate in Main Projekt? #361

Open gitpower2017 opened 5 years ago

gitpower2017 commented 5 years ago

Hello,

The main project is much better maintained and debugged. Meanwhile I can well imagine that the RGBW LED strips are just as popular as the pure RGB LED strips.

ChristophA commented 5 years ago

I‘d like that, too!

TheAndi commented 5 years ago

+1 As McLighting is intended as a room/mood lighting solution, I think it should definitely support the SK6812 strips because they can produce much nicer light.

Unfortunately I can't get the FabLab-Version to work properly (https://github.com/FabLab-Luenen/McLighting/issues/4). Therefore, I would really appreciate an official integration.

debsahu commented 5 years ago

@bpohvoodoo is a great collaborator and a programmer. McLighting's porting to RGBW is done single handedly and issues will arise as more things gets added. Everyone here is doing this on a voluntary basis and when free time is available. Please give all developers more time to sort through issues, unit test and if possible contribute by coding or help solve an issue marked "help wanted". As such there is no plan to port RGBW strip to McLighting, we could just take this request and mark it as Todo.

vemeT5ak commented 5 years ago

Apologies, I didn't hit "reply all" a good habit I do believe.

I'm not sure if this will help anyone. I have added a fork for McL, as of two weeks ago, that works with the SK6812 RGBW LEDs ( https://github.com/vemeT5ak/McLighting). I have also noted at the top of the definitions.h and mcL_vemet5ak_edits.ino which lines you will have to edit to get them to work for your application, at least the stuff I had to change to get it to work for my application. I may be missing a few files. If you get a file missing error, take it from the original McLightning repo.

hope this helps

On Fri, Mar 15, 2019 at 6:15 AM Debashish Sahu notifications@github.com wrote:

@BPoH_Voodoo is a great collaborator and a programmer. McLighting's porting to RGBW is done single handedly and issues will arise as more things gets added. Everyone here is doing this on a voluntary basis and when free is available. Please give all developers more time to sort through issues, unit test and if possible contribute by coding or help solve an issue marked "help wanted". As such there is no plan to port RGBW strip to McLighting, we could just take this request and mark it as Todo.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/toblum/McLighting/issues/361#issuecomment-473248306, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-nRu2Fe6UhC1I2lmfcZSj8_46q6HJ8ks5vW4DYgaJpZM4bzdfj .

debsahu commented 5 years ago

Thanks @vemeT5ak, will try to add your branch to README

toblum commented 5 years ago

Sure, having RGBW mode would be great and this is definitely something we could have a look at, but it has many implications as the API has to change and we have to take care that we don't break existing projects and still support RGB. Apart from the API the UI has to adapt to both RGB and RGBW. This is all possible but it takes time (which I personally have far too little of at the moment unfortunately) as @debsahu pointed out. I'll keep all that in mind for the next version of the UI. In the meantime give @bpohvoodoo version a try. BTW: I ordered a SK6812 RGBW strip some time ago but I fear that I received a RGB version. Maybe some kind of fake product or wrong listing. Is this possible? Are there RGB version of the SK6812 strips out there?

gitpower2017 commented 5 years ago

Hi toblum,

on this picture you can see the different models http://www.witop-tech.com/wp-content/uploads/2017/06/sk6812-programmable-led-chip-1.jpg

I have the model on the lower right

gitpower2017 commented 5 years ago

@vemeT5ak

I'm afraid I can't do anything with your explanation. Can you provide a version that I can compile directly?

TheAndi commented 5 years ago

Maybe a simple RGB -> RGBW conversion before the data is sent to the strip would do the trick for now.

There is already a lot of existing code for that like: http://codewelt.com/rgbw or https://stackoverflow.com/questions/40312216/converting-rgb-to-rgbw

This would avoid any changes of the API or the UI. Also, the effects should work seamlessly with that. It would "only" require a change at the pixel output part and an option in the definition.h for enabling it.

@toblum could be the case that there are just RGB versions concerning that datasheet: http://www.szledcolor.com/download/SK6812%20LED.pdf

Keep up the great work and no pressure ;)

bpohvoodoo commented 5 years ago

All changes implemented from 2.2.2 and many more! Html UI is intergrated now, as in original project Edit.htm.gz is integrated now, too. Homeassistant is now using the white channel, too, if in RGB Order. All settings are configurable via rest api, websockets and html ui. all RGB(W) Orders are supported, can be changed during runtime. Ui regognizes if W channel is present in RGB Order (for example GRBW), no switch needed anymore. Many more changes. Read version_info solved issue #145 from here integraded feature from issue #281 from here if @toblum and @debsahu want to merge, we can do so.

debsahu commented 5 years ago

@bpohvoodoo There are a few minor bug fixes I caught yesterday. They are in the develop branch. I'm not opposed to the idea of merging with develop and some people test before merge to master.

TheAndi commented 5 years ago

I can help with testing if you want

bpohvoodoo commented 5 years ago

Feel free! https://github.com/FabLab-Luenen/McLighting

bpohvoodoo commented 5 years ago

@debsahu One of the bugs i found myself. Corrected the neopixel stuff now, too.

gitpower2017 commented 5 years ago

Hello bpohvoodoo,

i have testing the version from 19.03.2019. I have the feel, this is a gut RGBW implementation. Many thanks for the good implementation

Can I control the color directly with HSB. OpenHab has a colorpiker with HSB

Can you better document the feature? What is:

bpohvoodoo commented 5 years ago
HiranChaudhuri commented 5 years ago

I just cloned https://github.com/FabLab-Luenen/GY33_MCU.git to give it a try. After all that is the version the pull request for RGBW is pending from, right?

I got caught in surprise as support for a color sensor is required. I'll add that library although not having understood the benefit for the color sensor.

debsahu commented 5 years ago

@HiranChaudhuri comment to disable https://github.com/FabLab-Luenen/McLighting/blob/ae219075583ff0cd8e391d75239b48c2d310317e/Arduino/McLighting/definitions.h#L23

HiranChaudhuri commented 5 years ago

Thank you for the hint, @debsahu. I also commented out the remote control and added the libraries FastLED and NeoPixelBus_by_Makuna. However now I get a compilation error:

In file included from sketch/mode_custom_ws2812fx_animations.h:10:0,
                 from /home/hiran/Arduino/McLighting-RGBW/Arduino/McLighting/McLighting.ino:267:
/home/hiran/Arduino/libraries/FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.002.006
 #    pragma message "FastLED version 3.002.006"
                     ^
In file included from /home/hiran/Arduino/libraries/FastLED/led_sysdefs.h:27:0,
                 from /home/hiran/Arduino/libraries/FastLED/FastLED.h:41,
                 from sketch/mode_custom_ws2812fx_animations.h:10,
                 from /home/hiran/Arduino/McLighting-RGBW/Arduino/McLighting/McLighting.ino:267:
/home/hiran/Arduino/libraries/FastLED/platforms/esp/8266/led_sysdefs_esp8266.h:15:17: error: conflicting declaration 'typedef uint8_t boolean'
 typedef uint8_t boolean;
                 ^
In file included from sketch/McLighting.ino.cpp:1:0:
/home/hiran/.arduino15/packages/esp8266/hardware/esp8266/2.5.1/cores/esp8266/Arduino.h:191:14: error: 'boolean' has a previous declaration as 'typedef bool boolean'
 typedef bool boolean;
              ^
In file included from /home/hiran/Arduino/libraries/FastLED/FastLED.h:65:0,
                 from sketch/mode_custom_ws2812fx_animations.h:10,
                 from /home/hiran/Arduino/McLighting-RGBW/Arduino/McLighting/McLighting.ino:267:
/home/hiran/Arduino/libraries/FastLED/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output
 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"
                       ^

I'm not sure: Will I have to use specific versions of the libraries? So far I installed the latest available ones.

debsahu commented 5 years ago

untested in esp8266 arduino core v2.5.1, use 2.4.2 instead for now.

HiranChaudhuri commented 5 years ago

Now I tried esp8266 core 2.4.2 and the project compiles. After an upload to the ESP it seems to crash though. Here is the serial output (which repeats roughly every second): ' Starting...Main Setup Enabled Button Mode on PIN: 14 FS File: /config.json, size: 99B FS File: /uistate.json, size: 104B FS File: /stripstate.json, size: 83B FS File: /neoconfig.json, size: 43B FS Usage: 2259/957314 bytes Reading config file... Opened! Config: Parsed! {"mqtt_host":"**","mqtt_port":"**","mqtt_user":"**","mqtt_pass":**"}

Exception (28): epc1=0x4022a1bc epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont sp: 3ffffba0 end: 3fffffd0 offset: 01a0

stack>>> 3ffffd40: 3fff189c 00000000 3fff16a8 40224208
3ffffd50: 3fff189c 00000063 3fff16a8 4021c5fd
3ffffd60: 3fff3758 3fff3758 3ffffd80 4021c5fd
3ffffd70: 3ffe8ff6 00000063 3fff16a8 00000001
3ffffd80: 3fff189c 00000063 3ffffdb4 4020b73c
3ffffd90: 00000000 00000063 3fff16a8 402101b5
3ffffda0: 3fff18ac 3fff3554 3fff3554 3fff3758
3ffffdb0: 3fff3798 3fff3788 3fff3758 401006a0
3ffffdc0: 402285b0 00000000 000003e8 4010020c
3ffffdd0: 00000000 00000000 3fff34ec 401006dc
3ffffde0: 3ffffdb4 3ffffda4 3ffffe20 40225ce4
3ffffdf0: 00000000 3fff34ec 3fff3494 40226177
3ffffe00: 3fff189c 3ffffec0 3fff34ec 3fff1768
3ffffe10: 3fff189c 3ffffec0 3fff16a8 40211696
3ffffe20: 000e9b82 000008d3 00002000 00000100
3ffffe30: 00000005 00000020 feefeffe feefeffe
3ffffe40: feefeffe feefeffe feefeffe feefeffe
3ffffe50: feefeffe feefeffe feefeffe feefeffe
3ffffe60: feefeffe feefeffe feefeffe feefeffe
3ffffe70: feefeffe feefeffe feefeffe feefeffe
3ffffe80: feefeffe feefeffe feefeffe feefeffe
3ffffe90: feefeffe feefeffe feefeffe feefeffe
3ffffea0: feefeffe feefeffe feefeffe 00000000
3ffffeb0: 00000000 00000000 feefeffe feefeffe
3ffffec0: 3fff3494 3fff34ec feefeffe feefeffe
3ffffed0: feefeffe feefeffe feefeffe feefeffe
3ffffee0: feefeffe feefeffe feefeffe feefeffe
3ffffef0: feefeffe feefeffe feefeffe feefeffe
3fffff00: feefeffe feefeffe feefeffe feefeffe
3fffff10: feefeffe feefeffe feefeffe feefeffe
3fffff20: feefeffe feefeffe feefeffe feefeffe
3fffff30: feefeffe feefeffe feefeffe feefeffe
3fffff40: feefeffe feefeffe feefeffe feefeffe
3fffff50: feefeffe feefeffe feefeffe feefeffe
3fffff60: feefeffe feefeffe feefeffe feefeffe
3fffff70: feefeffe feefeffe feefeffe feefeffe
3fffff80: feefeffe feefeffe feefeffe feefeffe
3fffff90: 3fff351c feefeffe feefeffe feefeffe
3fffffa0: feefeffe feefeffe feefeffe 3fff1768
3fffffb0: 3fffdad0 00000000 3fff1762 40225e4c
3fffffc0: feefeffe feefeffe 3ffe880c 40100739
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 tail 8 chksum 0x2d csum 0x2d vbb28d4a3 ~ld '

HiranChaudhuri commented 5 years ago

Ok, I erased the complete flash and then uploaded the sketch. This time the captive portal came up. It seems the behaviour before was caused by stale information in the flash.

I also had to connect the strip to a different GPIO, but now I can set color and effects in the UI. It looks like McLighting-RGBW does connect to MQTT but does not advertise itself to HomeAssistant.

HiranChaudhuri commented 5 years ago

I want to run multiple of these devices on my network. That's why I use ENABLE_MQTT_HOSTNAME_CHIPID. It seems strings like mqtt_intopic still get populated with just the hostname.

--- a/Arduino/McLighting/McLighting.ino
+++ b/Arduino/McLighting/McLighting.ino
@@ -361,18 +361,18 @@ void initMqtt() {
     snprintf(mqtt_clientid, sizeof(mqtt_clientid), "%s", HOSTNAME);
   #endif
   mqtt_clientid[sizeof(mqtt_clientid) - 1] = 0x00;
-  snprintf(mqtt_will_topic, sizeof(mqtt_will_topic), "%s/config", HOSTNAME);
+  snprintf(mqtt_will_topic, sizeof(mqtt_will_topic), "%s/config", mqtt_clientid);
   mqtt_will_topic[sizeof(mqtt_will_topic) - 1] = 0x00;
-  snprintf(mqtt_intopic,  sizeof(mqtt_intopic),  "%s/in",  HOSTNAME);
+  snprintf(mqtt_intopic,  sizeof(mqtt_intopic),  "%s/in",  mqtt_clientid);
   mqtt_intopic[sizeof(mqtt_intopic) - 1] = 0x00;
-  snprintf(mqtt_outtopic, sizeof(mqtt_outtopic), "%s/out", HOSTNAME);
+  snprintf(mqtt_outtopic, sizeof(mqtt_outtopic), "%s/out", mqtt_clientid);
   mqtt_outtopic[sizeof(mqtt_outtopic) - 1] = 0x00;
   #if defined(MQTT_HOME_ASSISTANT_SUPPORT)
-    snprintf(mqtt_ha_config, sizeof(mqtt_ha_config), "homeassistant/light/%s/config", HOSTNAME);
+    snprintf(mqtt_ha_config, sizeof(mqtt_ha_config), "homeassistant/light/%s/config", mqtt_clientid);
     mqtt_ha_config[sizeof(mqtt_ha_config) - 1] = 0x00;
-    snprintf(mqtt_ha_state_in,  sizeof(mqtt_ha_state_in),   "home/%s_ha/state/in",  HOSTNAME);
+    snprintf(mqtt_ha_state_in,  sizeof(mqtt_ha_state_in),   "home/%s_ha/state/in",  mqtt_clientid);
     mqtt_ha_state_in[sizeof(mqtt_ha_state_in) - 1] = 0x00;
-    snprintf(mqtt_ha_state_out, sizeof(mqtt_ha_state_out),  "home/%s_ha/state/out", HOSTNAME);
+    snprintf(mqtt_ha_state_out, sizeof(mqtt_ha_state_out),  "home/%s_ha/state/out", mqtt_clientid);
     mqtt_ha_state_out[sizeof(mqtt_ha_state_out) - 1] = 0x00;
   #endif
   if ((strlen(mqtt_host) != 0) && (mqtt_port != 0)) {

This fixed my issue and now I can control McLighting-RGBW through HomeAssistant. However there is no control of the additional white channel yet.

HiranChaudhuri commented 5 years ago

Ok, the white channel is controllable in HomeAssistant. I just had to discover how the UI renders it. All ok now. :-)

McLighting-RGBW-HomeAssistant

HiranChaudhuri commented 5 years ago

So it happened that after some time (I guess a restart of HomeAssistant was involved) the communication between McLighting-RGBW and HomeAssistant broke down. I tracked it to the wrong device name being in the advertizement message, which I fixed like this:

diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h
index 656ad98..ea3fe49 100644
--- a/Arduino/McLighting/request_handlers.h
+++ b/Arduino/McLighting/request_handlers.h
@@ -1326,7 +1326,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
             const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500;
             DynamicJsonDocument jsonBuffer(bufferSize);
             JsonObject root = jsonBuffer.to<JsonObject>();
-            root["name"] = HOSTNAME;
+            root["name"] = mqtt_clientid;
             #if defined(MQTT_HOME_ASSISTANT_0_87_SUPPORT)
             root["schema"] = "json";
             #else
@@ -1439,9 +1439,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
           const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500;
           DynamicJsonDocument jsonBuffer(bufferSize);
           JsonObject root = jsonBuffer.to<JsonObject>();
-          root["name"] = HOSTNAME;
+          root["name"] = mqtt_clientid;
           #if defined(MQTT_HOME_ASSISTANT_0_87_SUPPORT)
-          root["schema"] = "json";
+            root["schema"] = "json";
           #else
           root["platform"] = "mqtt_json";
           #endif