From 2b8d2f91bef666b04f2211457794580fd13549e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=94=B5=E8=84=91?= Date: Mon, 11 Apr 2022 15:48:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E5=90=8C=E7=81=AF=E5=85=89=20?= =?UTF-8?q?=E4=B8=8D=E6=B7=BB=E5=8A=A0=20=20=E5=8F=AA=E5=8F=A0=E5=8A=A0?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FlyCube/MainWindow.xaml.cs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/FlyCube/MainWindow.xaml.cs b/FlyCube/MainWindow.xaml.cs index 4303703..cce5762 100644 --- a/FlyCube/MainWindow.xaml.cs +++ b/FlyCube/MainWindow.xaml.cs @@ -142,16 +142,28 @@ namespace FlyCube { List ledInfos = new List(); Color[] colors = img.GetColorsForGifPos((int)item.X, (int)item.Y); + string c = ""; foreach (var color in colors) { - LedInfos led = new LedInfos(); - led.Delay = 0.1; - led.LEDMode = 0; - led.LEDInterval = 0.0; - led.LEDRate = 0; - led.LEDTimes = 0; - led.LEDRGB = color.ToString().Remove(0, 3); - ledInfos.Add(led); + if (c != color.ToString().Remove(0, 3))//判断和一帧颜色是否相同 不同的话添加 新的灯光信息 + { + //添加灯光信息 + LedInfos led = new LedInfos(); + led.Delay = 0.1; + led.LEDMode = 0; + led.LEDInterval = 0.0; + led.LEDRate = 0; + led.LEDTimes = 0; + led.LEDRGB = color.ToString().Remove(0, 3); + ledInfos.Add(led); + //记录这一帧颜色 用于下次循环和 这一帧进行对比 + c = color.ToString().Remove(0, 3); + } + else//如果和上一帧颜色一样 则不进行Add 并把上一帧的 灯光延时自加0.1秒 + { + ledInfos[ledInfos.Count-1].Delay += 0.1; + } + } this.FcgmInfo.tasks[2].singleCopterInfos[id].ledInfos = ledInfos; id++;