Browse Source

remove AsyncStart ,add SDL_Delay in event loop

cuu 1 year ago
parent
commit
83086d9381
4 changed files with 22 additions and 25 deletions
  1. 1 2
      Menu/GameShell/10_Settings/Bluetooth/bluetooth_page.go
  2. 4 6
      main.go
  3. 1 3
      sysgo/UI/main_screen.go
  4. 16 14
      sysgo/UI/title_bar.go

+ 1 - 2
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() {

+ 4 - 6
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)
 }

+ 1 - 3
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() 
 	}()
 }
 

+ 16 - 14
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)