color fix

This commit is contained in:
Yorick Rommers
2015-12-01 13:08:40 +01:00
parent 1109d90dca
commit 597309ca72
2 changed files with 12 additions and 9 deletions
+1 -3
View File
@@ -44,7 +44,7 @@ namespace HueUWP
{
if(l.IsOn)
{
var json = await nwh.SetLightInfo(l.ID, $"{{\"bri\": {l.Brightness},\"hue\": {l.Hue*255},\"sat\": {l.Saturation}}}");
var json = await nwh.SetLightInfo(l.ID, $"{{\"bri\": {l.Brightness-1},\"hue\": {(l.Hue/360)*65535},\"sat\": {l.Saturation*254}}}");
Debug.WriteLine(json);
}
@@ -55,9 +55,7 @@ namespace HueUWP
List<Light> lightlist = new List<Light>();
try {
var json = await nwh.AllLights();
Debug.WriteLine(json);
JObject o = JObject.Parse(json);
Debug.WriteLine(o.ToString());
for (int i = 1; i <= o.Count; i++)
{
+11 -6
View File
@@ -32,6 +32,8 @@ namespace HueUWP
private ObservableCollection<Light> _lightsViewModel = LightDataSource.GetLights();
private APIHandler api;
public ObservableCollection<Light> LightsViewModel
{
get { return this._lightsViewModel; }
@@ -43,11 +45,11 @@ namespace HueUWP
LOCAL_SETTINGS.Values["ip"] = "localhost";
LOCAL_SETTINGS.Values["port"] = 8000;
NetworkHandler nwh = new NetworkHandler();
APIHandler api = new APIHandler(nwh);
//api.Register();
api = new APIHandler(nwh);
api.GetAllLights(_lightsViewModel);
Debug.WriteLine(LOCAL_SETTINGS.Values["id"]);
}
@@ -73,6 +75,7 @@ namespace HueUWP
ToggleSwitch button = ((ToggleSwitch)sender);
Light light = (Light)button.DataContext;
light.UpdateState(button.IsOn);
light.UpdateColor(0, 38, 255);
}
private void slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
@@ -84,12 +87,14 @@ namespace HueUWP
private void RegisterButton_Click(object sender, RoutedEventArgs e)
{
api.Register();
Debug.WriteLine(LOCAL_SETTINGS.Values["id"]);
}
private void RefreshButton_Click(object sender, RoutedEventArgs e)
{
_lightsViewModel.Clear();
api.GetAllLights(_lightsViewModel);
}
}
}