Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions wled00/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
JsonObject nw = doc["nw"];
#ifndef WLED_DISABLE_ESPNOW
CJSON(enableESPNow, nw[F("espnow")]);
linked_remotes.clear();
JsonVariant lrem = nw[F("linked_remote")];
if (!lrem.isNull()) {
linked_remotes.clear();
if (lrem.is<JsonArray>()) {
for (size_t i = 0; i < lrem.size(); i++) {
std::array<char, 13> entry{};
Expand Down Expand Up @@ -180,13 +180,13 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
uint16_t total = hw_led[F("total")] | strip.getLengthTotal();
uint16_t ablMilliampsMax = hw_led[F("maxpwr")] | BusManager::ablMilliampsMax();
BusManager::setMilliampsMax(ablMilliampsMax);
Bus::setGlobalAWMode(hw_led[F("rgbwm")] | AW_GLOBAL_DISABLED);
Bus::setGlobalAWMode(hw_led[F("rgbwm")] | Bus::getGlobalAWMode());
CJSON(strip.correctWB, hw_led["cct"]);
CJSON(strip.cctFromRgb, hw_led[F("cr")]);
CJSON(cctICused, hw_led[F("ic")]);
uint8_t cctBlending = hw_led[F("cb")] | Bus::getCCTBlend();
Bus::setCCTBlend(cctBlending);
unsigned targetFPS = hw_led["fps"] | WLED_FPS;
unsigned targetFPS = hw_led["fps"] | strip.getTargetFps();
strip.setTargetFps(targetFPS); //unlimited if 0, default 42 FPS

#ifndef WLED_DISABLE_2D
Expand Down Expand Up @@ -528,12 +528,10 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
CJSON(strip.autoSegments, light[F("aseg")]);

CJSON(gammaCorrectVal, light["gc"]["val"]); // default 2.2
float light_gc_bri = light["gc"]["bri"] | 1.0f; // default to 1.0 (false)
float light_gc_col = light["gc"]["col"] | gammaCorrectVal; // default to gammaCorrectVal (true)
if (light_gc_bri != 1.0f) gammaCorrectBri = true;
else gammaCorrectBri = false;
if (light_gc_col != 1.0f) gammaCorrectCol = true;
else gammaCorrectCol = false;
JsonVariant gc_bri = light["gc"]["bri"]; // 1.0 = off, absent = keep current

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd done it this way, to future-proof it if Bri and Col ever change to bool.

  JsonVariant light_gc_bri = light["gc"]["bri"];
  JsonVariant light_gc_col = light["gc"]["col"];
  if (gammaCorrectVal > 1.0f && gammaCorrectVal <= 3.0f) {
    if (!light_gc_bri.isNull()) gammaCorrectBri = ((light_gc_bri.is<float>() && light_gc_bri.as<float>() > 1.0f) || (light_gc_bri.is<bool>() && light_gc_bri.as<bool>()));
    if (!light_gc_col.isNull()) gammaCorrectCol = ((light_gc_col.is<float>() && light_gc_col.as<float>() > 1.0f) || (light_gc_col.is<bool>() && light_gc_col.as<bool>()));
  } else {
    gammaCorrectBri = false;
    gammaCorrectCol = false;
    gammaCorrectVal = 1.0f;
  }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI 0.14.0 introduced custom gamma, prior to that it was fixed to 2.8.
gammaCorrectBri or gammaCorrectCol always used either 2.8 or 1.0 prior to custom gamma.
It would be safe to convert them to boolean (breaking downgrade compatibility) since 0.14 is already 3 years old.

JsonVariant gc_col = light["gc"]["col"];
if (!gc_bri.isNull()) gammaCorrectBri = (gc_bri.as<float>() != 1.0f);
if (!gc_col.isNull()) gammaCorrectCol = (gc_col.as<float>() != 1.0f);
if (gammaCorrectVal < 0.1f || gammaCorrectVal > 3) {
gammaCorrectVal = 1.0f; // no gamma correction
gammaCorrectBri = false;
Expand Down