Code: Select all
option base 1 ! option angle degrees
graphics ! graphics clear .8,.8,.8
fill color .8,.8,.8 ! draw color 0,0,0
draw font size 30 ! running=0
button "start" title "start" at 20,400 size 120,40
dt=0 ! nrec=0
iter:
if not running then
if not button_pressed("start") then iter
button "start" set title "stop"
if file_exists("abcd0") then file "abcd0" delete
if file_exists("abcd1") then file "abcd1" delete
running=1 ! set gps on
do ! get gps lat y ! until y>0 ' get a gps fix
ho=current_hour()
ts=get_seconds(ho)
end if
if button_pressed("start") then
file "abcd0" print nrec
button "start" delete
set gps off
tachograph(nrec)
stop
end if
t=get_seconds(ho)
if t<to+dt then goto iter
repeat: if not gps_count() then repeat ' new gps message
while gps_count()>0 ! get gps spd v ! end while
if v<0 then repeat
to=t ! nrec+=1
file "abcd1" print t-ts,3.6*v
fill rect 50,100 to 600,200
draw text t-ts & " " & 3.6*v at 50,100
goto iter
end
def tachograph(nrec)
dim t(nrec),v(nrec)
vmax=0 ! m=160 ! lab=.8
for i=1 to nrec
file "abcd1" input t(i),v(i)
if vmax<v(i) then vmax=v(i)
next i
draw color 0,0,.8 ! fill color .9,.9,.9
fill circle m,m size 150
fill color 0,0,.8
fill circle m,m size 3
draw size 3
draw circle m,m size 150
draw size 1
draw line 10,m to 310,m
draw line m,10 to m,310
draw size 2 ! draw dash 5
draw font size 10
if vmax<30 then
fac=5
draw color .2,.2,.2
draw circle m,m size 50
draw circle m,m size 100
draw text "10" at 154,110
draw text "20" at 154,60
draw text "30" at 154,12
else
fac=1
draw color 1,0,0
draw circle m,m size 30
draw circle m,m size 50
draw color .5,0,0
draw circle m,m size 80
draw circle m,m size 120
draw color .2,.2,.2
draw text "30" at 154,130
draw text "50" at 154,110
draw text "80" at 154,80
draw text "120" at 148,40
draw text "150" at 148,12
end if
da=350/t(nrec) ! a=0 ! vgem=v(1)
draw color 0,0,0 ! draw size 1
draw dash 0
draw to m,m
for i=2 to nrec
a+=da ! vgem=lab*v(i)+(1-lab)*vgem
x=160+fac*vgem*sin(a)
y=160-fac*vgem*cos(a)
draw line to x,y
next i
end def
def get_seconds(ho)
h=current_hour()-ho
m=current_minute()
s=current_second()
return 3600*h+60*m+s
end def