|
4 | 4 | # SPDX-License-Identifier: MIT
|
5 | 5 | """Library for the Adafruit PyCamera with OV5640 autofocus module"""
|
6 | 6 |
|
| 7 | +# pylint: disable=too-many-lines |
| 8 | + |
7 | 9 | import os
|
8 | 10 | import struct
|
9 | 11 | import time
|
@@ -276,6 +278,32 @@ def make_debounced_expander_pin(pin_no):
|
276 | 278 |
|
277 | 279 | self.mute = make_expander_output(_AW_MUTE, False)
|
278 | 280 |
|
| 281 | + self.check_for_update_needed() |
| 282 | + |
| 283 | + def check_for_update_needed(self): |
| 284 | + """Check whether CIRCUITPY is too big, indicating it was created |
| 285 | + by a version of CircuitPython older than 9.0.0 beta 2. |
| 286 | + If so display and print a message and hang. |
| 287 | + """ |
| 288 | + circuitpy_stat = os.statvfs("/") |
| 289 | + # CIRCUITPY should be 960KB or so. >1MB is too large |
| 290 | + # and indicates an older version of CircuitPython |
| 291 | + # created the filesystem. |
| 292 | + if circuitpy_stat[1] * circuitpy_stat[2] > 1000000: |
| 293 | + message = """\ |
| 294 | +CIRCUITPY problem. |
| 295 | +Backup. Update CPy |
| 296 | +to >= 9.0.0-beta.2. |
| 297 | +Reformat: |
| 298 | + import storage |
| 299 | + storage.erase_ |
| 300 | +filesystem() |
| 301 | +See Learn Guide.""" |
| 302 | + self.display_message(message, color=0xFFFFFF, scale=2, full_screen=True) |
| 303 | + print(message) |
| 304 | + while True: |
| 305 | + pass |
| 306 | + |
279 | 307 | def make_camera_ui(self):
|
280 | 308 | """Create displayio widgets for the standard camera UI"""
|
281 | 309 | self._sd_label = label.Label(
|
@@ -678,13 +706,15 @@ def deinit_display(self):
|
678 | 706 | self._display_bus = None
|
679 | 707 | self.display = None
|
680 | 708 |
|
681 |
| - def display_message(self, message, color=0xFF0000, scale=3): |
| 709 | + def display_message(self, message, color=0xFF0000, scale=3, full_screen=False): |
682 | 710 | """Display a message on the TFT"""
|
683 | 711 | text_area = label.Label(terminalio.FONT, text=message, color=color, scale=scale)
|
684 |
| - text_area.anchor_point = (0.5, 0.5) |
| 712 | + text_area.anchor_point = (0, 0) if full_screen else (0.5, 0.5) |
685 | 713 | if not self.display:
|
686 | 714 | self.init_display()
|
687 |
| - text_area.anchored_position = (self.display.width / 2, self.display.height / 2) |
| 715 | + text_area.anchored_position = ( |
| 716 | + (0, 0) if full_screen else (self.display.width / 2, self.display.height / 2) |
| 717 | + ) |
688 | 718 |
|
689 | 719 | # Show it
|
690 | 720 | self.splash.append(text_area)
|
@@ -994,6 +1024,7 @@ def __init__(self, init_autofocus=True):
|
994 | 1024 | self.init_neopixel()
|
995 | 1025 | self.init_display()
|
996 | 1026 | self.init_camera(init_autofocus)
|
| 1027 | + |
997 | 1028 | try:
|
998 | 1029 | self.mount_sd_card()
|
999 | 1030 | except Exception as exc: # pylint: disable=broad-exception-caught
|
|
0 commit comments