From 7d0eb77effcec400c1153633a89f32f67f3041d8 Mon Sep 17 00:00:00 2001 From: Ayrton Ricardo Date: Wed, 10 Sep 2025 21:48:23 +0200 Subject: [PATCH] feat: Add missing commands friction and inertia from axis --- OpenFFBClient/Program.cs | 2 ++ OpenFFBSharp/Commands.cs | 53 +++++++++++++++++++++++++++++++++++++--- OpenFFBSharp/Serial.cs | 1 + 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/OpenFFBClient/Program.cs b/OpenFFBClient/Program.cs index 02f7721..c875b9e 100644 --- a/OpenFFBClient/Program.cs +++ b/OpenFFBClient/Program.cs @@ -35,6 +35,8 @@ static void Main(string[] args) Console.WriteLine("Inverted: {0}", openFFBoard.Axis.GetInvert()); Console.WriteLine("Idle spring: {0}", openFFBoard.Axis.GetIdlespring()); Console.WriteLine("Damper: {0}", openFFBoard.Axis.GetAxisdamper()); + Console.WriteLine("Friction: {0}", openFFBoard.Axis.GetAxisfriction()); + Console.WriteLine("Inertia: {0}", openFFBoard.Axis.GetAxisinertia()); Console.WriteLine("Encoder type: {0}", openFFBoard.Axis.GetEnctype()); Console.WriteLine("Driver type: {0}", openFFBoard.Axis.GetDrvtype()); Console.WriteLine("Encoder position: {0}", openFFBoard.Axis.GetPos()); diff --git a/OpenFFBSharp/Commands.cs b/OpenFFBSharp/Commands.cs index f144ba7..2f7c621 100644 --- a/OpenFFBSharp/Commands.cs +++ b/OpenFFBSharp/Commands.cs @@ -936,9 +936,56 @@ public long GetCurpos() { return _curpos.GetValue(_board, this); } - #endregion - } - public class CANAnalogAxes : BoardClass + #endregion + + #region axisfriction + private readonly BoardCommand _axisfriction = new BoardCommand("axisfriction", 0x16, "Axis Friction. Independent friction effect. 255=100%", CmdTypes.Get | CmdTypes.Set); + + /// + /// Axis Friction configured position + /// + /// + public long GetAxisfriction() + { + return _axisfriction.GetValue(_board, this); + } + + /// + /// Axios Friction. Independent friction effect. 255=100% + /// + /// + public bool SetAxisfriction(byte newAxisfriction) + { + var query = _axisfriction.SetValue(_board, this, newAxisfriction); + return query.Type == CmdType.Acknowledgment && query.ClassId == ClassId && query.Cmd == _axisfriction; + } + #endregion + + #region axisinertia + private readonly BoardCommand _axisinertia = new BoardCommand("axisinertia", 0xF, "Axis Inertia. Independent inertia effect. 255=100%", CmdTypes.Get | CmdTypes.Set); + + /// + /// Axis Inertia configured position + /// + /// + public long GetAxisinertia() + { + return _axisinertia.GetValue(_board, this); + } + + /// + /// Axis Inertia. Independent inertia effect. 255=100% + /// + /// + public bool SetAxisinertia(byte newAxisinertia) + { + var query = _axisinertia.SetValue(_board, this, newAxisinertia); + return query.Type == CmdType.Acknowledgment && query.ClassId == ClassId && query.Cmd == _axisinertia; + } + #endregion + } + + public class CANAnalogAxes : BoardClass { private readonly Board _board; diff --git a/OpenFFBSharp/Serial.cs b/OpenFFBSharp/Serial.cs index a781c6f..5946a45 100644 --- a/OpenFFBSharp/Serial.cs +++ b/OpenFFBSharp/Serial.cs @@ -63,6 +63,7 @@ public override void Connect() public override void Disconnect() { _serialPort.Close(); + IsConnected = _serialPort.IsOpen; } public static string[] GetBoards()