Simply3DScan
ConfigurationControl.Arduino.cs
Go to the documentation of this file.
1 using System;
2 using SharedObjects;
3 
4 namespace Simple3DScan.UI
5 {
9  partial class ConfigurationControl
10  {
14  [LogException]
15  private void InitArduinoValues()
16  {
17  int[] allowedPorts = {300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200};
18 
19  int i = 0;
20 
21  foreach (int port in allowedPorts)
22  {
23  this.comboBoxBaudRate.Items.Add(port);
24 
25  if (this.configuration.Arduino.BaudRate == port)
26  this.comboBoxBaudRate.SelectedIndex = i;
27  i++;
28  }
29 
30  this.textBoxPort.Text = this.configuration.Arduino.Port;
31 
32  this.comboBoxBaudRate.SelectedIndexChanged += this.comboBoxBaudRate_SelectedIndexChanged;
33  }
34 
40  [Log]
41  [LogException]
42  private void comboBoxBaudRate_SelectedIndexChanged(object sender, EventArgs e)
43  {
44  this.configuration.Arduino.BaudRate = int.Parse(this.comboBoxBaudRate.Text);
45  }
46 
47  [Log]
48  [LogException]
49  private void buttonLoadArduinoDefaults_Click(object sender, EventArgs e)
50  {
51  this.DetachArduinoEvents();
52  this.comboBoxBaudRate.Items.Clear();
53  string temp = this.configuration.Arduino.Port;
54  this.configuration.Arduino = Configuration.Config.CreateDefaultArduinoSettings();
55  this.configuration.Arduino.Port = temp;
56  this.InitArduinoValues();
57  }
58 
59  private void DetachArduinoEvents()
60  {
61  this.comboBoxBaudRate.SelectedIndexChanged -= this.comboBoxBaudRate_SelectedIndexChanged;
62  }
63  }
64 }
string Port
Gets or sets the port.
Definition: Arduino.cs:15
static Arduino CreateDefaultArduinoSettings()
Creates the default arduino settings.
Definition: Config.cs:173
Configuration of arduino specific values
Class for accessing the configuration.
Definition: Config.cs:12