mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
Merge pull request #401 from PepperDash/hotfix/unable-to-use-hightest-IR-port-number
Multiple Fixes for IR
This commit is contained in:
@@ -424,10 +424,14 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sourceListKey))
|
if (string.IsNullOrEmpty(sourceListKey))
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "No sourceListKey present. RunRouteAction assumes default source list.");
|
||||||
RunRouteAction(routeKey, new Action(() => { }));
|
RunRouteAction(routeKey, new Action(() => { }));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "sourceListKey present but not yet implemented");
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
Debug.Console(0, "WARNING: device with IR ports '{0}' not found", portDevKey);
|
Debug.Console(0, "WARNING: device with IR ports '{0}' not found", portDevKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (portNum >= irDev.NumberOfIROutputPorts)
|
if (portNum > irDev.NumberOfIROutputPorts)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "WARNING: device '{0}' IR port {1} out of range",
|
Debug.Console(0, "WARNING: device '{0}' IR port {1} out of range",
|
||||||
portDevKey, portNum);
|
portDevKey, portNum);
|
||||||
@@ -134,10 +134,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
var port = irDev.IROutputPorts[portNum];
|
var port = irDev.IROutputPorts[portNum];
|
||||||
|
|
||||||
port.LoadIRDriver(Global.FilePathPrefix + "IR" + Global.DirectorySeparator + control["irFile"].Value<string>());
|
|
||||||
|
|
||||||
return port;
|
return port;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IrOutputPortController GetIrOutputPortController(DeviceConfig config)
|
public static IrOutputPortController GetIrOutputPortController(DeviceConfig config)
|
||||||
@@ -149,7 +148,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var irDevice = new IrOutputPortController(config.Key, GetIrOutputPort, config);
|
var postActivationFunc = new Func<DeviceConfig,IROutputPort> (GetIrOutputPort);
|
||||||
|
var irDevice = new IrOutputPortController(config.Key + "-ir", postActivationFunc, config);
|
||||||
|
|
||||||
return irDevice;
|
return irDevice;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
public string DriverFilepath { get; private set; }
|
public string DriverFilepath { get; private set; }
|
||||||
public bool DriverIsLoaded { get; private set; }
|
public bool DriverIsLoaded { get; private set; }
|
||||||
|
|
||||||
|
public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for IrDevice base class. If a null port is provided, this class will
|
/// Constructor for IrDevice base class. If a null port is provided, this class will
|
||||||
/// still function without trying to talk to a port.
|
/// still function without trying to talk to a port.
|
||||||
@@ -49,9 +51,30 @@ namespace PepperDash.Essentials.Core
|
|||||||
AddPostActivationAction(() =>
|
AddPostActivationAction(() =>
|
||||||
{
|
{
|
||||||
IrPort = postActivationFunc(config);
|
IrPort = postActivationFunc(config);
|
||||||
|
|
||||||
|
if (IrPort == null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
|
||||||
|
Debug.Console(1, "*************Attemting to load IR file: {0}***************", filePath);
|
||||||
|
|
||||||
|
LoadDriver(filePath);
|
||||||
|
|
||||||
|
PrintAvailableCommands();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PrintAvailableCommands()
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "Available IR Commands in IR File {0}", IrPortUid);
|
||||||
|
foreach (var cmd in IrPort.AvailableIRCmds())
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "{0}", cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -60,14 +83,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
public void LoadDriver(string path)
|
public void LoadDriver(string path)
|
||||||
{
|
{
|
||||||
|
Debug.Console(2, this, "***Loading IR File***");
|
||||||
if (string.IsNullOrEmpty(path)) path = DriverFilepath;
|
if (string.IsNullOrEmpty(path)) path = DriverFilepath;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IrPortUid = IrPort.LoadIRDriver(path);
|
IrPortUid = IrPort.LoadIRDriver(path);
|
||||||
DriverFilepath = path;
|
DriverFilepath = path;
|
||||||
StandardIrPulseTime = 200;
|
StandardIrPulseTime = 200;
|
||||||
DriverIsLoaded = true;
|
DriverIsLoaded = true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
DriverIsLoaded = false;
|
DriverIsLoaded = false;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharp.Reflection;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -32,39 +33,50 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio,
|
AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio,
|
||||||
eRoutingPortConnectionType.DigitalAudio, null, this);
|
eRoutingPortConnectionType.DigitalAudio, null, this);
|
||||||
OutputPorts = new RoutingPortCollection<RoutingOutputPort> { HdmiOut, AnyAudioOut };
|
OutputPorts = new RoutingPortCollection<RoutingOutputPort> { HdmiOut, AnyAudioOut };
|
||||||
|
|
||||||
|
PrintExpectedIrCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PrintExpectedIrCommands()
|
||||||
|
{
|
||||||
|
var cmds = typeof (AppleTvIrCommands).GetCType().GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||||
|
|
||||||
#region IDPad Members
|
foreach (var value in cmds.Select(cmd => cmd.GetValue(null)).OfType<string>())
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "Expected IR Function Name: {0}", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDPad Members
|
||||||
|
|
||||||
public void Up(bool pressRelease)
|
public void Up(bool pressRelease)
|
||||||
{
|
{
|
||||||
IrPort.PressRelease("+", pressRelease);
|
IrPort.PressRelease(AppleTvIrCommands.Up, pressRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Down(bool pressRelease)
|
public void Down(bool pressRelease)
|
||||||
{
|
{
|
||||||
IrPort.PressRelease("-", pressRelease);
|
IrPort.PressRelease(AppleTvIrCommands.Down, pressRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Left(bool pressRelease)
|
public void Left(bool pressRelease)
|
||||||
{
|
{
|
||||||
IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_MINUS, pressRelease);
|
IrPort.PressRelease(AppleTvIrCommands.Left, pressRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Right(bool pressRelease)
|
public void Right(bool pressRelease)
|
||||||
{
|
{
|
||||||
IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_PLUS, pressRelease);
|
IrPort.PressRelease(AppleTvIrCommands.Right, pressRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Select(bool pressRelease)
|
public void Select(bool pressRelease)
|
||||||
{
|
{
|
||||||
IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease);
|
IrPort.PressRelease(AppleTvIrCommands.Enter, pressRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Menu(bool pressRelease)
|
public void Menu(bool pressRelease)
|
||||||
{
|
{
|
||||||
IrPort.PressRelease("Menu", pressRelease);
|
IrPort.PressRelease(AppleTvIrCommands.Menu, pressRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Exit(bool pressRelease)
|
public void Exit(bool pressRelease)
|
||||||
@@ -78,12 +90,12 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
|
|
||||||
public void Play(bool pressRelease)
|
public void Play(bool pressRelease)
|
||||||
{
|
{
|
||||||
IrPort.PressRelease("PLAY/PAUSE", pressRelease);
|
IrPort.PressRelease(AppleTvIrCommands.PlayPause, pressRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Pause(bool pressRelease)
|
public void Pause(bool pressRelease)
|
||||||
{
|
{
|
||||||
IrPort.PressRelease("PLAY/PAUSE", pressRelease);
|
IrPort.PressRelease(AppleTvIrCommands.PlayPause, pressRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -190,4 +202,17 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class AppleTvIrCommands
|
||||||
|
{
|
||||||
|
|
||||||
|
public static string Up = "+";
|
||||||
|
public static string Down = "-";
|
||||||
|
public static string Left = IROutputStandardCommands.IROut_TRACK_MINUS;
|
||||||
|
public static string Right = IROutputStandardCommands.IROut_TRACK_PLUS;
|
||||||
|
public static string Enter = IROutputStandardCommands.IROut_ENTER;
|
||||||
|
public static string PlayPause = "PLAY/PAUSE";
|
||||||
|
public static string Rewind = "REWIND";
|
||||||
|
public static string Menu = "Menu";
|
||||||
|
public static string FastForward = "FASTFORWARD";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user