finished temperature querying

This commit is contained in:
lin committed 2026-10-06 02:24:44 +02:00
1 parent b1d4f3565d
commit be44d008c7
7 files changed
+168 -3

No files matched your search

+19 -2
View File
@@ -8,6 +8,7 @@ import (
loadaverage "rpi5-health/internal/load_average"
"rpi5-health/internal/memory"
"rpi5-health/internal/processor"
"rpi5-health/internal/temperature"
"rpi5-health/internal/uptime"
"strings"
)
@@ -15,10 +16,10 @@ import (
func Listen() {
reader := bufio.NewScanner(os.Stdin)
fmt.Print("> ")
for {
fmt.Print("\n> ")
if !reader.Scan() {
log.Println("Program terminated (SIGINT)")
return
@@ -34,6 +35,14 @@ func Listen() {
switch text {
case "exit":
return
case "help":
fmt.Print(`
exit - Exit the program
meminfo - Print memory information
cpuinfo - Print cpu information
uptime - Print system uptime
loadavg - Print cpu load average information`)
fmt.Println()
case "meminfo":
memInfo, _ := memory.GetRamInformation()
@@ -56,6 +65,14 @@ func Listen() {
loadAvg, _ := loadaverage.GetLoadAverage()
fmt.Printf("Load average: L1: %.2f | L5: %.2f | L15: %.2f\n", loadAvg.Load1, loadAvg.Load5, loadAvg.Load15)
case "temperature":
temp, _ := temperature.GetTemperatureInformation()
if temp.Supported {
fmt.Printf("Current temperature: %.2fC°", temp.Celsius)
} else {
fmt.Printf("Temperature reading is unsupported. Try installing Libre Hardware Monitor, or running as Administrator.")
}
}
}