Compare commits

...

2 Commits

Author SHA1 Message Date
Neil Dorin
29e2b88862 Adds property to set TvPresetsDigitSpacingMs from config 2021-01-14 14:39:28 -07:00
Neil Dorin
de068277de Sets default pulse time and digit spaceing to 200ms 2021-01-14 13:09:53 -07:00
4 changed files with 54 additions and 11 deletions

View File

@@ -37,6 +37,16 @@ namespace PepperDash.Essentials.Core
{
void Dash(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>

View File

@@ -70,8 +70,8 @@ namespace PepperDash.Essentials.Core.Presets
public DevicePresetsModel(string key, string fileName) : base(key)
{
PulseTime = 150;
DigitSpacingMs = 150;
PulseTimeMs = 200;
DigitSpacingMs = 200;
UseLocalImageStorage = true;
@@ -88,7 +88,7 @@ namespace PepperDash.Essentials.Core.Presets
public event PresetRecalledCallback PresetRecalled;
public event PresetsSavedCallback PresetsSaved;
public int PulseTime { get; set; }
public int PulseTimeMs { get; set; }
public int DigitSpacingMs { get; set; }
public bool PresetsAreLoaded { get; private set; }
@@ -154,11 +154,11 @@ namespace PepperDash.Essentials.Core.Presets
{
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)
{
@@ -173,18 +173,35 @@ namespace PepperDash.Essentials.Core.Presets
_dialIsRunning = true;
CrestronInvoke.BeginInvoke(o =>
{
var pulse = PulseTimeMs;
if (pulseTime > 0)
{
pulse = pulseTime;
}
foreach (var c in chanNum.ToCharArray())
{
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);
}
if (_enterFunction != null)
{
Pulse(_enterFunction);
Pulse(_enterFunction, pulse);
}
_dialIsRunning = false;
});
@@ -223,7 +240,7 @@ namespace PepperDash.Essentials.Core.Presets
OnPresetRecalled(setTopBox, chanNum);
Dial(chanNum);
Dial(chanNum, setTopBox.TvPresetsDigitSpacingMs, setTopBox.IrPulseTime);
}
private void OnPresetRecalled(ISetTopBoxNumericKeypad setTopBox, string channel)
@@ -290,10 +307,17 @@ namespace PepperDash.Essentials.Core.Presets
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);
CrestronEnvironment.Sleep(PulseTime);
CrestronEnvironment.Sleep(PulseTimeMs);
act(false);
}
}

View File

@@ -28,6 +28,8 @@ namespace PepperDash.Essentials.Devices.Common
public bool HasDpad { get; set; }
public bool HasNumeric { get; set; }
public int TvPresetsDigitSpacingMs { get; private set; }
public DevicePresetsModel PresetsModel { get; private set; }
public IRSetTopBoxBase(string key, string name, IrOutputPortController portCont,
@@ -35,13 +37,19 @@ namespace PepperDash.Essentials.Devices.Common
: base(key, name)
{
IrPort = portCont;
IrPulseTime = 200;
IrPulseTime = 200; // default
TvPresetsDigitSpacingMs = 200; // default
if (props.IrPulseTime > 0)
{
IrPulseTime = (ushort)props.IrPulseTime;
}
if (props.TvPresetsDigitSpacingMs > 0)
{
TvPresetsDigitSpacingMs = props.TvPresetsDigitSpacingMs;
}
DeviceManager.AddDevice(portCont);
HasPresets = props.HasPresets;

View File

@@ -15,6 +15,7 @@ namespace PepperDash.Essentials.Devices.Common
public bool HasDpad { get; set; }
public bool HasNumeric { get; set; }
public int IrPulseTime { get; set; }
public int TvPresetsDigitSpacingMs { get; set; }
public ControlPropertiesConfig Control { get; set; }
}