mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Adds property to set TvPresetsDigitSpacingMs from config
This commit is contained in:
@@ -37,6 +37,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
void Dash(bool pressRelease);
|
void Dash(bool pressRelease);
|
||||||
void KeypadEnter(bool pressRelease);
|
void KeypadEnter(bool pressRelease);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To be set to a custom value to override the default DigitSpacingMs in DevicePresetsModel
|
||||||
|
/// </summary>
|
||||||
|
int TvPresetsDigitSpacingMs { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To be set to a custom value to override the default IrPulseTime
|
||||||
|
/// </summary>
|
||||||
|
ushort IrPulseTime { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
|
|
||||||
public DevicePresetsModel(string key, string fileName) : base(key)
|
public DevicePresetsModel(string key, string fileName) : base(key)
|
||||||
{
|
{
|
||||||
PulseTime = 200;
|
PulseTimeMs = 200;
|
||||||
DigitSpacingMs = 200;
|
DigitSpacingMs = 200;
|
||||||
|
|
||||||
UseLocalImageStorage = true;
|
UseLocalImageStorage = true;
|
||||||
@@ -88,7 +88,7 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
public event PresetRecalledCallback PresetRecalled;
|
public event PresetRecalledCallback PresetRecalled;
|
||||||
public event PresetsSavedCallback PresetsSaved;
|
public event PresetsSavedCallback PresetsSaved;
|
||||||
|
|
||||||
public int PulseTime { get; set; }
|
public int PulseTimeMs { get; set; }
|
||||||
public int DigitSpacingMs { get; set; }
|
public int DigitSpacingMs { get; set; }
|
||||||
public bool PresetsAreLoaded { get; private set; }
|
public bool PresetsAreLoaded { get; private set; }
|
||||||
|
|
||||||
@@ -154,11 +154,11 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
{
|
{
|
||||||
if (presetNum <= PresetsList.Count)
|
if (presetNum <= PresetsList.Count)
|
||||||
{
|
{
|
||||||
Dial(PresetsList[presetNum - 1].Channel);
|
Dial(PresetsList[presetNum - 1].Channel, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dial(string chanNum)
|
public void Dial(string chanNum, int digitSpacingMs, int pulseTime)
|
||||||
{
|
{
|
||||||
if (_dialIsRunning || !_initSuccess)
|
if (_dialIsRunning || !_initSuccess)
|
||||||
{
|
{
|
||||||
@@ -173,18 +173,35 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
_dialIsRunning = true;
|
_dialIsRunning = true;
|
||||||
CrestronInvoke.BeginInvoke(o =>
|
CrestronInvoke.BeginInvoke(o =>
|
||||||
{
|
{
|
||||||
|
var pulse = PulseTimeMs;
|
||||||
|
|
||||||
|
if (pulseTime > 0)
|
||||||
|
{
|
||||||
|
pulse = pulseTime;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var c in chanNum.ToCharArray())
|
foreach (var c in chanNum.ToCharArray())
|
||||||
{
|
{
|
||||||
if (_dialFunctions.ContainsKey(c))
|
if (_dialFunctions.ContainsKey(c))
|
||||||
{
|
{
|
||||||
Pulse(_dialFunctions[c]);
|
Pulse(_dialFunctions[c], pulse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the default spacing interval
|
||||||
|
var spacing = DigitSpacingMs;
|
||||||
|
|
||||||
|
// check for override of default interval
|
||||||
|
if (digitSpacingMs > 0)
|
||||||
|
{
|
||||||
|
spacing = digitSpacingMs;
|
||||||
|
}
|
||||||
|
|
||||||
CrestronEnvironment.Sleep(DigitSpacingMs);
|
CrestronEnvironment.Sleep(DigitSpacingMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_enterFunction != null)
|
if (_enterFunction != null)
|
||||||
{
|
{
|
||||||
Pulse(_enterFunction);
|
Pulse(_enterFunction, pulse);
|
||||||
}
|
}
|
||||||
_dialIsRunning = false;
|
_dialIsRunning = false;
|
||||||
});
|
});
|
||||||
@@ -223,7 +240,7 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
|
|
||||||
OnPresetRecalled(setTopBox, chanNum);
|
OnPresetRecalled(setTopBox, chanNum);
|
||||||
|
|
||||||
Dial(chanNum);
|
Dial(chanNum, setTopBox.TvPresetsDigitSpacingMs, setTopBox.IrPulseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPresetRecalled(ISetTopBoxNumericKeypad setTopBox, string channel)
|
private void OnPresetRecalled(ISetTopBoxNumericKeypad setTopBox, string channel)
|
||||||
@@ -290,10 +307,17 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
handler(PresetsList);
|
handler(PresetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Pulse(Action<bool> act)
|
private void Pulse(Action<bool> act, int pulseTime)
|
||||||
{
|
{
|
||||||
|
var pulse = PulseTimeMs;
|
||||||
|
|
||||||
|
if (pulseTime > 0)
|
||||||
|
{
|
||||||
|
pulse = pulseTime;
|
||||||
|
}
|
||||||
|
|
||||||
act(true);
|
act(true);
|
||||||
CrestronEnvironment.Sleep(PulseTime);
|
CrestronEnvironment.Sleep(PulseTimeMs);
|
||||||
act(false);
|
act(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
public bool HasDpad { get; set; }
|
public bool HasDpad { get; set; }
|
||||||
public bool HasNumeric { get; set; }
|
public bool HasNumeric { get; set; }
|
||||||
|
|
||||||
|
public int TvPresetsDigitSpacingMs { get; private set; }
|
||||||
|
|
||||||
public DevicePresetsModel PresetsModel { get; private set; }
|
public DevicePresetsModel PresetsModel { get; private set; }
|
||||||
|
|
||||||
public IRSetTopBoxBase(string key, string name, IrOutputPortController portCont,
|
public IRSetTopBoxBase(string key, string name, IrOutputPortController portCont,
|
||||||
@@ -35,13 +37,19 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
: base(key, name)
|
: base(key, name)
|
||||||
{
|
{
|
||||||
IrPort = portCont;
|
IrPort = portCont;
|
||||||
IrPulseTime = 200;
|
IrPulseTime = 200; // default
|
||||||
|
TvPresetsDigitSpacingMs = 200; // default
|
||||||
|
|
||||||
if (props.IrPulseTime > 0)
|
if (props.IrPulseTime > 0)
|
||||||
{
|
{
|
||||||
IrPulseTime = (ushort)props.IrPulseTime;
|
IrPulseTime = (ushort)props.IrPulseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (props.TvPresetsDigitSpacingMs > 0)
|
||||||
|
{
|
||||||
|
TvPresetsDigitSpacingMs = props.TvPresetsDigitSpacingMs;
|
||||||
|
}
|
||||||
|
|
||||||
DeviceManager.AddDevice(portCont);
|
DeviceManager.AddDevice(portCont);
|
||||||
|
|
||||||
HasPresets = props.HasPresets;
|
HasPresets = props.HasPresets;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
public bool HasDpad { get; set; }
|
public bool HasDpad { get; set; }
|
||||||
public bool HasNumeric { get; set; }
|
public bool HasNumeric { get; set; }
|
||||||
public int IrPulseTime { get; set; }
|
public int IrPulseTime { get; set; }
|
||||||
|
public int TvPresetsDigitSpacingMs { get; set; }
|
||||||
|
|
||||||
public ControlPropertiesConfig Control { get; set; }
|
public ControlPropertiesConfig Control { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user