From ebf3323ce9d1b12925728f98a883cdb5f647ddfa Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Fri, 2 Feb 2024 14:49:15 -0500 Subject: [PATCH 1/3] fix: updated director factory --- src/NvxEpi/Factories/NvxDirectorFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NvxEpi/Factories/NvxDirectorFactory.cs b/src/NvxEpi/Factories/NvxDirectorFactory.cs index db641a3..564ae8e 100644 --- a/src/NvxEpi/Factories/NvxDirectorFactory.cs +++ b/src/NvxEpi/Factories/NvxDirectorFactory.cs @@ -29,7 +29,7 @@ public override EssentialsDevice BuildDevice(DeviceConfig dc) switch (dc.Type.ToLower()) { case "xiodirector": - xio = new DmXioDirector80(config.Control.IpIdInt, Global.ControlSystem); + xio = new DmXioDirectorEnterprise(config.Control.IpIdInt, Global.ControlSystem); break; case "xiodirector80": xio = new DmXioDirector80(config.Control.IpIdInt, Global.ControlSystem); From a9163a19d54e372950d001514c2d757ff6c911a1 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Thu, 15 Feb 2024 08:51:23 -0800 Subject: [PATCH 2/3] feat: removed extra usb logging --- src/NvxEpi/Services/Feedback/UsbRouteFeedback.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NvxEpi/Services/Feedback/UsbRouteFeedback.cs b/src/NvxEpi/Services/Feedback/UsbRouteFeedback.cs index 5ba5e8b..230f14a 100644 --- a/src/NvxEpi/Services/Feedback/UsbRouteFeedback.cs +++ b/src/NvxEpi/Services/Feedback/UsbRouteFeedback.cs @@ -68,7 +68,6 @@ private static int ReturnRoute(DmNvxBaseClass device) if (remoteEndpoint == null) { - Debug.Console(0, "RemoteEndpoint is Null", deviceIp); return 0; } From 9c1e6314fdd2ecb68e4677a7c425b10fab9dfbd5 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Thu, 15 Feb 2024 09:44:40 -0800 Subject: [PATCH 3/3] feat: 36x now implements ibasicvolumewithfeedback --- src/NvxEpi/Devices/Nvx36X.cs | 51 +++++++++++++- src/NvxEpi/Features/Audio/Nvx36xAudio.cs | 89 ++++++++++++++++++++++++ src/NvxEpi/NvxEpi.csproj | 1 + 3 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 src/NvxEpi/Features/Audio/Nvx36xAudio.cs diff --git a/src/NvxEpi/Devices/Nvx36X.cs b/src/NvxEpi/Devices/Nvx36X.cs index 8e6f38d..bd6f479 100644 --- a/src/NvxEpi/Devices/Nvx36X.cs +++ b/src/NvxEpi/Devices/Nvx36X.cs @@ -4,11 +4,10 @@ using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Streaming; -using NvxEpi.Abstractions; using NvxEpi.Abstractions.HdmiInput; using NvxEpi.Abstractions.HdmiOutput; -using NvxEpi.Abstractions.Stream; using NvxEpi.Abstractions.Usb; +using NvxEpi.Features.Audio; using NvxEpi.Features.AutomaticRouting; using NvxEpi.Features.Config; using NvxEpi.Features.Hdmi.Input; @@ -21,6 +20,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; +using Feedback = PepperDash.Essentials.Core.Feedback; namespace NvxEpi.Devices { @@ -32,8 +32,10 @@ public class Nvx36X : IHdmiInput, IVideowallMode, IRouting, - ICec + ICec, + IBasicVolumeWithFeedback { + private IBasicVolumeWithFeedback _audio; private IHdmiInput _hdmiInput; private IVideowallMode _hdmiOutput; private IUsbStreamWithHardware _usbStream; @@ -52,10 +54,13 @@ public override bool CustomActivate() { var result = base.CustomActivate(); + _audio = new Nvx36XAudio((DmNvx36x) Hardware, this); _usbStream = UsbStream.GetUsbStream(this, _config.Usb); _hdmiInput = new HdmiInput1(this); _hdmiOutput = new VideowallModeOutput(this); + Feedbacks.AddRange(new [] { (Feedback)_audio.MuteFeedback, _audio.VolumeLevelFeedback }); + if (_config.EnableAutoRoute) // ReSharper disable once ObjectCreationAsStatement new AutomaticInputRouter(_hdmiInput); @@ -215,5 +220,45 @@ public StringFeedback UsbLocalId { get { return _usbStream.UsbLocalId; } } + + public void VolumeUp(bool pressRelease) + { + _audio.VolumeUp(pressRelease); + } + + public void VolumeDown(bool pressRelease) + { + _audio.VolumeDown(pressRelease); + } + + public void MuteToggle() + { + _audio.MuteToggle(); + } + + public void SetVolume(ushort level) + { + _audio.SetVolume(level); + } + + public void MuteOn() + { + _audio.MuteOn(); + } + + public void MuteOff() + { + _audio.MuteOff(); + } + + public IntFeedback VolumeLevelFeedback + { + get { return _audio.VolumeLevelFeedback; } + } + + public BoolFeedback MuteFeedback + { + get { return _audio.MuteFeedback; } + } } } \ No newline at end of file diff --git a/src/NvxEpi/Features/Audio/Nvx36xAudio.cs b/src/NvxEpi/Features/Audio/Nvx36xAudio.cs new file mode 100644 index 0000000..088e0ca --- /dev/null +++ b/src/NvxEpi/Features/Audio/Nvx36xAudio.cs @@ -0,0 +1,89 @@ +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DM.Streaming; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace NvxEpi.Features.Audio +{ + public class Nvx36XAudio : IBasicVolumeWithFeedback + { + private readonly DmNvx36x _device; + private readonly IKeyed _parent; + + public Nvx36XAudio(DmNvx36x device, IKeyed parent) + { + _device = device; + _parent = parent; + + MuteFeedback = new BoolFeedback("Muted", () => _device.Control.AudioMutedFeedback.BoolValue); + + VolumeLevelFeedback = new IntFeedback("Volume", () => + { + var volume = _device.Control.AnalogAudioOutputVolumeFeedback.ShortValue; + var result = MapVolume(volume); + return result; + }); + + _device.OnlineStatusChange += (@base, args) => MuteFeedback.FireUpdate(); + _device.OnlineStatusChange += (@base, args) => VolumeLevelFeedback.FireUpdate(); + + _device.BaseEvent += (@base, args) => MuteFeedback.FireUpdate(); + _device.BaseEvent += (@base, args) => VolumeLevelFeedback.FireUpdate(); + } + + public static int MapVolume(short level) + { + const float inputMin = -800; + const float inputMax = 240; + + const float outputMin = 0; + const float outputMax = ushort.MaxValue; + + var normalized = (level - inputMin) / (inputMax - inputMin); + var mappedValue = (int)(normalized * (outputMax - outputMin) + outputMin); + + return mappedValue; + } + + public void VolumeUp(bool pressRelease) + { + Debug.Console(0, _parent, "Volume press not implemented"); + } + + public void VolumeDown(bool pressRelease) + { + Debug.Console(0, _parent, "Volume press not implemented"); + } + + public void MuteToggle() + { + if (_device.Control.AudioMutedFeedback.BoolValue) + { + _device.Control.AudioUnmute(); + } + else + { + _device.Control.AudioMute(); + } + } + + public void SetVolume(ushort level) + { + var volume = CrestronEnvironment.ScaleWithLimits(level, ushort.MaxValue, ushort.MinValue, 240, -800); + _device.Control.AnalogAudioOutputVolume.ShortValue = (short) volume; + } + + public void MuteOn() + { + _device.Control.AudioMute(); + } + + public void MuteOff() + { + _device.Control.AudioUnmute(); + } + + public IntFeedback VolumeLevelFeedback { get; private set; } + public BoolFeedback MuteFeedback { get; private set; } + } +} \ No newline at end of file diff --git a/src/NvxEpi/NvxEpi.csproj b/src/NvxEpi/NvxEpi.csproj index 96e9d18..ec5fde3 100644 --- a/src/NvxEpi/NvxEpi.csproj +++ b/src/NvxEpi/NvxEpi.csproj @@ -129,6 +129,7 @@ +