Repository navigation
Expand file tree
/
Copy pathdebugoverlay.lua
More file actions
69 lines (63 loc) · 1.67 KB
/
Copy pathdebugoverlay.lua
File metadata and controls
69 lines (63 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
debugoverlay = {}
local _cachedFlags = nil
local _debugButtons = {
{ id = "FREERAM", text = "Free RAM", state = false },
{ id = "BATTERY", text = "Battery", state = false },
{ id = "CPUFREQ", text = "CPU Freq", state = false },
{ id = "NICKNAME", text = "Nickname", state = false },
{ id = "TIMEDATE", text = "Time/Date", state = false },
}
function debugoverlay.getButtons()
return _debugButtons
end
function debugoverlay.saveDebugInfo()
local flags = {}
for _, btn in ipairs(_debugButtons) do
flags[btn.id] = btn.state
end
sav.set("debug", "flags", flags)
end
function debugoverlay.loadSettings()
local flags = { FREERAM = false, BATTERY = false, CPUFREQ = false, NICKNAME = false, TIMEDATE = false }
local saved = sav.get("debug", "flags")
if saved then
for _, btn in ipairs(_debugButtons) do
local v = saved[btn.id]
if v ~= nil then
btn.state = (v == true)
flags[btn.id] = (v == true)
end
end
end
_cachedFlags = flags
return flags
end
function debugoverlay.draw(flags)
local f = flags or _cachedFlags
if not f then return end
local y = 0
if f.FREERAM then
LUA.print(0, y, string.format("Free RAM: %.2f MB", LUA.getRAM() / (1024 * 1024)))
y = y + 13
end
if f.BATTERY then
LUA.print(0, y, "Battery: " .. System.getBatteryPercent() .. "%")
y = y + 13
end
if f.CPUFREQ then
LUA.print(0, y, "CPU: " .. System.getCPU() .. " MHz")
y = y + 13
end
if f.NICKNAME then
LUA.print(0, y, "Nickname: " .. System.getNickname())
y = y + 13
end
if f.TIMEDATE then
local t = System.getTime()
LUA.print(
0,
y,
string.format("Time: %02d:%02d:%02d %02d/%02d/%04d", t.hour, t.minutes, t.seconds, t.day, t.month, t.year)
)
end
end