Added new auto white modes (related to #573 )

pull/698/head^2
cschwinne 2020-02-20 00:45:09 +01:00
rodzic 05f5aaaeca
commit 65a32b4166
13 zmienionych plików z 2526 dodań i 2494 usunięć

Wyświetl plik

@ -28,6 +28,7 @@
#define WS2812FX_h
#include "NpbWrapper.h"
#include "const.h"
#define FASTLED_INTERNAL //remove annoying pragma messages
#include "FastLED.h"
@ -426,6 +427,7 @@ class WS2812FX {
uint8_t
mainSegment = 0,
rgbwMode = RGBW_MODE_DUAL,
paletteFade = 0,
paletteBlend = 0,
colorOrder = 0,
@ -589,7 +591,7 @@ class WS2812FX {
void fill(uint32_t);
bool
_rgbwMode,
_useRgbw = false,
_cronixieMode,
_cronixieBacklightEnabled,
_skipFirstMode,

Wyświetl plik

@ -32,9 +32,9 @@
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
{
if (supportWhite == _rgbwMode && countPixels == _length) return;
if (supportWhite == _useRgbw && countPixels == _length) return;
RESET_RUNTIME;
_rgbwMode = supportWhite;
_useRgbw = supportWhite;
_skipFirstMode = skipFirst;
_length = countPixels;
@ -65,6 +65,7 @@ void WS2812FX::service() {
{
if(nowUp > SEGENV.next_time || _triggered || (doShow && SEGMENT.mode == 0)) //last is temporary
{
if (SEGMENT.grouping == 0) SEGMENT.grouping = 1; //sanity check
_virtualSegmentLength = SEGMENT.virtualLength();
doShow = true;
handle_palette();
@ -106,6 +107,20 @@ uint16_t WS2812FX::realPixelIndex(uint16_t i) {
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
{
//auto calculate white channel value if enabled
if (_useRgbw) {
if (rgbwMode == RGBW_MODE_AUTO_BRIGHTER || (w == 0 && (rgbwMode == RGBW_MODE_DUAL || rgbwMode == RGBW_MODE_LEGACY)))
{
//white value is set to lowest RGB channel
//thank you to @Def3nder!
w = r < g ? (r < b ? r : b) : (g < b ? g : b);
} else if (rgbwMode == RGBW_MODE_AUTO_ACCURATE && w == 0)
{
w = r < g ? (r < b ? r : b) : (g < b ? g : b);
r -= w; g -= w; b -= w;
}
}
RgbwColor col;
switch (colorOrder)
{
@ -256,7 +271,7 @@ void WS2812FX::show(void) {
}
if (_rgbwMode) //RGBW led total output with white LEDs enabled is still 50mA, so each channel uses less
if (_useRgbw) //RGBW led total output with white LEDs enabled is still 50mA, so each channel uses less
{
powerSum *= 3;
powerSum = powerSum >> 2; //same as /= 4

Wyświetl plik

@ -3,10 +3,17 @@
//Access point behavior
#define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot
#define AP_BEHAVIOR_NO_CONN 1 //Open when no connection
#define AP_BEHAVIOR_NO_CONN 1 //Open when no connection (either after boot or if connection is lost)
#define AP_BEHAVIOR_ALWAYS 2 //Always open
#define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec
//RGB to RGBW conversion mode
#define RGBW_MODE_MANUAL_ONLY 0 //No automatic white channel calculation. Manual white channel slider
#define RGBW_MODE_AUTO_BRIGHTER 1 //New algorithm. Adds as much white as the darkest RGBW channel
#define RGBW_MODE_AUTO_ACCURATE 2 //New algorithm. Adds as much white as the darkest RGBW channel and subtracts this amount from each RGB channel
#define RGBW_MODE_DUAL 3 //Manual slider + auto calculation. Automatically calculates only if manual slider is set to off (0)
#define RGBW_MODE_LEGACY 4 //Old floating algorithm. Too slow for realtime and palette support
//realtime modes
#define REALTIME_MODE_INACTIVE 0
#define REALTIME_MODE_GENERIC 1

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -118,7 +118,15 @@ LED voltage (Max. current for a single LED):<br>
<br>
LEDs are 4-channel type (RGBW): <input type=checkbox name=EW onchange=UI() id=rgbw><br>
<span class=wc>
Auto-calculate white channel from RGB: <input type=checkbox name=AW><br></span>
Auto-calculate white channel from RGB:<br>
<select name=AW>
<option value=0>None</option>
<option value=1>Brighter</option>
<option value=2>Accurate</option>
<option value=3>Dual</option>
<option value=4>Legacy</option>
</select>
<br></span>
Color order:
<select name=CO>
<option value=0>GRB</option>

Plik diff jest za duży Load Diff

Wyświetl plik

@ -91,7 +91,7 @@
#endif
//version code in format yymmddb (b = daily build)
#define VERSION 2002191
#define VERSION 2002192
char versionString[] = "0.9.1";
@ -124,7 +124,6 @@ IPAddress staticSubnet(255, 255, 255, 0); //most common subnet in home netwo
//LED CONFIG
uint16_t ledCount = 30; //overcurrent prevented by ABL
bool useRGBW = false; //SK6812 strips can contain an extra White channel
bool autoRGBtoRGBW = false; //if RGBW enabled, calculate White channel from RGB
#define ABL_MILLIAMPS_DEFAULT 850; //auto lower brightness to stay close to milliampere limit
bool turnOnAtBoot = true; //turn on LEDs at power-up
byte bootPreset = 0; //save preset to load after power-up

Wyświetl plik

@ -218,7 +218,7 @@ void saveSettingsToEEPROM()
EEPROM.write(2200, !receiveDirect);
EEPROM.write(2201, notifyMacro); //was enableRealtime
EEPROM.write(2203, autoRGBtoRGBW);
EEPROM.write(2203, strip.rgbwMode);
EEPROM.write(2204, skipFirstLed);
if (saveCurrPresetCycConf)
@ -488,7 +488,7 @@ void loadSettingsFromEEPROM(bool first)
receiveDirect = !EEPROM.read(2200);
notifyMacro = EEPROM.read(2201);
autoRGBtoRGBW = EEPROM.read(2203);
strip.rgbwMode = EEPROM.read(2203);
skipFirstLed = EEPROM.read(2204);
if (EEPROM.read(2210) || EEPROM.read(2211) || EEPROM.read(2212))

Wyświetl plik

@ -46,7 +46,7 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
oappend("</ix><fp>");
oappendi(effectPalette);
oappend("</fp><wv>");
if (useRGBW && !autoRGBtoRGBW) {
if (strip.rgbwMode) {
oappendi(col[3]);
} else {
oappend("-1");
@ -238,7 +238,7 @@ void getSettingsJS(byte subPage, char* dest)
sappend('v',"CA",briS);
sappend('c',"EW",useRGBW);
sappend('i',"CO",strip.colorOrder);
sappend('c',"AW",autoRGBtoRGBW);
sappend('v',"AW",strip.rgbwMode);
sappend('c',"BO",turnOnAtBoot);
sappend('v',"BP",bootPreset);

Wyświetl plik

@ -77,7 +77,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
useRGBW = request->hasArg("EW");
strip.colorOrder = request->arg("CO").toInt();
autoRGBtoRGBW = request->hasArg("AW");
strip.rgbwMode = request->arg("AW").toInt();
briS = request->arg("CA").toInt();

Wyświetl plik

@ -47,7 +47,7 @@ void setAllLeds() {
colSecT[i] = colSec[i];
}
}
if (useRGBW && autoRGBtoRGBW)
if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY)
{
colorRGBtoRGBW(colT);
colorRGBtoRGBW(colSecT);

Wyświetl plik

@ -183,7 +183,7 @@ float maxf (float v, float w)
return v;
}
void colorRGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw)
void colorRGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw). (RGBW_MODE_LEGACY)
{
float low = minf(rgb[0],minf(rgb[1],rgb[2]));
float high = maxf(rgb[0],maxf(rgb[1],rgb[2]));

Wyświetl plik

@ -242,7 +242,7 @@ void serializeInfo(JsonObject root)
JsonObject leds = root.createNestedObject("leds");
leds["count"] = ledCount;
leds["rgbw"] = useRGBW;
leds["wv"] = useRGBW && !autoRGBtoRGBW; //should a white channel slider be displayed?
leds["wv"] = useRGBW && (strip.rgbwMode == RGBW_MODE_MANUAL_ONLY || strip.rgbwMode == RGBW_MODE_DUAL); //should a white channel slider be displayed?
JsonArray leds_pin = leds.createNestedArray("pin");
leds_pin.add(LEDPIN);