Initial commit of the configuration GUI, it still needs a few options added and some slight firmware changes are needed for persisting values to EEPROM and providing the config tool its initial values on first connect

This commit is contained in:
skogaby
2020-03-12 02:15:37 -05:00
parent 5207f9bbb0
commit 529e5f0ea7
13 changed files with 1132 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
.vs/
bin/
obj/
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpeNITHMConfig", "OpeNITHMConfig\OpeNITHMConfig.csproj", "{1AF9AA9B-86ED-4ABB-9B27-AC288B2BF7DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1AF9AA9B-86ED-4ABB-9B27-AC288B2BF7DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AF9AA9B-86ED-4ABB-9B27-AC288B2BF7DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AF9AA9B-86ED-4ABB-9B27-AC288B2BF7DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AF9AA9B-86ED-4ABB-9B27-AC288B2BF7DA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {741D525C-7CE8-49D3-B152-52B853FE38DD}
EndGlobalSection
EndGlobal
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
+364
View File
@@ -0,0 +1,364 @@
namespace OpeNITHMConfig
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mnuComPort = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.mnuExit = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mnuAbout = new System.Windows.Forms.ToolStripMenuItem();
this.tmrComPorts = new System.Windows.Forms.Timer(this.components);
this.grpSliderConfig = new System.Windows.Forms.GroupBox();
this.grpSliderCalibration = new System.Windows.Forms.GroupBox();
this.btnCalibrateSlider = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.trkSliderSensitivity = new System.Windows.Forms.TrackBar();
this.grpReactiveLightsConfig = new System.Windows.Forms.GroupBox();
this.btnSliderOnColor = new System.Windows.Forms.Button();
this.btnSliderOffColor = new System.Windows.Forms.Button();
this.grpLightsMode = new System.Windows.Forms.GroupBox();
this.btnChangeLightMode = new System.Windows.Forms.Button();
this.radHidLighting = new System.Windows.Forms.RadioButton();
this.radReactiveLighting = new System.Windows.Forms.RadioButton();
this.grpAirConfig = new System.Windows.Forms.GroupBox();
this.btnCalibrateAir = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.trkAirSensitivity = new System.Windows.Forms.TrackBar();
this.colorDialog = new System.Windows.Forms.ColorDialog();
this.menuStrip1.SuspendLayout();
this.grpSliderConfig.SuspendLayout();
this.grpSliderCalibration.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trkSliderSensitivity)).BeginInit();
this.grpReactiveLightsConfig.SuspendLayout();
this.grpLightsMode.SuspendLayout();
this.grpAirConfig.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trkAirSensitivity)).BeginInit();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(5, 5);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(301, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuComPort,
this.toolStripSeparator1,
this.mnuExit});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File";
//
// mnuComPort
//
this.mnuComPort.DropDown = this.contextMenuStrip1;
this.mnuComPort.Name = "mnuComPort";
this.mnuComPort.Size = new System.Drawing.Size(161, 22);
this.mnuComPort.Text = "Select COM port";
//
// contextMenuStrip1
//
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.OwnerItem = this.mnuComPort;
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(158, 6);
//
// mnuExit
//
this.mnuExit.Name = "mnuExit";
this.mnuExit.Size = new System.Drawing.Size(161, 22);
this.mnuExit.Text = "Exit";
//
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuAbout});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.helpToolStripMenuItem.Text = "Help";
//
// mnuAbout
//
this.mnuAbout.Name = "mnuAbout";
this.mnuAbout.Size = new System.Drawing.Size(107, 22);
this.mnuAbout.Text = "About";
this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);
//
// tmrComPorts
//
this.tmrComPorts.Enabled = true;
this.tmrComPorts.Interval = 1000;
this.tmrComPorts.Tick += new System.EventHandler(this.tmrComPorts_Tick);
//
// grpSliderConfig
//
this.grpSliderConfig.Controls.Add(this.grpSliderCalibration);
this.grpSliderConfig.Controls.Add(this.grpReactiveLightsConfig);
this.grpSliderConfig.Controls.Add(this.grpLightsMode);
this.grpSliderConfig.Enabled = false;
this.grpSliderConfig.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grpSliderConfig.Location = new System.Drawing.Point(8, 32);
this.grpSliderConfig.Name = "grpSliderConfig";
this.grpSliderConfig.Size = new System.Drawing.Size(294, 399);
this.grpSliderConfig.TabIndex = 2;
this.grpSliderConfig.TabStop = false;
this.grpSliderConfig.Text = "Slider configuration";
//
// grpSliderCalibration
//
this.grpSliderCalibration.Controls.Add(this.btnCalibrateSlider);
this.grpSliderCalibration.Controls.Add(this.label1);
this.grpSliderCalibration.Controls.Add(this.trkSliderSensitivity);
this.grpSliderCalibration.Location = new System.Drawing.Point(6, 260);
this.grpSliderCalibration.Name = "grpSliderCalibration";
this.grpSliderCalibration.Size = new System.Drawing.Size(283, 122);
this.grpSliderCalibration.TabIndex = 3;
this.grpSliderCalibration.TabStop = false;
this.grpSliderCalibration.Text = "Touch adjustment";
//
// btnCalibrateSlider
//
this.btnCalibrateSlider.Location = new System.Drawing.Point(6, 79);
this.btnCalibrateSlider.Name = "btnCalibrateSlider";
this.btnCalibrateSlider.Size = new System.Drawing.Size(271, 35);
this.btnCalibrateSlider.TabIndex = 8;
this.btnCalibrateSlider.Text = "Re-calibrate slider";
this.btnCalibrateSlider.UseVisualStyleBackColor = true;
this.btnCalibrateSlider.Click += new System.EventHandler(this.btnCalibrateSlider_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 22);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(215, 13);
this.label1.TabIndex = 7;
this.label1.Text = "Touch sensitivity (applied during calibration):";
//
// trkSliderSensitivity
//
this.trkSliderSensitivity.Location = new System.Drawing.Point(6, 38);
this.trkSliderSensitivity.Maximum = 100;
this.trkSliderSensitivity.Name = "trkSliderSensitivity";
this.trkSliderSensitivity.Size = new System.Drawing.Size(271, 45);
this.trkSliderSensitivity.TabIndex = 6;
this.trkSliderSensitivity.TickFrequency = 5;
//
// grpReactiveLightsConfig
//
this.grpReactiveLightsConfig.Controls.Add(this.btnSliderOnColor);
this.grpReactiveLightsConfig.Controls.Add(this.btnSliderOffColor);
this.grpReactiveLightsConfig.Enabled = false;
this.grpReactiveLightsConfig.Location = new System.Drawing.Point(6, 140);
this.grpReactiveLightsConfig.Name = "grpReactiveLightsConfig";
this.grpReactiveLightsConfig.Size = new System.Drawing.Size(283, 114);
this.grpReactiveLightsConfig.TabIndex = 5;
this.grpReactiveLightsConfig.TabStop = false;
this.grpReactiveLightsConfig.Text = "Reactive lighting colors";
//
// btnSliderOnColor
//
this.btnSliderOnColor.Location = new System.Drawing.Point(6, 23);
this.btnSliderOnColor.Name = "btnSliderOnColor";
this.btnSliderOnColor.Size = new System.Drawing.Size(271, 35);
this.btnSliderOnColor.TabIndex = 3;
this.btnSliderOnColor.Text = "Change slider key \"on\" color";
this.btnSliderOnColor.UseVisualStyleBackColor = true;
this.btnSliderOnColor.Click += new System.EventHandler(this.btnSliderOnColor_Click);
//
// btnSliderOffColor
//
this.btnSliderOffColor.Location = new System.Drawing.Point(6, 64);
this.btnSliderOffColor.Name = "btnSliderOffColor";
this.btnSliderOffColor.Size = new System.Drawing.Size(271, 35);
this.btnSliderOffColor.TabIndex = 4;
this.btnSliderOffColor.Text = "Change slider key \"off\" color";
this.btnSliderOffColor.UseVisualStyleBackColor = true;
this.btnSliderOffColor.Click += new System.EventHandler(this.btnSliderOffColor_Click);
//
// grpLightsMode
//
this.grpLightsMode.Controls.Add(this.btnChangeLightMode);
this.grpLightsMode.Controls.Add(this.radHidLighting);
this.grpLightsMode.Controls.Add(this.radReactiveLighting);
this.grpLightsMode.Location = new System.Drawing.Point(6, 19);
this.grpLightsMode.Name = "grpLightsMode";
this.grpLightsMode.Size = new System.Drawing.Size(283, 115);
this.grpLightsMode.TabIndex = 0;
this.grpLightsMode.TabStop = false;
this.grpLightsMode.Text = "Lighting mode";
//
// btnChangeLightMode
//
this.btnChangeLightMode.Location = new System.Drawing.Point(7, 65);
this.btnChangeLightMode.Name = "btnChangeLightMode";
this.btnChangeLightMode.Size = new System.Drawing.Size(271, 35);
this.btnChangeLightMode.TabIndex = 5;
this.btnChangeLightMode.Text = "Apply lighting mode";
this.btnChangeLightMode.UseVisualStyleBackColor = true;
this.btnChangeLightMode.Click += new System.EventHandler(this.btnChangeLightMode_Click);
//
// radHidLighting
//
this.radHidLighting.AutoSize = true;
this.radHidLighting.Location = new System.Drawing.Point(6, 19);
this.radHidLighting.Name = "radHidLighting";
this.radHidLighting.Size = new System.Drawing.Size(164, 17);
this.radHidLighting.TabIndex = 1;
this.radHidLighting.Text = "HID lighting (game-controlled)";
this.radHidLighting.UseVisualStyleBackColor = true;
//
// radReactiveLighting
//
this.radReactiveLighting.AutoSize = true;
this.radReactiveLighting.Location = new System.Drawing.Point(6, 42);
this.radReactiveLighting.Name = "radReactiveLighting";
this.radReactiveLighting.Size = new System.Drawing.Size(206, 17);
this.radReactiveLighting.TabIndex = 2;
this.radReactiveLighting.TabStop = true;
this.radReactiveLighting.Text = "Reactive lighting (lights when pressed)";
this.radReactiveLighting.UseVisualStyleBackColor = true;
//
// grpAirConfig
//
this.grpAirConfig.Controls.Add(this.btnCalibrateAir);
this.grpAirConfig.Controls.Add(this.label2);
this.grpAirConfig.Controls.Add(this.trkAirSensitivity);
this.grpAirConfig.Enabled = false;
this.grpAirConfig.Location = new System.Drawing.Point(9, 445);
this.grpAirConfig.Name = "grpAirConfig";
this.grpAirConfig.Size = new System.Drawing.Size(294, 127);
this.grpAirConfig.TabIndex = 3;
this.grpAirConfig.TabStop = false;
this.grpAirConfig.Text = "Air sensor configuration (analog controllers only)";
//
// btnCalibrateAir
//
this.btnCalibrateAir.Location = new System.Drawing.Point(12, 84);
this.btnCalibrateAir.Name = "btnCalibrateAir";
this.btnCalibrateAir.Size = new System.Drawing.Size(271, 35);
this.btnCalibrateAir.TabIndex = 8;
this.btnCalibrateAir.Text = "Re-calibrate air sensors";
this.btnCalibrateAir.UseVisualStyleBackColor = true;
this.btnCalibrateAir.Click += new System.EventHandler(this.btnCalibrateAir_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 28);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(196, 13);
this.label2.TabIndex = 7;
this.label2.Text = "Air sensitivity (applied during calibration):";
//
// trkAirSensitivity
//
this.trkAirSensitivity.Location = new System.Drawing.Point(12, 44);
this.trkAirSensitivity.Maximum = 100;
this.trkAirSensitivity.Name = "trkAirSensitivity";
this.trkAirSensitivity.Size = new System.Drawing.Size(271, 45);
this.trkAirSensitivity.TabIndex = 6;
this.trkAirSensitivity.TickFrequency = 5;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(311, 579);
this.Controls.Add(this.grpAirConfig);
this.Controls.Add(this.grpSliderConfig);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.MaximizeBox = false;
this.Name = "MainForm";
this.Padding = new System.Windows.Forms.Padding(5);
this.Text = "OpeNITHM Config";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.grpSliderConfig.ResumeLayout(false);
this.grpSliderCalibration.ResumeLayout(false);
this.grpSliderCalibration.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trkSliderSensitivity)).EndInit();
this.grpReactiveLightsConfig.ResumeLayout(false);
this.grpLightsMode.ResumeLayout(false);
this.grpLightsMode.PerformLayout();
this.grpAirConfig.ResumeLayout(false);
this.grpAirConfig.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trkAirSensitivity)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mnuComPort;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem mnuExit;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mnuAbout;
private System.Windows.Forms.Timer tmrComPorts;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.GroupBox grpSliderConfig;
private System.Windows.Forms.GroupBox grpSliderCalibration;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TrackBar trkSliderSensitivity;
private System.Windows.Forms.GroupBox grpReactiveLightsConfig;
private System.Windows.Forms.Button btnSliderOnColor;
private System.Windows.Forms.Button btnSliderOffColor;
private System.Windows.Forms.GroupBox grpLightsMode;
private System.Windows.Forms.RadioButton radHidLighting;
private System.Windows.Forms.RadioButton radReactiveLighting;
private System.Windows.Forms.Button btnCalibrateSlider;
private System.Windows.Forms.GroupBox grpAirConfig;
private System.Windows.Forms.Button btnCalibrateAir;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TrackBar trkAirSensitivity;
private System.Windows.Forms.Button btnChangeLightMode;
private System.Windows.Forms.ColorDialog colorDialog;
}
}
+237
View File
@@ -0,0 +1,237 @@
using System;
using System.Linq;
using System.IO.Ports;
using System.Windows.Forms;
namespace OpeNITHMConfig
{
public partial class MainForm : Form
{
// magic byte for the header in config commands
private const byte CONFIG_FLAG = 0xBB;
// config command opcodes
private const byte CMD_CHANGE_LIGHT_MODE = 0x11;
private const byte CMD_CHANGE_ON_COLOR = 0x22;
private const byte CMD_CHANGE_OFF_COLOR = 0x33;
private const byte CMD_CALIBRATE_SLIDER = 0x44;
private const byte CMD_CALIBRATE_AIR_SENSORS = 0x55;
// light modes for the change light mode command
private const byte LIGHT_MODE_SERIAL = 0x00;
private const byte LIGHT_MODE_REACTIVE = 0x01;
/// <summary>
/// Whether or not the controller is connected
/// </summary>
private bool isConnected;
/// <summary>
/// The port used to communicate with the controller
/// </summary>
private SerialPort serialPort;
public MainForm()
{
InitializeComponent();
serialPort = new SerialPort();
serialPort.BaudRate = 115200;
serialPort.Parity = Parity.None;
serialPort.DataBits = 8;
serialPort.StopBits = StopBits.One;
serialPort.Handshake = Handshake.None;
serialPort.ReadTimeout = 1000;
serialPort.WriteTimeout = 1000;
isConnected = false;
}
/// <summary>
/// Enables the appropriate sets of controls in the main form
/// </summary>
/// <param name="reactiveLighting"></param>
/// <param name="analogAirSensors"></param>
private void enableControls(bool reactiveLighting, bool analogAirSensors)
{
grpSliderConfig.Enabled = true;
grpReactiveLightsConfig.Enabled = reactiveLighting;
grpAirConfig.Enabled = analogAirSensors;
}
/// <summary>
/// Disables all the main form controls
/// </summary>
private void disableControls()
{
grpSliderConfig.Enabled = false;
grpReactiveLightsConfig.Enabled = false;
grpAirConfig.Enabled = false;
}
/// <summary>
/// Connects to a new controller and initializes our values
/// </summary>
/// <param name="port"></param>
private void ConnectToController(string port)
{
serialPort.PortName = port;
isConnected = true;
enableControls(true, true);
}
/// <summary>
/// Sends a command and its arguments to the controller
/// </summary>
/// <param name="command"></param>
/// <param name="args"></param>
private void sendCommand(byte command, byte[] args)
{
try
{
if (isConnected)
{
byte[] data = new byte[100];
// command header
data[0] = CONFIG_FLAG;
data[1] = CONFIG_FLAG;
// command opcode
data[2] = command;
// command data
Array.Copy(args, 0, data, 3, args.Length);
// send the data
serialPort.Open();
serialPort.Write(data, 0, 100);
serialPort.Close();
}
}
catch (InvalidOperationException)
{
// serial port was likely closed
isConnected = false;
disableControls();
}
}
/// <summary>
/// Show the "About" dialog
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mnuAbout_Click(object sender, EventArgs e)
{
MessageBox.Show("This tool is a configuration application for any OpeNITHM controllers running the following firmware: https://github.com/skogaby/OpeNITHM",
"About",
MessageBoxButtons.OK);
}
/// <summary>
/// Changes the lighting mode of the controller
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnChangeLightMode_Click(object sender, EventArgs e)
{
byte lightMode = (radHidLighting.Checked ? LIGHT_MODE_SERIAL : LIGHT_MODE_REACTIVE);
sendCommand(CMD_CHANGE_LIGHT_MODE, new byte[] { lightMode });
}
/// <summary>
/// Changes the color of the slider's "on" lights in reactive lighting mode
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSliderOnColor_Click(object sender, EventArgs e)
{
if (colorDialog.ShowDialog() == DialogResult.OK)
{
sendCommand(CMD_CHANGE_ON_COLOR, new byte[] {
colorDialog.Color.R,
colorDialog.Color.G,
colorDialog.Color.B
});
}
}
/// <summary>
/// Changes the color of the slider's "off" lights in reactive lighting mode
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSliderOffColor_Click(object sender, EventArgs e)
{
if (colorDialog.ShowDialog() == DialogResult.OK)
{
sendCommand(CMD_CHANGE_OFF_COLOR, new byte[] {
colorDialog.Color.R,
colorDialog.Color.G,
colorDialog.Color.B
});
}
}
/// <summary>
/// Forces a re-calibration of the touch slider
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCalibrateSlider_Click(object sender, EventArgs e)
{
sendCommand(CMD_CALIBRATE_SLIDER, new byte[] { (byte) trkSliderSensitivity.Value });
}
/// <summary>
/// Forces a re-calibration of the air sensors
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCalibrateAir_Click(object sender, EventArgs e)
{
sendCommand(CMD_CALIBRATE_AIR_SENSORS, new byte[] { (byte) trkAirSensitivity.Value });
}
/// <summary>
/// Every time the timer ticks, we'll refresh the COM ports on the file submenu
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tmrComPorts_Tick(object sender, EventArgs e)
{
// read the available COM ports
string[] ports = SerialPort.GetPortNames();
// update the menu if the set doesn't match what we have loaded
mnuComPort.Enabled = (ports.Length != 0);
if (mnuComPort.DropDownItems.Count != ports.Length)
{
mnuComPort.DropDownItems.Clear();
foreach (string port in ports)
{
// set the click handler for the menu items
ToolStripItem item = new ToolStripMenuItem(port, null, new EventHandler(delegate (Object o, EventArgs a)
{
ConnectToController(((ToolStripItem)o).Text);
((ToolStripMenuItem)o).Checked = true;
}));
mnuComPort.DropDownItems.Add(item);
}
}
// if we were connected and now the selected port is no longer present,
// assume we disconnected
if (isConnected && !ports.Contains(serialPort.PortName))
{
isConnected = false;
disableControls();
}
}
}
}
+132
View File
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>256, 17</value>
</metadata>
<metadata name="tmrComPorts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value>
</metadata>
<metadata name="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>411, 17</value>
</metadata>
</root>
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1AF9AA9B-86ED-4ABB-9B27-AC288B2BF7DA}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>OpeNITHMConfig</RootNamespace>
<AssemblyName>OpeNITHMConfig</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OpeNITHMConfig
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpeNITHMConfig")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpeNITHMConfig")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1af9aa9b-86ed-4abb-9b27-ac288b2bf7da")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OpeNITHMConfig.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpeNITHMConfig.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OpeNITHMConfig.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>