Skip to content

Commit

Permalink
Added create new preset
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioFPVdev authored and MarioFPVdev committed Feb 27, 2025
1 parent 89f1949 commit 202edf9
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 39 deletions.
63 changes: 47 additions & 16 deletions Configurator.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 77 additions & 3 deletions Configurator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,7 @@ err1:

Private Sub cmbFPS_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbFPS.SelectedIndexChanged
txtFPS.Text = " fps: " & cmbFPS.SelectedItem.ToString
cmbExposure.Text = Math.Floor(1000 / CInt(cmbFPS.SelectedItem.ToString))
txtExposure.Text = " exposure: " & Math.Floor(1000 / CInt(cmbFPS.SelectedItem.ToString))
End Sub

Expand Down Expand Up @@ -2787,7 +2788,7 @@ err1:
IO.File.WriteAllLines(WFBfilePath, lines)
End If
End If
If txtResolution.Text <> "" Then
If txtResolution.Text <> "" Then
Dim majestic = "majestic.yaml"
If Not IO.File.Exists(majestic) Then
MsgBox("File " + majestic + " not found!" + vbCrLf + "Install the latest version of Putty and try again.")
Expand Down Expand Up @@ -3373,7 +3374,7 @@ err1:
End Sub

Private Sub btnPreset_Click(sender As Object, e As EventArgs) Handles btnPreset.Click
Dim selected_preset = "presets/" + CStr(cmbPresets.Text) + ".bat"
Dim selected_preset = "presets/" + cmbPresets.Text + ".bat"
If Not File.Exists(selected_preset) Then
MsgBox("File " + selected_preset + " not found!")
Return
Expand All @@ -3386,7 +3387,7 @@ err1:
.StartInfo.FileName = selected_preset
.StartInfo.Arguments = "preset " + String.Format("{0}", txtIP.Text) + " " + txtPassword.Text
.StartInfo.RedirectStandardOutput = False
.Start()
.Start
End With
Else
MsgBox("Please enter a valid IP address")
Expand All @@ -3399,5 +3400,78 @@ err1:
lblPreset.Text = System.IO.File.ReadAllText(wfbconf)
End Sub

Private Sub createPreset_Click(sender As Object, e As EventArgs) Handles createPreset.Click
Dim i As Integer
Dim dirPresets = "presets\"
Dim sSource As String
Dim sTarget As String
sSource = "presets/1080p60_15Mbps_40MHz_AF1_12_15_UART0_MSPOSD.bat"
sTarget = "presets/custom_1.bat"
If btnRead.Enabled = True Then
If namePreset.Text <> "" Then
sTarget = "presets/" + namePreset.Text & ".bat"
Else
Do While System.IO.File.Exists(sTarget) = True
i = i + 1
sTarget = "presets/custom_" & i & ".bat"
Loop
End If
File.Copy(sSource, sTarget, True)
Dim x As Integer
Dim PresetfilePath As String = sTarget
Dim lines = IO.File.ReadAllLines(PresetfilePath)
For x = 0 To lines.Count() - 1
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 cli -s .video0.fps ") And Not cmbFPS.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 cli -s .video0.fps " + cmbFPS.Text
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 cli -s .isp.exposure ") And Not cmbExposure.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 cli -s .isp.exposure " + cmbExposure.Text
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 cli -s .video0.size ") And Not cmbResolution.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 cli -s .video0.size " + cmbResolution.Text
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 cli -s .video0.bitrate ") And Not cmbBitrate.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 cli -s .video0.bitrate " + cmbBitrate.Text
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/driver_txpower_override=/c\driver_txpower_override=") And Not ComboBox2.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/driver_txpower_override=/c\driver_txpower_override=" + ComboBox2.Text + "' /etc/wfb.conf"
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/stbc=/c\stbc=") And Not ComboBox6.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/stbc=/c\stbc=" + ComboBox6.Text + "' /etc/wfb.conf"
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/ldpc=/c\ldpc=") And Not ComboBox7.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/stbc=/c\stbc=" + ComboBox7.Text + "' /etc/wfb.conf"
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/mcs_index=/c\mcs_index=") And Not ComboBox5.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/mcs_index=/c\mcs_index=" + ComboBox5.Text + "' /etc/wfb.conf"
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/bandwidth=/c\bandwidth=") And Not cmbBandwidth.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/bandwidth=/c\bandwidth=" + cmbBandwidth.Text + "' /etc/wfb.conf"
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/fec_k=/c\fec_k=") And Not ComboBox8.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/fec_k=/c\fec_k=" + ComboBox8.Text + "' /etc/wfb.conf"
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/fec_n=/c\fec_n=") And Not ComboBox9.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/fec_n=/c\fec_n=" + ComboBox9.Text + "' /etc/wfb.conf"
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/serial=/c\serial=") And Not cmbSerial.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/serial=/c\serial=" + cmbSerial.Text + "' /etc/telemetry.conf"
End If
If lines(x).StartsWith(" plink -ssh root@%2 -pw %3 sed -i '/router=/c\router=") And Not cmbRouter.Text.StartsWith("Select") Then
lines(x) = " plink -ssh root@%2 -pw %3 sed -i '/router=/c\router=" + cmbRouter.Text + "' /etc/telemetry.conf"
End If
Next
IO.File.WriteAllLines(PresetfilePath, lines)
cmbPresets.Items.Clear()
For Each filePresets As String In System.IO.Directory.GetFiles(dirPresets)
cmbPresets.Items.Add(System.IO.Path.GetFileNameWithoutExtension(filePresets))
Next
cmbPresets.Text = "Select Preset"
MsgBox("Your Custom Preset is created with name " + sTarget.Replace("presets/", "") + vbCrLf + "Please select it from the list and hit Apply Selected Preset.")
Else
MsgBox("You must Connect and Load the settings before you can Create a new Custom Preset.")
End If
End Sub

#End Region
End Class
21 changes: 11 additions & 10 deletions presets/1080p60_15Mbps_40MHz_AF1_12_15_UART0_MSPOSD.bat
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
@echo off

if "%1" == "preset" (
echo y | pscp -scp -pw %3 sensors/imx415_milos15.bin root@%2:/etc/sensors/
echo y | pscp -scp -pw %3 vtxmenu.ini root@%2:/etc/
echo y | pscp -scp -pw %3 reset/wifibroadcast root@%2:/usr/bin/
plink -ssh root@%2 -pw %3 dos2unix /etc/vtxmenu.ini
plink -ssh root@%2 -pw %3 dos2unix /usr/bin/wifibroadcast
plink -ssh root@%2 -pw %3 cli -s .isp.sensorConfig /etc/sensors/imx415_milos15.bin
plink -ssh root@%2 -pw %3 cli -s .isp.exposure 16
plink -ssh root@%2 -pw %3 cli -s .video0.codec h265
plink -ssh root@%2 -pw %3 cli -s .video0.fps 60
plink -ssh root@%2 -pw %3 cli -s .isp.exposure 16
plink -ssh root@%2 -pw %3 cli -s .video0.size 1920x1080
plink -ssh root@%2 -pw %3 cli -s .video0.bitrate 15360
plink -ssh root@%2 -pw %3 cli -s .fpv.enabled true
plink -ssh root@%2 -pw %3 cli -s .fpv.noiseLevel 0
plink -ssh root@%2 -pw %3 sed -i '/driver_txpower_override=/c\driver_txpower_override=30' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/stbc=/c\stbc=1' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/ldpc=/c\ldpc=1' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/mcs_index=/c\mcs_index=2' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/bandwidth=/c\bandwidth=40' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/fec_k=/c\fec_k=12' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/fec_n=/c\fec_n=15' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/serial=/c\serial=/dev/ttyS0' /etc/telemetry.conf
plink -ssh root@%2 -pw %3 sed -i '/router=/c\router=2' /etc/telemetry.conf
plink -ssh root@%2 -pw %3 sed -i 's/console::respawn:\/sbin\/getty -L console 0 vt100/#console::respawn:\/sbin\/getty -L console 0 vt100/' /etc/inittab
plink -ssh root@%2 -pw %3 dos2unix /etc/vtxmenu.ini
plink -ssh root@%2 -pw %3 dos2unix /usr/bin/wifibroadcast
plink -ssh root@%2 -pw %3 cli -s .isp.sensorConfig /etc/sensors/imx415_milos15.bin
plink -ssh root@%2 -pw %3 cli -s .fpv.enabled true
plink -ssh root@%2 -pw %3 cli -s .fpv.noiseLevel 0
plink -ssh root@%2 -pw %3 cli -s .video0.codec h265
echo y | pscp -scp -pw %3 sensors/imx415_milos15.bin root@%2:/etc/sensors/
echo y | pscp -scp -pw %3 vtxmenu.ini root@%2:/etc/
echo y | pscp -scp -pw %3 reset/wifibroadcast root@%2:/usr/bin/
plink -ssh root@%2 -pw %3 reboot
)

Expand Down
21 changes: 11 additions & 10 deletions presets/720p120_15Mbps_40MHz_AF1_8_12_UART0_MSPOSD.bat
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
@echo off

if "%1" == "preset" (
echo y | pscp -scp -pw %3 sensors/imx415_milos15.bin root@%2:/etc/sensors/
echo y | pscp -scp -pw %3 vtxmenu.ini root@%2:/etc/
echo y | pscp -scp -pw %3 reset/wifibroadcast root@%2:/usr/bin/
plink -ssh root@%2 -pw %3 dos2unix /etc/vtxmenu.ini
plink -ssh root@%2 -pw %3 dos2unix /usr/bin/wifibroadcast
plink -ssh root@%2 -pw %3 cli -s .isp.sensorConfig /etc/sensors/imx415_milos15.bin
plink -ssh root@%2 -pw %3 cli -s .isp.exposure 8
plink -ssh root@%2 -pw %3 cli -s .video0.codec h265
plink -ssh root@%2 -pw %3 cli -s .video0.fps 120
plink -ssh root@%2 -pw %3 cli -s .isp.exposure 8
plink -ssh root@%2 -pw %3 cli -s .video0.size 1280x720
plink -ssh root@%2 -pw %3 cli -s .video0.bitrate 15360
plink -ssh root@%2 -pw %3 cli -s .fpv.enabled true
plink -ssh root@%2 -pw %3 cli -s .fpv.noiseLevel 0
plink -ssh root@%2 -pw %3 sed -i '/driver_txpower_override=/c\driver_txpower_override=40' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/stbc=/c\stbc=1' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/ldpc=/c\ldpc=1' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/mcs_index=/c\mcs_index=2' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/bandwidth=/c\bandwidth=40' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/fec_k=/c\fec_k=8' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/fec_n=/c\fec_n=12' /etc/wfb.conf
plink -ssh root@%2 -pw %3 sed -i '/serial=/c\serial=/dev/ttyS0' /etc/telemetry.conf
plink -ssh root@%2 -pw %3 sed -i '/router=/c\router=2' /etc/telemetry.conf
plink -ssh root@%2 -pw %3 sed -i 's/console::respawn:\/sbin\/getty -L console 0 vt100/#console::respawn:\/sbin\/getty -L console 0 vt100/' /etc/inittab
plink -ssh root@%2 -pw %3 dos2unix /etc/vtxmenu.ini
plink -ssh root@%2 -pw %3 dos2unix /usr/bin/wifibroadcast
plink -ssh root@%2 -pw %3 cli -s .isp.sensorConfig /etc/sensors/imx415_milos15.bin
plink -ssh root@%2 -pw %3 cli -s .fpv.enabled true
plink -ssh root@%2 -pw %3 cli -s .fpv.noiseLevel 0
plink -ssh root@%2 -pw %3 cli -s .video0.codec h265
echo y | pscp -scp -pw %3 sensors/imx415_milos15.bin root@%2:/etc/sensors/
echo y | pscp -scp -pw %3 vtxmenu.ini root@%2:/etc/
echo y | pscp -scp -pw %3 reset/wifibroadcast root@%2:/usr/bin/
plink -ssh root@%2 -pw %3 reboot
)

Expand Down

0 comments on commit 202edf9

Please sign in to comment.