mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Slash Lightning tweaks
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
using NAudio.CoreAudioApi;
|
using NAudio.CoreAudioApi;
|
||||||
using NAudio.Wave;
|
using NAudio.Wave;
|
||||||
using Starlight.AnimeMatrix;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using static GHelper.AnimeMatrix.BuiltInAnimation;
|
||||||
|
|
||||||
namespace GHelper.AnimeMatrix
|
namespace GHelper.AnimeMatrix
|
||||||
{
|
{
|
||||||
@@ -25,6 +25,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
private MMDeviceEnumerator? AudioDeviceEnum;
|
private MMDeviceEnumerator? AudioDeviceEnum;
|
||||||
|
|
||||||
public bool IsValid => deviceMatrix != null || deviceSlash != null;
|
public bool IsValid => deviceMatrix != null || deviceSlash != null;
|
||||||
|
public bool IsSlash => deviceSlash != null;
|
||||||
|
|
||||||
private long lastPresent;
|
private long lastPresent;
|
||||||
private List<double> maxes = new List<double>();
|
private List<double> maxes = new List<double>();
|
||||||
@@ -35,30 +36,18 @@ namespace GHelper.AnimeMatrix
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
deviceMatrix = new AnimeMatrixDevice();
|
if (AppConfig.ContainsModel("GA40"))
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
deviceMatrix = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AppConfig.ContainsModel("GA403"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
deviceSlash = new SlashDevice();
|
deviceSlash = new SlashDevice();
|
||||||
}
|
else
|
||||||
catch
|
deviceMatrix = new AnimeMatrixDevice();
|
||||||
{
|
|
||||||
deviceSlash = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsValid)
|
|
||||||
{
|
|
||||||
matrixTimer = new System.Timers.Timer(100);
|
matrixTimer = new System.Timers.Timer(100);
|
||||||
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//Logger.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,15 +84,14 @@ namespace GHelper.AnimeMatrix
|
|||||||
{
|
{
|
||||||
deviceSlash.Init();
|
deviceSlash.Init();
|
||||||
deviceSlash.SetOptions(false);
|
deviceSlash.SetOptions(false);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
deviceSlash.Init();
|
deviceSlash.Init();
|
||||||
deviceSlash.SetMode((SlashMode)running);
|
deviceSlash.SetMode((SlashMode)running);
|
||||||
deviceSlash.SetOptions(false, (byte)(brightness*85.333), 0);
|
deviceSlash.SetOptions(false, (byte)(brightness * 85.333), 0);
|
||||||
deviceSlash.Save();
|
deviceSlash.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,13 +104,6 @@ namespace GHelper.AnimeMatrix
|
|||||||
int running = AppConfig.Get("matrix_running", 0);
|
int running = AppConfig.Get("matrix_running", 0);
|
||||||
bool auto = AppConfig.Is("matrix_auto");
|
bool auto = AppConfig.Is("matrix_auto");
|
||||||
|
|
||||||
BuiltInAnimation animation = new BuiltInAnimation(
|
|
||||||
(BuiltInAnimation.Running)running,
|
|
||||||
BuiltInAnimation.Sleeping.Starfield,
|
|
||||||
BuiltInAnimation.Shutdown.SeeYa,
|
|
||||||
BuiltInAnimation.Startup.StaticEmergence
|
|
||||||
);
|
|
||||||
|
|
||||||
StopMatrixTimer();
|
StopMatrixTimer();
|
||||||
StopMatrixAudio();
|
StopMatrixAudio();
|
||||||
|
|
||||||
@@ -163,8 +144,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
SetMatrixAudio();
|
SetMatrixAudio();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
deviceMatrix.SetBuiltInAnimation(true, animation);
|
SetBuiltIn(running);
|
||||||
Logger.WriteLine("Matrix builtin " + animation.AsByte);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +153,19 @@ namespace GHelper.AnimeMatrix
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetBuiltIn(int running)
|
||||||
|
{
|
||||||
|
BuiltInAnimation animation = new BuiltInAnimation(
|
||||||
|
(Running)running,
|
||||||
|
Sleeping.Starfield,
|
||||||
|
Shutdown.SeeYa,
|
||||||
|
BuiltInAnimation.Startup.StaticEmergence
|
||||||
|
);
|
||||||
|
deviceMatrix.SetBuiltInAnimation(true, animation);
|
||||||
|
Logger.WriteLine("Matrix builtin: " + animation.AsByte);
|
||||||
|
}
|
||||||
|
|
||||||
private void StartMatrixTimer(int interval = 100)
|
private void StartMatrixTimer(int interval = 100)
|
||||||
{
|
{
|
||||||
matrixTimer.Interval = interval;
|
matrixTimer.Interval = interval;
|
||||||
@@ -187,7 +180,8 @@ namespace GHelper.AnimeMatrix
|
|||||||
|
|
||||||
private void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
private void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
//if (!IsValid) return;
|
|
||||||
|
if (deviceMatrix is null) return;
|
||||||
|
|
||||||
switch (AppConfig.Get("matrix_running"))
|
switch (AppConfig.Get("matrix_running"))
|
||||||
{
|
{
|
||||||
@@ -235,7 +229,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
|
|
||||||
void SetMatrixAudio()
|
void SetMatrixAudio()
|
||||||
{
|
{
|
||||||
if (!IsValid) return;
|
if (deviceMatrix is null) return;
|
||||||
|
|
||||||
deviceMatrix.SetBuiltInAnimation(false);
|
deviceMatrix.SetBuiltInAnimation(false);
|
||||||
StopMatrixTimer();
|
StopMatrixTimer();
|
||||||
@@ -317,6 +311,8 @@ namespace GHelper.AnimeMatrix
|
|||||||
void PresentAudio(double[] audio)
|
void PresentAudio(double[] audio)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (deviceMatrix is null) return;
|
||||||
|
|
||||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastPresent) < 70) return;
|
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastPresent) < 70) return;
|
||||||
lastPresent = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
lastPresent = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
|
||||||
@@ -376,7 +372,8 @@ namespace GHelper.AnimeMatrix
|
|||||||
public void SetMatrixPicture(string fileName, bool visualise = true)
|
public void SetMatrixPicture(string fileName, bool visualise = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!IsValid) return;
|
if (deviceMatrix is null) return;
|
||||||
|
|
||||||
StopMatrixTimer();
|
StopMatrixTimer();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Drawing.Drawing2D;
|
|||||||
using System.Drawing.Text;
|
using System.Drawing.Text;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Starlight.AnimeMatrix
|
namespace GHelper.AnimeMatrix
|
||||||
{
|
{
|
||||||
public class BuiltInAnimation
|
public class BuiltInAnimation
|
||||||
{
|
{
|
||||||
@@ -91,7 +91,6 @@ namespace Starlight.AnimeMatrix
|
|||||||
public int MaxRows = 61;
|
public int MaxRows = 61;
|
||||||
public int MaxColumns = 34;
|
public int MaxColumns = 34;
|
||||||
public int LedStart = 0;
|
public int LedStart = 0;
|
||||||
|
|
||||||
public int FullRows = 11;
|
public int FullRows = 11;
|
||||||
|
|
||||||
private int frameIndex = 0;
|
private int frameIndex = 0;
|
||||||
|
|||||||
@@ -37,14 +37,11 @@ namespace GHelper.AnimeMatrix.Communication.Platform
|
|||||||
HidDevice = DeviceList.Local
|
HidDevice = DeviceList.Local
|
||||||
.GetHidDevices(vendorId, productId)
|
.GetHidDevices(vendorId, productId)
|
||||||
.First(x => x.GetMaxFeatureReportLength() >= maxFeatureReportLength);
|
.First(x => x.GetMaxFeatureReportLength() >= maxFeatureReportLength);
|
||||||
|
Logger.WriteLine("Matrix Device: " + HidDevice.DevicePath + " " + HidDevice.GetMaxFeatureReportLength());
|
||||||
Logger.WriteLine("Matrix Device: " + HidDevice.DevicePath);
|
|
||||||
Logger.WriteLine("Matrix Features: " + HidDevice.GetMaxFeatureReportLength());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
throw new IOException("AniMe Matrix control device was not found on your machine.");
|
throw new IOException("Matrix control device was not found on your machine.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = new OpenConfiguration();
|
var config = new OpenConfiguration();
|
||||||
|
|||||||
@@ -896,7 +896,7 @@ namespace GHelper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matrixControl.deviceSlash is not null)
|
if (matrixControl.IsSlash)
|
||||||
{
|
{
|
||||||
labelMatrix.Text = "Slash Lightning";
|
labelMatrix.Text = "Slash Lightning";
|
||||||
comboMatrixRunning.Items.Clear();
|
comboMatrixRunning.Items.Clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user