Index: src/daemon/gnuboat
===================================================================
--- src/daemon/gnuboat	(revision 0e5045f4468f7e9d01b332b029704e36ab075783)
+++ src/daemon/gnuboat	(revision 92ac6bc6d06bd30b4764f44548b592bb09f608ce)
@@ -53,4 +53,11 @@
 
 shutdownRequested = None
+latitude = None
+longitude = None
+speedThroughWater = None
+speedOverGround = None
+waterDepth = None
+waterTemperature = None
+gpsFix = None
 
 # Copied from https://gist.github.com/wolfg1969/4653340
@@ -86,4 +93,87 @@
       pass
 
+"""@class DisplayHandler
+"""
+class DisplayHandler(threading.Thread):
+  def __init__(self, displayperiod):
+    threading.Thread.__init__(self)
+    self._epd = EPD()
+    self._epd.clear()
+    self._updatePeriod = displayperiod
+    self._running = True
+    
+  def stop(self):
+    self._running = False
+    
+  def run(self):
+    global latitude
+    global longitude
+    global speedThroughWater
+    global speedOverGround
+    global waterDepth
+    global waterTemperature
+    global gpsFix
+
+    try:
+      while self._running:
+        self.displayValues(epd, speedThroughWater, speedOverGround, waterDepth, waterTemperature, gpsFix)
+        time.sleep(self._updatePeriod)
+    except StopIteration:
+      pass
+
+  def displayValues(epd, speedThroughWater, speedOverGround, waterDepth, waterTemperature, gpsFix):
+    if not epdEnabled:
+      return
+
+    # requires dejavu package!!!!
+    fontValues = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 34)
+    fontTitles = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 24)
+
+    # initially set all white background
+    image = Image.new('1', epd.size, WHITE)
+    width, height = image.size
+
+    rowHeightTitles = 25
+    rowHeightValues = float(height - 2 * rowHeightTitles - 3 * marginVertical) / 2.0
+    columnWidthUnit = 30
+    columnWidthValues = int(float(width - 3 * marginHorizontal - 2 * columnWidthUnit) / 2.0)
+
+    draw = ImageDraw.Draw(image)
+    # draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE)
+
+    x = marginHorizontal
+    y = marginVertical
+    draw.text((x, y), "STW", fill=BLACK, font=fontTitles)
+    if speedThroughWater is not None:
+      draw.text((x, y + rowHeightTitles), str(speedThroughWater), fill=BLACK, font=fontValues)
+    draw.text((x + columnWidthValues, y + rowHeightTitles * 1.4), "kts", fill=BLACK, font=fontTitles)
+
+    x = x + marginHorizontal + columnWidthValues + columnWidthUnit
+    draw.text((x, y), "SOG", fill=BLACK, font=fontTitles)
+    if speedOverGround is not None:
+      draw.text((x, y + rowHeightTitles), str(speedOverGround), fill=BLACK, font=fontValues)
+    draw.text((x + columnWidthValues, y + rowHeightTitles * 1.4), "kts", fill=BLACK, font=fontTitles)
+
+    x = marginHorizontal
+    y = y + rowHeightTitles + rowHeightValues + marginVertical
+    draw.text((x, y), "Depth", fill=BLACK, font=fontTitles)
+    if waterDepth is not None:
+      draw.text((x, y + rowHeightTitles), str(waterDepth), fill=BLACK, font=fontValues)
+    draw.text((x + int(float(columnWidthValues) / 1.5), y + rowHeightTitles * 1.4), "m", fill=BLACK, font=fontTitles)
+
+    x = x + marginHorizontal + columnWidthValues + columnWidthUnit
+    draw.text((x, y), "Water", fill=BLACK, font=fontTitles)
+    if waterTemperature is not None:
+      draw.text((x, y + rowHeightTitles), str(waterTemperature), fill=BLACK, font=fontValues)
+    draw.text((x + int(float(columnWidthValues) / 1.5), y + rowHeightTitles * 1.4), "C", fill=BLACK, font=fontTitles)
+
+    x = int((x + marginHorizontal + columnWidthValues) * 0.93)
+    draw.text((x, y), "Fix", fill=BLACK, font=fontTitles)
+    if gpsFix is not None:
+      draw.text((x, y + rowHeightTitles), str(gpsFix), fill=BLACK, font=fontValues)
+  
+    epd.display(image)
+    epd.update()
+
 def createDatabase(databaseFile):
   rrdDataSources = [ 'DS:latitude:GAUGE:15:-90:90',
@@ -109,53 +199,4 @@
                    rrdDataSources,
                    rrdArchives)
-
-def displayValues(epd, speedThroughWater, speedOverGround, waterDepth, waterTemperature, gpsFix):
-  if not epdEnabled:
-    return
-
-  # requires dejavu package!!!!
-  fontValues = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 34)
-  fontTitles = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 24)
-
-  # initially set all white background
-  image = Image.new('1', epd.size, WHITE)
-  width, height = image.size
-
-  rowHeightTitles = 25
-  rowHeightValues = float(height - 2 * rowHeightTitles - 3 * marginVertical) / 2.0
-  columnWidthUnit = 30
-  columnWidthValues = int(float(width - 3 * marginHorizontal - 2 * columnWidthUnit) / 2.0)
-
-  draw = ImageDraw.Draw(image)
-  # draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE)
-
-  x = marginHorizontal
-  y = marginVertical
-  draw.text((x, y), "STW", fill=BLACK, font=fontTitles)
-  draw.text((x, y + rowHeightTitles), str(speedThroughWater), fill=BLACK, font=fontValues)
-  draw.text((x + columnWidthValues, y + rowHeightTitles * 1.4), "kts", fill=BLACK, font=fontTitles)
-
-  x = x + marginHorizontal + columnWidthValues + columnWidthUnit
-  draw.text((x, y), "SOG", fill=BLACK, font=fontTitles)
-  draw.text((x, y + rowHeightTitles), str(speedOverGround), fill=BLACK, font=fontValues)
-  draw.text((x + columnWidthValues, y + rowHeightTitles * 1.4), "kts", fill=BLACK, font=fontTitles)
-
-  x = marginHorizontal
-  y = y + rowHeightTitles + rowHeightValues + marginVertical
-  draw.text((x, y), "Depth", fill=BLACK, font=fontTitles)
-  draw.text((x, y + rowHeightTitles), str(waterDepth), fill=BLACK, font=fontValues)
-  draw.text((x + int(float(columnWidthValues) / 1.5), y + rowHeightTitles * 1.4), "m", fill=BLACK, font=fontTitles)
-
-  x = x + marginHorizontal + columnWidthValues + columnWidthUnit
-  draw.text((x, y), "Water", fill=BLACK, font=fontTitles)
-  draw.text((x, y + rowHeightTitles), str(waterTemperature), fill=BLACK, font=fontValues)
-  draw.text((x + int(float(columnWidthValues) / 1.5), y + rowHeightTitles * 1.4), "C", fill=BLACK, font=fontTitles)
-
-  x = int((x + marginHorizontal + columnWidthValues) * 0.93)
-  draw.text((x, y), "Fix", fill=BLACK, font=fontTitles)
-  draw.text((x, y + rowHeightTitles), str(gpsFix), fill=BLACK, font=fontValues)
-  
-  epd.display(image)
-  epd.update()
 
 def checkShutdownRequest(shutdownFile):
@@ -189,4 +230,11 @@
   global logperiod
   global displayperiod
+  global latitude
+  global longitude
+  global speedThroughWater
+  global speedOverGround
+  global waterDepth
+  global waterTemperature
+  global gpsFix
 
   try:                                
@@ -237,7 +285,7 @@
   createDatabase(rrdfile)
 
+  displayHandler = None
   if epdEnabled:
-    epd = EPD()
-    epd.clear()
+    displayHandler = DisplayHandler(displayperiod)
 
   gpsp = GpsdPoller()
@@ -258,7 +306,4 @@
       # update rrd database for the webservice
       rrdtool.update(rrdfile, "N:%s:%s:%s:%s:%s:%s:%s" % (latitude, longitude, speedThroughWater, speedOverGround, waterDepth, waterTemperature, gpsFix))
-      # update display, if needed
-      if epdEnabled and round(time.time(),0) % displayperiod == 0:
-        displayValues(epd, speedThroughWater, speedOverGround, waterDepth, waterTemperature, gpsFix)
       #check for shutdown request
       checkShutdownRequest(shutdownfile)
@@ -267,4 +312,7 @@
     gpsp.stop()
     gpsp.join() # wait for the thread to finish what it's doing
+    if displayHandler is not None:
+      displayHandler.stop()
+      displayHandler.join() # wait for the thread to finish what it's doing
 
 if __name__ == "__main__":
Index: src/daemon/gnuboat.service
===================================================================
--- src/daemon/gnuboat.service	(revision 92ac6bc6d06bd30b4764f44548b592bb09f608ce)
+++ src/daemon/gnuboat.service	(revision 92ac6bc6d06bd30b4764f44548b592bb09f608ce)
@@ -0,0 +1,16 @@
+[Unit]
+Description=GNUBoat logging service
+After=epd-fuse
+After=gpsd
+
+[Service]
+Type=simple
+User=root
+Group=root
+WorkingDirectory=/tmp
+ExecStart=/usr/bin/gnuboat -r /usr/share/gnuboat/webservice/data/gnuboat.rrd -s /var/spool/gnuboat/shutdown.request
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
