//fill with defaults public DisplayConfiguration(bool t) { ButtonFunctions = new List <ButtonFunctionsEnum> { ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None }; ButtonOptions = new List <string> { "", "", "", "", "", "", "", "" }; ButtonOptionsScreens = new List <int> { -1, -1, -1, -1, -1, -1, -1, -1 }; //LapDisplayTime = 2; LapStyle = LapDisplayStylesEnum.LapTimeDeltaPersonal; NumScreens = 1; PitLights = false; PitLimiterSpeed = PitFlashSpeedsEnum.Full; PitLimiterStyle = PitFlashStyleEnum.GreenRedAlternateFlash; RevLimiterLights = false; RevLimiterStyle = RevFlashStyleEnum.StayRed; ShiftLightStyle = ShiftStyleEnum.GreenRedProgressiveRedShift; ShowLap = false; ShowShiftLights = false; FFBClippingLights = false; FFBClippingScreen = -1; if (t) { var temp = new Screen { Example = "148 3 43", Variables = new List <string> { "Speed", "Space", "Gear", "Space", "Laps2" } }; Screens = new List <Screen> { temp }; } }
/// <summary> /// Gets LED bytes using ShiftStyles /// </summary> /// <param name="dictionarys"></param> /// <param name="currentRPM">Current RPM</param> /// <param name="shiftStart">RPM of first shift light</param> /// <param name="shiftEnd">RPM of last Shift light</param> /// <param name="shiftPoint">RPM of optimal shift point</param> /// <param name="style">Shift Light Style</param> /// <param name="pastShiftPoint"></param> /// <param name="red">RED LEDs byte</param> /// <param name="green">Green LEDS byte</param> /// <param name="shiftClumps"></param> public static void GetShiftLights(Dictionarys dictionarys, float currentRPM, float shiftStart, float shiftEnd, float shiftPoint, ShiftStyleEnum style, bool shiftClumps, out bool pastShiftPoint, out byte red, out byte green) { pastShiftPoint = false; red = 0; green = 0; if (style == ShiftStyleEnum.None) { return; } if (shiftStart < 1 || shiftEnd < 1) { if (shiftPoint > 1) { shiftStart = shiftPoint - 1; shiftEnd = shiftPoint; } else { return; // No Valid Shift values for this current gear/map/car } } if (shiftPoint < 1) { shiftPoint = 40000; } if (!(currentRPM >= shiftStart)) { return; } //get length of shift style int shiftStyleLength = dictionarys.RPMStyles[style].Length; //calc point in shift lists to use float calc = ((currentRPM - shiftStart) / (shiftEnd - shiftStart)) * Convert.ToSingle(shiftStyleLength - 1); int place = Convert.ToInt32(Math.Floor(calc)); if (place >= shiftStyleLength) { place = shiftStyleLength - 1; } if (shiftClumps) { if (place >= shiftStyleLength - 1) { //last seg, all lights on so leave as is } else if (place >= (shiftStyleLength / 2) - 1) { //middle seg switch (shiftStyleLength) { case 4: place = 1; break; case 8: place = 4; break; case 16: place = 10; break; case 32: place = 20; break; } } else { //first seg switch (shiftStyleLength) { case 4: place = 0; break; case 8: place = 1; break; case 16: place = 4; break; case 32: place = 9; break; } } } //end shiftClumps if (shiftPoint <= 1) // Shift Point RPM value not valid { shiftPoint = 50000; } if (currentRPM >= shiftPoint && dictionarys.RPMStyles[style].UseShiftedArray) { pastShiftPoint = true; Lights temp = dictionarys.RPMStyles[style].Shifted[place]; red = temp.Red; green = temp.Green; } else { Lights temp = dictionarys.RPMStyles[style].Normal[place]; //-1? red = temp.Red; green = temp.Green; } }
//fill with defaults public DisplayConfiguration(bool t) { ButtonFunctions = new List<ButtonFunctionsEnum> { ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None, ButtonFunctionsEnum.None }; ButtonOptions = new List<string> {"", "", "", "", "", "", "", ""}; ButtonOptionsScreens = new List<int> {-1, -1, -1, -1, -1, -1, -1, -1}; //LapDisplayTime = 2; LapStyle = LapDisplayStylesEnum.LapTimeDeltaPersonal; NumScreens = 1; PitLights = false; PitLimiterSpeed = PitFlashSpeedsEnum.Full; PitLimiterStyle = PitFlashStyleEnum.GreenRedAlternateFlash; RevLimiterLights = false; RevLimiterStyle = RevFlashStyleEnum.StayRed; ShiftLightStyle = ShiftStyleEnum.GreenRedProgressiveRedShift; ShowLap = false; ShowShiftLights = false; FFBClippingLights = false; FFBClippingScreen = -1; if (t) { var temp = new Screen { Example = "148 3 43", Variables = new List<string> {"Speed", "Space", "Gear", "Space", "Laps2"} }; Screens = new List<Screen> {temp}; } }
/// <summary> /// Gets LED bytes using ShiftStyles /// </summary> /// <param name="dictionarys"></param> /// <param name="currentRPM">Current RPM</param> /// <param name="shiftStart">RPM of first shift light</param> /// <param name="shiftEnd">RPM of last Shift light</param> /// <param name="shiftPoint">RPM of optimal shift point</param> /// <param name="style">Shift Light Style</param> /// <param name="pastShiftPoint"></param> /// <param name="red">RED LEDs byte</param> /// <param name="green">Green LEDS byte</param> /// <param name="shiftClumps"></param> public static void GetShiftLights(Dictionarys dictionarys,float currentRPM, float shiftStart, float shiftEnd, float shiftPoint, ShiftStyleEnum style, bool shiftClumps,out bool pastShiftPoint, out byte red, out byte green) { pastShiftPoint = false; red = 0; green = 0; if (style == ShiftStyleEnum.None) return; if (shiftStart < 1 || shiftEnd < 1) { if (shiftPoint > 1) { shiftStart = shiftPoint - 1; shiftEnd = shiftPoint; } else { return; // No Valid Shift values for this current gear/map/car } } if (shiftPoint < 1) shiftPoint = 40000; if (!(currentRPM >= shiftStart)) return; //get length of shift style int shiftStyleLength = dictionarys.RPMStyles[style].Length; //calc point in shift lists to use float calc = ((currentRPM - shiftStart) / (shiftEnd - shiftStart)) * Convert.ToSingle(shiftStyleLength - 1); int place = Convert.ToInt32(Math.Floor(calc)); if (place >= shiftStyleLength) { place = shiftStyleLength - 1; } if (shiftClumps) { if (place >= shiftStyleLength - 1) { //last seg, all lights on so leave as is } else if (place >= (shiftStyleLength / 2) - 1) { //middle seg switch (shiftStyleLength) { case 4: place = 1; break; case 8: place = 4; break; case 16: place = 10; break; case 32: place = 20; break; } } else { //first seg switch (shiftStyleLength) { case 4: place = 0; break; case 8: place = 1; break; case 16: place = 4; break; case 32: place = 9; break; } } } //end shiftClumps if (shiftPoint <= 1) // Shift Point RPM value not valid { shiftPoint = 50000; } if (currentRPM >= shiftPoint && dictionarys.RPMStyles[style].UseShiftedArray) { pastShiftPoint = true; Lights temp = dictionarys.RPMStyles[style].Shifted[place]; red = temp.Red; green = temp.Green; } else { Lights temp = dictionarys.RPMStyles[style].Normal[place]; //-1? red = temp.Red; green = temp.Green; } }
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(); } }