From 7a9ee27662e3faa0d2089353a52d73dcf07c84db Mon Sep 17 00:00:00 2001 From: hexawyz <8518235+hexawyz@users.noreply.github.com> Date: Thu, 2 Jan 2025 01:00:45 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Kraken=20Z:=20Allow=20loading=20a?= =?UTF-8?q?=20GIF=20image=20from=20the=20disk=20upon=20startup.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a workaround for the lack of UI to configure those features at the moment. The image name is expected to be "nzkt-kraken-z.gif" and put in the same directory as the service executable. --- .../Exo.Devices.Nzxt.Kraken/KrakenDriver.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Exo/Devices/Exo.Devices.Nzxt.Kraken/KrakenDriver.cs b/src/Exo/Devices/Exo.Devices.Nzxt.Kraken/KrakenDriver.cs index 5903e17f..bfb81dfb 100644 --- a/src/Exo/Devices/Exo.Devices.Nzxt.Kraken/KrakenDriver.cs +++ b/src/Exo/Devices/Exo.Devices.Nzxt.Kraken/KrakenDriver.cs @@ -124,7 +124,21 @@ await KrakenImageStorageManager.CreateAsync(screenInfo.ImageCount, screenInfo.Me if (storageManager is not null) { await hidTransport.DisplayPresetVisualAsync(KrakenPresetVisual.LiquidTemperature, cancellationToken).ConfigureAwait(false); - await storageManager.UploadImageAsync(0, KrakenImageFormat.Raw, GenerateImage(screenInfo.Width, screenInfo.Height), cancellationToken).ConfigureAwait(false); + KrakenImageFormat imageFormat; + byte[] imageData; + try + { + // Hardcoded way of loading a GIF onto the device. + // It may not be very nice, but it will be a good enough workaround until we deal with UI stuff & possibly programming model in the service. + imageData = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(typeof(Driver).Assembly.Location)!, "nzkt-kraken-z.gif")); + imageFormat = KrakenImageFormat.Gif; + } + catch (IOException) + { + imageData = GenerateImage(screenInfo.Width, screenInfo.Height); + imageFormat = KrakenImageFormat.Raw; + } + await storageManager.UploadImageAsync(0, imageFormat, imageData, cancellationToken).ConfigureAwait(false); await hidTransport.DisplayImageAsync(0, cancellationToken).ConfigureAwait(false); }