I've finished writing 3 new CHDK functions for Lua to convert and display tv96, av96, and sv96 to human readable strings. Please take a look at them and let me know if you want to add them to the trunk as is. If so, I'll add them for uBasic and post a patch. Here's a description of the functions, a test Lua script that uses them, and the log produced by the script (attached):
tv96_to_string(tv96 [,ndig] [,scale])
ndig: 0..9 precision (digits after decimal point) 1/x format starts at 1/4 second
10..19 no 1/x format precision is last digit (%10)
-1: (default) automatic ndig Change of 1 tv96 unit always gives unique result (see log)
-2: automatic ndig No 1/x format
scale: (default 1) Result multiplier. I.E. 1000 for msec
av96_to_string(av96 [,ndig] [,scale])
ndig: 0..9 precision (digits after decimal point)
-1: (default) automatic ndig Change of 1 av96 unit always gives unique result
scale: (default 1) Result multiplier
sv96_to_string(sv96 [,ndig] [,scale])
ndig: 0..9 precision (digits after decimal point) MARKET ISO result
10..19 REAL ISO result precision is last digit (%10)
-1: (default) automatic ndig MARKET ISO
-2: automatic ndig REAL ISO
scale: (default 1) Result multiplier
--[[
@title ApexStr 1
@param d Dummy
@default d 1
--]]
print_screen(1)
print("Apex to String Test")
set_console_autoredraw(-1)
print()
av=aperture_to_av96(1000)
avlast=aperture_to_av96(40000)
print("av96 from",av,"to",avlast)
av=0
avlast=1000 -- aperture_to_av96 overflows
print("av96 | aperture_to_av96 | to_aperture | to_string 3 | to_string -1")
repeat
f0=av96_to_aperture(av)
print(string.format("%d | %d | %d | %s | %s",av,aperture_to_av96(f0),f0,av96_to_string(av,3),av96_to_string(av,-1)))
av=av+1
until av>avlast
print()
sv=iso_to_sv96(25);
svlast=iso_to_sv96(6400);
print("sv96 from",sv,"to",svlast)
print("sv96 | to_iso | to_string 10 | to_string -2 | to_string -1")
repeat
print(string.format("%d | %s | %s | %s | %s",sv,sv96_to_iso(sv),sv96_to_string(sv,10),sv96_to_string(sv,-2),sv96_to_string(sv)))
sv=sv+1
until sv>svlast
print()
tv=seconds_to_tv96(256,1)
tvlast=seconds_to_tv96(1,8192)
print("tv96 from",tv,"to",tvlast)
print("tv96 | to_usec | to_string 10,1000000 | to_string -2,1000 | to_string -1")
repeat
print(string.format("%d | %s | %s | %s | %s",tv,tv96_to_usec(tv),tv96_to_string(tv,10,1000000),tv96_to_string(tv,-2,1000),tv96_to_string(tv)))
tv=tv+1
until tv>tvlast
set_console_autoredraw(1)