private void MainWindowLoaded(object sender, RoutedEventArgs e) { DisplayMngr = new DisplayManager(this); String[] ports = ArduinoLink.CheckComPorts(); foreach (var item in ports) { ComPortBox.Items.Add(item); } ComPortBox.SelectedIndex = 0; StartButtonLabel.Content = "Start"; StartButtonImage.Source = this.startImage; this.ArduinoConnection = new ArduinoLink(); this.ArduinoMessagesReceivingMngr = new ArduinoMessagesReceiving(); this.ArduinoMessagesSendingMngr = new ArduinoMessagesSending(); this.ArduinoConnection.SerialMessageReceived += ArduinoMessagesReceivingMngr.SerialMessageReceiver; this.ArduinoMessagesReceivingMngr.ButtonPress += this.ArduinoSLIButtonPress; this.ArduinoMessagesSendingMngr.TestFinished += this.ArduinoSLITestFinished; // Create a new instance of the SdkWrapper object this.wrapper = new SdkWrapper { EventRaiseType = SdkWrapper.EventRaiseTypes.CurrentThread, TelemetryUpdateFrequency = 30 //60 //NEWBUILD }; // Tell it to raise events on the current thread (don't worry if you don't know what a thread is) // Only update telemetry 60 times per second // Attach some useful events so you can respond when they get raised this.wrapper.Connected += this.WrapperConnected; this.wrapper.Disconnected += this.WrapperDisconnected; this.wrapper.SessionInfoUpdated += this.WrapperSessionInfoUpdated; this.wrapper.TelemetryUpdated += this.WrapperTelemetryUpdated; DisplayMngr.ArduinoConnection = this.ArduinoConnection; DisplayMngr.Wrapper = this.wrapper; if (ComPortBox.SelectedIndex >= 0) { if (DisplayMngr.ConfSet) { StartButton.IsEnabled = true; } } else { StartButton.IsEnabled = false; } LoadConfsinDirectory(); DisplayMngr.ShiftLightData = ShiftLightData.LoadShiftData(AppDomain.CurrentDomain.BaseDirectory + "ShiftLightData.xml"); //Load ShiftLightData.xml if (StartButton.IsEnabled) { DisplayMngr.Test = true; this._conect(); this.TMDisplayTest(); } //this.MyNotifyIcon.ShowBalloonTip("iRduino", "Estamos Rodando", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info); this.Hide(); }
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(); } }