Tachograph

Post Reply
Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Tachograph

Post by Henko »

Merely a prototype, but functioning. Maybe someone has interest to beautify the graphics and add functionality

image.jpg
image.jpg (122.3 KiB) Viewed 3243 times

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

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Tachograph

Post by Mr. Kibernetik »

I am a bit curious about this line:

Code: Select all

do ! get gps lat y ! until y>0   ' get a gps fix
For those who reside in southern hemisphere can this be a constant freeze because of y < 0?

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Tachograph

Post by Henko »

Mr. Kibernetik wrote:I am a bit curious about this line:

Code: Select all

do ! get gps lat y ! until y>0   ' get a gps fix
For those who reside in southern hemisphere can this be a constant freeze because of y < 0?
Yes, i guess the until statement should be : until y<>-1

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Tachograph

Post by Dutchman »

May I suggest a linear plot of the speed, not limited in length, and a geographic plot of the trip. :?:

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Tachograph

Post by Henko »

Dutchman wrote:May I suggest a linear plot of the speed, not limited in length, and a geographic plot of the trip. :?:
I made a linear plot this very afternoon (coincidence :) ), but trew it away. It would need additional functionality, like a means to indicate certain locations. For tracking I use an app "Gps Motion x".

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Tachograph

Post by Dutchman »

What is the problem with plotting without certain cities etc.?
You could also plot it like the examples in "Mercator World" viewtopic.php?f=20&t=419&hilit=mercator
The maps of the standard iPad app "maps" ("kaarten") are in Mercator projection.
Last edited by Dutchman on Thu Jan 19, 2023 3:46 pm, edited 1 time in total.

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Tachograph

Post by Henko »

"Mercator world" is out of reach for me (I don't use dropbox).
Are you saying that the maps of "kaarten" can be imported in the SB environment?

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Tachograph

Post by Dutchman »

As photo via screenshot.
Files on dropbox can be downloaded and entered in SB via copy/paste

Post Reply