本文整理汇总了Java中org.eclipse.smarthome.core.library.types.HSBType.getBrightness方法的典型用法代码示例。如果您正苦于以下问题:Java HSBType.getBrightness方法的具体用法?Java HSBType.getBrightness怎么用?Java HSBType.getBrightness使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.smarthome.core.library.types.HSBType
的用法示例。
在下文中一共展示了HSBType.getBrightness方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setHue
import org.eclipse.smarthome.core.library.types.HSBType; //导入方法依赖的package包/类
@Override
public CompletableFuture<Void> setHue(Double value) throws Exception {
if (value == null) {
value = 0.0;
}
State state = getItem().getStateAs(HSBType.class);
if (state instanceof HSBType) {
HSBType hsb = (HSBType) state;
HSBType newState = new HSBType(new DecimalType(value), hsb.getSaturation(), hsb.getBrightness());
((ColorItem) getItem()).send(newState);
return CompletableFuture.completedFuture(null);
} else {
// state is undefined (light is not connected)
return CompletableFuture.completedFuture(null);
}
}
示例2: setSaturation
import org.eclipse.smarthome.core.library.types.HSBType; //导入方法依赖的package包/类
@Override
public CompletableFuture<Void> setSaturation(Double value) throws Exception {
if (value == null) {
value = 0.0;
}
State state = getItem().getStateAs(HSBType.class);
if (state instanceof HSBType) {
HSBType hsb = (HSBType) state;
HSBType newState = new HSBType(hsb.getHue(), new PercentType(value.intValue()), hsb.getBrightness());
((ColorItem) getItem()).send(newState);
return CompletableFuture.completedFuture(null);
} else {
// state is undefined (light is not connected)
return CompletableFuture.completedFuture(null);
}
}
示例3: handleCommand
import org.eclipse.smarthome.core.library.types.HSBType; //导入方法依赖的package包/类
@Override
public void handleCommand(final Command command) {
try {
if (command instanceof HSBType) {
HSBType current = currentHSB;
HSBType color = (HSBType) command;
PercentType brightness = color.getBrightness();
boolean changeColor = true;
if (delayedColorChange) {
// Color conversion (HUE -> XY -> HUE) makes this necessary due to rounding & precision
int changeSensitivity = supportsHue ? 0 : 1;
changeColor = Math.abs(current.getHue().intValue() - color.getHue().intValue()) > changeSensitivity
|| Math.abs(current.getSaturation().intValue()
- color.getSaturation().intValue()) > changeSensitivity;
}
if (brightness.intValue() != currentHSB.getBrightness().intValue()) {
changeBrightness(brightness);
if (changeColor && delayedColorChange) {
Thread.sleep(1100);
}
}
if (changeColor) {
if (supportsHue) {
changeColorHueSaturation(color);
} else {
changeColorXY(color);
}
}
} else if (command instanceof PercentType) {
changeBrightness((PercentType) command);
} else if (command instanceof OnOffType) {
changeOnOff((OnOffType) command);
}
} catch (InterruptedException | ExecutionException e) {
logger.warn("{}: Exception processing command", endpoint.getIeeeAddress(), e);
}
}
示例4: updateColorHSB
import org.eclipse.smarthome.core.library.types.HSBType; //导入方法依赖的package包/类
private void updateColorHSB(DecimalType hue, PercentType saturation) {
// Extra temp variable to avoid thread sync concurrency issues on currentUSB
HSBType oldHSB = currentHSB;
HSBType newHSB = new HSBType(hue, saturation, oldHSB.getBrightness());
currentHSB = newHSB;
updateChannelState(newHSB);
}