Skip to content

Commit

Permalink
✨ Kraken Z: Allow loading a GIF image from the disk upon startup.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hexawyz committed Jan 2, 2025
1 parent f63d638 commit 7a9ee27
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Exo/Devices/Exo.Devices.Nzxt.Kraken/KrakenDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 7a9ee27

Please sign in to comment.