• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PHLightState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.philips.lighting.model.PHLightState的典型用法代码示例。如果您正苦于以下问题:Java PHLightState类的具体用法?Java PHLightState怎么用?Java PHLightState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PHLightState类属于com.philips.lighting.model包,在下文中一共展示了PHLightState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:21,代码来源:HueController.java


示例2: turnOff

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
void turnOff() {
  Log.d("HUE", "turn off...");

  PHLightState lightState = new PHLightState();
  lightState.setOn(false);

  if (allLights != null) {
    for (PHLight light : allLights) {
      PHBridge bridge = hueSDK.getSelectedBridge();

      if (light != null) {
        bridge.updateLightState(light, lightState, lightListener);
      }
    }
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:17,代码来源:HueController.java


示例3: changeColor

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
void changeColor(int r, int g, int b, int pid) {
  Log.d("HUE", "change light color...");

  PHBridge bridge = hueSDK.getSelectedBridge();

  for (PHLight light : allLights) {
    PHLightState lightState = new PHLightState();

    if (r > 0 || g > 0 || b > 0) {
      lightState.setOn(true);
    } else {
      lightState.setOn(false);
    }

    float[] xy = PHUtilities.calculateXYFromRGB(r, g, b, light.getModelNumber());

    if (!light.getModelNumber().equals("LWB014")) {
      lightState.setX(xy[0]);
      lightState.setY(xy[1]);
    }

    bridge.updateLightState(light, lightState, lightListener);
  }

  isTurnOn[pid] = b > 0;
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:27,代码来源:HueController.java


示例4: 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;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:23,代码来源:HueLightProfile.java


示例5: actionPerformed

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public void actionPerformed(ActionEvent event) {
    
    Color lightColour  = JColorChooser.showDialog(getContentPane(), "Choose Bulb Color", getBackground());

    if (lightColour !=null) {
        int selectedBulb = lightIdentifiersList.getSelectedIndex();
        if (selectedBulb !=-1) {
            int selectedIndex= lightIdentifiersList.getSelectedIndex();
            String lightIdentifer = allLights.get(selectedIndex).getIdentifier();
            
            PHLightState lightState = new PHLightState();
            float xy[] = PHUtilities.calculateXYFromRGB(lightColour.getRed(), lightColour.getGreen(), lightColour.getBlue(), "LCT001");
            lightState.setX(xy[0]);
            lightState.setY(xy[1]);
             
            phHueSDK.getSelectedBridge().updateLightState(lightIdentifer, lightState, null);  // null is passed here as we are not interested in the response from the Bridge. 
            
        }
    }
}
 
开发者ID:carstena,项目名称:game-to-philips-hue,代码行数:21,代码来源:LightColoursFrame.java


示例6: 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);
		}
	}
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:16,代码来源:HueServiceImpl.java


示例7: 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);
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:11,代码来源:IntegrationPhilipsHue.java


示例8: onBridgeConnected

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void onBridgeConnected(PHBridge phBridge, String s) {
  Log.d("HUE", "Bridge Connected...");

  hueSDK.setSelectedBridge(phBridge);
  hueSDK.enableHeartbeat(phBridge, PHHueSDK.HB_INTERVAL);
  hueSDK.getLastHeartbeat()
      .put(phBridge.getResourceCache().getBridgeConfiguration().getIpAddress(),
          System.currentTimeMillis());

  setLastConnectIp(phBridge.getResourceCache().getBridgeConfiguration().getIpAddress());
  setUsername(s);

  allLights = phBridge.getResourceCache().getAllLights();

  for (PHLight light : allLights) {
    PHLightState lightState = light.getLastKnownLightState();

    Log.d("HUE",
        "id = " + light.getIdentifier() + " " + light.getModelNumber() + " " + light.getUniqueId()
            + " " + lightState.getBrightness() + " " + lightState.getSaturation());
    Log.d("HUE", "type = " + light.getLightType().name() + " " + light.getLightType().ordinal());
  }

  closeProgressDialog();

  turnOn();
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:29,代码来源:HueController.java


示例9: setColor

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public boolean setColor(PHLight light, int color) {
    if (bridge == null) {
        return false;
    }

    float[] xy = PHUtilities.calculateXYFromRGB(Color.red(color), Color.green(color), Color.blue(color), light.getModelNumber());
    PHLightState state = new PHLightState();
    state.setX(xy[0]);
    state.setY(xy[1]);
    state.setEffectMode(PHLight.PHLightEffectMode.EFFECT_NONE);
    state.setAlertMode(PHLight.PHLightAlertMode.ALERT_NONE);
    bridge.updateLightState(light, state);
    return true;
}
 
开发者ID:ConnectSDK,项目名称:SmartHomeSamplerAndroid,代码行数:15,代码来源:HueAdapter.java


示例10: 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;
}
 
开发者ID:ConnectSDK,项目名称:SmartHomeSamplerAndroid,代码行数:13,代码来源:HueAdapter.java


示例11: setPower

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public boolean setPower(PHLight light, boolean power) {
    if (bridge == null) {
        return false;
    }

    PHLightState state = new PHLightState();
    state.setOn(power);
    state.setEffectMode(PHLight.PHLightEffectMode.EFFECT_NONE);
    state.setAlertMode(PHLight.PHLightAlertMode.ALERT_NONE);
    bridge.updateLightState(light, state);
    return true;
}
 
开发者ID:ConnectSDK,项目名称:SmartHomeSamplerAndroid,代码行数:13,代码来源:HueAdapter.java


示例12: randomLights

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public void randomLights() {
    PHBridge bridge = phHueSDK.getSelectedBridge();
    PHBridgeResourcesCache cache = bridge.getResourceCache();

    List<PHLight> allLights = cache.getAllLights();
    Random rand = new Random();

    for (PHLight light : allLights) {
        PHLightState lightState = new PHLightState();
        lightState.setHue(rand.nextInt(MAX_HUE));
        bridge.updateLightState(light, lightState); // If no bridge response is required then use this simpler form.
    }
}
 
开发者ID:carstena,项目名称:game-to-philips-hue,代码行数:14,代码来源:Controller.java


示例13: on

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void on()
{
	// turns the lamp on

	// 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)
	{
		// not already on
		// get the light
		PHLight light = bridge.getResourceCache().getLights()
				.get(this.localId);

		// get the latest light state
		PHLightState lightState = light.getLastKnownLightState();

		// check current state
		if (!lightState.isOn())
		{
			// create a new state object
			PHLightState newLightState = new PHLightState();

			// set the state at on
			newLightState.setOn(true);

			// updated the state on the real device
			bridge.updateLightState(light, newLightState);
		}
	}

}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:37,代码来源:HueColorDimmableLightDriverInstance.java


示例14: off

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void off()
{
	// turns the lamp off

	// 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)
	{
		// not already on
		// get the light
		PHLight light = bridge.getResourceCache().getLights()
				.get(this.localId);

		// get the latest light state
		PHLightState lightState = light.getLastKnownLightState();

		// check current state
		if (lightState.isOn())
		{
			// create a new state object
			PHLightState newLightState = new PHLightState();

			// set the state at on
			newLightState.setOn(false);

			// updated the state on the real device
			bridge.updateLightState(light, newLightState);
		}
	}

}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:37,代码来源:HueColorDimmableLightDriverInstance.java


示例15: 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();

	}
}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:35,代码来源:HueColorDimmableLightDriverInstance.java


示例16: updateLightStateColor

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
private void updateLightStateColor(PHLightState lightState, String lightModelNumber, String colorHex) {
	Color color = Color.decode(colorHex); // AWT ist auch OK
	float[] xy = PHUtilities.calculateXYFromRGB(color.getRed(), color.getGreen(), color.getBlue(), lightModelNumber);
	lightState.setX(xy[0]);
	lightState.setY(xy[1]);
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:7,代码来源:HueServiceImpl.java


示例17: setHue

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
protected void setHue(String name, Hue hue) throws IOException
{
	// conversion formula taken from https://stackoverflow.com/questions/22564187/rgb-to-philips-hue-hsb
	PHLight light = this.lights.get(name);
	if (light == null)
		throw new IOException("No such light: " + name);
	float x, y;
	if (hue == null)
	{
		x = ThreadLocalRandom.current().nextFloat();
		y = ThreadLocalRandom.current().nextFloat();
	}
	else
	{
		double r = (hue.r / 255.0);
		double g = (hue.g / 255.0);
		double b = (hue.b / 255.0);
		float red, green, blue;
		if (r > 0.04045)
		{
			red = (float) Math.pow((r + 0.055) / (1.0 + 0.055), 2.4);
		}
		else
		{
			red = (float) (r / 12.92);
		}
		if (g > 0.04045)
		{
			green = (float) Math.pow((g + 0.055) / (1.0 + 0.055), 2.4);
		}
		else
		{
			green = (float) (g / 12.92);
		}
		if (b > 0.04045)
		{
			blue = (float) Math.pow((b + 0.055) / (1.0 + 0.055), 2.4);
		}
		else
		{
			blue = (float) (b / 12.92);
		}
		float X = (float) (red * 0.649926 + green * 0.103455 + blue * 0.197109);
		float Y = (float) (red * 0.234327 + green * 0.743075 + blue * 0.022598);
		float Z = (float) (red * 0.0000000 + green * 0.053077 + blue * 0.935763); // I reduced the blue multiplier a little bit here (from 1.035763) because the white seemed too blue
		x = X / (X + Y + Z);
		y = Y / (X + Y + Z);
	}
	PHLightState lightState = new PHLightState();
	lightState.setColorMode(PHLightColorMode.COLORMODE_XY);
	lightState.setX(x);
	lightState.setY(y);
	this.activeBridge.updateLightState(light, lightState);
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:55,代码来源:IntegrationPhilipsHue.java


示例18: HueController

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
HueController(Context context, FragmentManager fragmentManager) {
  handler = new Handler();

  sharedPreferences = context.getSharedPreferences(HUE_SHARED_PREFERENCES_STORE, 0);
  sharedPreferencesEditor = sharedPreferences.edit();

  this.fragmentManager = fragmentManager;

  alert = new AlertDialog.Builder(context);

  hueSDK = PHHueSDK.create();

  hueSDK.setAppName("JINS MEME BRIDGE");
  hueSDK.setDeviceName(Build.MODEL);

  hueSDK.getNotificationManager().registerSDKListener(this);

  if (getLastConnectedIp() != null && !getLastConnectedIp().equals("")) {
    Log.d("HUE", "connect... " + getLastConnectedIp() + " / " + getUsername());

    PHAccessPoint accessPoint = new PHAccessPoint();
    accessPoint.setIpAddress(getLastConnectedIp());
    accessPoint.setUsername(getUsername());

    if (!hueSDK.isAccessPointConnected(accessPoint)) {
      hueSDK.connect(accessPoint);
    } else {
      PHBridge bridge = hueSDK.getSelectedBridge();
      allLights = bridge.getResourceCache().getAllLights();

      for (PHLight light : allLights) {
        PHLightState lightState = light.getLastKnownLightState();

        Log.d("DEBUG",
            "HUE:: id = " + light.getIdentifier() + " " + light.getModelNumber() + " " + light
                .getUniqueId() + " " + lightState.getBrightness() + " " + lightState
                .getSaturation());
        Log.d("DEBUG",
            "HUE:: type = " + light.getLightType().name() + " " + light.getLightType().ordinal());
      }
    }
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:44,代码来源:HueController.java


示例19: newMessageFromHouse

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void newMessageFromHouse(PHLightState lastKnownLightState)
{
	// intentionally left empty
}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:6,代码来源:HueGatewayDriverInstance.java


示例20: newMessageFromHouse

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void newMessageFromHouse(PHLightState lastKnownLightState)
{
	// Intentionally left empty as it does not apply for this synthetic
	// device
}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:7,代码来源:HueManagerDriverInstance.java



注:本文中的com.philips.lighting.model.PHLightState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TObjectShortProcedure类代码示例发布时间:2022-05-23
下一篇:
Java CPRefInfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap