本文整理汇总了Java中com.philips.lighting.model.PHLightState.setBrightness方法的典型用法代码示例。如果您正苦于以下问题:Java PHLightState.setBrightness方法的具体用法?Java PHLightState.setBrightness怎么用?Java PHLightState.setBrightness使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.philips.lighting.model.PHLightState
的用法示例。
在下文中一共展示了PHLightState.setBrightness方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: turnOn
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
void turnOn() {
PHBridge bridge = hueSDK.getSelectedBridge();
for (PHLight light : allLights) {
PHLightState lightState = new PHLightState();
lightState.setOn(true);
if (light.getModelNumber().equals("LWB014")) {
lightState.setBrightness(50);
} else {
float[] xy = PHUtilities.calculateXYFromRGB(255, 255, 255, light.getModelNumber());
lightState.setX(xy[0]);
lightState.setY(xy[1]);
lightState.setBrightness(50);
}
bridge.updateLightState(light, lightState, lightListener);
}
}
示例2: makeLightState
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
private PHLightState makeLightState(Integer color, Double brightness, long[] flashing) {
int[] colors = convertColor(color);
// Brightness magnification conversion
calcColorParam(colors, brightness);
// Calculation of brightness.
int calcBrightness = calcBrightnessParam(colors);
PHLightState lightState = new PHLightState();
lightState.setOn(true);
lightState.setColorMode(PHLightColorMode.COLORMODE_XY);
Color hueColor = new Color(color);
lightState.setX(hueColor.mX);
lightState.setY(hueColor.mY);
lightState.setBrightness(calcBrightness);
if (flashing != null) {
lightState.setTransitionTime(1);
}
return lightState;
}
示例3: showRandomColorsOnAllLamps
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
@Override
public void showRandomColorsOnAllLamps() {
for (PHBridge bridge : bridges) {
PHBridgeResourcesCache resourceCache = bridge.getResourceCache();
List<PHLight> allLights = resourceCache.getAllLights();
Random rand = new Random();
for (PHLight light : allLights) {
PHLightState lightState = new PHLightState();
lightState.setBrightness(HueConstants.MAX_BRI);
lightState.setSaturation(HueConstants.MAX_SAT);
lightState.setHue(rand.nextInt(HueConstants.MAX_HUE + 1));
bridge.updateLightState(light, lightState);
}
}
}
示例4: setBrightness
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
public void setBrightness(String name, int brightness) throws IOException
{
PHLight light = this.lights.get(name);
if (light == null)
throw new IOException("No such light: " + name);
PHLightState lightState = new PHLightState();
lightState.setOn(brightness > 0);
lightState.setBrightness(brightness, true);
this.activeBridge.updateLightState(light, lightState);
}
示例5: changeColor
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
void changeColor(int r, int g, int b, int brightness, int time, int pid) {
Log.d("HUE", "change light color...");
PHBridge bridge = hueSDK.getSelectedBridge();
if (allLights != null) {
for (PHLight light : allLights) {
PHLightState lightState = new PHLightState();
if (brightness > 0) {
lightState.setOn(true);
} else {
lightState.setOn(false);
}
if (light != null) {
float[] xy = PHUtilities.calculateXYFromRGB(r, g, b, light.getModelNumber());
if (!light.getModelNumber().equals("LWB014")) {
lightState.setX(xy[0]);
lightState.setY(xy[1]);
}
lightState.setBrightness(brightness);
lightState.setTransitionTime(time);
bridge.updateLightState(light, lightState, lightListener);
}
}
}
isTurnOn[pid] = brightness > 0;
}
示例6: setBrightness
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
public boolean setBrightness(PHLight light, int brightness) {
if (bridge == null) {
return false;
}
PHLightState state = new PHLightState();
state.setBrightness(brightness);
state.setEffectMode(PHLight.PHLightEffectMode.EFFECT_NONE);
state.setAlertMode(PHLight.PHLightAlertMode.ALERT_NONE);
bridge.updateLightState(light, state);
return true;
}
示例7: setColorHSB
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
@Override
public void setColorHSB(HSBColor colorHSB)
{
// get the bridge object (asks it to the network driver to get the most
// updated version) TODO: check if the received reference is kept up to
// date
PHBridge bridge = this.gateway.getBridge();
// check not null
if (bridge != null)
{
// get the light
PHLight light = bridge.getResourceCache().getLights()
.get(this.localId);
// prepare the new lamp state
PHLightState newLightState = new PHLightState();
// update hue and saturation
newLightState.setHue(colorHSB.getHue());
newLightState.setSaturation(colorHSB.getSaturation());
newLightState.setBrightness(colorHSB.getBrightness());
// update the real device
bridge.updateLightState(light, newLightState);
// notify...
// update the status
this.updateStatus();
}
}
示例8: stepDown
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
@Override
public void stepDown()
{
// decrease luminosity by one step
// get the bridge object (asks it to the network driver to get the most
// updated version) TODO: check if the received reference is kept up to
// date
PHBridge bridge = this.gateway.getBridge();
// check not null
if (bridge != null)
{
// get the light
PHLight light = bridge.getResourceCache().getLights()
.get(this.localId);
// get the latest light state
PHLightState lightState = light.getLastKnownLightState();
// create a new light state
PHLightState newLightState = new PHLightState();
// get the brightness
int brightness = lightState.getBrightness();
// decrease the brightness by step percentage, if less than 0 turn
// the
// lamp off
brightness = (int) (brightness - (HueInfo.MAX_BRIGHTNESS
* (double) this.stepPercentage / 100.0));
if (brightness <= 0)
{
// turn off the lamp
newLightState.setOn(false);
// set brightness at zer
brightness = 0;
}
// set the new light state
newLightState.setBrightness(brightness);
// set the new brightness
bridge.updateLightState(light, newLightState);
// notify level change
this.notifyChangedLevel(DecimalMeasure
.valueOf(brightness, Unit.ONE));
// update the status
this.updateStatus();
}
}
示例9: stepUp
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
@Override
public void stepUp()
{
// increase luminosity by one step
// get the bridge object (asks it to the network driver to get the most
// updated version) TODO: check if the received reference is kept up to
// date
PHBridge bridge = this.gateway.getBridge();
// check not null
if (bridge != null)
{
// get the light
PHLight light = bridge.getResourceCache().getLights()
.get(this.localId);
// get the latest light state
PHLightState lightState = light.getLastKnownLightState();
// create a new light state
PHLightState newLightState = new PHLightState();
// get the brightness
int brightness = lightState.getBrightness();
// decrease the brightness by step percentage, if less than 0 turn
// the
// lamp off
brightness = (int) (brightness + (HueInfo.MAX_BRIGHTNESS
* (double) this.stepPercentage / 100.0));
if (!lightState.isOn())
// turn off the lamp
newLightState.setOn(true);
if (brightness >= 0)
{
if (brightness >= HueInfo.MAX_BRIGHTNESS)
// set brightness at 255
brightness = HueInfo.MAX_BRIGHTNESS;
}
// set the new light state
newLightState.setBrightness(brightness);
// set the new brightness
bridge.updateLightState(light, newLightState);
// notify level change
this.notifyChangedLevel(DecimalMeasure
.valueOf(brightness, Unit.ONE));
this.updateStatus();
}
}
示例10: setLampState
import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
private void setLampState(String... parameters) {
String valueStr = getArgumentValue("-on", parameters);
String nameStr = getArgumentValue("-name", parameters);
String ttStr = getArgumentValue("-tt", parameters);
String iStr = getArgumentValue("-i", parameters);
String rStr = getArgumentValue("-r", parameters);
String gStr = getArgumentValue("-g", parameters);
String bStr = getArgumentValue("-b", parameters);
Boolean value = Boolean.valueOf(valueStr);
for (PHLight light : bridge.getResourceCache().getAllLights()) {
if (nameStr == null || nameStr.equals(light.getName())) {
PHLightState lightState = new PHLightState();
if (value != null) {
lightState.setOn(value);
}
if (ttStr != null) {
print("transition time:" + ttStr);
lightState.setTransitionTime(Integer.parseInt(ttStr));
}
if (iStr != null) {
print("brightness:" + iStr);
lightState.setBrightness(Integer.parseInt(iStr));
}
if (rStr != null || gStr != null || bStr != null) {
int r = getColorValue(rStr);
int g = getColorValue(gStr);
int b = getColorValue(bStr);
print(String.format("color red:%s green:%s blue:%s", r, g, b));
float[] xy = PHUtilities.calculateXYFromRGB(r, g, b, light.getIdentifier());
lightState.setX(xy[0]);
lightState.setY(xy[1]);
}
bridge.updateLightState(light, lightState);
}
}
}