From aafa7a2d29eef7ca0a02ffc6a0c2f30315d961cd Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 1 Apr 2021 13:24:38 -0600 Subject: [PATCH] add friendly names --- epi-display-samsung-mdc/SamsungMdc.cs | 15 +++++++++++--- .../SamsungMdcConfigObject.cs | 20 ++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/epi-display-samsung-mdc/SamsungMdc.cs b/epi-display-samsung-mdc/SamsungMdc.cs index 355fd61..b465845 100644 --- a/epi-display-samsung-mdc/SamsungMdc.cs +++ b/epi-display-samsung-mdc/SamsungMdc.cs @@ -675,17 +675,26 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); // Input digitals - var count = 1; + var count = 0; foreach (var input in InputPorts) { var i = input; trilist.SetSigTrueAction((ushort) (joinMap.InputSelectOffset.JoinNumber + count), () => ExecuteSwitch(InputPorts[i.Key].Selector)); + + var friendlyName = _config.FriendlyNames.FirstOrDefault(n => n.InputKey == i.Key); - trilist.StringInput[(ushort) (joinMap.InputNamesOffset.JoinNumber + count)].StringValue = i.Key; + if (friendlyName != null) + { + Debug.Console(1, this, "Friendly Name found for input {0}: {1}", i.Key, friendlyName.Name); + } + + var name = friendlyName == null ? i.Key : friendlyName.Name; + + trilist.StringInput[(ushort) (joinMap.InputNamesOffset.JoinNumber + count)].StringValue = name; - InputFeedback[count - 1].LinkInputSig( + InputFeedback[count].LinkInputSig( trilist.BooleanInput[joinMap.InputSelectOffset.JoinNumber + (uint) count]); count++; } diff --git a/epi-display-samsung-mdc/SamsungMdcConfigObject.cs b/epi-display-samsung-mdc/SamsungMdcConfigObject.cs index 8dfe797..0b6d594 100644 --- a/epi-display-samsung-mdc/SamsungMdcConfigObject.cs +++ b/epi-display-samsung-mdc/SamsungMdcConfigObject.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; using System; namespace PepperDash.Plugin.Display.SamsungMdc @@ -22,5 +23,22 @@ public class SamsungMDCDisplayPropertiesConfig [JsonProperty("warmingTimeMs")] public uint warmingTimeMs { get; set; } + + [JsonProperty("friendlyNames")] + public List FriendlyNames { get; set; } + + public SamsungMDCDisplayPropertiesConfig() + { + FriendlyNames = new List(); + } } + + public class FriendlyName + { + [JsonProperty("inputKey")] + public string InputKey { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + } } \ No newline at end of file