Added sig held helper function

This commit is contained in:
Heath Volmer
2017-08-23 22:03:54 -06:00
parent d5dddade85
commit 057d8ac5f5
8 changed files with 36 additions and 13 deletions

View File

@@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
@@ -59,6 +61,36 @@ namespace PepperDash.Essentials.Core
return sig.SetBoolSigAction(b => { if (!b) a(); }); return sig.SetBoolSigAction(b => { if (!b) a(); });
} }
/// <summary>
///
/// </summary>
/// <param name="tl"></param>
/// <param name="sigNum"></param>
/// <param name="heldAction"></param>
/// <returns></returns>
public static BoolOutputSig SetSigHeldAction(this BasicTriList tl, uint sigNum, uint heldMs, Action heldAction)
{
CTimer heldTimer = null;
return tl.SetBoolSigAction(sigNum, press =>
{
if (press)
{
// Could insert a pressed action here
heldTimer = new CTimer(o =>
{
// if still held and there's an action
if (tl.BooleanInput[sigNum].BoolValue && heldAction != null)
// Hold action here
heldAction();
}, heldMs);
}
else if (heldTimer != null) // released
heldTimer.Stop();
// could also revise this else to fire a released action as well as cancel the timer
});
}
/// <summary> /// <summary>
/// ///

View File

@@ -215,20 +215,11 @@ namespace PepperDash.Essentials
//TriList.SetSigFalseAction(UIBoolJoin.RoomHeaderButtonPress, () => //TriList.SetSigFalseAction(UIBoolJoin.RoomHeaderButtonPress, () =>
// ShowInterlockedModal(UIBoolJoin.RoomHeaderPageVisible)); // ShowInterlockedModal(UIBoolJoin.RoomHeaderPageVisible));
#warning Add press and hold to gear button here
#warning CHANGE BACK THIS JOIN NUMBER to GearHeaderButtonPress!!!!!! #warning CHANGE BACK THIS JOIN NUMBER to GearHeaderButtonPress!!!!!!
// Hold button
CTimer GearButtonHoldTimer = null; TriList.SetSigHeldAction(UIBoolJoin.GearButtonVisible, 2000,
TriList.SetBoolSigAction(UIBoolJoin.GearButtonVisible, b => { //GearHeaderButtonPress () => ShowInterlockedModal(UIBoolJoin.TechPanelSetupVisible));
if (b)
GearButtonHoldTimer = new CTimer(o =>
{
if (TriList.BooleanInput[UIBoolJoin.GearButtonVisible].BoolValue) //GearHeaderButtonPress
ShowInterlockedModal(UIBoolJoin.TechPanelSetupVisible);
}, 2000);
else if (GearButtonHoldTimer != null)
GearButtonHoldTimer.Stop();
});
TriList.SetSigFalseAction(UIBoolJoin.TechPagesExitButton, () => TriList.SetSigFalseAction(UIBoolJoin.TechPagesExitButton, () =>
HideCurrentInterlockedModal()); HideCurrentInterlockedModal());
TriList.BooleanInput[UIBoolJoin.GearButtonVisible].BoolValue = true; TriList.BooleanInput[UIBoolJoin.GearButtonVisible].BoolValue = true;