Thomas Buck преди 10 месеца
родител
ревизия
2088cc2a7b
променени са 1 файла, в които са добавени 116 реда и са изтрити 37 реда
  1. 116
    37
      pico_ota.py

+ 116
- 37
pico_ota.py Целия файл

42
         self.version_file = "ota_version"
42
         self.version_file = "ota_version"
43
         self.blacklist = []
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
     def path(self, p):
52
     def path(self, p):
46
         self.update_path = p
53
         self.update_path = p
47
 
54
 
157
             if f["path"] in self.blacklist:
164
             if f["path"] in self.blacklist:
158
                 continue
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
             gc.collect()
191
             gc.collect()
161
             if hasattr(gc, "mem_free"):
192
             if hasattr(gc, "mem_free"):
162
                 print("Collected Garbage:", gc.mem_free())
193
                 print("Collected Garbage:", gc.mem_free())
167
             if verbose:
198
             if verbose:
168
                 print("Writing " + f["path"] + " to " + self.update_path)
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
             # overwrite existing file
225
             # overwrite existing file
171
             fo = open(self.update_path + "/" + f["path"], "w")
226
             fo = open(self.update_path + "/" + f["path"], "w")
172
             fo.write(r)
227
             fo.write(r)
176
                 if verbose:
231
                 if verbose:
177
                     print("Writing " + f["path"] + " to main.py")
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
                 fo.write(r)
235
                 fo.write(r)
181
                 fo.close()
236
                 fo.close()
182
 
237
 
207
     else:
262
     else:
208
         print("No update required")
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
     i = util.getInput()
267
     i = util.getInput()
215
     t = util.getTarget(i)
268
     t = util.getTarget(i)
269
+    s = PicoText(t)
216
 
270
 
271
+def pico_ota_run(ota):
217
     gc.collect()
272
     gc.collect()
218
     print("Collected Garbage:", gc.mem_free())
273
     print("Collected Garbage:", gc.mem_free())
219
 
274
 
220
-    from pico import PicoText
221
-    s = PicoText(t)
222
     t.loop_start()
275
     t.loop_start()
276
+
277
+    s.fg = (255, 255, 0)
223
     s.setText("OTA", "bitmap6")
278
     s.setText("OTA", "bitmap6")
224
     s.draw(0, 6 * 0, False)
279
     s.draw(0, 6 * 0, False)
280
+
281
+    s.fg = (0, 255, 255)
225
     s.setText("Check", "bitmap6")
282
     s.setText("Check", "bitmap6")
226
     s.draw(0, 6 * 2, False)
283
     s.draw(0, 6 * 2, False)
284
+
227
     t.loop_end()
285
     t.loop_end()
228
 
286
 
229
     gc.collect()
287
     gc.collect()
237
 
295
 
238
     if newer:
296
     if newer:
239
         t.loop_start()
297
         t.loop_start()
298
+
299
+        s.fg = (255, 255, 0)
240
         s.setText("OTA", "bitmap6")
300
         s.setText("OTA", "bitmap6")
241
         s.draw(0, 6 * 0, False)
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
         s.draw(0, 6 * 1, False)
305
         s.draw(0, 6 * 1, False)
244
-        s.setText(commit[6 : 12], "bitmap6")
306
+
307
+        s.setText(commit[ 5 : 10], "bitmap6")
245
         s.draw(0, 6 * 2, False)
308
         s.draw(0, 6 * 2, False)
246
-        s.setText(commit[12 : 18], "bitmap6")
309
+
310
+        s.setText(commit[10 : 15], "bitmap6")
247
         s.draw(0, 6 * 3, False)
311
         s.draw(0, 6 * 3, False)
248
-        s.setText(commit[18 : 24], "bitmap6")
312
+
313
+        s.setText(commit[15 : 20], "bitmap6")
249
         s.draw(0, 6 * 4, False)
314
         s.draw(0, 6 * 4, False)
315
+
250
         t.loop_end()
316
         t.loop_end()
251
 
317
 
252
         print("Updating to:", commit)
318
         print("Updating to:", commit)
256
         machine.soft_reset()
322
         machine.soft_reset()
257
     else:
323
     else:
258
         t.loop_start()
324
         t.loop_start()
325
+
326
+        s.fg = (255, 255, 0)
259
         s.setText("OTA", "bitmap6")
327
         s.setText("OTA", "bitmap6")
260
         s.draw(0, 6 * 0, False)
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
         s.draw(0, 6 * 3, False)
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
         t.loop_end()
345
         t.loop_end()
264
 
346
 
265
     fallback = False
347
     fallback = False
289
     #    ota.update_to_commit(previous, True)
371
     #    ota.update_to_commit(previous, True)
290
     #    machine.soft_reset()
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…
Отказ
Запис