diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4b82ccd --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +bin/ +obj/ diff --git a/OpeNITHMConfig/OpeNITHMConfig.sln b/OpeNITHMConfig/OpeNITHMConfig.sln new file mode 100644 index 0000000..dbae0f9 --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig.sln @@ -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 diff --git a/OpeNITHMConfig/OpeNITHMConfig/App.config b/OpeNITHMConfig/OpeNITHMConfig/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OpeNITHMConfig/OpeNITHMConfig/Form1.Designer.cs b/OpeNITHMConfig/OpeNITHMConfig/Form1.Designer.cs new file mode 100644 index 0000000..9ba30f1 --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Form1.Designer.cs @@ -0,0 +1,364 @@ +namespace OpeNITHMConfig +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} + diff --git a/OpeNITHMConfig/OpeNITHMConfig/Form1.cs b/OpeNITHMConfig/OpeNITHMConfig/Form1.cs new file mode 100644 index 0000000..0c9bc0d --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Form1.cs @@ -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; + + /// + /// Whether or not the controller is connected + /// + private bool isConnected; + + /// + /// The port used to communicate with the controller + /// + 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; + } + + /// + /// Enables the appropriate sets of controls in the main form + /// + /// + /// + private void enableControls(bool reactiveLighting, bool analogAirSensors) + { + grpSliderConfig.Enabled = true; + grpReactiveLightsConfig.Enabled = reactiveLighting; + grpAirConfig.Enabled = analogAirSensors; + } + + /// + /// Disables all the main form controls + /// + private void disableControls() + { + grpSliderConfig.Enabled = false; + grpReactiveLightsConfig.Enabled = false; + grpAirConfig.Enabled = false; + } + + /// + /// Connects to a new controller and initializes our values + /// + /// + private void ConnectToController(string port) + { + serialPort.PortName = port; + isConnected = true; + enableControls(true, true); + } + + /// + /// Sends a command and its arguments to the controller + /// + /// + /// + 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(); + } + } + + /// + /// Show the "About" dialog + /// + /// + /// + 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); + } + + /// + /// Changes the lighting mode of the controller + /// + /// + /// + 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 }); + } + + /// + /// Changes the color of the slider's "on" lights in reactive lighting mode + /// + /// + /// + 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 + }); + } + } + + /// + /// Changes the color of the slider's "off" lights in reactive lighting mode + /// + /// + /// + 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 + }); + } + } + + /// + /// Forces a re-calibration of the touch slider + /// + /// + /// + private void btnCalibrateSlider_Click(object sender, EventArgs e) + { + sendCommand(CMD_CALIBRATE_SLIDER, new byte[] { (byte) trkSliderSensitivity.Value }); + } + + /// + /// Forces a re-calibration of the air sensors + /// + /// + /// + private void btnCalibrateAir_Click(object sender, EventArgs e) + { + sendCommand(CMD_CALIBRATE_AIR_SENSORS, new byte[] { (byte) trkAirSensitivity.Value }); + } + + /// + /// Every time the timer ticks, we'll refresh the COM ports on the file submenu + /// + /// + /// + 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(); + } + } + } +} diff --git a/OpeNITHMConfig/OpeNITHMConfig/Form1.resx b/OpeNITHMConfig/OpeNITHMConfig/Form1.resx new file mode 100644 index 0000000..7575b51 --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Form1.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 256, 17 + + + 132, 17 + + + 411, 17 + + \ No newline at end of file diff --git a/OpeNITHMConfig/OpeNITHMConfig/OpeNITHMConfig.csproj b/OpeNITHMConfig/OpeNITHMConfig/OpeNITHMConfig.csproj new file mode 100644 index 0000000..ef3de5b --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/OpeNITHMConfig.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {1AF9AA9B-86ED-4ABB-9B27-AC288B2BF7DA} + WinExe + OpeNITHMConfig + OpeNITHMConfig + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/OpeNITHMConfig/OpeNITHMConfig/Program.cs b/OpeNITHMConfig/OpeNITHMConfig/Program.cs new file mode 100644 index 0000000..d364a0e --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Program.cs @@ -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 + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/OpeNITHMConfig/OpeNITHMConfig/Properties/AssemblyInfo.cs b/OpeNITHMConfig/OpeNITHMConfig/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c0d9036 --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Properties/AssemblyInfo.cs @@ -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")] diff --git a/OpeNITHMConfig/OpeNITHMConfig/Properties/Resources.Designer.cs b/OpeNITHMConfig/OpeNITHMConfig/Properties/Resources.Designer.cs new file mode 100644 index 0000000..88f9d74 --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace OpeNITHMConfig.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/OpeNITHMConfig/OpeNITHMConfig/Properties/Resources.resx b/OpeNITHMConfig/OpeNITHMConfig/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpeNITHMConfig/OpeNITHMConfig/Properties/Settings.Designer.cs b/OpeNITHMConfig/OpeNITHMConfig/Properties/Settings.Designer.cs new file mode 100644 index 0000000..9e76efb --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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; + } + } + } +} diff --git a/OpeNITHMConfig/OpeNITHMConfig/Properties/Settings.settings b/OpeNITHMConfig/OpeNITHMConfig/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/OpeNITHMConfig/OpeNITHMConfig/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + +