Skip to content

Commit

Permalink
feat: implement IPartitionStateProvider to Generic VersaPortInput
Browse files Browse the repository at this point in the history
  • Loading branch information
ngenovese11 committed Jan 30, 2025
1 parent d8a88b2 commit 54dcb5d
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
/// <summary>
/// Represents a generic digital input deviced tied to a versiport
/// </summary>
public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput
public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IPartitionStateProvider
{
public Versiport InputPort { get; private set; }

Expand All @@ -35,10 +35,15 @@ Func<bool> InputStateFeedbackFunc
}
}

public BoolFeedback PartitionPresentFeedback { get; }

public bool PartitionPresent => !InputStateFeedbackFunc();

public GenericVersiportDigitalInputDevice(string key, string name, Func<IOPortConfig, Versiport> postActivationFunc, IOPortConfig config) :
base(key, name)
{
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
PartitionPresentFeedback = new BoolFeedback(() => !InputStateFeedbackFunc());

AddPostActivationAction(() =>
{
Expand All @@ -52,7 +57,8 @@ public GenericVersiportDigitalInputDevice(string key, string name, Func<IOPortCo

InputPort.VersiportChange += InputPort_VersiportChange;


InputStateFeedback.FireUpdate();
PartitionPresentFeedback.FireUpdate();

Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportDigitalInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor);

Expand All @@ -65,7 +71,10 @@ void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event);

if(args.Event == eVersiportEvent.DigitalInChange)
{
InputStateFeedback.FireUpdate();
PartitionPresentFeedback.FireUpdate();
}
}


Expand Down

0 comments on commit 54dcb5d

Please sign in to comment.