Beispiel #1
0
        void temp_OnTempUpdated(object sender, CpuTempEventArgs e)
        {
            float? actualtemp = e.currentTemp;
            ushort hueTemp    = 0;

            lblCpuTemp.Content = string.Format("{0:0.0}ºC", Temp.temperature);
            if (!(bool)btnTestGradient.IsChecked)
            {
                return;
            }
            gradientStartColor = slHueGradientStart.Value;
            gradientStopColor  = slHueGradientStop.Value;
            gradientStopTemp   = (double)dudUpperTemp.Value;
            gradientStartTemp  = (double)dudLowerTemp.Value;

            if ((bool)btnTestGradient.IsChecked)
            {
                if (actualtemp == null)
                {
                    hueTemp = (ushort)gradientStartColor;
                }
                else
                {
                    double gradientRange = gradientStartColor - gradientStopColor;
                    double tempRange     = gradientStopTemp - gradientStartTemp;


                    if (gradientRange > 0)
                    {
                        double multiplier = gradientStartColor / tempRange;
                        hueTemp = (ushort)(gradientStartColor - (multiplier * (actualtemp - gradientStartTemp)));
                    }
                    else
                    {
                        hueTemp = (ushort)((gradientStopColor * actualtemp) / gradientStopTemp);
                    }
                }

                if (cbObject.SelectedItem is KeyValuePair <string, Light> )
                {
                    Host.SetLightState(((KeyValuePair <string, Light>)cbObject.SelectedItem).Key,
                                       new State()
                    {
                        hue = hueTemp, bri = 255, sat = 255, @on = true, transitiontime = 9
                    });
                }
                else
                {
                    Host.SetGroupState(((KeyValuePair <string, Group>)cbObject.SelectedItem).Key,
                                       new HueLib_base.Action()
                    {
                        hue = hueTemp, bri = 255, sat = 255, @on = true, transitiontime = 9
                    });
                }
            }
        }
Beispiel #2
0
        void temp_OnTempUpdated(object sender, CpuTempEventArgs e)
        {
            float? actualtemp = e.currentTemp;
            ushort hueTemp    = 0;

            if (actualtemp == null)
            {
                hueTemp = (ushort)_gradientStartColor;
            }
            else
            {
                double gradientRange = _gradientStartColor - _gradientStopColor;
                double tempRange     = _gradientStopTemp - _gradientStartTemp;

                // Check for the order of the sliders. Is the first slider before the 2nd or the other way around.
                if (gradientRange > 0)
                {
                    double multiplier = _gradientStartColor / tempRange;
                    hueTemp = (ushort)(_gradientStartColor - (multiplier * (actualtemp - _gradientStartTemp)));
                }
                else
                {
                    hueTemp = (ushort)((_gradientStopColor * actualtemp) / _gradientStopTemp);
                }
            }

            if (_objectType == true)
            {
                Host.SetLightState(_objectId, new State()
                {
                    hue = hueTemp, bri = _userBri, sat = _userSat, @on = true, transitiontime = 9
                });
            }
            else
            {
                Host.SetGroupState(_objectId, new HueLib2.Action()
                {
                    hue = hueTemp, bri = _userBri, sat = _userSat, @on = true, transitiontime = 9
                });
            }
        }