--SIMPLE stop watch with spocken to 1/10th second and drawn to 1/100th. By nigelsheffield. local function drawPreciseTimer( x, y, val ) local ti = math.floor( val / 100 ) local tr = val % 100-- % 100 gives remainder after dividing by 100, can use 60 to get minutes from seconds. if tr < 10 then tr = '.0' .. tr else tr = '.' .. tr end lcd.drawTimer( x, y, ti, DBLSIZE ) lcd.drawText( lcd.getLastPos(), y, tr, MIDSIZE ) end local function playPreciseTimer( val ) local minutes = math.floor( val / 6000 ) local seconds = val % 6000 if minutes > 0 then playNumber(minutes, 16, 0) end playNumber(seconds/10, 17, PREC1) end local timeold = getTime() local timer = 0 local mark = 0 local switch = getFieldInfo("sh").id local function run() if getValue(switch)>0 and mark == 0 then timer = getTime()-timeold timeold = getTime() mark = 1 --playNumber(timer/10, 17, PREC2) playPreciseTimer( timer ) end if getValue(switch)<0 then mark = 0 end drawPreciseTimer( 100, 10, timer ) drawPreciseTimer( 100, 40, getTime()-timeold ) end return { run=run }