Replies: 1 comment 2 replies
|
Hello, Here is the code: `-- BatTimer: shows battery voltage and time since last charge local txVoltId local function checkVoltage (aktbatv) local oldbatv = aktbatv if batfile ~= nil then batfile = io.open (batFileName, "w"); local options = { local function create(zone, options) local function update(wgt, options) local function background(wgt) -- Zone size: top bar widgets --- Zone size: 160x32 1/8th --- Zone size: 180x70 1/4th local function refresh(wgt) if (wgt==nil) then if (wgt.options==nil) then lcd.setColor(CUSTOM_COLOR, wgt.options.TextColor) local t1 = getGlobalTimer() if batv > 5 and voltageChecked == 0 then if t1.total % 600 == 0 and t1.total ~= checkTime and t1.total ~= 0 then voltageChecked = 0 end -- check every 10 min. if wgt.zone.w > 170 and wgt.zone.h > 65 then refreshZoneMedium(wgt, batInfo, timeInfo) return { name="BatTimer", options=options, create=create, update=update, background=background, refresh=refresh } |
Uh oh!
There was an error while loading. Please reload this page.
Hey there, a question for you lua programing gurus. I have a friend that wants a timer to know haw long the tx battery has been on. I have a widget made that times whenever the radio is on. I have it saving to a file so it can be loaded into all models and start with the previous value saved. The problem is I dont want it writing to the file continously and wear out the sd card. I have it writing once a minute but it can loose up to a minute each time it is shutdown. Is there any way to trigger something like a function as it is shutdown? I can't seem to be able to find a way.
Is there a way to trigger on button press in lua?
Thanks.
All reactions