Пример #1
0
        public uint Initialize()
        {
            PhilipsHueController.Prompt        += PhilipsHueController_Prompt;
            PhilipsHueController.CompletedInit += PhilipsHueController_CompletedInit;
            bool ret = PhilipsHueController.Init();

            return(ERROR_SUCCESS);
        }
Пример #2
0
        private bool PhilipsHueController_Prompt()
        {
            var  dispatcher = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher;
            bool ret        = false;

            dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
            {
                var messageDialog = new MessageDialog(PRESS_BUTTON_MESSAGE);
                await messageDialog.ShowAsync();
                PhilipsHueController.Init();
            });
            return(true);
        }
Пример #3
0
        private void SetLamp(Light light, BridgeRT.State thestate, uint Period)
        {
            var command = new LightCommand();

            command.TransitionTime = TimeSpan.FromMilliseconds(Period);
            command.On             = thestate.IsOn;

            uint saturation = thestate.Saturation >> 24;
            uint brightness = thestate.Brightness >> 24;
            int  hue        = (int)thestate.Hue >> 24;

            hue &= 0X000000FF;

            byte r = 0; byte g = 0; byte b = 0;

            ColorFromHSV((double)hue, (double)saturation, (double)brightness, out r, out g, out b);
            PhilipsHueController.SetColorAndOnOff(light, (int)r, (int)g, (int)b, thestate.IsOn);
        }
Пример #4
0
        public async void SetupValues(Q42.HueApi.Light thelight)
        {
            light = thelight;

            if (light != null)
            {
                Native_Hue         = (uint)light.State.Hue << 24;
                Native_Brightness  = (uint)light.State.Brightness << 24;
                Native_Saturation  = (uint)light.State.Saturation << 24;
                Native_Temperature = (uint)light.State.ColorTemperature << 24;

                light.State.Saturation = 0xFF;
                light.State.Brightness = 0xFF;

                byte r = 0; byte g = 0; byte b = 0;
                ColorFromHSV((double)125, (double)light.State.Saturation, (double)light.State.Brightness, out r, out g, out b);

                await Task.Delay(1500);

                PhilipsHueController.SetColorAndOn(light, (int)r, (int)g, (int)b);
            }
        }