Fixed share button sync issues around power off dialogs

This commit is contained in:
Heath Volmer
2017-08-25 15:16:21 -06:00
parent efd630c8f1
commit d55d30be3f
17 changed files with 285 additions and 415 deletions

View File

@@ -10,18 +10,6 @@ using System.Text.RegularExpressions;
namespace PepperDash.Essentials.Devices.Common.DSP
{
// QUESTIONS:
//
// When subscribing, just use the Instance ID for Custom Name?
// Verbose on subscriptions?
// ! "publishToken":"name" "value":-77.0
// ! "myLevelName" -77
#warning Working here when set aside for config editor work
public class TesiraForteLevelControl : TesiraForteControlPoint, IDspLevelControl, IKeyed
{
bool _IsMuted;

View File

@@ -266,7 +266,7 @@ namespace PepperDash.Essentials.Devices.Displays
/// </summary>
void UpdateVolumeFB(byte b)
{
var newVol = (ushort)Scale((double)b, 0, 100, 0, 65535);
var newVol = (ushort)NumericalHelpers.Scale((double)b, 0, 100, 0, 65535);
if (!VolumeIsRamping)
_LastVolumeSent = newVol;
if (newVol != _VolumeLevelForSig)
@@ -482,40 +482,11 @@ namespace PepperDash.Essentials.Devices.Displays
public void SetVolume(ushort level)
{
_LastVolumeSent = level;
var scaled = (int)Scale(level, 0, 65535, 0, 100);
var scaled = (int)NumericalHelpers.Scale(level, 0, 65535, 0, 100);
// The inputs to Scale ensure that byte won't overflow
SendBytes(new byte[] { 0xAA, 0x12, 0x00, 0x01, Convert.ToByte(scaled), 0x00 });
}
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <param name="inMin"></param>
/// <param name="inMax"></param>
/// <param name="outMin"></param>
/// <param name="outMax"></param>
/// <returns></returns>
double Scale(double input, double inMin, double inMax, double outMin, double outMax)
{
//Debug.Console(2, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax);
double inputRange = inMax - inMin;
if (inputRange <= 0)
{
throw new ArithmeticException(string.Format("Invalid Input Range '{0}' for Scaling. Min '{1}' Max '{2}'.", inputRange, inMin, inMax));
}
double outputRange = outMax - outMin;
var output = (((input - inMin) * outputRange) / inputRange) + outMin;
// Debug.Console(2, this, "Scaled output '{0}'", output);
return output;
}
#region IBasicVolumeWithFeedback Members
public IntFeedback VolumeLevelFeedback { get; private set; }