Update to use ArduinoJson 6+ (#1071)

This commit is contained in:
h2zero authored and GitHub committed 2021-09-01 19:18:19 -05:00
1 parent 149712b573
commit ed4949f769
30 files changed
+452 -430

No files matched your search

+5 -5
View File
@@ -204,7 +204,7 @@ void MQTTtoPWM(char* topicOri, JsonObject& jsonData) {
for (int i = 0; i < kNumChannels; ++i) {
fadeStartValues[i] = currentValues[i];
JsonVariant value = jsonData[channelJsonKeys[i]];
if (value.success()) {
if (!value.isNull()) {
float targetValue = value.as<float>();
targetValue = min(targetValue, 1.f);
targetValue = max(targetValue, 0.f);
@@ -219,7 +219,7 @@ void MQTTtoPWM(char* topicOri, JsonObject& jsonData) {
}
// ...unless there is a "fade" value in the JSON
JsonVariant fade = jsonData["fade"];
if (fade.success()) {
if (!fade.isNull()) {
// "fade" json value is in seconds. Convert to milliseconds
long endUpdateTime = currentUpdateTime + (long)(fade.as<float>() * (1000.f));
// Set the fadeEndUpdateTime for the channels that were modified in the JSON
@@ -236,7 +236,7 @@ void MQTTtoPWM(char* topicOri, JsonObject& jsonData) {
char key[64];
snprintf(key, sizeof(key), "gamma-%s", channelJsonKeys[i]);
JsonVariant value = jsonData[key];
if (value.success()) {
if (!value.isNull()) {
float gamma = value.as<float>();
// Sanity check
gamma = min(gamma, 4.f);
@@ -245,12 +245,12 @@ void MQTTtoPWM(char* topicOri, JsonObject& jsonData) {
}
snprintf(key, sizeof(key), "min-%s", channelJsonKeys[i]);
value = jsonData[key];
if (value.success()) {
if (!value.isNull()) {
calibrationMinLinear[i] = perceptualToLinear(value.as<float>(), i);
}
snprintf(key, sizeof(key), "max-%s", channelJsonKeys[i]);
value = jsonData[key];
if (value.success()) {
if (!value.isNull()) {
calibrationMaxLinear[i] = perceptualToLinear(value.as<float>(), i);
}
}