TempMonitor
Temperature monitor for RPi
include GtkEngine.e include std/io.e uses("vcgencmd") -- this should come standard with Raspbian constant -- interface; win = create(GtkWindow,"background=darkgreen,size=160x80,border=2,$destroy=Quit"), lbl = create(GtkLabel,"font=bold 16"), tick = create(GTimeout,1000,_("read_temps")) -- once per second set(win,"keep above",TRUE) set(win,"move",1450,20) -- change as needed to position display on screen; set(win,"decorated",FALSE) -- no titlebar, thanks add(win,lbl) show_all(win) main() --------------------- function read_temps() --------------------- system("vcgencmd measure_temp > GPU_TEMP",0) -- to temp file system("cat /sys/class/thermal/thermal_zone0/temp > CPU_TEMP",0) -- add to temp file object gpu_t = read_file("GPU_TEMP") gpu_t = to_number(gpu_t[6..9]) -- parse gpu temp object cpu_t = read_file("CPU_TEMP") cpu_t = to_number(cpu_t[1..$-1])/1000 -- parse cpu temp set(lbl,"color","skyblue") -- within safe limits if cpu_t > 60 or gpu_t > 60 then set(lbl,"color","yellow") end if -- getting sweaty! if cpu_t > 80 or gpu_t > 80 then set(lbl,"color","red") end if -- Oh, better do something! set(lbl,"markup",text:format("CPU [:4.1] C\nGPU [] C",{cpu_t,gpu_t})) return 1 end function
Not Categorized, Please Help
|