Skip to content

Commit

Permalink
feat: adds input feedback mechanism for IHasInputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ndorin committed Apr 26, 2024
1 parent 1654c93 commit fa9593c
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions epi-sony-bravia.4Series/SonyBraviaDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
using PepperDash.Essentials.Core.Queues;
using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Devices.Displays;
using static Crestron.SimplSharpPro.DM.Audio;

namespace SonyBraviaEpi
{
public class SonyBraviaDevice : TwoWayDisplayBase, ICommunicationMonitor, IBridgeAdvanced,
IInputHdmi1, IInputHdmi2, IInputHdmi3, IInputHdmi4, IInputVga1,
IOnline
#if SERIES4
,IHasInputs<string, string>
#endif
{
private readonly IBasicCommunication _coms;
private readonly bool _comsIsRs232;
Expand Down Expand Up @@ -100,9 +99,8 @@ public SonyBraviaDevice(DeviceConfig config, IBasicCommunication comms)

BuildInputRoutingPorts();

#if SERIES4
SetupInputs();
#endif


var worker = _comsIsRs232
? new Thread(ProcessRs232Response, null)
Expand Down Expand Up @@ -377,7 +375,6 @@ public void BuildInputRoutingPorts()
new Action(InputComponent3), this), 12);
}

#if SERIES4
private void SetupInputs()
{
Inputs = new SonyBraviaInputs
Expand Down Expand Up @@ -447,7 +444,6 @@ private void SetupInputs()
}
};
}
#endif

/// <summary>
/// Select HDMI 1 input
Expand Down Expand Up @@ -756,8 +752,20 @@ private object ProcessRs232Response(object _)
{
_currentInput = input;
CurrentInputFeedback.FireUpdate();

if(Inputs.Items.ContainsKey(input))
{
foreach (var item in Inputs.Items)
{
item.Value.IsSelected = item.Key.Equals(input);
}
}

Inputs.CurrentItem = input;
}



buffer = buffer.NumberOfHeaders() > 1 ? buffer.CleanOutFirstMessage() : new byte[0];

Debug.Console(DebugLevels.DebugLevel, this, seperator);
Expand Down Expand Up @@ -867,6 +875,18 @@ private object ProcessSimpleIpResponse(object _)
}
}


// No idea if this will work with _currentInput. It's not clear how the input is determined for IP communication
if (Inputs.Items.ContainsKey(_currentInput))
{
foreach (var item in Inputs.Items)
{
item.Value.IsSelected = item.Key.Equals(_currentInput);
}
}

Inputs.CurrentItem = _currentInput;

Debug.Console(DebugLevels.ErrorLevel, this, "ProcessSimpleIpResponse: _currentInput == '{0}'", _currentInput);

break;
Expand Down

0 comments on commit fa9593c

Please sign in to comment.