Revert "fix"

This reverts commit ed2454ea64.
This commit is contained in:
cuu
2023-01-24 14:47:42 +08:00
parent 4eefd21a8b
commit 6a360f5101
29 changed files with 104 additions and 80 deletions

View File

@@ -110,8 +110,6 @@ type TitleBar struct {
TitleFont *ttf.Font
TimeFont *ttf.Font
updateScreen chan bool
}
func NewTitleBar() *TitleBar {
@@ -138,16 +136,13 @@ func NewTitleBar() *TitleBar {
t.TimeFont = Fonts["varela12"]
t.InLowBackLight = -1
t.updateScreen = make(chan bool,1)
return t
}
func (self *TitleBar) Redraw() {
self.UpdateDownloadStatus()
DisplayFlip()
SwapAndShow()
}
func (self *TitleBar) UpdateDownloadStatus() {
@@ -181,7 +176,7 @@ func (self *TitleBar) RoundRobinCheck() {
self.CheckBluetooth()
self.UpdateWifiStrength()
self.UpdateDownloadStatus()
self.Refresh()
SwapAndShow()
} else if self.InLowBackLight >= 0 {
self.InLowBackLight += 1
@@ -192,7 +187,6 @@ func (self *TitleBar) RoundRobinCheck() {
self.UpdateWifiStrength()
self.UpdateDownloadStatus()
self.InLowBackLight = 0 // reset
self.Refresh()
}
}
@@ -299,6 +293,8 @@ func (self *TitleBar) SetSoundVolume(vol int) {
func (self *TitleBar) CheckBatteryStat() {
bat_segs := [][]int{[]int{0, 6}, []int{7, 15}, []int{16, 20}, []int{21, 30}, []int{31, 50}, []int{51, 60}, []int{61, 80}, []int{81, 90}, []int{91, 100}}
self.Icons["battery"] = self.Icons["battery_unknown"]
if FileExists(sysgo.Battery) == false {
return
}
@@ -341,11 +337,14 @@ func (self *TitleBar) CheckBatteryStat() {
break
}
}
if val, ok := bat_uevent["POWER_SUPPLY_STATUS"]; ok {
if val == "Charging" {
self.Icons["battery"].SetIconIndex(1+cap_ge)
self.Icons["battery_charging"].SetIconIndex(cap_ge)
self.Icons["battery"] = self.Icons["battery_charging"]
} else {
self.Icons["battery"].SetIconIndex(1+9+cap_ge)
self.Icons["battery_discharging"].SetIconIndex(cap_ge)
self.Icons["battery"] = self.Icons["battery_discharging"]
}
}
@@ -393,13 +392,29 @@ func (self *TitleBar) Init(main_screen *MainScreen) {
self.Icons["wifistatus"] = icon_wifi_status
battery_charging := NewTitleBarIconItem()
battery_charging.MyType = ICON_TYPES["STAT"]
battery_charging.Parent = self
battery_charging.ImageName = self.icon_base_path + "withcharging.png"
battery_charging.Adjust(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
self.Icons["battery_charging"] = battery_charging
battery_discharging := NewTitleBarIconItem()
battery_discharging.MyType = ICON_TYPES["STAT"]
battery_discharging.Parent = self
battery_discharging.ImageName = self.icon_base_path + "without_charging.png"
battery_discharging.Adjust(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
self.Icons["battery_discharging"] = battery_discharging
battery_unknown := NewTitleBarIconItem()
battery_unknown.MyType = ICON_TYPES["STAT"]
battery_unknown.Parent = self
battery_unknown.ImageName = self.icon_base_path + "battery.png"
battery_unknown.ImageName = self.icon_base_path + "battery_unknown.png"
battery_unknown.Adjust(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
self.Icons["battery"] = battery_unknown
self.Icons["battery_unknown"] = battery_unknown
self.CheckBatteryStat()
@@ -478,12 +493,6 @@ func (self *TitleBar) ClearCanvas() {
self.Icons["round_corners"].SetIconIndex(1)
self.Icons["round_corners"].Draw()
go func() {
sdl.Do(func() {
self.RefreshLoop()
})
}()
}
func (self *TitleBar) UpdateTimeLocation() {
@@ -567,22 +576,3 @@ func (self *TitleBar) Draw(title string) {
title_text_surf.Free()
time_text_surf.Free()
}
func (self *TitleBar) Refresh() {
self.updateScreen <- true
}
func (self *TitleBar) RefreshLoop() {
L:
for {
select {
case v:= <- self.updateScreen:
if v == true {
DisplayFlip()
}
if v== false {
break L
}
}
}
}