示例#1
0
 private void ButtonValueChange(GpioPin gpioPin, EncoderRotaryEventArgs encoderEventArgs)
 {
     if (ButtonValueChanged != null)
     {
         ButtonValueChanged.Invoke(gpioPin, encoderEventArgs);
     }
 }
示例#2
0
 private void EncoderValueChange(GpioPin gpioPin, EncoderRotaryEventArgs encoderEventArgs)
 {
     if (RotaryValueChanged != null)
     {
         RotaryValueChanged.Invoke(gpioPin, encoderEventArgs);
     }
 }
示例#3
0
        private void EncoderCheckStatus(GpioPin gpioPin, Mode mode)
        {
            EncoderRotaryEventArgs args = new EncoderRotaryEventArgs();

            args.Button   = GetButtonState();
            args.ValueCLK = encoderCLK.Read();
            args.ValueDT  = encoderDT.Read();

            aState = encoderCLK.Read();

            if (aState != aLastState)
            {
                if (encoderDT.Read() != aState)
                {
                    args.Position = EncoderRotaryEventArgs.LastPosition.Left;
                }
                else
                {
                    args.Position = EncoderRotaryEventArgs.LastPosition.Right;
                }
            }
            aLastState = aState;

            switch (mode)
            {
            case Mode.Encoder:
                EncoderValueChange(gpioPin, args);
                break;

            case Mode.Button:
                ButtonValueChange(gpioPin, args);
                break;

            default:
                EncoderValueChange(gpioPin, args);
                break;
            }
        }