add color correction

This commit is contained in:
Stephan Mühl
2023-04-10 18:28:28 +02:00
parent 73c18fbb9e
commit 6866d4d3f2
5 changed files with 36 additions and 6 deletions

View File

@@ -12,5 +12,6 @@ The JSON object has the following properties:
| Key | Type | Description | Default |
| --- | ---- | ----------- | ------- |
| `bootsound` | string | Uses a custom melodie while booting | |
| `uppercase` | boolean | Print every character in uppercase | true |
| `temp_dec_places` | int | Number of decimal places for temperature measurements | 0 |
| `uppercase` | boolean | Print every character in uppercase | `true` |
| `temp_dec_places` | int | Number of decimal places for temperature measurements | `0` |
| `color_correction` | array of int | Sets the colorcorrection of the matrix | `[255,255,255]` |

View File

@@ -56,7 +56,11 @@ void DisplayManager_::setBrightness(uint8_t bri)
else
{
matrix->setBrightness(bri);
// napplyGamma_video(&leds[256], 256, 2.2);
if (GAMMA > 0)
{
Serial.println(GAMMA);
napplyGamma_video(&leds[256], 256, GAMMA);
}
}
}
@@ -537,8 +541,12 @@ void DisplayManager_::setup()
TJpgDec.setCallback(jpg_output);
TJpgDec.setJpgScale(1);
FastLED.addLeds<NEOPIXEL, MATRIX_PIN>(leds, MATRIX_WIDTH * MATRIX_HEIGHT).setCorrection(OvercastSky);
FastLED.addLeds<NEOPIXEL, MATRIX_PIN>(leds, MATRIX_WIDTH * MATRIX_HEIGHT);
setMatrixLayout(MATRIX_LAYOUT);
if (COLOR_CORRECTION)
{
FastLED.setCorrection(COLOR_CORRECTION);
}
gif.setMatrix(matrix);
ui->setAppAnimation(SLIDE_DOWN);
ui->setTimePerApp(TIME_PER_APP);

View File

@@ -2,6 +2,7 @@
#include "Preferences.h"
#include <WiFi.h>
#include <ArduinoJson.h>
#include <LittleFS.h>
Preferences Settings;
@@ -66,6 +67,22 @@ void loadDevSettings()
TEMP_DECIMAL_PLACES = doc["temp_dec_places"].as<int>();
}
if (doc.containsKey("gamma"))
{
GAMMA = doc["gamma"].as<float>();
}
if (doc.containsKey("color_correction"))
{
auto correction = doc["color_correction"];
if (correction.is<JsonArray>() && correction.size() == 3)
{
uint8_t r = correction[0];
uint8_t g = correction[1];
uint8_t b = correction[2];
COLOR_CORRECTION.setRGB(r, g, b);
}
}
file.close();
}
}
@@ -210,4 +227,6 @@ uint8_t VOLUME;
#endif
int MATRIX_LAYOUT;
bool UPDATE_AVAILABLE = false;
long RECEIVED_MESSAGES;
long RECEIVED_MESSAGES;
CRGB COLOR_CORRECTION;
float GAMMA = 0;

View File

@@ -1,6 +1,7 @@
#ifndef GLOBALS_H
#define GLOBALS_H
#include <Arduino.h>
#include <FastLED.h>
extern const char *uniqueID;
extern const char *VERSION;
@@ -76,6 +77,8 @@ extern uint8_t VOLUME;
extern int MATRIX_LAYOUT;
extern bool UPDATE_AVAILABLE;
extern long RECEIVED_MESSAGES;
extern CRGB COLOR_CORRECTION;
extern float GAMMA;
void loadSettings();
void saveSettings();
#endif // Globals_H

View File

@@ -94,7 +94,6 @@ void setup()
delay(200);
DisplayManager.setBrightness(BRIGHTNESS);
DisplayManager.clearMatrix();
}
void loop()