/// <summary> /// Checks the IAnalogueInput for the new angle, and sends events if applicable. /// Cannot determine the total amount turned since the last UpdateState call, only the net change. /// As such, if the potentiometer is turned one direction, then back to the same place, we have no way of determining any movement occured. /// </summary> public void UpdateState() { int NewAngle = this.Range - (int)((((float)this.Input.GetRawInput() / (float)this.Input.GetRawRange()) * this.Range)); if (this.Invert) { NewAngle = this.Range - NewAngle; } int AngleChange = this.Angle - NewAngle; this.Angle = NewAngle; if (AngleChange != 0) { PotentiometerTurn Event = new PotentiometerTurn() { TurnAmount = AngleChange, Angle = this.Angle }; OnTurn(Event); } }
protected virtual void OnTurn(PotentiometerTurn Event) { Turned?.Invoke(this, Event); }