source: src/python/bin/gnuboat-splashscreen@ f48b5ac

debian/bullseye debian/jessie
Last change on this file since f48b5ac was cfdd201, checked in by Joachim Langenbach <joachim.langenbach@…>, 9 years ago

Improved gnuboat python daemon, which now uses modules and setup.py to be packaged.
Also it put outs the nmea1983 messages for GPS rmc (current position and speed) and DPT (depth)
to an log file

  • Property mode set to 100755
File size: 2.2 KB
Line 
1#!/usr/bin/python
2'''
3 Copyright (C) 2016 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17'''
18
19import sys
20import os
21import getopt
22try:
23 from PIL import Image
24 from PIL import ImageOps
25 from EPD import EPD
26 epdEnabled = True
27except:
28 epdEnabled = False
29
30def displayImage(epd, imageFilePath):
31 image = Image.open(imageFilePath)
32 image = ImageOps.grayscale(image)
33 imageResized = image.resize((epd.width, epd.height))
34 imageBlackWhite = imageResized.convert("1", dither=Image.FLOYDSTEINBERG)
35 epd.display(imageBlackWhite)
36 epd.update()
37
38def usage():
39 print "Usage of gnuboat-splashscreen:"
40 print " gnuboat-splashscreen [-h] -i PATH_TO_IMAGE_TO_DISPLAY"
41 print ""
42 print " -h --help Print this help"
43 print " -i --image Path to the image, which should be displayed"
44 sys.exit()
45
46def main(argv):
47 image = ""
48 try:
49 opts, args = getopt.getopt(argv, "hi:", ["help", "image="])
50 except getopt.GetoptError:
51 usage()
52 sys.exit(2)
53
54 for option, argument in opts:
55 if option == ("-h", "--help"):
56 usage()
57 sys.exit()
58 elif option in ("-i", "--image"):
59 image = argument
60 else:
61 assert False, "unhandled option"
62
63 if not os.path.exists(image):
64 print "Image %s not found" % image
65 print ""
66 usage()
67 sys.exit(2)
68
69 if not epdEnabled:
70 print "Could not initialize EPD or PIL python packages"
71 sys.exit(2)
72
73 epd = EPD()
74 epd.clear()
75 displayImage(epd, image)
76
77if __name__ == "__main__":
78 main(sys.argv[1:])
Note: See TracBrowser for help on using the repository browser.