From 39a04f91c4da3a23e355108cf4499bba85c14ddb Mon Sep 17 00:00:00 2001 From: Chad Nedzlek Date: Mon, 5 Feb 2024 00:04:24 -0800 Subject: [PATCH] Remove support for looping animations Looping animations have had breaking firmware changes, so just remove support for it, because I don't have a good way to deal with firmware breaking changes right now. --- CmdLine/Program.cs | 4 ++-- VaettirNet.PixelsDice.Net/Animations/Animation.cs | 5 ++--- .../Animations/Definitions/SimpleAnimation.cs | 1 - VaettirNet.PixelsDice.Net/PixelsDie.cs | 7 +++++-- .../VaettirNet.PixelsDice.Net.csproj | 1 - WpfUIDice/App.xaml.cs | 1 - WpfUIDice/ConnectPage.xaml.cs | 1 - WpfUIDice/DiceCollection.cs | 1 - WpfUIDice/DieView.cs | 1 - WpfUIDice/MainWindow.xaml.cs | 2 -- WpfUIDice/ProxyPage.xaml.cs | 9 --------- 11 files changed, 9 insertions(+), 24 deletions(-) diff --git a/CmdLine/Program.cs b/CmdLine/Program.cs index d386e06..939b066 100644 --- a/CmdLine/Program.cs +++ b/CmdLine/Program.cs @@ -97,7 +97,7 @@ public static async Task Main(string[] args) $"Connected to die {die.PixelId} (color:{die.Colorway}, type:{die.Type}, firmware:{die.BuildTimestamp.ToLocalTime()}"); await die.SendInstantAnimations(animations); - die.PlayInstantAnimation(2, 1, 1); + die.PlayInstantAnimation(2, 1); } Console.WriteLine($"Found {found.Count} dice!"); @@ -131,7 +131,7 @@ private static AnimationCollection BuildAnimationCollection() private static SimpleAnimation BuildSimpleAnimation(Color color) { - return new SimpleAnimation(TimeSpan.FromMilliseconds(50), 1, color, 1, 0); + return new SimpleAnimation(TimeSpan.FromSeconds(2), 1, color, 1, 0); } private static NoiseAnimation BuildNoiseAnimation() diff --git a/VaettirNet.PixelsDice.Net/Animations/Animation.cs b/VaettirNet.PixelsDice.Net/Animations/Animation.cs index a951e6c..abb4b90 100644 --- a/VaettirNet.PixelsDice.Net/Animations/Animation.cs +++ b/VaettirNet.PixelsDice.Net/Animations/Animation.cs @@ -1,4 +1,3 @@ -using System; using VaettirNet.PixelsDice.Net.Animations.Protocol.AnimationData; namespace VaettirNet.PixelsDice.Net.Animations; @@ -21,9 +20,9 @@ internal CombinedAnimationData ToProtocol(GlobalAnimationData data) return ToProtocol( new SharedAnimationData { - Duration = (ushort)DurationMs, Type = Type, - Flags = Flags + Flags = Flags, + Duration = (ushort)DurationMs, }, data); } diff --git a/VaettirNet.PixelsDice.Net/Animations/Definitions/SimpleAnimation.cs b/VaettirNet.PixelsDice.Net/Animations/Definitions/SimpleAnimation.cs index ebbcee1..f05c92e 100644 --- a/VaettirNet.PixelsDice.Net/Animations/Definitions/SimpleAnimation.cs +++ b/VaettirNet.PixelsDice.Net/Animations/Definitions/SimpleAnimation.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.Metrics; using System.Drawing; using VaettirNet.PixelsDice.Net.Animations.Protocol.AnimationData; diff --git a/VaettirNet.PixelsDice.Net/PixelsDie.cs b/VaettirNet.PixelsDice.Net/PixelsDie.cs index fd91a1f..34f8e95 100644 --- a/VaettirNet.PixelsDice.Net/PixelsDie.cs +++ b/VaettirNet.PixelsDice.Net/PixelsDie.cs @@ -151,10 +151,13 @@ await SendAndWaitForAck( await finishAck; } - public void PlayInstantAnimation(int index, int loopCount, byte faceIndex) + public void PlayInstantAnimation(int index, byte faceIndex) { + // BUG: "loopCount" is recent, before that, it's a boolean, so we can't set it to anything + // without checking the firmware version and having lots of versions of the messages + // For now, no looping. _ble.SendMessage(new PlayInstantAnimationMessage - { Animation = (byte)index, LoopCount = (byte)2, FaceIndex = faceIndex }); + { Animation = (byte)index, LoopCount = (byte)0, FaceIndex = faceIndex }); } public void StopAllAnimations() diff --git a/VaettirNet.PixelsDice.Net/VaettirNet.PixelsDice.Net.csproj b/VaettirNet.PixelsDice.Net/VaettirNet.PixelsDice.Net.csproj index 88b8078..5ea7d0b 100644 --- a/VaettirNet.PixelsDice.Net/VaettirNet.PixelsDice.Net.csproj +++ b/VaettirNet.PixelsDice.Net/VaettirNet.PixelsDice.Net.csproj @@ -3,7 +3,6 @@ VaettirNet.PixelsDice.Net true - Cross-platform library for interacting with Pixels dice from .NET, using SimpleBle Chad Nedzlek 2024 Chad Nedzlek diff --git a/WpfUIDice/App.xaml.cs b/WpfUIDice/App.xaml.cs index a206567..aa7ce8e 100644 --- a/WpfUIDice/App.xaml.cs +++ b/WpfUIDice/App.xaml.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.IO; using System.Linq; diff --git a/WpfUIDice/ConnectPage.xaml.cs b/WpfUIDice/ConnectPage.xaml.cs index c41c5d6..ff1cacf 100644 --- a/WpfUIDice/ConnectPage.xaml.cs +++ b/WpfUIDice/ConnectPage.xaml.cs @@ -1,4 +1,3 @@ -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; diff --git a/WpfUIDice/DiceCollection.cs b/WpfUIDice/DiceCollection.cs index 47243a8..47122a2 100644 --- a/WpfUIDice/DiceCollection.cs +++ b/WpfUIDice/DiceCollection.cs @@ -5,7 +5,6 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; -using System.Data; using System.Linq; using System.Windows; using VaettirNet.PixelsDice.Net; diff --git a/WpfUIDice/DieView.cs b/WpfUIDice/DieView.cs index 28144c4..e7a23cc 100644 --- a/WpfUIDice/DieView.cs +++ b/WpfUIDice/DieView.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows; diff --git a/WpfUIDice/MainWindow.xaml.cs b/WpfUIDice/MainWindow.xaml.cs index 38295fb..0adc37b 100644 --- a/WpfUIDice/MainWindow.xaml.cs +++ b/WpfUIDice/MainWindow.xaml.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; using System.Windows; diff --git a/WpfUIDice/ProxyPage.xaml.cs b/WpfUIDice/ProxyPage.xaml.cs index c1613e1..96ec730 100644 --- a/WpfUIDice/ProxyPage.xaml.cs +++ b/WpfUIDice/ProxyPage.xaml.cs @@ -1,14 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Collections.Specialized; -using System.ComponentModel; -using System.Linq; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using VaettirNet.PixelsDice.Net; -using DataGrid = Wpf.Ui.Controls.DataGrid; namespace WpfUIDice;