Esempio n. 1
0
 public static byte[] SendTMLEDS(TMLEDSMessage tmLEDMessage)
 {
     int expectedLength = (tmLEDMessage.Green.Count * 2) + 1;
     if (expectedLength < 3) return null;
     byte[] messageData = new byte[expectedLength];
     int serialCount = -1;
     messageData[++serialCount] = Convert.ToByte(IntValueCheck(tmLEDMessage.Intensity, 0, Constants.MaxIntensityTM));
     for (int i = 0; i < tmLEDMessage.Green.Count;i++)
     {
         messageData[++serialCount] = tmLEDMessage.Green[i];
         messageData[++serialCount] = tmLEDMessage.Red[i];
     }
     return messageData;
 }
        public static byte[] SendTMLEDS(TMLEDSMessage tmLEDMessage)
        {
            int expectedLength = (tmLEDMessage.Green.Count * 2) + 1;

            if (expectedLength < 3)
            {
                return(null);
            }
            byte[] messageData = new byte[expectedLength];
            int    serialCount = -1;

            messageData[++serialCount] = Convert.ToByte(IntValueCheck(tmLEDMessage.Intensity, 0, Constants.MaxIntensityTM));
            for (int i = 0; i < tmLEDMessage.Green.Count; i++)
            {
                messageData[++serialCount] = tmLEDMessage.Green[i];
                messageData[++serialCount] = tmLEDMessage.Red[i];
            }
            return(messageData);
        }
        private void TestTimerTick(object sender, EventArgs e)
        {
            this.testCounter++;
            int numberUnits = this.unitTypes.Count;
            var displays    = new List <string>(numberUnits);
            var greens      = new List <byte>(numberUnits);
            var reds        = new List <byte>(numberUnits);
            var dotsList    = new List <byte[]>(numberUnits);

            byte green;
            byte red;
            byte dots;

            for (int t = 0; t < numberUnits; t++)
            {
                displays.Add("");
                greens.Add(0);
                reds.Add(0);
                dotsList.Add(this.unitTypes[t] ? new Byte[] { 0, 0 } : new Byte[] { 0 });
            }

            string display = this.TestSequence(this.testCounter, out green, out red, out dots);

            this.DuplicateDisplayAcrossAllUnits(display, green, red, dots, displays, greens, reds, dotsList, this.unitTypes);
            var tmLEDs = new TMLEDSMessage
            {
                Green     = greens,
                Red       = reds,
                Intensity = 3
            };
            var tmDisplay = new TMStringMessage
            {
                Display   = displays,
                Dots      = dotsList,
                Intensity = 3,
                UnitType  = this.unitTypes
            };

            this.arduinoConnection.SendSerialMessage(Constants.MessageID_TMLED, SendTMLEDS(tmLEDs));
            this.arduinoConnection.SendSerialMessage(Constants.MessageID_TMString, SendTMStrings(tmDisplay));
        }
Esempio n. 4
0
 private void ShiftPreviewTick(object sender, EventArgs e)
 {
     if (this.shiftPreviewRpm <= 7000)
     {
         var displays = new List<string>();
         var dots = new List<byte[]>();
         var greens = new List<byte>();
         var reds = new List<byte>();
         var pastShift = false;
         foreach (DisplayUnitConfiguration t in this.configurationOptions.DisplayUnitConfigurations)
         {
             displays.Add(this.shiftPreviewRpm.ToString(CultureInfo.InvariantCulture));
             dots.Add(t.IsTM1640 ? new byte[] { 0, 0 } : new byte[] { 0 });
             if (t.LEDsConfigurations.ShowShiftLights)
             {
                 byte red;
                 byte green;
                 ShiftStyleEnum temp =
                     this.hostApp.DisplayMngr.Dictionarys.ShiftStyles[t.LEDsConfigurations.ShiftLightStyle];
                 LEDFunctions.GetShiftLights(this.hostApp.DisplayMngr.Dictionarys, this.shiftPreviewRpm, 6000, 7000, 6800,
                                                     temp, t.LEDsConfigurations.ShiftClumps, out pastShift, out red,
                                                     out green);
                 greens.Add(green);
                 reds.Add(red);
             }
             else
             {
                 greens.Add(0);
                 reds.Add(0);
             }
         }
         int newInt = this.configurationOptions.Intensity;
         if (pastShift && this.configurationOptions.ShiftIntensity)
         {
             if (this.configurationOptions.ShiftIntensityType)
             {
                 //relative
                 newInt += this.configurationOptions.ShiftIntensityAmount + 1;
             }
             else
             {
                 newInt += this.configurationOptions.ShiftIntensityAmount;
             }
         }
         var tmLEDs = new TMLEDSMessage
         {
             Green = greens,
             Red = reds,
             Intensity = newInt
         };
         var tmDisplay = new TMStringMessage
         {
             Display = displays,
             Dots = dots,
             Intensity = newInt,
             UnitType = this.hostApp.DisplayMngr.TM1640Units
         };
         this.hostApp.ArduinoConnection.SendSerialMessage(Constants.MessageID_TMLED, ArduinoMessagesSending.SendTMLEDS(tmLEDs));
         this.hostApp.ArduinoConnection.SendSerialMessage(Constants.MessageID_TMString, ArduinoMessagesSending.SendTMStrings(tmDisplay));
         this.shiftPreviewRpm += 50;
     }
     else
     {
         this.hostApp.ArduinoConnection.Clear();
         this.hostApp.DisplayMngr.Previewing = false;
         this.shiftPreviewTimer.Stop();
     }
 }
Esempio n. 5
0
        private void SendTMLEDS()
        {
            if (CurrentConfiguration == null) return;
            List<TMLEDVariables> final = new List<TMLEDVariables>();
            for (int i = 0; i < CurrentConfiguration.TMDisplaySettings.NumDisplayUnits; i++)
            {
                final.Add(new TMLEDVariables());
                if (this.LEDSOn && !(Wrapper.IsConnected == false && ArduinoConnection.Running && !Previewing) && this.SavedTelemetry.OnTrack)
                {
                    final[i].GreenLEDS = RequestedTMLEDVariables[i].GreenLEDS;
                    final[i].RedLEDS = RequestedTMLEDVariables[i].RedLEDS;
                    int result = DateTime.Now.CompareTo(this.WaitTimeTMLEDS[i]);
                    if (result < 0) //use wait Leds
                    {
                        if (RequestedTMLEDVariables[i].WaitPassThrough)
                        {
                            //bit function like && for bytes
                            var greenTemp = final[i].GreenLEDS | RequestedTMLEDVariables[i].WaitGreen;
                            var redTemp = final[i].RedLEDS | RequestedTMLEDVariables[i].WaitRed;
                            final[i].GreenLEDS = Convert.ToByte(greenTemp);
                            final[i].RedLEDS = Convert.ToByte(redTemp);
                        }
                        else
                        {
                            final[i].GreenLEDS = RequestedTMLEDVariables[i].WaitGreen;
                            final[i].RedLEDS = RequestedTMLEDVariables[i].WaitRed;
                        }
                    }
                }
                else
                {
                    //no LEDS
                    final[i].GreenLEDS = 0;
                    final[i].RedLEDS = 0;
                }
            }
            //send to display
            if (ArduinoConnection.Running && !Test)
            {
                //Merge
                var greenLEDSList = new List<byte>();
                var redLEDSList = new List<byte>();
                for (int i = 0; i < final.Count; i++)
                {
                    if (CurrentConfiguration.DisplayConfigurations[i].SwitchLEDs)
                    {
                        greenLEDSList.Add(final[i].RedLEDS);
                        redLEDSList.Add(final[i].GreenLEDS);
                    }
                    else
                    {
                        greenLEDSList.Add(final[i].GreenLEDS);
                        redLEDSList.Add(final[i].RedLEDS);
                    }
                }

                int newInt = Intensity;
                if (this.pastShiftPoint && CurrentConfiguration.TMDisplaySettings.ShiftIntensity)
                {
                    if (CurrentConfiguration.TMDisplaySettings.ShiftIntensityType)
                    {
                        //relative
                        newInt += CurrentConfiguration.TMDisplaySettings.ShiftIntensityAmount + 1;
                    }
                    else
                    {
                        newInt += CurrentConfiguration.TMDisplaySettings.ShiftIntensityAmount;
                    }
                }
                var tmLEDs = new TMLEDSMessage
                {
                    Green = greenLEDSList,
                    Red = redLEDSList,
                    Intensity = newInt
                };
                ArduinoConnection.SendSerialMessage(Constants.MessageID_TMLED, ArduinoMessagesSending.SendTMLEDS(tmLEDs));
            }
        }
Esempio n. 6
0
        private void TestTimerTick(object sender, EventArgs e)
        {
            this.testCounter++;
            int numberUnits = this.unitTypes.Count;
            var displays = new List<string>(numberUnits);
            var greens = new List<byte>(numberUnits);
            var reds = new List<byte>(numberUnits);
            var dotsList = new List<byte[]>(numberUnits);

            byte green;
            byte red;
            byte dots;

            for (int t = 0; t < numberUnits; t++)
            {
                displays.Add("");
                greens.Add(0);
                reds.Add(0);
                dotsList.Add(this.unitTypes[t] ? new Byte[] { 0, 0 } : new Byte[] { 0 });
            }

            string display = this.TestSequence(this.testCounter, out green, out red, out dots);

            this.DuplicateDisplayAcrossAllUnits(display, green, red, dots, displays, greens, reds, dotsList, this.unitTypes);
            var tmLEDs = new TMLEDSMessage
            {
                Green = greens,
                Red = reds,
                Intensity = 3
            };
            var tmDisplay = new TMStringMessage
            {
                Display = displays,
                Dots = dotsList,
                Intensity = 3,
                UnitType = this.unitTypes
            };
            this.arduinoConnection.SendSerialMessage(Constants.MessageID_TMLED, SendTMLEDS(tmLEDs));
            this.arduinoConnection.SendSerialMessage(Constants.MessageID_TMString, SendTMStrings(tmDisplay));
        }