Add geofence code based on Julien Cayzac's blog posting; tidy up lcdsim a bit