Thomas Buck vor 1 Jahr
Ursprung
Commit
93bf94c75b
2 geänderte Dateien mit 17 neuen und 5 gelöschten Zeilen
  1. 9
    3
      camp_small.py
  2. 8
    2
      image.py

+ 9
- 3
camp_small.py Datei anzeigen

@@ -25,36 +25,42 @@ if __name__ == "__main__":
25 25
     import util
26 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 30
     splash = SplashScreen(t)
29 31
     t.loop_start()
30 32
     splash.draw()
31 33
     t.loop_end()
32 34
 
35
+    # UbaBot is online
33 36
     success = Manager(t)
34 37
     success.add(ImageScreen(t, "drinka.gif", 0.2, 2, 20.0))
35 38
     success.add(Solid(t, 1.0))
36 39
     success.add(QRScreen(t, url, 30.0, "Drinks:", "tom-thumb", (255, 255, 255), (0, 0, 0)))
37 40
     success.add(Solid(t, 1.0))
38 41
 
42
+    # UbaBot is offline
39 43
     fail = Manager(t)
40 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 46
     fail.add(Solid(t, 1.0))
43 47
     fail.add(GameOfLife(t, 20, (0, 255, 0), (0, 0, 0), None, 2.0))
44 48
     fail.add(Solid(t, 1.0))
45 49
 
50
+    # UbaBot status checker
46 51
     d = CheckHTTP(url)
47 52
     d.success(success)
48 53
     d.fail(fail)
49 54
 
55
+    # Main "Menu"
50 56
     m = Manager(t)
51 57
     m.add(ScrollText(t, "#CCCAMP23", "lemon", 1, 75, camp_green))
52 58
     m.add(Solid(t, 1.0))
53 59
     m.add(ImageScreen(t, "Favicon.png", 0, 1, 10.0))
54 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 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 64
     m.add(Solid(t, 1.0))
59 65
 
60 66
     m.restart()

+ 8
- 2
image.py Datei anzeigen

@@ -13,6 +13,7 @@
13 13
 from PIL import Image
14 14
 import time
15 15
 import os
16
+import util
16 17
 
17 18
 class ImageScreen:
18 19
     def __init__(self, g, p, t = 0.2, i = 1, to = 10.0, bg = None):
@@ -34,8 +35,13 @@ class ImageScreen:
34 35
         # automatically crop and scale large images
35 36
         if not self.image.is_animated and ((self.image.width > self.gui.width) or (self.image.height > self.gui.height)):
36 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 46
             # new image object is also missing these
41 47
             self.image.is_animated = False

Laden…
Abbrechen
Speichern