serial port dropdown
This commit is contained in:
20
src/main.go
20
src/main.go
@@ -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
9
src/serial/serial.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user