Sfoglia il codice sorgente

pretty pico_ota output

Thomas Buck 1 anno fa
parent
commit
2088cc2a7b
1 ha cambiato i file con 116 aggiunte e 37 eliminazioni
  1. 116
    37
      pico_ota.py

+ 116
- 37
pico_ota.py Vedi File

@@ -42,6 +42,13 @@ class PicoOTA:
42 42
         self.version_file = "ota_version"
43 43
         self.blacklist = []
44 44
 
45
+        self.gui = None
46
+        self.text = None
47
+
48
+    def ui(self, g, t):
49
+        self.gui = g
50
+        self.text = t
51
+
45 52
     def path(self, p):
46 53
         self.update_path = p
47 54
 
@@ -157,6 +164,30 @@ class PicoOTA:
157 164
             if f["path"] in self.blacklist:
158 165
                 continue
159 166
 
167
+            if (self.gui != None) and (self.text != None):
168
+                self.gui.loop_start()
169
+
170
+                self.text.fg = (255, 255, 0)
171
+                self.text.setText("OTA", "bitmap6")
172
+                self.text.draw(0, 6 * 0, False)
173
+
174
+                self.text.fg = (255, 0, 255)
175
+                self.text.setText(commit[ 0 :  5], "bitmap6")
176
+                self.text.draw(0, 6 * 1, False)
177
+
178
+                self.text.fg = (0, 255, 255)
179
+                self.text.setText("Get", "bitmap6")
180
+                self.text.draw(0, 6 * 2, False)
181
+
182
+                self.text.fg = (0, 255, 0)
183
+                self.text.setText(f["path"][0 : 5], "bitmap6")
184
+                self.text.draw(0, 6 * 3, False)
185
+
186
+                self.text.setText(f["path"][5 : ], "bitmap6")
187
+                self.text.draw(0, 6 * 4, False)
188
+
189
+                self.gui.loop_end()
190
+
160 191
             gc.collect()
161 192
             if hasattr(gc, "mem_free"):
162 193
                 print("Collected Garbage:", gc.mem_free())
@@ -167,6 +198,30 @@ class PicoOTA:
167 198
             if verbose:
168 199
                 print("Writing " + f["path"] + " to " + self.update_path)
169 200
 
201
+            if (self.gui != None) and (self.text != None):
202
+                self.gui.loop_start()
203
+
204
+                self.text.fg = (255, 255, 0)
205
+                self.text.setText("OTA", "bitmap6")
206
+                self.text.draw(0, 6 * 0, False)
207
+
208
+                self.text.fg = (255, 0, 255)
209
+                self.text.setText(commit[ 0 :  5], "bitmap6")
210
+                self.text.draw(0, 6 * 1, False)
211
+
212
+                self.text.fg = (0, 255, 255)
213
+                self.text.setText("Write", "bitmap6")
214
+                self.text.draw(0, 6 * 2, False)
215
+
216
+                self.text.fg = (0, 255, 0)
217
+                self.text.setText(f["path"][0 : 5], "bitmap6")
218
+                self.text.draw(0, 6 * 3, False)
219
+
220
+                self.text.setText(f["path"][5 : ], "bitmap6")
221
+                self.text.draw(0, 6 * 4, False)
222
+
223
+                self.gui.loop_end()
224
+
170 225
             # overwrite existing file
171 226
             fo = open(self.update_path + "/" + f["path"], "w")
172 227
             fo.write(r)
@@ -176,7 +231,7 @@ class PicoOTA:
176 231
                 if verbose:
177 232
                     print("Writing " + f["path"] + " to main.py")
178 233
 
179
-                fo = open(self.update_path + "/" + "main.py", "w")
234
+                fo = open(self.update_path + "/main.py", "w")
180 235
                 fo.write(r)
181 236
                 fo.close()
182 237
 
@@ -207,23 +262,26 @@ def non_pico_ota_test(ota):
207 262
     else:
208 263
         print("No update required")
209 264
 
210
-def pico_ota_run(ota):
211
-    gc.collect()
212
-    print("Collected Garbage:", gc.mem_free())
213
-
265
+if on_pico:
266
+    from pico import PicoText
214 267
     i = util.getInput()
215 268
     t = util.getTarget(i)
269
+    s = PicoText(t)
216 270
 
271
+def pico_ota_run(ota):
217 272
     gc.collect()
218 273
     print("Collected Garbage:", gc.mem_free())
219 274
 
220
-    from pico import PicoText
221
-    s = PicoText(t)
222 275
     t.loop_start()
276
+
277
+    s.fg = (255, 255, 0)
223 278
     s.setText("OTA", "bitmap6")
224 279
     s.draw(0, 6 * 0, False)
280
+
281
+    s.fg = (0, 255, 255)
225 282
     s.setText("Check", "bitmap6")
226 283
     s.draw(0, 6 * 2, False)
284
+
227 285
     t.loop_end()
228 286
 
229 287
     gc.collect()
@@ -237,16 +295,24 @@ def pico_ota_run(ota):
237 295
 
238 296
     if newer:
239 297
         t.loop_start()
298
+
299
+        s.fg = (255, 255, 0)
240 300
         s.setText("OTA", "bitmap6")
241 301
         s.draw(0, 6 * 0, False)
242
-        s.setText(commit[0 : 6], "bitmap6")
302
+
303
+        s.fg = (255, 0, 255)
304
+        s.setText(commit[ 0 :  5], "bitmap6")
243 305
         s.draw(0, 6 * 1, False)
244
-        s.setText(commit[6 : 12], "bitmap6")
306
+
307
+        s.setText(commit[ 5 : 10], "bitmap6")
245 308
         s.draw(0, 6 * 2, False)
246
-        s.setText(commit[12 : 18], "bitmap6")
309
+
310
+        s.setText(commit[10 : 15], "bitmap6")
247 311
         s.draw(0, 6 * 3, False)
248
-        s.setText(commit[18 : 24], "bitmap6")
312
+
313
+        s.setText(commit[15 : 20], "bitmap6")
249 314
         s.draw(0, 6 * 4, False)
315
+
250 316
         t.loop_end()
251 317
 
252 318
         print("Updating to:", commit)
@@ -256,10 +322,26 @@ def pico_ota_run(ota):
256 322
         machine.soft_reset()
257 323
     else:
258 324
         t.loop_start()
325
+
326
+        s.fg = (255, 255, 0)
259 327
         s.setText("OTA", "bitmap6")
260 328
         s.draw(0, 6 * 0, False)
261
-        s.setText("Done", "bitmap6")
329
+
330
+        s.fg = (0, 255, 0)
331
+        s.setText("Done!", "bitmap6")
332
+        s.draw(0, 6 * 1, False)
333
+
334
+        s.fg = (255, 0, 255)
335
+        s.setText("Boot", "bitmap6")
336
+        s.draw(0, 6 * 2, False)
337
+
338
+        s.fg = (0, 255, 255)
339
+        s.setText(ota.exe_path[0 : 5], "bitmap6")
262 340
         s.draw(0, 6 * 3, False)
341
+
342
+        s.setText(ota.exe_path[5 : ], "bitmap6")
343
+        s.draw(0, 6 * 4, False)
344
+
263 345
         t.loop_end()
264 346
 
265 347
     fallback = False
@@ -289,28 +371,25 @@ def pico_ota_run(ota):
289 371
     #    ota.update_to_commit(previous, True)
290 372
     #    machine.soft_reset()
291 373
 
292
-if True: #__name__ == "__main__":
293
-    ota = PicoOTA("https://git.xythobuz.de", "thomas/rgb-matrix-visualizer")
294
-
295
-    # stuff not needed on Pico
296
-    ota.ignore(".gitignore")
297
-    ota.ignore("README.md")
298
-    ota.ignore("copy.sh")
299
-    ota.ignore("config.py")
300
-    ota.ignore("fonts")
301
-    ota.ignore("hardware")
302
-    ota.ignore("images")
303
-    ota.ignore("bdf.py")
304
-    ota.ignore("camp_small.py")
305
-    ota.ignore("gamepad.py")
306
-    ota.ignore("pi.py")
307
-    ota.ignore("test.py")
308
-
309
-    if not on_pico:
310
-        non_pico_ota_test(ota)
311
-    else:
312
-        # TODO overwriting pico_ota causes problems?!
313
-        #ota.exe("pico_ota.py")
314
-        ota.ignore("pico_ota.py")
315
-
316
-        pico_ota_run(ota)
374
+ota = PicoOTA("https://git.xythobuz.de", "thomas/rgb-matrix-visualizer")
375
+
376
+# stuff not needed on Pico
377
+ota.ignore(".gitignore")
378
+ota.ignore("README.md")
379
+ota.ignore("copy.sh")
380
+ota.ignore("config.py")
381
+ota.ignore("fonts")
382
+ota.ignore("hardware")
383
+ota.ignore("images")
384
+ota.ignore("bdf.py")
385
+ota.ignore("camp_small.py")
386
+ota.ignore("gamepad.py")
387
+ota.ignore("pi.py")
388
+ota.ignore("test.py")
389
+
390
+if not on_pico:
391
+    non_pico_ota_test(ota)
392
+else:
393
+    ota.exe("pico_ota.py")
394
+    ota.ui(t, s)
395
+    pico_ota_run(ota)

Loading…
Annulla
Salva