diff --git a/Menu/GameShell/10_Settings/Bluetooth/bluetooth_page.go b/Menu/GameShell/10_Settings/Bluetooth/bluetooth_page.go index 76e9aa2..153a19b 100644 --- a/Menu/GameShell/10_Settings/Bluetooth/bluetooth_page.go +++ b/Menu/GameShell/10_Settings/Bluetooth/bluetooth_page.go @@ -507,9 +507,8 @@ func (self *BluetoothPage) ShowBox(msg string) { } func (self *BluetoothPage) HideBox() { - self.Draw() self.ShowingMessageBox = false - self.Screen.SwapAndShow() + self.Screen.Refresh() } func (self *BluetoothPage) Init() { diff --git a/main.go b/main.go index 1c4fd3e..fd50250 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ import ( "github.com/cuu/gogame/event" // "github.com/cuu/gogame/color" "github.com/cuu/gogame/font" - //"github.com/cuu/gogame/time" + "github.com/cuu/gogame/time" "github.com/clockworkpi/LauncherGoDev/sysgo" "github.com/clockworkpi/LauncherGoDev/sysgo/UI" @@ -487,8 +487,8 @@ func run() int { main_screen.KeyDown(ev) main_screen.LastKeyDown = everytime_keydown } - - gotime.Sleep(50 * gotime.Millisecond) + //gotime.Sleep(50 * gotime.Millisecond) + time.SDL_Delay(20) } return 0 @@ -502,9 +502,7 @@ func main() { //runtime.GOMAXPROCS(1) os.Setenv("SDL_VIDEO_CENTERED", "1") - gogame.AsyncStart(func() { - exitcode = run() - }) + exitcode = run() os.Exit(exitcode) } diff --git a/sysgo/UI/main_screen.go b/sysgo/UI/main_screen.go index 435b353..9b50d45 100644 --- a/sysgo/UI/main_screen.go +++ b/sysgo/UI/main_screen.go @@ -223,9 +223,7 @@ func (self *MainScreen) Init() { //self.GenList() // load predefined plugin list,ready to be injected ,or ,as a .so for dynamic loading go func() { - sdl.Do(func() { - self.RefreshLoop() - }) + self.RefreshLoop() }() } diff --git a/sysgo/UI/title_bar.go b/sysgo/UI/title_bar.go index 2d67b61..305c9b3 100644 --- a/sysgo/UI/title_bar.go +++ b/sysgo/UI/title_bar.go @@ -101,6 +101,8 @@ type TitleBar struct { InLowBackLight int InAirPlaneMode bool + + WifiStrength int SkinManager *SkinManager //set by MainScreen @@ -136,6 +138,7 @@ func NewTitleBar() *TitleBar { t.TimeFont = Fonts["varela12"] t.InLowBackLight = -1 + t.WifiStrength = 0 return t } @@ -212,23 +215,22 @@ func (self *TitleBar) IsWifiConnectedNow() bool { } func (self *TitleBar) UpdateWifiStrength() { + self.GetWifiStrength() self.Draw(self.Title) } -func (t *TitleBar) GetWifiStrength() int { +func (self *TitleBar) GetWifiStrength() int { qua := 0 - cli := fmt.Sprintf("sudo iwconfig %s | grep Signal | /usr/bin/awk '{print $4}' | /usr/bin/cut -d'=' -f2", sysgo.WifiDev) + + cli := fmt.Sprintf("sudo iwgetid %s -r",sysgo.WifiDev) out := System(cli) - if len(out) > 2 { - if strings.Contains(out, "No") == false { - out = strings.TrimSuffix(out, "\n") - stren, err := strconv.ParseInt(out, 10, 0) - if err == nil { - qua = 2 * (int(stren) + 100) - } else { - fmt.Println(err) - } - } + if len(out) > 2{ + out = strings.TrimSuffix(out, "\n") + cli = fmt.Sprintf("sudo nmcli -t -f SSID,SIGNAL dev wifi list | grep \"^%s:\" | cut -d : -f 2",out) + out = System(cli) + + out = strings.TrimSuffix(out, "\n") + qua,_ = strconv.Atoi(out) } segs := [][]int{[]int{-2, -1}, []int{0, 25}, []int{25, 50}, []int{50, 75}, []int{75, 100}} @@ -244,7 +246,7 @@ func (t *TitleBar) GetWifiStrength() int { break } } - + self.WifiStrength = ge return ge } @@ -522,7 +524,7 @@ func (self *TitleBar) Draw(title string) { self.Icons["battery"].NewCoord(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2) if self.IsWifiConnectedNow() == true { - ge := self.GetWifiStrength() + ge := self.WifiStrength //fmt.Println("wifi ge: ",ge) if ge > 0 { self.Icons["wifistatus"].SetIconIndex(ge)