Skip to content

Commit

Permalink
add friendly names
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-welker committed Apr 1, 2021
1 parent e207981 commit aafa7a2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
15 changes: 12 additions & 3 deletions epi-display-samsung-mdc/SamsungMdc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
20 changes: 19 additions & 1 deletion epi-display-samsung-mdc/SamsungMdcConfigObject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
using System;

namespace PepperDash.Plugin.Display.SamsungMdc
Expand All @@ -22,5 +23,22 @@ public class SamsungMDCDisplayPropertiesConfig

[JsonProperty("warmingTimeMs")]
public uint warmingTimeMs { get; set; }

[JsonProperty("friendlyNames")]
public List<FriendlyName> FriendlyNames { get; set; }

public SamsungMDCDisplayPropertiesConfig()
{
FriendlyNames = new List<FriendlyName>();
}
}

public class FriendlyName
{
[JsonProperty("inputKey")]
public string InputKey { get; set; }

[JsonProperty("name")]
public string Name { get; set; }
}
}

0 comments on commit aafa7a2

Please sign in to comment.