Cleanups of battery logging

1. No need to pass the header through string.format()
2. Check for G_battery_logging value inside logBatteryLevel() function
to simply the code in the callers thereof.
Tigran Aivazian 12 years ago
parent fa0c08cb56
commit f047084320

@ -9,10 +9,12 @@ end
-- log battery level in "batlog.txt" file, blevent can be any string
function logBatteryLevel(blevent)
if not G_battery_logging then return end
local file = io.open("batlog.txt", "a+")
if file then
if file:seek("end") == 0 then -- write the header only once
file:write(string.format("DATE\t\tTIME\t\tBATTERY\tEVENT\n"))
file:write("DATE\t\tTIME\t\tBATTERY\tEVENT\n")
end
file:write(string.format("%s\t%s\t%s\t%s\n",
os.date("%d-%b-%y"), os.date("%T"),

@ -168,7 +168,7 @@ function Commands:new(obj)
function()
--os.execute("echo 'screensaver in' >> /mnt/us/event_test.txt")
if G_charging_mode == false and G_screen_saver_mode == false then
if G_battery_logging then logBatteryLevel("SLEEP") end
logBatteryLevel("SLEEP")
Screen:saveCurrentBB()
InfoMessage:inform("Going into screensaver... ", DINFO_NODELAY, 0, MSG_AUX)
Screen.kpv_rotation_mode = Screen.cur_rotation_mode
@ -184,7 +184,7 @@ function Commands:new(obj)
function()
--os.execute("echo 'screensaver out' >> /mnt/us/event_test.txt")
if G_screen_saver_mode == true and G_charging_mode == false then
if G_battery_logging then logBatteryLevel("WAKEUP") end
logBatteryLevel("WAKEUP")
util.usleep(1500000)
os.execute("killall -stop cvm")
fb:setOrientation(Screen.kpv_rotation_mode)
@ -199,7 +199,7 @@ function Commands:new(obj)
function()
--os.execute("echo 'usb in' >> /mnt/us/event_test.txt")
if G_charging_mode == false and G_screen_saver_mode == false then
if G_battery_logging then logBatteryLevel("USB PLUG") end
logBatteryLevel("USB PLUG")
Screen:saveCurrentBB()
Screen.kpv_rotation_mode = Screen.cur_rotation_mode
fb:setOrientation(Screen.native_rotation_mode)
@ -220,7 +220,7 @@ function Commands:new(obj)
fb:setOrientation(Screen.kpv_rotation_mode)
Screen:restoreFromSavedBB()
fb:refresh(0)
if G_battery_logging then logBatteryLevel("USB UNPLUG") end
logBatteryLevel("USB UNPLUG")
end
FileChooser:setPath(FileChooser.path)
FileChooser.pagedirty = true
@ -231,7 +231,7 @@ function Commands:new(obj)
-- I suggest one should probably change the hotkey to, say, Alt+Space
obj:add(KEY_P, MOD_SHIFT, "P", "make screenshot",
function()
if G_battery_logging then logBatteryLevel("SCREENSHOT") end
logBatteryLevel("SCREENSHOT")
Screen:screenshot()
end
)

Loading…
Cancel
Save