fix bug in RestoreLastBackLightBrightness

This commit is contained in:
cuu 2018-12-24 13:20:31 +00:00
parent c9808c96c7
commit 33136b6b16
3 changed files with 12 additions and 2 deletions

11
main.go
View File

@ -30,7 +30,7 @@ import (
var ( var (
flash_led1_counter = 0 flash_led1_counter = 0
last_brt = 0 last_brt = -1
passout_time_stage = 0 passout_time_stage = 0
led1_proc_file = "/proc/driver/led1" led1_proc_file = "/proc/driver/led1"
@ -146,6 +146,10 @@ func InspectionTeam(main_screen *UI.MainScreen) {
if elapsed > gotime.Duration(time1) *gotime.Second && passout_time_stage == 0 { if elapsed > gotime.Duration(time1) *gotime.Second && passout_time_stage == 0 {
fmt.Println("timeout, dim screen ",elapsed) fmt.Println("timeout, dim screen ",elapsed)
if main_screen.TitleBar.InLowBackLight >= 0 {
return
}
if UI.FileExists(sysgo.BackLight) { if UI.FileExists(sysgo.BackLight) {
lines,err := UI.ReadLines(sysgo.BackLight) lines,err := UI.ReadLines(sysgo.BackLight)
@ -156,7 +160,7 @@ func InspectionTeam(main_screen *UI.MainScreen) {
if last_brt < 0 { if last_brt < 0 {
last_brt = brt last_brt = brt
} }
d := []byte(fmt.Sprintf("%d",1)) d := []byte(fmt.Sprintf("%d",1)) // lowest backlight
ioutil.WriteFile(sysgo.BackLight,d,0644) ioutil.WriteFile(sysgo.BackLight,d,0644)
} }
} }
@ -171,6 +175,9 @@ func InspectionTeam(main_screen *UI.MainScreen) {
}else if elapsed > gotime.Duration(time2) *gotime.Second && passout_time_stage == 1 { }else if elapsed > gotime.Duration(time2) *gotime.Second && passout_time_stage == 1 {
fmt.Println("timeout, close screen ", elapsed) fmt.Println("timeout, close screen ", elapsed)
if main_screen.Closed == true {
return
}
if UI.FileExists(sysgo.BackLight) { if UI.FileExists(sysgo.BackLight) {
d := []byte(fmt.Sprintf("%d",0)) d := []byte(fmt.Sprintf("%d",0))
ioutil.WriteFile(sysgo.BackLight,d,0644) ioutil.WriteFile(sysgo.BackLight,d,0644)

View File

@ -172,6 +172,7 @@ func NewMainScreen() *MainScreen {
m.MsgBoxFont = Fonts["veramono20"] m.MsgBoxFont = Fonts["veramono20"]
m.IconFont = Fonts["varela15"] m.IconFont = Fonts["varela15"]
m.Closed = false
return m return m
} }

View File

@ -139,6 +139,8 @@ func NewTitleBar() *TitleBar {
t.TitleFont = Fonts["varela16"] t.TitleFont = Fonts["varela16"]
t.TimeFont = Fonts["varela12"] t.TimeFont = Fonts["varela12"]
t.InLowBackLight = -1
return t return t
} }