* Fix brightness * Revert to old beahaviour if segments are used * Fix formatting * Remove unused Var Signed-off-by: Sebastian Garske <sebgarske@gmail.com>pull/10049/head
parent
bd949518de
commit
d6fe0e1328
|
@ -29,6 +29,7 @@ public class WLedBindingConstants {
|
||||||
|
|
||||||
public static final String BINDING_ID = "wled";
|
public static final String BINDING_ID = "wled";
|
||||||
public static final BigDecimal BIG_DECIMAL_2_55 = new BigDecimal(2.55);
|
public static final BigDecimal BIG_DECIMAL_2_55 = new BigDecimal(2.55);
|
||||||
|
public static final BigDecimal BIG_DECIMAL_182_04 = new BigDecimal(182.04);
|
||||||
|
|
||||||
// List of all Thing Type UIDs
|
// List of all Thing Type UIDs
|
||||||
public static final ThingTypeUID THING_TYPE_WLED = new ThingTypeUID(BINDING_ID, "wled");
|
public static final ThingTypeUID THING_TYPE_WLED = new ThingTypeUID(BINDING_ID, "wled");
|
||||||
|
|
|
@ -66,6 +66,8 @@ public class WLedHandler extends BaseThingHandler {
|
||||||
private final HttpClient httpClient;
|
private final HttpClient httpClient;
|
||||||
private final WledDynamicStateDescriptionProvider stateDescriptionProvider;
|
private final WledDynamicStateDescriptionProvider stateDescriptionProvider;
|
||||||
private @Nullable ScheduledFuture<?> pollingFuture = null;
|
private @Nullable ScheduledFuture<?> pollingFuture = null;
|
||||||
|
private BigDecimal hue65535 = BigDecimal.ZERO;
|
||||||
|
private BigDecimal saturation255 = BigDecimal.ZERO;
|
||||||
private BigDecimal masterBrightness255 = BigDecimal.ZERO;
|
private BigDecimal masterBrightness255 = BigDecimal.ZERO;
|
||||||
private HSBType primaryColor = new HSBType();
|
private HSBType primaryColor = new HSBType();
|
||||||
private BigDecimal primaryWhite = BigDecimal.ZERO;
|
private BigDecimal primaryWhite = BigDecimal.ZERO;
|
||||||
|
@ -320,6 +322,8 @@ public class WLedHandler extends BaseThingHandler {
|
||||||
sendGetRequest("/win&TT=500&T=0");
|
sendGetRequest("/win&TT=500&T=0");
|
||||||
}
|
}
|
||||||
primaryColor = (HSBType) command;
|
primaryColor = (HSBType) command;
|
||||||
|
hue65535 = primaryColor.getHue().toBigDecimal().multiply(BIG_DECIMAL_182_04);
|
||||||
|
saturation255 = primaryColor.getSaturation().toBigDecimal().multiply(BIG_DECIMAL_2_55);
|
||||||
masterBrightness255 = primaryColor.getBrightness().toBigDecimal().multiply(BIG_DECIMAL_2_55);
|
masterBrightness255 = primaryColor.getBrightness().toBigDecimal().multiply(BIG_DECIMAL_2_55);
|
||||||
if (primaryColor.getSaturation().intValue() < config.saturationThreshold) {
|
if (primaryColor.getSaturation().intValue() < config.saturationThreshold) {
|
||||||
sendWhite();
|
sendWhite();
|
||||||
|
@ -327,10 +331,15 @@ public class WLedHandler extends BaseThingHandler {
|
||||||
&& hasWhite) {
|
&& hasWhite) {
|
||||||
// Google sends this when it wants white
|
// Google sends this when it wants white
|
||||||
sendWhite();
|
sendWhite();
|
||||||
|
} else {
|
||||||
|
if (config.segmentIndex == -1) {
|
||||||
|
sendGetRequest("/win&TT=1000&FX=0&CY=0&HU=" + hue65535 + "&SA=" + saturation255 + "&A="
|
||||||
|
+ masterBrightness255);
|
||||||
} else {
|
} else {
|
||||||
sendGetRequest("/win&TT=1000&FX=0&CY=0&CL=" + createColorHex(primaryColor) + "&A="
|
sendGetRequest("/win&TT=1000&FX=0&CY=0&CL=" + createColorHex(primaryColor) + "&A="
|
||||||
+ masterBrightness255);
|
+ masterBrightness255);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (command instanceof PercentType) {
|
} else if (command instanceof PercentType) {
|
||||||
masterBrightness255 = ((PercentType) command).toBigDecimal().multiply(BIG_DECIMAL_2_55);
|
masterBrightness255 = ((PercentType) command).toBigDecimal().multiply(BIG_DECIMAL_2_55);
|
||||||
sendGetRequest("/win&TT=1000&A=" + masterBrightness255);
|
sendGetRequest("/win&TT=1000&A=" + masterBrightness255);
|
||||||
|
|
Loading…
Reference in New Issue