protected virtual void OnStatusUpdate(I2cEncoderEventArgs e) { StatusUpdateEventHandler handler = StatusUpdate; if (handler != null) { handler(this, e); } }
internal void OnValueChanged(object sender, GpioPinValueChangedEventArgs e) { if (e.Edge == GpioPinEdge.FallingEdge) { _stat = (byte)Read8(I2cEncoderAddress.REG_ESTATUS); _stat2 = 0; var args = new I2cEncoderEventArgs(); if ((_stat & (byte)I2cEncoderStatus.PUSHP) != 0) { args.ButtonPressed = true; } if ((_stat & (byte)I2cEncoderStatus.PUSHR) != 0) { args.ButtonReleased = true; } if ((_stat & (byte)I2cEncoderStatus.PUSHD) != 0) { args.ButtonDoublePressed = true; } if ((_stat & (byte)I2cEncoderStatus.RDEC) != 0) { args.CounterDecremented = true; if (_dataType == I2cEncoderDataType.INT) { args.Counter = ReadCounter(); } else { args.CounterFloat = ReadCounterFloat(); } } if ((_stat & (byte)I2cEncoderStatus.RINC) != 0) { args.CounterIncremented = true; if (_dataType == I2cEncoderDataType.INT) { args.Counter = ReadCounter(); } else { args.CounterFloat = ReadCounterFloat(); } } if ((_stat & (byte)I2cEncoderStatus.RMAX) != 0) { args.CounterMax = true; if (_dataType == I2cEncoderDataType.INT) { args.Counter = ReadCounter(); } else { args.CounterFloat = ReadCounterFloat(); } } if ((_stat & (byte)I2cEncoderStatus.RMIN) != 0) { args.CounterMin = true; if (_dataType == I2cEncoderDataType.INT) { args.Counter = ReadCounter(); } else { args.CounterFloat = ReadCounterFloat(); } } if ((_stat & (byte)I2cEncoderStatus.INT_2) != 0) { // Imprement INT } OnStatusUpdate(args); } }