mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Slash Lighting support for GA605
This commit is contained in:
@@ -40,9 +40,16 @@ namespace GHelper.AnimeMatrix
|
||||
try
|
||||
{
|
||||
if (AppConfig.IsSlash())
|
||||
deviceSlash = new SlashDevice();
|
||||
{
|
||||
if (AppConfig.IsSlashAura())
|
||||
deviceSlash = new SlashDeviceAura();
|
||||
else
|
||||
deviceSlash = new SlashDevice();
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceMatrix = new AnimeMatrixDevice();
|
||||
}
|
||||
|
||||
matrixTimer = new System.Timers.Timer(100);
|
||||
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
||||
@@ -111,7 +118,8 @@ namespace GHelper.AnimeMatrix
|
||||
if (custom is not null && custom.Length > 0)
|
||||
{
|
||||
deviceSlash.SetCustom(AppConfig.StringToBytes(custom));
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceSlash.SetStatic(brightness);
|
||||
}
|
||||
@@ -279,14 +287,14 @@ namespace GHelper.AnimeMatrix
|
||||
|
||||
// create the timer if first call
|
||||
// this way, the timer only spawns if user tries to use battery pattern
|
||||
if(slashTimer == default(System.Timers.Timer))
|
||||
if (slashTimer == default(System.Timers.Timer))
|
||||
{
|
||||
slashTimer = new System.Timers.Timer(interval);
|
||||
slashTimer.Elapsed += SlashTimer_elapsed;
|
||||
slashTimer.AutoReset = true;
|
||||
}
|
||||
// only write if interval changed
|
||||
if(slashTimer.Interval != interval)
|
||||
if (slashTimer.Interval != interval)
|
||||
{
|
||||
slashTimer.Interval = interval;
|
||||
}
|
||||
@@ -304,7 +312,7 @@ namespace GHelper.AnimeMatrix
|
||||
if (deviceSlash is null) return;
|
||||
|
||||
//kill timer if called but not in battery pattern mode
|
||||
if((SlashMode)AppConfig.Get("matrix_running", 0) != SlashMode.BatteryLevel)
|
||||
if ((SlashMode)AppConfig.Get("matrix_running", 0) != SlashMode.BatteryLevel)
|
||||
{
|
||||
slashTimer.Stop();
|
||||
slashTimer.Dispose();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using GHelper.AnimeMatrix.Communication;
|
||||
using System.Management;
|
||||
using System.Text;
|
||||
using System.Timers;
|
||||
|
||||
namespace GHelper.AnimeMatrix
|
||||
{
|
||||
@@ -26,6 +25,9 @@ namespace GHelper.AnimeMatrix
|
||||
BatteryLevel,
|
||||
}
|
||||
|
||||
public class SlashDevice : Device
|
||||
{
|
||||
|
||||
internal class SlashPacket : Packet
|
||||
{
|
||||
public SlashPacket(byte[] command) : base(0x5E, 128, command)
|
||||
@@ -33,9 +35,6 @@ namespace GHelper.AnimeMatrix
|
||||
}
|
||||
}
|
||||
|
||||
public class SlashDevice : Device
|
||||
{
|
||||
|
||||
public static Dictionary<SlashMode, string> Modes = new Dictionary<SlashMode, string>
|
||||
{
|
||||
{ SlashMode.Bounce, "Bounce"},
|
||||
@@ -85,7 +84,7 @@ namespace GHelper.AnimeMatrix
|
||||
{ SlashMode.Buzzer, 0x44},
|
||||
};
|
||||
|
||||
public SlashDevice() : base(0x0B05, 0x193B, 128)
|
||||
public SlashDevice(ushort productId = 0x193B) : base(0x0B05, productId, 128)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -159,23 +158,23 @@ namespace GHelper.AnimeMatrix
|
||||
// set brightness to reflect battery's percentage within that range
|
||||
|
||||
int bracket = (int)Math.Floor(percentage / 14.2857);
|
||||
if(bracket >= 7) return Enumerable.Repeat((byte)(brightness * 85.333), 7).ToArray();
|
||||
if (bracket >= 7) return Enumerable.Repeat((byte)(brightness * 85.333), 7).ToArray();
|
||||
|
||||
byte[] batteryPattern = Enumerable.Repeat((byte)(0x00), 7).ToArray();
|
||||
for (int i = 6; i > 6-bracket; i--)
|
||||
for (int i = 6; i > 6 - bracket; i--)
|
||||
{
|
||||
batteryPattern[i] = (byte)(brightness * 85.333);
|
||||
}
|
||||
|
||||
//set the "selected" bracket to the percentage of that bracket filled from 0 to 255 as a hex
|
||||
batteryPattern[6-bracket] = (byte)(((percentage % 14.2857) * brightness * 85.333) / 14.2857);
|
||||
batteryPattern[6 - bracket] = (byte)(((percentage % 14.2857) * brightness * 85.333) / 14.2857);
|
||||
|
||||
return batteryPattern;
|
||||
}
|
||||
|
||||
public void SetBatteryPattern(int brightness)
|
||||
{
|
||||
SetCustom(GetBatteryPattern(brightness, 100*(GetBatteryChargePercentage()/AppConfig.Get("charge_limit",100))));
|
||||
SetCustom(GetBatteryPattern(brightness, 100 * (GetBatteryChargePercentage() / AppConfig.Get("charge_limit", 100))));
|
||||
}
|
||||
|
||||
public void SetCustom(byte[] data)
|
||||
@@ -214,9 +213,22 @@ namespace GHelper.AnimeMatrix
|
||||
public void Set(Packet packet, string? log = null)
|
||||
{
|
||||
_usbProvider?.Set(packet.Data);
|
||||
if (log is not null) Logger.WriteLine($"{log}:" + BitConverter.ToString(packet.Data).Substring(0,48));
|
||||
if (log is not null) Logger.WriteLine($"{log}:" + BitConverter.ToString(packet.Data).Substring(0, 48));
|
||||
}
|
||||
}
|
||||
|
||||
public class SlashDeviceAura : SlashDevice
|
||||
{
|
||||
public SlashDeviceAura(): base(0x193B)
|
||||
{
|
||||
}
|
||||
|
||||
internal new class SlashPacket : Packet
|
||||
{
|
||||
public SlashPacket(byte[] command) : base(0x5D, 128, command)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -405,6 +405,11 @@ public static class AppConfig
|
||||
return ContainsModel("GA403") || ContainsModel("GU605") || ContainsModel("GA605");
|
||||
}
|
||||
|
||||
public static bool IsSlashAura()
|
||||
{
|
||||
return ContainsModel("GA605");
|
||||
}
|
||||
|
||||
public static bool IsInputBacklight()
|
||||
{
|
||||
return ContainsModel("GA503") || IsSlash();
|
||||
@@ -583,7 +588,7 @@ public static class AppConfig
|
||||
|
||||
public static bool IsFanRequired()
|
||||
{
|
||||
return ContainsModel("GA402X") || ContainsModel("G513") || ContainsModel("G713R") || ContainsModel("G713P") || ContainsModel("GU605") || ContainsModel("GA605") || ContainsModel("GA403") || ContainsModel("G634J") || ContainsModel("G834J") || ContainsModel("G614J") || ContainsModel("G814J") || ContainsModel("FX507V");
|
||||
return ContainsModel("GA402X") || ContainsModel("G513") || ContainsModel("G713R") || ContainsModel("G713P") || ContainsModel("GU605") || ContainsModel("GA403") || ContainsModel("G634J") || ContainsModel("G834J") || ContainsModel("G614J") || ContainsModel("G814J") || ContainsModel("FX507V");
|
||||
}
|
||||
|
||||
public static bool IsAMDLight()
|
||||
|
||||
Reference in New Issue
Block a user