serial port dropdown

This commit is contained in:
2026-04-04 00:42:19 +01:00
parent 13b4f78905
commit ffe363e777
2 changed files with 26 additions and 3 deletions

View File

@@ -1,14 +1,28 @@
package main
import (
"fmt"
"main/serial"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main () {
app := app.New()
win := app.NewWindow("OpenBPS - The Open Source Battery Profiler & Simulator")
deviceSelectorWindow := app.NewWindow("OpenBPS - The Open Source Battery Profiler & Simulator")
win.SetContent(widget.NewLabel("Please Select Serial Port"))
win.ShowAndRun()
//Dropdown for USB Port Selection
portSelector :=widget.NewSelect(serial.Get_Ports(), func(value string) {
fmt.Println("Selected Port: ",value)
})
portSelector.PlaceHolder = "First Should Be an Autodetect"
//set first window
deviceSelectorWindow.SetContent(container.NewVBox(
widget.NewLabel("Please Select Serial Port"),
portSelector,
))
deviceSelectorWindow.ShowAndRun()
}

9
src/serial/serial.go Normal file
View File

@@ -0,0 +1,9 @@
package serial
func Get_Ports() []string {
//will eventually hold a list of connected usb devices with matching ID
ports := []string{"/dev/tty0","/dev/tty2","/dev/tty3"}
return ports
}