Thomas Buck 1 year ago
parent
commit
93bf94c75b
2 changed files with 17 additions and 5 deletions
  1. 9
    3
      camp_small.py
  2. 8
    2
      image.py

+ 9
- 3
camp_small.py View File

25
     import util
25
     import util
26
     t = util.getTarget()
26
     t = util.getTarget()
27
 
27
 
28
+    # Loading fonts and graphics takes a while.
29
+    # So show a splash screen while the user waits.
28
     splash = SplashScreen(t)
30
     splash = SplashScreen(t)
29
     t.loop_start()
31
     t.loop_start()
30
     splash.draw()
32
     splash.draw()
31
     t.loop_end()
33
     t.loop_end()
32
 
34
 
35
+    # UbaBot is online
33
     success = Manager(t)
36
     success = Manager(t)
34
     success.add(ImageScreen(t, "drinka.gif", 0.2, 2, 20.0))
37
     success.add(ImageScreen(t, "drinka.gif", 0.2, 2, 20.0))
35
     success.add(Solid(t, 1.0))
38
     success.add(Solid(t, 1.0))
36
     success.add(QRScreen(t, url, 30.0, "Drinks:", "tom-thumb", (255, 255, 255), (0, 0, 0)))
39
     success.add(QRScreen(t, url, 30.0, "Drinks:", "tom-thumb", (255, 255, 255), (0, 0, 0)))
37
     success.add(Solid(t, 1.0))
40
     success.add(Solid(t, 1.0))
38
 
41
 
42
+    # UbaBot is offline
39
     fail = Manager(t)
43
     fail = Manager(t)
40
     fail.add(ImageScreen(t, "attention.gif", 0.2, 2, 20.0, (0, 0, 0)))
44
     fail.add(ImageScreen(t, "attention.gif", 0.2, 2, 20.0, (0, 0, 0)))
41
-    fail.add(ScrollText(t, "The UbaBot Cocktail machine is currently closed. Please come back later for more drinks!", "ib8x8u", 2))
45
+    fail.add(ScrollText(t, "The UbaBot Cocktail machine is currently closed. Please come back later for more drinks!", "lemon", 2, 75, camp_pink))
42
     fail.add(Solid(t, 1.0))
46
     fail.add(Solid(t, 1.0))
43
     fail.add(GameOfLife(t, 20, (0, 255, 0), (0, 0, 0), None, 2.0))
47
     fail.add(GameOfLife(t, 20, (0, 255, 0), (0, 0, 0), None, 2.0))
44
     fail.add(Solid(t, 1.0))
48
     fail.add(Solid(t, 1.0))
45
 
49
 
50
+    # UbaBot status checker
46
     d = CheckHTTP(url)
51
     d = CheckHTTP(url)
47
     d.success(success)
52
     d.success(success)
48
     d.fail(fail)
53
     d.fail(fail)
49
 
54
 
55
+    # Main "Menu"
50
     m = Manager(t)
56
     m = Manager(t)
51
     m.add(ScrollText(t, "#CCCAMP23", "lemon", 1, 75, camp_green))
57
     m.add(ScrollText(t, "#CCCAMP23", "lemon", 1, 75, camp_green))
52
     m.add(Solid(t, 1.0))
58
     m.add(Solid(t, 1.0))
53
     m.add(ImageScreen(t, "Favicon.png", 0, 1, 10.0))
59
     m.add(ImageScreen(t, "Favicon.png", 0, 1, 10.0))
54
     m.add(Solid(t, 1.0))
60
     m.add(Solid(t, 1.0))
55
-    m.add(ScrollText(t, "#CCCAMP23", "lemon", 1, 75, camp_pink))
61
+    m.add(d) # HTTP Check, either "success" or "fail"
56
     m.add(Solid(t, 1.0))
62
     m.add(Solid(t, 1.0))
57
-    m.add(d)
63
+    m.add(ScrollText(t, "Your advertisement could appear here. Open a Pull Request on git.xythobuz.de/thomas/rgb-matrix-visualizer or send an e-mail to thomas@xythobuz.de", "iv18x16u", 2, 70, camp_green))
58
     m.add(Solid(t, 1.0))
64
     m.add(Solid(t, 1.0))
59
 
65
 
60
     m.restart()
66
     m.restart()

+ 8
- 2
image.py View File

13
 from PIL import Image
13
 from PIL import Image
14
 import time
14
 import time
15
 import os
15
 import os
16
+import util
16
 
17
 
17
 class ImageScreen:
18
 class ImageScreen:
18
     def __init__(self, g, p, t = 0.2, i = 1, to = 10.0, bg = None):
19
     def __init__(self, g, p, t = 0.2, i = 1, to = 10.0, bg = None):
34
         # automatically crop and scale large images
35
         # automatically crop and scale large images
35
         if not self.image.is_animated and ((self.image.width > self.gui.width) or (self.image.height > self.gui.height)):
36
         if not self.image.is_animated and ((self.image.width > self.gui.width) or (self.image.height > self.gui.height)):
36
             self.image = self.image.crop(self.image.getbbox())
37
             self.image = self.image.crop(self.image.getbbox())
37
-            self.image = self.image.resize((self.gui.width, self.gui.height),
38
-                                           Image.Resampling.NEAREST)
38
+
39
+            if util.isPi():
40
+                # TODO PIL version is too old on Pi
41
+                self.image = self.image.resize((self.gui.width, self.gui.height))
42
+            else:
43
+                self.image = self.image.resize((self.gui.width, self.gui.height),
44
+                                            Image.Resampling.NEAREST)
39
 
45
 
40
             # new image object is also missing these
46
             # new image object is also missing these
41
             self.image.is_animated = False
47
             self.image.is_animated = False

Loading…
Cancel
Save