private void ButtonValueChange(GpioPin gpioPin, EncoderRotaryEventArgs encoderEventArgs) { if (ButtonValueChanged != null) { ButtonValueChanged.Invoke(gpioPin, encoderEventArgs); } }
private void EncoderValueChange(GpioPin gpioPin, EncoderRotaryEventArgs encoderEventArgs) { if (RotaryValueChanged != null) { RotaryValueChanged.Invoke(gpioPin, encoderEventArgs); } }
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; } }