Public Class Form1

    ' TCVR Icom používá protokol tvaru FE FE A4 E0 Cn Sc Data FD
    ' Cn je příkaz (Command) Sc Subcommand
    ' Data pro nastavování/čtení frekvencí jsou složena z 5 bajtů, níže pořadí 5-4-3-2-1, data se použijí pro Cn: 00, 03, 05 a 1C 03

    Dim b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, colapse As Byte       ' deklarace bajtů - hodnoty 0 až 9
    Dim bajts(0 To 11) As Byte
    Dim vfo_a(0 To 11) As Byte
    Dim vfo_b(0 To 11) As Byte
    Dim povel_2b(0 To 11) As Byte

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Label2.Text = SerialPort1.PortName
        colapse = 0
        'přiřazení konstant protokolu Icom

        bajts(1) = 254
        vfo_a(1) = 254
        vfo_b(1) = 254
        povel_2b(1) = 254                      ' preambule FE
        bajts(2) = 254
        vfo_a(2) = 254
        vfo_b(2) = 254
        povel_2b(2) = 254                      ' preambule FE
        bajts(3) = NumericUpDown11.Value
        vfo_a(3) = NumericUpDown11.Value
        vfo_b(3) = NumericUpDown11.Value
        povel_2b(3) = NumericUpDown11.Value    ' adresa Icom 706, hexadecimálně 58
        bajts(4) = 224
        vfo_a(4) = 224
        vfo_b(4) = 224
        povel_2b(4) = 224                      ' adresa kontroleru, hex E0
        bajts(5) = 5                                                            ' příkaz set freq, příkaz hexadecimálně 00 nebo 05
        vfo_a(5) = 7
        vfo_a(6) = 0
        vfo_b(5) = 7
        vfo_b(6) = 1
        povel_2b(5) = 15
        povel_2b(6) = 1
        bajts(11) = 253
        vfo_a(7) = 253
        vfo_b(7) = 253
        povel_2b(7) = 253                     ' konec - znak FD
        povel_2b(8) = 253

    End Sub

    Private Sub Vyssi_rad()         'pro bajty b2, b4, b6 a b8 se přepočítává základ, pomocná proměnná je b0

        b0 = b2
        Zaklad()
        b2 = b0

        b0 = b4
        Zaklad()
        b4 = b0

        b0 = b6
        Zaklad()
        b6 = b0

        b0 = b8
        Zaklad()
        b8 = b0

    End Sub
    Private Sub Zaklad()            'pomocná proměnná je b0, přepočtení řádu (základu)

        If b0 = 0 Then
            b0 = 0
        End If
        If b0 = 1 Then
            b0 = 16
        End If
        If b0 = 2 Then
            b0 = 32
        End If
        If b0 = 3 Then
            b0 = 48
        End If
        If b0 = 4 Then
            b0 = 64
        End If
        If b0 = 5 Then
            b0 = 80
        End If
        If b0 = 6 Then
            b0 = 96
        End If
        If b0 = 7 Then
            b0 = 112
        End If
        If b0 = 8 Then
            b0 = 128
        End If
        If b0 = 9 Then
            b0 = 144
        End If

    End Sub
    Private Sub Nastav_com()    'nastavování sériových portů
        SerialPort1.Close()     'na otevřeném portu nelze měnit parametry
        SerialPort1.PortName = TextBox3.Text

        Dim br1 As Integer
        br1 = TextBox4.Text
        SerialPort1.BaudRate = br1
    End Sub

    Private Sub Posli_bajty()   'posílání bajtů
        SerialPort1.Close()     'když se dvakrát za sebou otevře, tak se to zesere, tak ho zavírám
        SerialPort1.Open()      'otevření serial portu
        SerialPort1.Write(bajts, 1, 11) ' toto skutečně pošle bajty do Icom 7200
    End Sub
    Private Sub Nastavuj()

        bajts(3) = NumericUpDown11.Value        'nastavení adresy TCVRu

        'přiřazení hodnot bajtům z NumericUpdown objektů pro zadávání

        b1 = NumericUpDown1.Value
        b2 = NumericUpDown2.Value
        b3 = NumericUpDown3.Value
        b4 = NumericUpDown4.Value
        b5 = NumericUpDown5.Value
        b6 = NumericUpDown6.Value
        b7 = NumericUpDown7.Value
        b8 = NumericUpDown8.Value
        b9 = 0

        Vyssi_rad()  ' procedura kvůli Icomu

        'přiřazení dvojice dvou bajtů, které tvoří jeden bajt dat v protokolu Icom

        bajts(6) = b8 + b9
        bajts(7) = b6 + b7
        bajts(8) = b4 + b5
        bajts(9) = b2 + b3
        bajts(10) = b1

        TextBox1.Text = "Set F (MHz): " + Str(bajts(10)) + ", " + Str(bajts(9)) + ", " + Str(bajts(8)) + ", " + Str(bajts(7)) + ", " + Str(bajts(6))

        Posli_bajty()              'posílání bajtů protokolem Icom
    End Sub
 
    Private Sub Cti_serial()
        For i As Integer = 1 To 11
            If SerialPort1.BytesToRead > 0 Then
                bajts(i) = SerialPort1.ReadByte()       ' toto přijme byte a dosadí jako číslo!
            End If
        Next i

        TextBox1.Text = "SYNC Dusimplex TX: " + Str(bajts(10)) + ", " + Str(bajts(9)) + ", " + Str(bajts(8)) + ", " + Str(bajts(7)) + ", " + Str(bajts(6))
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        For j = 1 To 2          'Icom nejdřív zopakuje příkaz a s druhým krokrem odešle výsledek
            Cti_serial()
        Next j

        'přiřazení konstant protokolu Icom

        bajts(1) = 254                          ' preambule FE
        bajts(2) = 254                          ' preambule FE
        bajts(3) = NumericUpDown11.Value        ' adresa Icom 706, hexadecimálně 58
        bajts(4) = 224                          ' adresa kontroleru, hex E0
        bajts(5) = 5                            ' příkaz set freq, příkaz hexadecimálně 00 nebo 05

        bajts(9) = 80                           ' bajty pro kmitočet 50 MHz
        bajts(10) = 0
        bajts(11) = 253                         ' konec - znak FD

        SerialPort1.Write(vfo_b, 1, 11)          ' nastavi VFO B

        SerialPort1.Close()
        SerialPort1.Open()

        SerialPort1.Write(bajts, 1, 11)          ' toto pošle frekvenci do Icomu

        SerialPort1.Close()
        SerialPort1.Open()

        SerialPort1.Write(vfo_a, 1, 11)          ' nastavi VFO A

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom

        SerialPort1.Close()                     'zavře serial, kvůli přístupu druhých aplikací
    End Sub
    Private Sub Split_ON()
        povel_2b(5) = 15
        povel_2b(6) = 1

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "SPLIT ON: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Nastav_com()

        VFO_Asub()     'nastaví VFO A
        FMsub()     'nastaví FM
        Step12k5sub()    'nastaví Step 12.5 kHz
        PREONsub()     'nastaví PRE amp
        ToneOFF_sub()    'nastaví CTCSS off
        SIMPsub()     'nastaví DUP off"

        F145M500()

        Sroluj()

    End Sub
    Private Sub Button2_Click_1(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Nastavuj()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 7)       ' toto pošle bajty do Icom
        SerialPort1.Close()
    End Sub

    Private Sub VFO_Asub()

        vfo_a(5) = 7
        vfo_a(6) = 0
        vfo_b(5) = 7
        vfo_b(6) = 1
        SerialPort1.Close()
        SerialPort1.Open()

        TextBox1.Text = "VFO A: " + Str(vfo_a(2)) + ", " + Str(vfo_a(3)) + ", " + Str(vfo_a(4)) + ", " + Str(vfo_a(5)) + ", " + Str(vfo_a(6))
        SerialPort1.Write(vfo_a, 1, 7)          ' nastavi VFO A
        SerialPort1.Close()

    End Sub

    Private Sub VFO_Bsub()

        vfo_a(5) = 7
        vfo_a(6) = 0
        vfo_b(5) = 7
        vfo_b(6) = 1
        SerialPort1.Close()
        SerialPort1.Open()

        TextBox1.Text = "VFO B: " + Str(vfo_b(2)) + ", " + Str(vfo_b(3)) + ", " + Str(vfo_b(4)) + ", " + Str(vfo_b(5)) + ", " + Str(vfo_b(6))
        SerialPort1.Write(vfo_b, 1, 7)          ' nastavi VFO A
        SerialPort1.Close()

    End Sub

    Private Sub Split_ONsub()
        povel_2b(5) = 15
        povel_2b(6) = 1

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "SPLIT ON: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub A_Bsub()
        vfo_a(5) = 7
        vfo_a(6) = 160
        SerialPort1.Close()
        SerialPort1.Open()

        TextBox1.Text = "A=B: " + Str(vfo_a(2)) + ", " + Str(vfo_a(3)) + ", " + Str(vfo_a(4)) + ", " + Str(vfo_a(5)) + ", " + Str(vfo_a(6))
        SerialPort1.Write(vfo_a, 1, 7)          ' nastavi VFO A
        SerialPort1.Close()

    End Sub

    Private Sub Split_OFFsub()
        povel_2b(5) = 15
        povel_2b(6) = 0

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "SPLIT OFF: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub USBsub()
        povel_2b(5) = 6
        povel_2b(6) = 1

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "USB: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub LSBsub()
        povel_2b(5) = 6
        povel_2b(6) = 0

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "LSB: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub ATTONsub()
        povel_2b(5) = 17
        povel_2b(6) = 32

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "ATT ON: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub ATTOFFsub()
        povel_2b(5) = 17
        povel_2b(6) = 0

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "ATT OFF: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub PREONsub()
        povel_2b(5) = 22
        povel_2b(6) = 2
        povel_2b(7) = 1
        povel_2b(8) = 253

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "PRE ON: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6)) + ", " + Str(povel_2b(7))
        SerialPort1.Close()
        povel_2b(7) = 253
    End Sub

    Private Sub PREOFFsub()
        povel_2b(5) = 22
        povel_2b(6) = 2
        povel_2b(7) = 0
        povel_2b(8) = 253

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "PRE OFF: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6)) + ", " + Str(povel_2b(7))
        SerialPort1.Close()
        povel_2b(7) = 253
    End Sub

    Private Sub Tone_sub()
        povel_2b(5) = 22
        povel_2b(6) = 66
        povel_2b(7) = 1
        povel_2b(8) = 253

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "TONE: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6)) + ", " + Str(povel_2b(7))
        SerialPort1.Close()
        povel_2b(7) = 253
    End Sub

    Private Sub ToneOFF_sub()
        povel_2b(5) = 22
        povel_2b(6) = 66
        povel_2b(7) = 0
        povel_2b(8) = 253

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "TONE OFF: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6)) + ", " + Str(povel_2b(7))
        SerialPort1.Close()
        povel_2b(7) = 253
    End Sub

    Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If colapse = 1 Then
            Nastav_com()
            Label2.Text = TextBox3.Text
            Me.Height = 142
            Button4.Text = "Expand"
            colapse = 0
        Else
            Me.Height = 252
            Button4.Text = "Collapse"
            colapse = 1
        End If
       
    End Sub

    Private Sub FMsub()

        povel_2b(5) = 6
        povel_2b(6) = 5

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "FM: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub AMsub()

        povel_2b(5) = 6
        povel_2b(6) = 2

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "AM: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub WFMsub()

        povel_2b(5) = 6
        povel_2b(6) = 6

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "WFM: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub RTTYsub()

        povel_2b(5) = 6
        povel_2b(6) = 4

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "RTTY: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Step1ksub()

        povel_2b(5) = 16
        povel_2b(6) = 2

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "1kHz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Step9ksub()

        povel_2b(5) = 16
        povel_2b(6) = 4

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "9kHz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Step12k5sub()

        povel_2b(5) = 16
        povel_2b(6) = 6

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "12.5kHz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Step25ksub()

        povel_2b(5) = 16
        povel_2b(6) = 8

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "25kHz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Step100ksub()

        povel_2b(5) = 16
        povel_2b(6) = 9

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "100kHz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Step100Hsub()

        povel_2b(5) = 16
        povel_2b(6) = 1

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "100Hz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Step10Hsub()

        povel_2b(5) = 16
        povel_2b(6) = 0

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "10Hz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub DUP_plus_sub()

        povel_2b(5) = 15
        povel_2b(6) = 18

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "Duplex + : " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Dup_minus_sub()

        povel_2b(5) = 15
        povel_2b(6) = 17

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "Duplex - : " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub SIMPsub()


        povel_2b(5) = 15
        povel_2b(6) = 16

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "Duplex Off: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub CompON_sub()
        povel_2b(5) = 22
        povel_2b(6) = 68
        povel_2b(7) = 1
        povel_2b(8) = 253

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "COMP: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6)) + ", " + Str(povel_2b(7))
        SerialPort1.Close()
        povel_2b(7) = 253
    End Sub

    Private Sub CompOFF_sub()
        povel_2b(5) = 22
        povel_2b(6) = 68
        povel_2b(7) = 0
        povel_2b(8) = 253

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom
        TextBox1.Text = "Comp OFF: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6)) + ", " + Str(povel_2b(7))
        SerialPort1.Close()
        povel_2b(7) = 253
    End Sub

    Private Sub Step5ksub()

        povel_2b(5) = 16
        povel_2b(6) = 3

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "5kHz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub Step10ksub()

        povel_2b(5) = 16
        povel_2b(6) = 5

        SerialPort1.Close()
        SerialPort1.Open()
        SerialPort1.Write(povel_2b, 1, 11)       ' toto pošle bajty do Icom 
        TextBox1.Text = "10kHz: " + Str(povel_2b(2)) + ", " + Str(povel_2b(3)) + ", " + Str(povel_2b(4)) + ", " + Str(povel_2b(5)) + ", " + Str(povel_2b(6))
        SerialPort1.Close()
    End Sub

    Private Sub F145M500()
        NumericUpDown1.Value = 1
        NumericUpDown2.Value = 4
        NumericUpDown3.Value = 5
        NumericUpDown4.Value = 5
        NumericUpDown5.Value = 0
        NumericUpDown6.Value = 0
        NumericUpDown7.Value = 0
        NumericUpDown8.Value = 0
        b9 = 0

        Nastavuj()

    End Sub
    Private Sub F145M575()
        NumericUpDown1.Value = 1
        NumericUpDown2.Value = 4
        NumericUpDown3.Value = 5
        NumericUpDown4.Value = 5
        NumericUpDown5.Value = 7
        NumericUpDown6.Value = 5
        NumericUpDown7.Value = 0
        NumericUpDown8.Value = 0
        b9 = 0

        Nastavuj()

    End Sub
    Private Sub F106M4()
        NumericUpDown1.Value = 1
        NumericUpDown2.Value = 0
        NumericUpDown3.Value = 6
        NumericUpDown4.Value = 4
        NumericUpDown5.Value = 0
        NumericUpDown6.Value = 0
        NumericUpDown7.Value = 0
        NumericUpDown8.Value = 0
        b9 = 0

        Nastavuj()
    End Sub
    Private Sub F18M1()

        NumericUpDown1.Value = 0
        NumericUpDown2.Value = 1
        NumericUpDown3.Value = 8
        NumericUpDown4.Value = 1
        NumericUpDown5.Value = 0
        NumericUpDown6.Value = 0
        NumericUpDown7.Value = 0
        NumericUpDown8.Value = 0
        b9 = 0

        Nastavuj()
    End Sub
    Private Sub F954()
        NumericUpDown1.Value = 0
        NumericUpDown2.Value = 0
        NumericUpDown3.Value = 0
        NumericUpDown4.Value = 9
        NumericUpDown5.Value = 5
        NumericUpDown6.Value = 4
        NumericUpDown7.Value = 0
        NumericUpDown8.Value = 0
        b9 = 0

        Nastavuj()
    End Sub
    Private Sub F27M()

        NumericUpDown1.Value = 0
        NumericUpDown2.Value = 2
        NumericUpDown3.Value = 6
        NumericUpDown4.Value = 9
        NumericUpDown5.Value = 8
        NumericUpDown6.Value = 5
        NumericUpDown7.Value = 0
        NumericUpDown8.Value = 0
        b9 = 0

        Nastavuj()

    End Sub

    Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Nastav_com()

        VFO_Asub()          'nastaví VFO A
        WFMsub()            'nastaví WFM
        Step100ksub()         'nastaví Step 100 kHz
        PREONsub()            'nastaví PRE amp
        ToneOFF_sub()         'nastaví CTCSS off
        SIMPsub()             'nastaví DUP off"

        F106M4()

        Sroluj()
    End Sub

    Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Nastav_com()

        VFO_Asub()     'nastaví VFO A
        FMsub()     'nastaví FM
        Step12k5sub()     'nastaví Step 12.5 kHz
        PREONsub()     'nastaví PRE amp
        Tone_sub()     'nastaví CTCSS jako FM-T
        Dup_minus_sub()     'nastaví DUP --"

        F145M575()

        Sroluj()
    End Sub

    Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Nastav_com()

        VFO_Asub()    'nastaví VFO A
        AMsub()     'nastaví AM
        Step9ksub()   'nastaví Step 9 kHz
        PREOFFsub()     'nastaví PRE amp OFF
        ToneOFF_sub()     'nastaví CTCSS off
        SIMPsub()     'nastaví DUP off"

        F954()

        Sroluj()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Nastav_com()

        VFO_Asub()     'nastaví VFO A
        FMsub()     'nastaví FM
        Step5ksub()     'nastaví Step 10 kHz
        PREONsub()     'nastaví PRE amp
        ToneOFF_sub()     'nastaví CTCSS off
        SIMPsub()     'nastaví DUP off"

        F27M()

        Sroluj()
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Nastav_com()

        VFO_Asub()     'nastaví VFO A
        USBsub()     'nastaví USB
        Step1ksub()     'nastaví Step 1 kHz
        PREONsub()     'nastaví PRE amp
        ToneOFF_sub()    'nastaví CTCSS off
        SIMPsub()     'nastaví DUP off"

        F18M1()

        Sroluj()
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Nastav_com()

        VFO_Asub()     'nastaví VFO A
        USBsub()     'nastaví USB
        Step10Hsub()     'nastaví Step 10 Hz
        PREONsub()    'nastaví PRE amp
        ToneOFF_sub()     'nastaví CTCSS off
        SIMPsub()     'nastaví DUP off"

        'nastavení frekvence zde deaktivováno

        Sroluj()

    End Sub
    Private Sub Sroluj()
        Label2.Text = TextBox3.Text
        Button4.Text = "Expand"
        Me.Height = 142
        colapse = 0
    End Sub

    Private Sub VFOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VFOToolStripMenuItem.Click

    End Sub

    Private Sub VFOAToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VFOAToolStripMenuItem.Click
        VFO_Asub()
    End Sub

    Private Sub VFOBToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VFOBToolStripMenuItem.Click
        VFO_Bsub()
    End Sub

    Private Sub ABToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ABToolStripMenuItem.Click
        A_Bsub()
    End Sub

    Private Sub SplitONToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplitONToolStripMenuItem.Click
        Split_ON()
    End Sub

    Private Sub SplitOFFToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplitOFFToolStripMenuItem.Click
        Split_OFFsub()
    End Sub

    Private Sub USBToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles USBToolStripMenuItem.Click
        USBsub()
    End Sub

    Private Sub LSBToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LSBToolStripMenuItem.Click
        LSBsub()
    End Sub

    Private Sub FMToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FMToolStripMenuItem.Click
        FMsub()
    End Sub

    Private Sub WFMToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WFMToolStripMenuItem.Click
        WFMsub()
    End Sub

    Private Sub AMToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AMToolStripMenuItem.Click
        AMsub()
    End Sub

    Private Sub RTTYToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RTTYToolStripMenuItem.Click
        RTTYsub()
    End Sub

    Private Sub HzToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HzToolStripMenuItem.Click
        Step10Hsub()
    End Sub

    Private Sub HzToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HzToolStripMenuItem1.Click
        Step100Hsub()
    End Sub

    Private Sub KHzToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KHzToolStripMenuItem.Click
        Step1ksub()
    End Sub

    Private Sub KHzToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KHzToolStripMenuItem1.Click
        Step5ksub()
    End Sub

    Private Sub KHzToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KHzToolStripMenuItem2.Click
        Step9ksub()
    End Sub

    Private Sub KHzToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KHzToolStripMenuItem3.Click
        Step10ksub()
    End Sub

    Private Sub KHzToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KHzToolStripMenuItem4.Click
        Step12k5sub()
    End Sub

    Private Sub KHzToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KHzToolStripMenuItem5.Click
        Step25ksub()
    End Sub

    Private Sub KHzToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KHzToolStripMenuItem6.Click
        Step100ksub()
    End Sub

    Private Sub ONToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ONToolStripMenuItem.Click
        PREONsub()
    End Sub

    Private Sub OFFToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OFFToolStripMenuItem.Click
        PREOFFsub()
    End Sub

    Private Sub ATTONToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATTONToolStripMenuItem.Click
        ATTONsub()
    End Sub

    Private Sub ATTOFFToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATTOFFToolStripMenuItem.Click
        ATTOFFsub()
    End Sub

    Private Sub CTCSSONToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CTCSSONToolStripMenuItem.Click
        Tone_sub()
    End Sub

    Private Sub TOFFToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOFFToolStripMenuItem.Click
        ToneOFF_sub()
    End Sub

    Private Sub DUPToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DUPToolStripMenuItem1.Click
        Dup_minus_sub()
    End Sub

    Private Sub DUPToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DUPToolStripMenuItem2.Click
        DUP_plus_sub()
    End Sub

    Private Sub DUPOFFToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DUPOFFToolStripMenuItem.Click
        SIMPsub()
    End Sub

    Private Sub CompOFFToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompOFFToolStripMenuItem.Click
        CompOFF_sub()
    End Sub

    Private Sub CompONNToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompONNToolStripMenuItem.Click
        CompON_sub()
    End Sub
End Class
