Freenove / Freenove_WS2812_Lib_for_ESP32

GNU Lesser General Public License v3.0
45 stars 17 forks source link

Cannot set brightness dynamically? #7

Closed ThePureCC closed 8 months ago

ThePureCC commented 1 year ago

I have a bunch of codes that looks like this to change the brightness:

} else if (strcmp(message.data().c_str(), "brightness30") == 0) { strip.setBrightness(30); delay(10); strip.show(); } else if (strcmp(message.data().c_str(), "brightness50") == 0) { strip.setBrightness(50); delay(10); strip.show();

however it doesn't seem to change the brightness at all.

Is the brightness setting only able to be set at start? Would it be possible to change brightness dynamically?

Zhentao-Lin commented 1 year ago

The method of use is correct. Maybe there is no entry if.

livinghub commented 8 months ago

strip.setBrightness(bright); //This function did not trigger any action. strip.setAllLedsColorData(255, 255, 255); //This function is needed to trigger the setup. strip.show();

/***** Function code ****/ void Freenove_ESP32_WS2812::setBrightness(u8 brightness) { br = constrain(brightness, 0, 255); }

esp_err_t Freenove_ESP32_WS2812::setLedColorData(int index, u8 r, u8 g, u8 b) { u8 p[3]; p[rOffset] = r br / 255; p[gOffset] = g br / 255; p[bOffset] = b * br / 255; return set_pixel(index, p[0], p[1], p[2]); }