相同灯光 不添加 只叠加时间

This commit is contained in:
小电脑 2022-04-11 15:48:53 +08:00
parent ba51f93b17
commit 2b8d2f91be

View File

@ -142,16 +142,28 @@ namespace FlyCube
{
List<LedInfos> ledInfos = new List<LedInfos>();
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++;