From 62051665bd1ab3a3b5bcfad0939028ed7bc42f4f Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 19 Sep 2017 22:08:03 -0500 Subject: [PATCH] Tweak pulse charging routine --- DS4Windows/DS4Control/DS4LightBar.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/DS4Windows/DS4Control/DS4LightBar.cs b/DS4Windows/DS4Control/DS4LightBar.cs index f845d91..c1f5f12 100644 --- a/DS4Windows/DS4Control/DS4LightBar.cs +++ b/DS4Windows/DS4Control/DS4LightBar.cs @@ -34,8 +34,9 @@ namespace DS4Windows public static DS4Color[] forcedColor = new DS4Color[4]; public static byte[] forcedFlash = new byte[4]; internal const int PULSE_FLASH_DURATION = 2000; - internal const int PULSE_FLASH_SEGMENTS = PULSE_FLASH_DURATION / 40; + internal const double PULSE_FLASH_SEGMENTS = PULSE_FLASH_DURATION / 40; internal const int PULSE_CHARGING_DURATION = 4000; + internal const double PULSE_CHARGING_SEGMENTS = PULSE_CHARGING_DURATION / 40; public static void updateLightBar(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState, Mouse tp) @@ -83,13 +84,9 @@ namespace DS4Windows } else if (getLedAsBatteryIndicator(deviceNum)) { - //if (device.Charging == false || device.Battery >= 100) // when charged, don't show the charging animation - { - DS4Color fullColor = getMainColor(deviceNum); - DS4Color lowColor = getLowColor(deviceNum); - - color = getTransitionedColor(lowColor, fullColor, device.getBattery()); - } + DS4Color fullColor = getMainColor(deviceNum); + DS4Color lowColor = getLowColor(deviceNum); + color = getTransitionedColor(lowColor, fullColor, device.getBattery()); } else { @@ -193,7 +190,8 @@ namespace DS4Windows { if (elapsed < PULSE_CHARGING_DURATION) { - ratio = 100.0 * (elapsed / (double)PULSE_CHARGING_DURATION); + elapsed = elapsed / 40; + ratio = 100.0 * (elapsed / PULSE_CHARGING_SEGMENTS); } else { @@ -205,7 +203,8 @@ namespace DS4Windows { if (elapsed < PULSE_CHARGING_DURATION) { - ratio = (0 - 100.0) * (elapsed / (double)PULSE_CHARGING_DURATION) + 100.0; + elapsed = elapsed / 40; + ratio = (0 - 100.0) * (elapsed / PULSE_CHARGING_SEGMENTS) + 100.0; } else {