Thingiverse has some suitable cases (needs to be landsape) for different display sizes.
. .
Seismic Portal is a European site which gathers seismic events (earthquakes) from worldwide regional sites in real time and makes the data and history available via its API. My program takes data from the Seismic Portal API and displays it on a map of the world, keeping a local history of the most recent 100 events; usually about a day's worth.
The most recent event is shown by a flashing red / white dot on the map with text showing the magnitude, time and region it ocurred in.
I've given two options for time - Either the actual time of the event as UTC or the time it first appeared on the data feed as your local time (as long as your config offset is correct) which will be a few minutes delayed.
Older events are displayed as slowly fading from bright red to dull orange as they move down the 100 event history.
You will rarely see all 100 as newer events at the same location will display on top of older ones. It does give a very good show of the currently most active regions in the world. California usually has several low level quakes a day and also quite a few show up in more inland states which a bit of research told me are caused by fracking and high-pressure disposal of oil industry waste water into underground fissures.
You'll need to download the attached image W1.bmp into your Program directory for the map.
Code: [Local Link Removed for Guests]
' Quakes V1.3
'
' Fixed magnitude less than 1.5 bug
' Now displaying previous 100 events
' Colour scheme now bright yellow for new fading to dull red for older events
' Added (rough) count of how many events in past 12 hours at bottom RHS
' White dot indicating API server access now at top middle
' Tweaked magnitude dot size for better display
' Improved line splitting for long region names
'
pause 2000
TFT.INIT 16, 4, 3
'May need TFT.INIT 16, 4, 1 depending on screen orientation.
pause 2000
wlog "Rebooted at " + Time$ + " on " + Date$
' Various variable definitions.
FName$ = "/program/data.txt"
OldRef$ = ""
dim Hist(100,3)
PLat = 0 : PLon = 0 : PMag = 0
EOL$ = chr$(10)
SecCnt = 0
FreqMA = 1200
' Display bare map on screen.
TFT.BMP "/W1.bmp"
if file.exists(FName$) = 1 then
' Read event history from file into array.
for FCnt = 1 to 100
FLine$ = file.read$(FName$,FCnt)
Hist(FCnt,0) = val(word$(FLine$,1,"|"))
Hist(FCnt,1) = val(word$(FLine$,2,"|"))
Hist(FCnt,2) = val(word$(FLine$,3,"|"))
next FCnt
end if
gosub QueryServer
ONWGETASYNC MsgReceived
timer0 500, Blink
timer1 60000, QueryServer
wait
QueryServer:
' Request data from SeismicPortal API - No key needed.
' JSON is an option but chose simple delimited text string output.
' Requesting only most recent event.
' White dot in top centre of screen - Clears when data received.
TFT.CIRCLE 160, 6, 3,&HFFFF,1
print Time$
wgetasync("seismicportal.eu/fdsnws/event/1/query?limit=1&format=text",443,0,1)
return
MsgReceived:
Res$ = WGETRESULT$
'Option.WDTReset
wlog Time$
wlog Res$
TFT.CIRCLE 160, 6, 3,&H3475,1
Line$ = WORD$(RES$, 2, chr$(10))
wlog line$
Ref$ = word$(Line$,1,"|")
'wlog time$ + " " + Line$
' Only process result if it is a new event.
if (Ref$ <> OldRef$) and (val(Ref$) <> 0) then
OldRef$ = Ref$
TD$ = word$(Line$,2,"|")
EDate$ = left$(TD$,10)
' Uncomment the first line for actual event time from API as UTC or use 2nd line
' for your local time (assuming timezone set correctly) delayed by a few minutes.
' ETime$ = mid$(TD$,12,5)
ETime$ = left$(time$,5)
EMag$ = word$(Line$,11,"|")
ELoc$ = word$(Line$,13,"|")
Lat = val(word$(Line$,3,"|"))
Lon = val(word$(Line$,4,"|"))
' Wilder's moving average - Does not require storing all previous values.
' Response is similar to EMA with twice the period.
FreqMA = ((FreqMA * 9) + SecCnt)/10
SecCnt = 0
' Load map to clear display, then print text info about event.
pause 200
TFT.BMP "/W1.bmp"
pause 500
TFT.TEXT.COL &HFFE0
TFT.TEXT.SIZE 3
TFT.TEXT.POS 8,6
TFT.PRINT EMag$
TFT.TEXT.SIZE 2
TFT.TEXT.POS 254,6
TFT.PRINT ETime$
TFT.TEXT.POS 280,220
' MA value scaled up to give approx. events in last 12 hours.
TFT.PRINT str$(cint(2 * 43200 / FreqMA))
' Break location text neatly and display on 2 lines if long.
if len(ELoc$) <= 22 then
TFT.TEXT.POS 4,220
TFT.PRINT ELoc$
else
sp = instr(14,ELoc$," ")
TFT.TEXT.POS 4,206
TFT.PRINT left$(ELoc$,sp)
TFT.TEXT.POS 4,223
TFT.PRINT right$(ELoc$,len(ELoc$) - sp)
endif
' Shift array.
For Cnt = 0 to 99
Hist(Cnt,0) = Hist(Cnt+1,0)
Hist(Cnt,1) = Hist(Cnt+1,1)
Hist(Cnt,2) = Hist(Cnt+1,2)
next Cnt
' Convert longitude and latitude of event to screen co-ordinates.
' Size of plotted circle is proportional to quake magnitude.
PLon = 151 + (0.889 * Lon)
PLat = 157 - ((0.75 * Lat) + (Lat * 0.0475)^3)
'PMag = cint(val(EMag$)-2)
PMag = cint(val(EMag$) * 0.8)
if PMag <= 1 then PMag = 1
' Write new event to array.
Hist(100,0) = PLon
Hist(100,1) = PLat
Hist(100,2) = PMag
' Plot event history from array.
for HCnt = 0 to 100
RedVal = 155 + HCnt
GrnVal = 55 + (HCnt * 2)
BluVal = 0
' Colour of plotted point fades from bright yellow through orange to dull red with age.
TFT.CIRCLE Hist(HCnt,0),Hist(HCnt,1),Hist(HCnt,2),TFT.RGB(RedVal,GrnVal,BluVal),1
next HCnt
' Plot most recent event.
TFT.CIRCLE PLon,Plat,PMag,&HF800,1
' Store array to file.
x = file.delete(FName$)
for FCnt = 1 to 100
FLine$ = str$(Hist(FCnt,0)) + "|" + str$(Hist(FCnt,1)) + "|" + str$(Hist(FCnt,2)) + EOL$
file.append FName$,FLine$
next FCnt
endif
return
Blink:
' Flashing red / yellow dot to mark most recent event.
Flsh = (Flsh + 1) mod 2
if Flsh = 0 then
TFT.CIRCLE PLon,PLat,PMag,&HFFE0,1
SecCnt = SecCnt + 1 ' Counting seconds for moving average.
else
TFT.CIRCLE PLon,PLat,PMag,&HF800,1
endif
return