Skip to content

Commit

Permalink
feat: Adds support for IHasInputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ndorin committed Apr 30, 2024
1 parent 50ecff1 commit 687b456
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,4 @@ MigrationBackup/
# VS Code settings folders
.vscode/
*.projectinfo
/output/epi-display-lg.4Series.1.0.0-local.cplz
3 changes: 0 additions & 3 deletions output/epi-display-lg.4Series.1.0.0-local.cplz

This file was deleted.

96 changes: 96 additions & 0 deletions src/LGInputs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Queues;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Epi.Display.Lg
{
#if SERIES4
public class LgInputs : ISelectableItems<string>
{
private Dictionary<string, ISelectableItem> _items = new Dictionary<string, ISelectableItem>();

public Dictionary<string, ISelectableItem> Items
{
get
{
return _items;
}
set
{
if (_items == value)
return;

_items = value;

ItemsUpdated?.Invoke(this, null);
}
}

private string _currentItem;

public string CurrentItem
{
get
{
return _currentItem;
}
set
{
if (_currentItem == value)
return;

_currentItem = value;

CurrentItemChanged?.Invoke(this, null);
}
}

public event EventHandler ItemsUpdated;
public event EventHandler CurrentItemChanged;

}

public class LgInput : ISelectableItem
{
private bool _isSelected;

private readonly LgDisplayController _parent;

public LgInput(string key, string name, LgDisplayController parent)
{
Key = key;
Name = name;
_parent = parent;
}

public string Key { get; private set; }
public string Name { get; private set; }

public event EventHandler ItemUpdated;

public bool IsSelected
{
get { return _isSelected; }
set
{
if (value == _isSelected)
return;

_isSelected = value;
var handler = ItemUpdated;
if (handler != null)
handler(this, EventArgs.Empty);
}
}

public void Select()
{
_parent.SendData(Key);
}
}
#endif
}
63 changes: 61 additions & 2 deletions src/LgDisplayDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
using PepperDash.Essentials.Core.Routing;

using PepperDash.Essentials.Core.Queues;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Fusion;
using static Crestron.SimplSharpPro.DM.Audio;

namespace Epi.Display.Lg
{
public class LgDisplayController : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor,
IBridgeAdvanced

#if SERIES4
,IHasInputs<string, string>
#endif
{

GenericQueue ReceiveQueue;
Expand Down Expand Up @@ -301,6 +306,10 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E

#endregion

#if SERIES4
public ISelectableItems<string> Inputs { get; private set; }
#endif

private void Init()
{
WarmupTime = _warmingTimeMs > 0 ? _warmingTimeMs : 10000;
Expand Down Expand Up @@ -365,6 +374,10 @@ private void Init()
AddRoutingInputPort(
new RoutingInputPort(RoutingPortNames.DisplayPortIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.DisplayPort, new Action(InputDisplayPort), this), "c0");

#if SERIES4
SetupInputs();
#endif
}

public override bool CustomActivate()
Expand All @@ -379,6 +392,27 @@ public override bool CustomActivate()
return base.CustomActivate();
}

#if SERIES4
private void SetupInputs()
{
Inputs = new LgInputs
{
Items = new Dictionary<string, ISelectableItem>
{
{
"90", new LgInput("90", "HDMI 1", this)},
{

"91", new LgInput("91", "HDMI 2", this)
},
{
"c0", new LgInput("c0", "DisplayPort", this)
},
}
};
}
#endif

private void CommunicationMonitor_StatusChange(object sender, MonitorStatusChangeEventArgs e)
{
CommunicationMonitor.IsOnlineFeedback.FireUpdate();
Expand Down Expand Up @@ -451,7 +485,7 @@ private void AddRoutingInputPort(RoutingInputPort port, string fbMatch)
///
/// </summary>
/// <param name="s"></param>
private void SendData(string s)
public void SendData(string s)
{
if (_lastCommandSentWasVolume)
{
Expand Down Expand Up @@ -624,6 +658,19 @@ public void UpdateInputFb(string s)
break;
}
}

#if SERIES4
if (Inputs.Items.ContainsKey(s))
{

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

Inputs.CurrentItem = s;
#endif
}

/// <summary>
Expand Down Expand Up @@ -782,5 +829,17 @@ private void WolFunction(string macAddress)
Debug.Console(2, this, "Invalid Mad Address sent to WolFunction - {0}", macAddress);
throw new ArgumentException("Invalid MAC Address");
}

#if SERIES4
public void SetInput(string selector)
{
var input = Inputs.Items[selector];

if(input != null)
{
input.Select();
}
}
#endif
}
}
9 changes: 7 additions & 2 deletions src/epi-display-lg.4Series.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<RootNamespace>PepperDash.Essentials.Plugins.Display.LG</RootNamespace>
<TargetFramework>net472</TargetFramework>
<Deterministic>false</Deterministic>
` <Deterministic>false</Deterministic>
<AssemblyTitle>epi-lg-display</AssemblyTitle>
<Company>PepperDash Technologies</Company>
<Description>This software is a plugin designed to work as a part of PepperDash Essentials for Crestron control processors. This plugin allows for control LG Diplays.</Description>
Expand All @@ -19,6 +18,12 @@
<PackageId>PepperDash.Essentials.Plugin.4Series.LgDisplay</PackageId>
<PackageProjectUrl>https://github.com/PepperDash/epi-lg-display</PackageProjectUrl>
<PackageTags>crestron 4series lg display</PackageTags>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants);SERIES4</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>$(DefineConstants);SERIES4</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 687b456

Please sign in to comment.