mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 16:08:52 +01:00
about
This commit is contained in:
parent
c0f57bd88c
commit
95a1cde04c
@ -92,7 +92,7 @@ type AboutPage struct {
|
||||
}
|
||||
|
||||
func NewAboutPage() *AboutPage {
|
||||
p := &HelloWorldPage{}
|
||||
p := &AboutPage{}
|
||||
|
||||
p.FootMsg = [5]string{"Nav.","","","Back",""}
|
||||
|
||||
@ -136,7 +136,21 @@ func (self *AboutPage) Uname() {
|
||||
|
||||
|
||||
func (self *AboutPage) CpuMhz() {
|
||||
|
||||
|
||||
lines, err := readLines("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")
|
||||
UI.ShowErr(err)
|
||||
|
||||
mhz ,_ := strconv.ParseInt(lines[0], 10, 0))
|
||||
|
||||
mhz_float := float64(mhz)/1000.0
|
||||
|
||||
out := make(map[string]string)
|
||||
out["key"] = "cpuscalemhz"
|
||||
out["label"]="CPU Mhz:"
|
||||
out["value"] = strconv.FormatFloat(mhz_float, 'f', 2, 64)
|
||||
|
||||
self.AList["cpuscalemhz"] = out
|
||||
|
||||
}
|
||||
|
||||
func (self *AboutPage) CpuInfo() {
|
||||
@ -144,11 +158,66 @@ func (self *AboutPage) CpuInfo() {
|
||||
}
|
||||
|
||||
func (self *AboutPage) MemInfo() {
|
||||
|
||||
lines, err := readLines("/proc/meminfo")
|
||||
UI.ShowErr(err)
|
||||
|
||||
for _,line := range lines {
|
||||
if strings.HasPrefix(line,"MemTotal") {
|
||||
parts := strings.Split(line,":")
|
||||
kb := strings.Replace(parts[1],"KB","",-1)
|
||||
kb = strings.TrimSpace(kb)
|
||||
kb_int,_ := strconv.ParseInt(kb,10,0)
|
||||
|
||||
kb_float := float64(kb_int)/1000.0
|
||||
memory := make(map[string]string)
|
||||
memory["key"] = "memory"
|
||||
memory["label"] = "Memory:"
|
||||
memory["value"] = strconv.FormatFloat(kb_float,'f',2,64) + " MB"
|
||||
self.AList["memory"] = memory
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *AboutPage) GenList() {
|
||||
self.MyList = nil
|
||||
self.MyList = make([]*InfoPageListItem,0)
|
||||
|
||||
start_x := 0
|
||||
start_y := 10
|
||||
last_height := 0
|
||||
|
||||
for i,u := range ( []string{"processor","armcores","cpuscalemhz","features","memory","uname"} ) {
|
||||
if val, ok := self.AList[u]; ok {
|
||||
|
||||
li := NewInfoPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + last_height
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFontObj
|
||||
li.Fonts["small"] = UI.Fonts["varela12"]
|
||||
|
||||
if self.AList[u]["label"] != "" {
|
||||
li.Init( self.AList[u]["label"] )
|
||||
}else {
|
||||
li.Init( self.AList[u]["key"])
|
||||
}
|
||||
|
||||
li.Flag = val["key"]
|
||||
li.SetSmallText(val["value"])
|
||||
|
||||
self.MyList = append(self.MyList,li)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *AboutPage) Init() {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,9 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"fmt"
|
||||
|
||||
"bufio"
|
||||
"bytes"
|
||||
|
||||
"github.com/cuu/gogame/display"
|
||||
|
||||
"github.com/cuu/LauncherGo/sysgo"
|
||||
@ -118,3 +120,55 @@ func ReplaceSuffix(orig_file_str string, new_ext string) string {
|
||||
func SwapAndShow() {
|
||||
display.Flip()
|
||||
}
|
||||
|
||||
func ReadLines(path string)(lines [] string,err error){
|
||||
var (
|
||||
file *os.File
|
||||
part [] byte
|
||||
prefix bool
|
||||
)
|
||||
|
||||
if file, err = os.Open(path); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
reader := bufio.NewReader(file)
|
||||
buffer := bytes.NewBuffer(make([]byte,1024))
|
||||
|
||||
for {
|
||||
if part, prefix, err = reader.ReadLine();err != nil {
|
||||
break
|
||||
}
|
||||
buffer.Write(part)
|
||||
if !prefix {
|
||||
lines = append(lines,buffer.String())
|
||||
buffer.Reset()
|
||||
}
|
||||
}
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func WriteLines(lines [] string,path string)(err error){
|
||||
var file *os.File
|
||||
|
||||
if file,err = os.Create(path); err != nil{
|
||||
return
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
||||
for _,elem := range lines {
|
||||
_,err := file.WriteString(strings.TrimSpace(elem)+"\n")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user