Add the VisBasic version

This commit is contained in:
2026-01-17 10:27:37 -06:00
parent cb15d61c5e
commit f7826bd69f
9 changed files with 936 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36705.20 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AVRcvrWinSerial", "AVRcvrWinSerial.vbproj", "{E0C900FB-1B11-4234-9A71-5517B52DD89E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E0C900FB-1B11-4234-9A71-5517B52DD89E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0C900FB-1B11-4234-9A71-5517B52DD89E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0C900FB-1B11-4234-9A71-5517B52DD89E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0C900FB-1B11-4234-9A71-5517B52DD89E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {85185DF1-6E70-468D-B054-AE68D3FE07D2}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows</TargetFramework>
<StartupObject>Sub Main</StartupObject>
<UseWindowsForms>true</UseWindowsForms>
<MyType>WindowsForms</MyType>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
<ItemGroup>
<Import Include="System.Data" />
<Import Include="System.Drawing" />
<Import Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.IO.Ports" Version="10.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="My Project\Application.Designer.vb">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="Form1.vb">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,29 @@
Imports Microsoft.VisualBasic.ApplicationServices
Namespace My
' The following events are available for MyApplication:
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
' **NEW** ApplyApplicationDefaults: Raised when the application queries default values to be set for the application.
' Example:
' Private Sub MyApplication_ApplyApplicationDefaults(sender As Object, e As ApplyApplicationDefaultsEventArgs) Handles Me.ApplyApplicationDefaults
'
' ' Setting the application-wide default Font:
' e.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular)
'
' ' Setting the HighDpiMode for the Application:
' e.HighDpiMode = HighDpiMode.PerMonitorV2
'
' ' If a splash dialog is used, this sets the minimum display time:
' e.MinimumSplashScreenDisplayTime = 4000
' End Sub
Partial Friend Class MyApplication
End Class
End Namespace

388
AVR VisBasic/Form1.Designer.vb generated Normal file
View File

@@ -0,0 +1,388 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
components = New ComponentModel.Container()
btnSendReady = New Button()
ButtonSend3 = New Button()
ListBoxReceived = New ListBox()
ComboBoxPorts = New ComboBox()
ComboBoxBaud = New ComboBox()
ComboBoxHandshake = New ComboBox()
ButtonConnect = New Button()
ButtonDisconnect = New Button()
LabelStatus = New Label()
CheckBoxRTS = New CheckBox()
CheckBoxCTS = New CheckBox()
TimerCTS = New Timer(components)
GroupBox1 = New GroupBox()
btnPowerZone1Off = New Button()
btnPowerZone1On = New Button()
ButtonMasterVolDown = New Button()
ButtonMasterVolUp = New Button()
CheckBoxMasterMute = New CheckBox()
GroupBox2 = New GroupBox()
btnPowerZone2Off = New Button()
btnPowerZone2On = New Button()
ButtonZone2VolDown = New Button()
ButtonZone2VolUp = New Button()
CheckBoxZone2Mute = New CheckBox()
GroupBoxPower = New GroupBox()
btnPowerOff = New Button()
btnPowerOn = New Button()
txtPartialInput = New TextBox()
GroupBox1.SuspendLayout()
GroupBox2.SuspendLayout()
GroupBoxPower.SuspendLayout()
SuspendLayout()
'
' btnSendReady
'
btnSendReady.Location = New Point(18, 227)
btnSendReady.Name = "btnSendReady"
btnSendReady.Size = New Size(90, 23)
btnSendReady.TabIndex = 0
btnSendReady.Text = "Send Ready"
btnSendReady.UseVisualStyleBackColor = True
'
' ButtonSend3
'
ButtonSend3.Location = New Point(315, 227)
ButtonSend3.Name = "ButtonSend3"
ButtonSend3.Size = New Size(75, 23)
ButtonSend3.TabIndex = 2
ButtonSend3.Text = "Button3"
ButtonSend3.UseVisualStyleBackColor = True
'
' ListBoxReceived
'
ListBoxReceived.FormattingEnabled = True
ListBoxReceived.HorizontalScrollbar = True
ListBoxReceived.Location = New Point(12, 97)
ListBoxReceived.Name = "ListBoxReceived"
ListBoxReceived.Size = New Size(387, 124)
ListBoxReceived.TabIndex = 3
'
' ComboBoxPorts
'
ComboBoxPorts.FormattingEnabled = True
ComboBoxPorts.Location = New Point(6, 12)
ComboBoxPorts.Name = "ComboBoxPorts"
ComboBoxPorts.Size = New Size(68, 23)
ComboBoxPorts.TabIndex = 4
'
' ComboBoxBaud
'
ComboBoxBaud.FormattingEnabled = True
ComboBoxBaud.Location = New Point(80, 12)
ComboBoxBaud.Name = "ComboBoxBaud"
ComboBoxBaud.Size = New Size(75, 23)
ComboBoxBaud.TabIndex = 5
'
' ComboBoxHandshake
'
ComboBoxHandshake.FormattingEnabled = True
ComboBoxHandshake.Location = New Point(161, 12)
ComboBoxHandshake.Name = "ComboBoxHandshake"
ComboBoxHandshake.Size = New Size(157, 23)
ComboBoxHandshake.TabIndex = 6
'
' ButtonConnect
'
ButtonConnect.Enabled = False
ButtonConnect.Location = New Point(324, 12)
ButtonConnect.Name = "ButtonConnect"
ButtonConnect.Size = New Size(75, 23)
ButtonConnect.TabIndex = 7
ButtonConnect.Text = "Connect"
ButtonConnect.UseVisualStyleBackColor = True
'
' ButtonDisconnect
'
ButtonDisconnect.Enabled = False
ButtonDisconnect.Location = New Point(324, 41)
ButtonDisconnect.Name = "ButtonDisconnect"
ButtonDisconnect.Size = New Size(75, 23)
ButtonDisconnect.TabIndex = 8
ButtonDisconnect.Text = "Disconnect"
ButtonDisconnect.UseVisualStyleBackColor = True
'
' LabelStatus
'
LabelStatus.Location = New Point(6, 45)
LabelStatus.Name = "LabelStatus"
LabelStatus.Size = New Size(182, 19)
LabelStatus.TabIndex = 9
LabelStatus.Text = "Serial Port Status Appears Here"
'
' CheckBoxRTS
'
CheckBoxRTS.AutoSize = True
CheckBoxRTS.Location = New Point(194, 44)
CheckBoxRTS.Name = "CheckBoxRTS"
CheckBoxRTS.Size = New Size(58, 19)
CheckBoxRTS.TabIndex = 10
CheckBoxRTS.Text = "RTS(7)"
CheckBoxRTS.UseVisualStyleBackColor = True
'
' CheckBoxCTS
'
CheckBoxCTS.AutoSize = True
CheckBoxCTS.Checked = True
CheckBoxCTS.CheckState = CheckState.Indeterminate
CheckBoxCTS.Enabled = False
CheckBoxCTS.Location = New Point(258, 44)
CheckBoxCTS.Name = "CheckBoxCTS"
CheckBoxCTS.Size = New Size(60, 19)
CheckBoxCTS.TabIndex = 11
CheckBoxCTS.Text = "CTS(8)"
CheckBoxCTS.ThreeState = True
CheckBoxCTS.UseVisualStyleBackColor = True
'
' TimerCTS
'
'
' GroupBox1
'
GroupBox1.Controls.Add(btnPowerZone1Off)
GroupBox1.Controls.Add(btnPowerZone1On)
GroupBox1.Controls.Add(ButtonMasterVolDown)
GroupBox1.Controls.Add(ButtonMasterVolUp)
GroupBox1.Controls.Add(CheckBoxMasterMute)
GroupBox1.FlatStyle = FlatStyle.Flat
GroupBox1.Location = New Point(12, 256)
GroupBox1.Name = "GroupBox1"
GroupBox1.Size = New Size(84, 168)
GroupBox1.TabIndex = 13
GroupBox1.TabStop = False
GroupBox1.Text = "Zone 1"
'
' btnPowerZone1Off
'
btnPowerZone1Off.Location = New Point(6, 56)
btnPowerZone1Off.Name = "btnPowerZone1Off"
btnPowerZone1Off.Size = New Size(66, 23)
btnPowerZone1Off.TabIndex = 19
btnPowerZone1Off.Text = "O&ff"
btnPowerZone1Off.UseVisualStyleBackColor = True
'
' btnPowerZone1On
'
btnPowerZone1On.Location = New Point(6, 27)
btnPowerZone1On.Name = "btnPowerZone1On"
btnPowerZone1On.Size = New Size(66, 23)
btnPowerZone1On.TabIndex = 18
btnPowerZone1On.Text = "&On"
btnPowerZone1On.UseVisualStyleBackColor = True
'
' ButtonMasterVolDown
'
ButtonMasterVolDown.Location = New Point(6, 114)
ButtonMasterVolDown.Name = "ButtonMasterVolDown"
ButtonMasterVolDown.Size = New Size(66, 23)
ButtonMasterVolDown.TabIndex = 15
ButtonMasterVolDown.Text = "Vol Down"
ButtonMasterVolDown.UseVisualStyleBackColor = True
'
' ButtonMasterVolUp
'
ButtonMasterVolUp.Location = New Point(6, 85)
ButtonMasterVolUp.Name = "ButtonMasterVolUp"
ButtonMasterVolUp.Size = New Size(66, 23)
ButtonMasterVolUp.TabIndex = 14
ButtonMasterVolUp.Text = "Vol Up"
ButtonMasterVolUp.UseVisualStyleBackColor = True
'
' CheckBoxMasterMute
'
CheckBoxMasterMute.AutoSize = True
CheckBoxMasterMute.Location = New Point(6, 143)
CheckBoxMasterMute.Name = "CheckBoxMasterMute"
CheckBoxMasterMute.Size = New Size(54, 19)
CheckBoxMasterMute.TabIndex = 13
CheckBoxMasterMute.Text = "Mute"
CheckBoxMasterMute.UseVisualStyleBackColor = True
'
' GroupBox2
'
GroupBox2.Controls.Add(btnPowerZone2Off)
GroupBox2.Controls.Add(btnPowerZone2On)
GroupBox2.Controls.Add(ButtonZone2VolDown)
GroupBox2.Controls.Add(ButtonZone2VolUp)
GroupBox2.Controls.Add(CheckBoxZone2Mute)
GroupBox2.FlatStyle = FlatStyle.Flat
GroupBox2.Location = New Point(104, 256)
GroupBox2.Name = "GroupBox2"
GroupBox2.Size = New Size(84, 168)
GroupBox2.TabIndex = 14
GroupBox2.TabStop = False
GroupBox2.Text = "Zone 2"
'
' btnPowerZone2Off
'
btnPowerZone2Off.Location = New Point(6, 56)
btnPowerZone2Off.Name = "btnPowerZone2Off"
btnPowerZone2Off.Size = New Size(66, 23)
btnPowerZone2Off.TabIndex = 21
btnPowerZone2Off.Text = "O&ff"
btnPowerZone2Off.UseVisualStyleBackColor = True
'
' btnPowerZone2On
'
btnPowerZone2On.Location = New Point(6, 27)
btnPowerZone2On.Name = "btnPowerZone2On"
btnPowerZone2On.Size = New Size(66, 23)
btnPowerZone2On.TabIndex = 20
btnPowerZone2On.Text = "&On"
btnPowerZone2On.UseVisualStyleBackColor = True
'
' ButtonZone2VolDown
'
ButtonZone2VolDown.Location = New Point(6, 114)
ButtonZone2VolDown.Name = "ButtonZone2VolDown"
ButtonZone2VolDown.Size = New Size(66, 23)
ButtonZone2VolDown.TabIndex = 15
ButtonZone2VolDown.Text = "Vol Down"
ButtonZone2VolDown.UseVisualStyleBackColor = True
'
' ButtonZone2VolUp
'
ButtonZone2VolUp.Location = New Point(6, 85)
ButtonZone2VolUp.Name = "ButtonZone2VolUp"
ButtonZone2VolUp.Size = New Size(66, 23)
ButtonZone2VolUp.TabIndex = 14
ButtonZone2VolUp.Text = "Vol Up"
ButtonZone2VolUp.UseVisualStyleBackColor = True
'
' CheckBoxZone2Mute
'
CheckBoxZone2Mute.AutoSize = True
CheckBoxZone2Mute.Location = New Point(6, 143)
CheckBoxZone2Mute.Name = "CheckBoxZone2Mute"
CheckBoxZone2Mute.Size = New Size(54, 19)
CheckBoxZone2Mute.TabIndex = 13
CheckBoxZone2Mute.Text = "Mute"
CheckBoxZone2Mute.UseVisualStyleBackColor = True
'
' GroupBoxPower
'
GroupBoxPower.Controls.Add(btnPowerOff)
GroupBoxPower.Controls.Add(btnPowerOn)
GroupBoxPower.FlatStyle = FlatStyle.Flat
GroupBoxPower.Location = New Point(315, 341)
GroupBoxPower.Name = "GroupBoxPower"
GroupBoxPower.Size = New Size(84, 83)
GroupBoxPower.TabIndex = 15
GroupBoxPower.TabStop = False
GroupBoxPower.Text = "Power"
'
' btnPowerOff
'
btnPowerOff.Location = New Point(6, 51)
btnPowerOff.Name = "btnPowerOff"
btnPowerOff.Size = New Size(66, 23)
btnPowerOff.TabIndex = 18
btnPowerOff.Text = "O&ff"
btnPowerOff.UseVisualStyleBackColor = True
'
' btnPowerOn
'
btnPowerOn.Location = New Point(6, 22)
btnPowerOn.Name = "btnPowerOn"
btnPowerOn.Size = New Size(66, 23)
btnPowerOn.TabIndex = 17
btnPowerOn.Text = "&On"
btnPowerOn.UseVisualStyleBackColor = True
'
' txtPartialInput
'
txtPartialInput.Location = New Point(12, 70)
txtPartialInput.Name = "txtPartialInput"
txtPartialInput.Size = New Size(387, 23)
txtPartialInput.TabIndex = 16
txtPartialInput.Text = "partial messages appear here..."
'
' Form1
'
AutoScaleDimensions = New SizeF(7F, 15F)
AutoScaleMode = AutoScaleMode.Font
AutoSize = True
AutoSizeMode = AutoSizeMode.GrowAndShrink
ClientSize = New Size(413, 436)
Controls.Add(txtPartialInput)
Controls.Add(GroupBoxPower)
Controls.Add(GroupBox2)
Controls.Add(GroupBox1)
Controls.Add(CheckBoxCTS)
Controls.Add(CheckBoxRTS)
Controls.Add(LabelStatus)
Controls.Add(ButtonDisconnect)
Controls.Add(ButtonConnect)
Controls.Add(ComboBoxHandshake)
Controls.Add(ComboBoxBaud)
Controls.Add(ComboBoxPorts)
Controls.Add(ListBoxReceived)
Controls.Add(ButtonSend3)
Controls.Add(btnSendReady)
Name = "Form1"
RightToLeft = RightToLeft.No
Text = "Yamaha RX-2400 Controller"
GroupBox1.ResumeLayout(False)
GroupBox1.PerformLayout()
GroupBox2.ResumeLayout(False)
GroupBox2.PerformLayout()
GroupBoxPower.ResumeLayout(False)
ResumeLayout(False)
PerformLayout()
End Sub
Friend WithEvents btnSendReady As Button
Friend WithEvents ButtonSend3 As Button
Friend WithEvents ListBoxReceived As ListBox
Friend WithEvents ComboBoxPorts As ComboBox
Friend WithEvents ComboBoxBaud As ComboBox
Friend WithEvents ComboBoxHandshake As ComboBox
Friend WithEvents ButtonConnect As Button
Friend WithEvents ButtonDisconnect As Button
Friend WithEvents LabelStatus As Label
Friend WithEvents CheckBoxRTS As CheckBox
Friend WithEvents CheckBoxCTS As CheckBox
Friend WithEvents TimerCTS As Timer
Friend WithEvents GroupBox1 As GroupBox
Friend WithEvents CheckBoxMasterMute As CheckBox
Friend WithEvents ButtonMasterVolDown As Button
Friend WithEvents ButtonMasterVolUp As Button
Friend WithEvents GroupBox2 As GroupBox
Friend WithEvents ButtonZone2VolDown As Button
Friend WithEvents ButtonZone2VolUp As Button
Friend WithEvents CheckBoxZone2Mute As CheckBox
Friend WithEvents GroupBoxPower As GroupBox
Friend WithEvents txtPartialInput As TextBox
Friend WithEvents btnPowerZone1On As Button
Friend WithEvents btnPowerOff As Button
Friend WithEvents btnPowerOn As Button
Friend WithEvents btnPowerZone1Off As Button
Friend WithEvents btnPowerZone2Off As Button
Friend WithEvents btnPowerZone2On As Button
End Class

123
AVR VisBasic/Form1.resx Normal file
View File

@@ -0,0 +1,123 @@
<?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="TimerCTS.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

271
AVR VisBasic/Form1.vb Normal file
View File

@@ -0,0 +1,271 @@
Imports System.IO.Ports
Imports Microsoft.VisualBasic.Logging
Public Class Form1
Private formIsLoaded As Boolean = False
Private formStartingWidth As Integer
Private textBoxesStartingWidth As Integer
Private connectButtonsStartingLeft As Integer
Private powerGroupStartingLeft As Integer
Private ControlCodeMap As New Dictionary(Of Integer, String) From {
{0, "NUL"}, {1, "SOH"}, {2, "STX"}, {3, "ETX"},
{4, "EOT"}, {5, "ENQ"}, {6, "ACK"}, {7, "BEL"},
{8, "BS"}, {9, "TAB"}, {10, "LF"}, {11, "VT"},
{12, "FF"}, {13, "CR"}, {14, "SO"}, {15, "SI"},
{16, "DLE"}, {17, "DC1"}, {18, "DC2"}, {19, "DC3"},
{20, "DC4"}, {21, "NAK"}, {22, "SYN"}, {23, "ETB"},
{24, "CAN"}, {25, "EM"}, {26, "SUB"}, {27, "ESC"},
{28, "FS"}, {29, "GS"}, {30, "RS"}, {31, "US"},
{127, "DEL"}
}
Private WithEvents SerialPort1 As New SerialPort()
Private Sub Form1_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged
If (formIsLoaded) Then
If (Me.Width < formStartingWidth) Then
Me.Width = formStartingWidth
End If
Dim formCurrentWidth As Integer = Me.Width
Dim xDelta As Integer = formCurrentWidth - formStartingWidth
txtPartialInput.Width = textBoxesStartingWidth + xDelta
ListBoxReceived.Width = textBoxesStartingWidth + xDelta
ButtonConnect.Left = connectButtonsStartingLeft + xDelta
ButtonDisconnect.Left = connectButtonsStartingLeft + xDelta
GroupBoxPower.Left = powerGroupStartingLeft + xDelta
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Startup
formStartingWidth = Width
Dim fixedHeight As Integer = Height
' Allow width to change, but lock height
MinimumSize = New Size(formStartingWidth, fixedHeight) ' Minimum width 200
MaximumSize = New Size(1200, fixedHeight) ' Unlimited width, fixed height
textBoxesStartingWidth = txtPartialInput.Width
connectButtonsStartingLeft = ButtonConnect.Left
powerGroupStartingLeft = GroupBoxPower.Left
FormBorderStyle = FormBorderStyle.Sizable
WindowState = FormWindowState.Normal
' Timer to check CTS status
TimerCTS.Interval = 500
TimerCTS.Start()
' Populate COM ports
ComboBoxPorts.Items.AddRange(SerialPort.GetPortNames())
' Populate baud rates
ComboBoxBaud.Items.AddRange(New Object() {9600, 19200, 38400, 57600, 115200})
ComboBoxBaud.SelectedIndex = 0
' Populate handshake options
ComboBoxHandshake.Items.AddRange([Enum].GetNames(GetType(Handshake)))
ComboBoxHandshake.SelectedItem = "RequestToSend" ' RTS/CTS default
formIsLoaded = True
End Sub
' Poll CTS state
Private Sub TimerCTS_Tick(sender As Object, e As EventArgs) Handles TimerCTS.Tick
If SerialPort1.IsOpen Then
CheckBoxCTS.CheckState = IIf(SerialPort1.CtsHolding = True, CheckState.Checked, CheckState.Unchecked)
Else
CheckBoxCTS.CheckState = CheckState.Indeterminate
End If
End Sub
Private Sub ButtonConnect_Click(sender As Object, e As EventArgs) Handles ButtonConnect.Click
Try
If Not SerialPort1.IsOpen And ComboBoxPorts.SelectedItem <> Nothing Then
SerialPort1.PortName = ComboBoxPorts.SelectedItem.ToString()
SerialPort1.BaudRate = CInt(ComboBoxBaud.SelectedItem)
SerialPort1.Handshake = CType([Enum].Parse(GetType(Handshake), ComboBoxHandshake.SelectedItem.ToString()), Handshake)
SerialPort1.Parity = Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = StopBits.One
SerialPort1.Open()
LabelStatus.Text = "Connected"
CheckBoxRTS.Enabled = IIf(ComboBoxHandshake.SelectedItem = "None", True, False)
ButtonConnect.Enabled = False
ButtonDisconnect.Enabled = True
End If
Catch ex As Exception
MessageBox.Show("Error opening port: " & ex.Message)
End Try
End Sub
Private Sub ButtonDisconnect_Click(sender As Object, e As EventArgs) Handles ButtonDisconnect.Click
If SerialPort1.IsOpen Then
SerialPort1.Close()
LabelStatus.Text = "Disconnected"
ButtonDisconnect.Enabled = False
ButtonConnect.Enabled = True
End If
End Sub
' Send buttons
Private Sub ButtonSend1_Click(sender As Object, e As EventArgs) Handles btnSendReady.Click
If SerialPort1.IsOpen Then
Dim msg As String = Chr(17) & "000" & Chr(3)
SerialPort1.WriteLine(msg)
ListBoxReceived.Items.Add("> " & ExpandControlCodes(msg))
ListBoxReceived.SelectedIndex = ListBoxReceived.Items.Count - 1
End If
End Sub
' Handle incoming data
Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) _
Handles SerialPort1.DataReceived
Static Dim receivedMessage As String = ""
Try
receivedMessage &= SerialPort1.ReadExisting()
Dim pos As Integer = InStr(receivedMessage, Chr(3), CompareMethod.Binary) ' ETX
If (pos > 0) Then
While (pos > 0)
Dim oneMessage As String = ""
Debug.Print("ETX at pos: " & pos.ToString() & " in '" & receivedMessage & "'")
oneMessage = Mid(receivedMessage, 1, pos)
Dim parsed As String = ExpandControlCodes(oneMessage)
'
' Analyze and deal with the message
'
ProcessAVRMessage(oneMessage)
Me.Invoke(Sub() ListBoxReceived.Items.Add("< " & parsed))
Me.Invoke(Sub() ListBoxReceived.SelectedIndex = ListBoxReceived.Items.Count - 1)
receivedMessage = Mid(receivedMessage, pos + 1)
Me.Invoke(Sub() txtPartialInput.Text = receivedMessage)
pos = InStr(receivedMessage, Chr(3), CompareMethod.Binary)
End While
Else
'Debug.Print("No ETX in '" & receivedMessage & "'")
Me.Invoke(Sub() txtPartialInput.Text = receivedMessage)
End If
Catch ex As Exception
' Handle errors
Debug.Print("Exception caught and ignored?")
End Try
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If SerialPort1.IsOpen Then SerialPort1.Close()
End Sub
Private Function ExpandControlCodes(input As String) As String
Dim sb As New Text.StringBuilder()
For Each ch As Char In input
Dim code As Integer = Asc(ch)
If ControlCodeMap.ContainsKey(code) Then
sb.Append("[" & ControlCodeMap(code) & "]")
Else
sb.Append(ch)
End If
Next
Return sb.ToString()
End Function
Private Sub CheckBoxRTS_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxRTS.CheckedChanged
SerialPort1.RtsEnable = CheckBoxRTS.Checked
End Sub
Private Sub ButtonMasterVolUp_Click(sender As Object, e As EventArgs) Handles ButtonMasterVolUp.Click
SendMessageToAVR(Chr(2) & "07A1A" & Chr(3))
End Sub
Private Sub ButtonMasterVolDown_Click(sender As Object, e As EventArgs) Handles ButtonMasterVolDown.Click
SendMessageToAVR(Chr(2) & "07A1B" & Chr(3))
End Sub
Private Sub CheckBoxMasterMute_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxMasterMute.CheckedChanged
SendMessageToAVR(IIf(CheckBoxMasterMute.Checked, Chr(2) & "07EA2" & Chr(3), "07EA3"))
End Sub
Private Sub ButtonZone2VolUp_Click(sender As Object, e As EventArgs) Handles ButtonZone2VolUp.Click
SendMessageToAVR(Chr(2) & "07ADA" & Chr(3))
End Sub
Private Sub ButtonZone2VolDown_Click(sender As Object, e As EventArgs) Handles ButtonZone2VolDown.Click
SendMessageToAVR(Chr(2) & "07ADB" & Chr(3))
End Sub
Private Sub CheckBoxZone2Mute_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxZone2Mute.CheckedChanged
SendMessageToAVR(IIf(CheckBoxZone2Mute.Checked, Chr(2) & "07EA0" & Chr(3), "07EA1"))
End Sub
Private Sub SendMessageToAVR(msg As String)
If Not ButtonConnect.Enabled Then
SerialPort1.WriteLine(msg)
ListBoxReceived.Items.Add("> " & ExpandControlCodes(msg))
ListBoxReceived.SelectedIndex = ListBoxReceived.Items.Count - 1
End If
End Sub
'
' Power - main and zone
'
Private Sub btnPowerOn_Click(sender As Object, e As EventArgs) Handles btnPowerOn.Click
SendMessageToAVR(Chr(2) & "07A1D" & Chr(3))
End Sub
Private Sub btnPowerOff_Click(sender As Object, e As EventArgs) Handles btnPowerOff.Click
SendMessageToAVR(Chr(2) & "07A1E" & Chr(3))
End Sub
Private Sub btnPowerZone1On_Click(sender As Object, e As EventArgs) Handles btnPowerZone1On.Click
SendMessageToAVR(Chr(2) & "07E7E" & Chr(3))
End Sub
Private Sub btnPowerZone1Off_Click(sender As Object, e As EventArgs) Handles btnPowerZone1Off.Click
SendMessageToAVR(Chr(2) & "07E7F" & Chr(3))
End Sub
Private Sub btnPowerZone2On_Click(sender As Object, e As EventArgs) Handles btnPowerZone2On.Click
SendMessageToAVR(Chr(2) & "07EBa" & Chr(3))
End Sub
Private Sub btnPowerZone2Off_Click(sender As Object, e As EventArgs) Handles btnPowerZone2Off.Click
SendMessageToAVR(Chr(2) & "07EBA" & Chr(3))
End Sub
'
' Other stuff
'
Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Debug.Print("Resize")
End Sub
Private Sub ComboBoxPorts_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxPorts.SelectedIndexChanged
If ComboBoxPorts.Text <> "" Then
ButtonConnect.Enabled = True
Else
ButtonConnect.Enabled = False
End If
End Sub
Private Sub ProcessAVRMessage(msg As String)
' Process incoming messages from AVR here
Debug.Print("Processing AVR message: " & ExpandControlCodes(msg))
Dim response As String = Mid(msg, 2, Len(msg) - 2)
Debug.Print(" : " & response)
If (Mid(response, 1, 4) = "0026") Then
' Volume in the next byte
Dim vol As Single = Convert.ToInt16(Mid(response, 5, 2), 16) ' C7 is 0db
If (vol > &HC7) Then
Debug.Print((vol - &HC7) / 2)
Else
Debug.Print((vol - &HC7) / 2.5)
End If
End If
End Sub
End Class

View File

@@ -0,0 +1,45 @@
'------------------------------------------------------------------------------
' <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>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
' or if you encounter build errors in this file, go to the Project Designer
' (go to Project Properties or double-click the My Project node in
' Solution Explorer), and make changes on the Application tab.
'
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false
Me.EnableVisualStyles = true
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
Me.HighDpiMode = HighDpiMode.DpiUnaware
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.AVRcvrWinSerial.Form1
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
Me.MinimumSplashScreenDisplayTime = 0
Return MyBase.OnInitialize(commandLineArgs)
End Function
End Class
End Namespace

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain>
<MainForm>Form1</MainForm>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>