Ejemplo n.º 1
0
        public void SetBrightness(string Nickname, int Brightness)
        {
            int pin;

            if (GetPin(Nickname, out pin))
            {
                GpioManager.SetPwm(pin, Brightness);
            }
        }
Ejemplo n.º 2
0
        public async Task TurnOnAsync(string NickName)
        {
            int pin;

            if (GetPin(NickName, out pin))
            {
                for (int i = 0; i < MaxBrightness; i++)
                {
                    GpioManager.SetPwm(pin, i);
                    await Task.Delay(TransitionSpeed);
                }
                Debug.WriteLine("light on");
            }
        }
Ejemplo n.º 3
0
        public async Task TurnOffAsync(string NickName)
        {
            int pin;

            if (GetPin(NickName, out pin))
            {
                Debug.WriteLine("turning light off");
                for (int i = 100; i > -1; i--)
                {
                    GpioManager.SetPwm(pin, i);
                    await Task.Delay(TransitionSpeed);

                    Debug.WriteLine(i.ToString());
                }
                Debug.WriteLine("light off");
            }
        }
Ejemplo n.º 4
0
 private async Task SetBrightnessTo(int value)
 {
     if (_CurrentBrightness > value)
     {
         for (int i = _CurrentBrightness; i >= value; i--)
         {
             GpioManager.SetPwm(Pin, i);
             await Task.Delay(TransitionSpeed);
         }
     }
     else if (_CurrentBrightness < value)
     {
         for (int i = _CurrentBrightness; i <= value; i++)
         {
             GpioManager.SetPwm(Pin, i);
             await Task.Delay(TransitionSpeed);
         }
     }
     _CurrentBrightness = value;
 }