kitesurfer1404 / WS2812FX

WS2812 FX Library for Arduino and ESP8266
MIT License
1.58k stars 344 forks source link

WebInterface theme for myModes #244

Closed Devilscave closed 4 years ago

Devilscave commented 4 years ago

I looked at the example "esp8266 - Webinterface" and tried to implement it in my project. Which in itself also worked. But now I wanted to use the "myModes" function to play my own list of effects in a different order. In the web interface, everything is displayed correctly, only the stored effects are no longer correct. For example, if the first effect in the array of myModes is (25,12,13,45,48) = Hyper Sparkle and I then also click on the first field with "Hyper Sparkle" text in the web browser, it is the mode "Static", the second "Blink" etc... I would like to transfer this to a stored integer called "menu", but this has all failed so far. Could someone from the sketch "webinterface" explain "viod modes_setup ()" in more detail.

void modes_setup() { modes = ""; uint8_t num_modes = sizeof(myModes) > 0 ? sizeof(myModes) : ws2812fx.getModeCount(); for(uint8_t i=0; i < num_modes; i++) { uint8_t m = sizeof(myModes) > 0 ? myModes[i] : i; modes += "<li><a href='#'>"; modes += ws2812fx.getModeName(m); modes += "</a></li>";

moose4lord commented 4 years ago

There is a bug in the esp8266_webinterface sketch when using the myModes[] array. See issue #243.

Devilscave commented 4 years ago

OK thanks, that almost overlapped. But it works. But I have a question. How can I change the line if my goal is "Menu == 1 ... 2 ... 3"? Instead of getModeCount

uint8_t new_mode = sizeof(myModes) > 0 ? myModes[tmp % sizeof(myModes)] : tmp % ws2812fx.getModeCount(); ws2812fx.setMode(new_mode);

I've adjusted most of the effects to the values, but when you switch them via the browser, neither brightness, speed nor color is correct.

moose4lord commented 4 years ago

Hmm, I'm not sure I understand what you mean. Can you paste your code?

Devilscave commented 4 years ago

I'm trying to explain better, in my sketch I switch between the effects with a simple "menu function". It is called very simply "menu = 1;" or "menu = 2" I would now like to use the browser (like in the webinterface Sketch) when I click the button with the effect, I don't want the "ws2812fx.getModeCount ()" to be passed but a menu number defined by me 1...2...3... I have to ask because I don't understand the new line for the bugfix.

Devilscave commented 4 years ago

Ok i found a way, think so it's ok, at least it works.

uint8_t new_mode = sizeof(myModes) > 0 ? myModes[tmp % sizeof(myModes)] : tmp % ws2812fx.getModeCount(); switch(new_mode){ //myModes 25,50,11,12 case 25:
menu=1;
break; case 50:
menu=3;
break; case 11: menu=4;
break; case 12: menu=5;
break; }