public static void ConvertHSVtoRGB(string name) { HSV tempHSV = new HSV(RGBTempObject.Hue, RGBTempObject.Saturation, RGBTempObject.Brightness); RGB tempRGB = HBLightbulbConversion.HSVtoRGB(tempHSV); LightbulbEvent(new HBCrestronEventArgs(name, "Red", tempRGB.R)); LightbulbEvent(new HBCrestronEventArgs(name, "Green", tempRGB.G)); LightbulbEvent(new HBCrestronEventArgs(name, "Blue", tempRGB.B)); }
public static void SetRGBFeedback(string name, ushort red, ushort green, ushort blue) { if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsRGB == 1) { RGB tempRgb = new RGB((byte)red, (byte)green, (byte)blue); HSV tempHsv = HBLightbulbConversion.RGBtoHSV(tempRgb); Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue = (ushort)tempHsv.H; Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation = (ushort)tempHsv.S; Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Brightness = (ushort)tempHsv.V; UpdateBrightnessFeedback(name); UpdateSaturationFeedback(name); UpdateHueFeedback(name); } }
public static void SetRGB(string name, ushort red, ushort green, ushort blue) { if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsRGB == 1) { RGB tempRgb = new RGB((byte)red, (byte)green, (byte)blue); HSV tempHsv = HBLightbulbConversion.RGBtoHSV(tempRgb); if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue != (ushort)tempHsv.H) { Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue = (ushort)tempHsv.H; ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject(); tempControlIntValueObject.Characteristics[0] = new ControlIntValuePayload(); tempControlIntValueObject.Characteristics[0].AID = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID; tempControlIntValueObject.Characteristics[0].IID = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceHueIID; tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue; var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject); HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend); } if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation != (ushort)tempHsv.S) { Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation = (ushort)tempHsv.S; ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject(); tempControlIntValueObject.Characteristics[0] = new ControlIntValuePayload(); tempControlIntValueObject.Characteristics[0].AID = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID; tempControlIntValueObject.Characteristics[0].IID = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceSaturationIID; tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation; var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject); HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend); } if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue != (ushort)tempHsv.V) { Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue = (ushort)tempHsv.V; ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject(); tempControlIntValueObject.Characteristics[0] = new ControlIntValuePayload(); tempControlIntValueObject.Characteristics[0].AID = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID; tempControlIntValueObject.Characteristics[0].IID = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceBrightnessIID; tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Brightness; var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject); HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend); } } }