Thomas Buck 10 місяці тому
джерело
коміт
ca04c1c52f
5 змінених файлів з 32 додано та 31 видалено
  1. 1
    1
      camp_pico.py
  2. 1
    1
      camp_small.py
  3. 26
    25
      manager.py
  4. 3
    3
      net.py
  5. 1
    1
      scroll.py

+ 1
- 1
camp_pico.py Переглянути файл

62
 
62
 
63
 # Main "Menu"
63
 # Main "Menu"
64
 m = Manager(t, i)
64
 m = Manager(t, i)
65
-m.add(QRScreen(t, img_data, 15.0))
65
+m.add(QRScreen(t, img_data, 15.0, None, None, (255, 255, 255), (0, 0, 0)))
66
 m.add(Solid(t, 1.0))
66
 m.add(Solid(t, 1.0))
67
 m.add(d) # HTTP Check, either "success" or "fail"
67
 m.add(d) # HTTP Check, either "success" or "fail"
68
 m.add(Solid(t, 1.0))
68
 m.add(Solid(t, 1.0))

+ 1
- 1
camp_small.py Переглянути файл

25
 #url = "http://ubabot.frubar.net"
25
 #url = "http://ubabot.frubar.net"
26
 url = "http://www.xythobuz.de"
26
 url = "http://www.xythobuz.de"
27
 
27
 
28
-scroll_speed = 15
28
+scroll_speed = 50
29
 
29
 
30
 # Need to import InputWrapper before initializing RGB Matrix on Pi
30
 # Need to import InputWrapper before initializing RGB Matrix on Pi
31
 i = util.getInput()
31
 i = util.getInput()

+ 26
- 25
manager.py Переглянути файл

42
         keys = self.input.get()
42
         keys = self.input.get()
43
 
43
 
44
         if keys["l"] and (not self.old_keys["l"]):
44
         if keys["l"] and (not self.old_keys["l"]):
45
-            c = self.screens[self.index][0]
46
-            if hasattr(c, "switch_to") and hasattr(c, "child_count"):
47
-                if c.child_count(-1):
48
-                    self.switch_to(-1, False)
49
-                else:
50
-                    c.switch_to(-1, False)
51
-            else:
52
-                self.switch_to(-1, False)
45
+            self.switch_to(-1, False)
53
         elif keys["r"] and (not self.old_keys["r"]):
46
         elif keys["r"] and (not self.old_keys["r"]):
54
-            c = self.screens[self.index][0]
55
-            if hasattr(c, "switch_to") and hasattr(c, "child_count"):
56
-                if c.child_count(1):
57
-                    self.switch_to(1, False)
58
-                else:
59
-                    c.switch_to(1, False)
60
-            else:
61
-                self.switch_to(1, False)
47
+            self.switch_to(1, False)
62
 
48
 
63
         self.old_keys = keys.copy()
49
         self.old_keys = keys.copy()
64
 
50
 
65
-    def child_count(self, i):
51
+    def child_count(self, i, update_flag):
66
         if i > 0:
52
         if i > 0:
67
-            index = int(self.index / self.step_size)
68
-            l = int(len(self.screens) / self.step_size)
53
+            if update_flag:
54
+                index = self.index
55
+                l = len(self.screens)
56
+            else:
57
+                index = int(self.index / self.step_size)
58
+                l = int(len(self.screens) / self.step_size)
59
+            #print(self.index, len(self.screens), index, l, (index >= (l - 1)))
69
             return index >= (l - 1)
60
             return index >= (l - 1)
70
         else:
61
         else:
71
             return self.index <= 0
62
             return self.index <= 0
72
 
63
 
73
-    def switch_to(self, i, update_flag):
64
+    def switch_this_to(self, i, update_flag):
74
         self.lastTime = time.time()
65
         self.lastTime = time.time()
75
 
66
 
76
         if update_flag:
67
         if update_flag:
77
-            self.done = (self.index == 0)
78
-
79
             # go through all for normal operation
68
             # go through all for normal operation
80
             self.index = (self.index + i) % len(self.screens)
69
             self.index = (self.index + i) % len(self.screens)
81
         else:
70
         else:
82
             # use step_size for button presses
71
             # use step_size for button presses
83
             self.index = int((int(self.index / self.step_size) + i) * self.step_size) % len(self.screens)
72
             self.index = int((int(self.index / self.step_size) + i) * self.step_size) % len(self.screens)
84
 
73
 
74
+        self.done = self.child_count(i, update_flag)
75
+
85
         #print("Manager ", len(self.screens), " switch to ", self.index, update_flag)
76
         #print("Manager ", len(self.screens), " switch to ", self.index, update_flag)
86
 
77
 
87
         self.screens[self.index][0].restart()
78
         self.screens[self.index][0].restart()
88
 
79
 
80
+    def switch_to(self, i, update_flag):
81
+        c = self.screens[self.index][0]
82
+        if hasattr(c, "switch_to") and hasattr(c, "child_count"):
83
+            if c.child_count(i, update_flag):
84
+                self.switch_this_to(i, update_flag)
85
+            else:
86
+                c.switch_to(i, update_flag)
87
+        else:
88
+            self.switch_this_to(i, update_flag)
89
+
89
     def draw(self):
90
     def draw(self):
90
         if self.input != None:
91
         if self.input != None:
91
             self.buttons()
92
             self.buttons()
117
     splash.draw()
118
     splash.draw()
118
     t.loop_end()
119
     t.loop_end()
119
 
120
 
120
-    m = Manager(t, i)
121
-
122
     sub = Manager(t)
121
     sub = Manager(t)
123
     sub.add(ScrollText(t, "Hello", "ib8x8u"))
122
     sub.add(ScrollText(t, "Hello", "ib8x8u"))
124
     sub.add(Solid(t, 1.0, (0, 255, 0)))
123
     sub.add(Solid(t, 1.0, (0, 255, 0)))
125
     sub.add(ScrollText(t, "World", "ib8x8u"))
124
     sub.add(ScrollText(t, "World", "ib8x8u"))
126
     sub.add(Solid(t, 1.0, (0, 0, 255)))
125
     sub.add(Solid(t, 1.0, (0, 0, 255)))
126
+
127
+    m = Manager(t, i)
127
     m.add(sub)
128
     m.add(sub)
128
-    m.add(Solid(t, 1.0))
129
+    m.add(Solid(t, 1.0, (255, 255, 0)))
129
 
130
 
130
     m.add(ScrollText(t, "This appears once", "ib8x8u"))
131
     m.add(ScrollText(t, "This appears once", "ib8x8u"))
131
     m.add(Solid(t, 1.0))
132
     m.add(Solid(t, 1.0))

+ 3
- 3
net.py Переглянути файл

29
         self.failScreen = f
29
         self.failScreen = f
30
 
30
 
31
     # Compatibility to Manager button events
31
     # Compatibility to Manager button events
32
-    def child_count(self, i):
32
+    def child_count(self, i, update_flag):
33
         self.request()
33
         self.request()
34
         if self.response:
34
         if self.response:
35
             if hasattr(self.successScreen, "child_count"):
35
             if hasattr(self.successScreen, "child_count"):
36
-                return self.successScreen.child_count(i)
36
+                return self.successScreen.child_count(i, update_flag)
37
         else:
37
         else:
38
             if hasattr(self.failScreen, "child_count"):
38
             if hasattr(self.failScreen, "child_count"):
39
-                return self.failScreen.child_count(i)
39
+                return self.failScreen.child_count(i, update_flag)
40
         return True
40
         return True
41
 
41
 
42
     # Compatibility to Manager button events
42
     # Compatibility to Manager button events

+ 1
- 1
scroll.py Переглянути файл

78
 
78
 
79
         fontName = filename[:-4]
79
         fontName = filename[:-4]
80
         s = fontName + " Abcdefgh " + fontName
80
         s = fontName + " Abcdefgh " + fontName
81
-        m.add(ScrollText(t, s, fontName, 1, 75, (0, 255, 0), (0, 0, 25)))
81
+        m.add(ScrollText(t, s, fontName, 1, 50, (0, 255, 0), (0, 0, 25)))
82
 
82
 
83
     m.restart()
83
     m.restart()
84
     util.loop(t, m.draw)
84
     util.loop(t, m.draw)

Завантаження…
Відмінити
Зберегти