From f2c5a6fe91619b3ea70fdc84dd981a7ce4e13b74 Mon Sep 17 00:00:00 2001 From: "Peter D. Gray" Date: Wed, 2 Aug 2023 16:16:45 -0400 Subject: [PATCH] more --- shared/glob.py | 6 +++--- shared/login.py | 4 ++++ shared/manifest_q1.py | 4 +++- shared/q1.py | 17 ++++++++++------- shared/sim_display.py | 1 + shared/st7788.py | 18 ++++++++++-------- shared/ux.py | 9 +++++---- 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/shared/glob.py b/shared/glob.py index 5af629cc..0c30e97d 100644 --- a/shared/glob.py +++ b/shared/glob.py @@ -17,13 +17,13 @@ hsm_active = None # setup by main.py, expected to always be present settings = None -# PSRAM (on Mk4 only) +# PSRAM PSRAM = None -# Virtual Disk (Mk4) +# Virtual Disk VD = None -# NFC interface (Mk4, and can be disabled) +# NFC interface (Mk4, can be disabled) NFC = None # QR scanner (Q1 only) diff --git a/shared/login.py b/shared/login.py index bfd023c3..d784d876 100644 --- a/shared/login.py +++ b/shared/login.py @@ -115,6 +115,10 @@ class LoginUX: if self.pin: self.pin = self.pin[:-1] self.show_pin() + else: + # clear input, because they have a BS key + self.pin = '' + self.show_pin() elif ch == KEY_SELECT: if len(self.pin) < MIN_PIN_PART_LEN: diff --git a/shared/manifest_q1.py b/shared/manifest_q1.py index fbeb8305..3d0b5b80 100644 --- a/shared/manifest_q1.py +++ b/shared/manifest_q1.py @@ -7,6 +7,7 @@ freeze_as_mpy('', [ 'scanner.py', 'lcd_display.py', 'st7788.py', + 'gpu.py', 'vdisk.py', 'nfc.py', 'ndef.py', @@ -17,8 +18,9 @@ freeze_as_mpy('', [ # Optimize data-like files, since no need to debug them. freeze_as_mpy('', [ 'graphics.py', # TODO remove - 'graphics_mk4.py', # TODO remove + #'graphics_mk4.py', # TODO remove 'graphics_q1.py', 'font_iosevka.py', + 'gpu_binary.py', # remove someday? ], opt=3) diff --git a/shared/q1.py b/shared/q1.py index ab0e2cb2..9b3f79d9 100644 --- a/shared/q1.py +++ b/shared/q1.py @@ -16,21 +16,24 @@ def init0(): mk4_init0() - from scanner import QRScanner - glob.SCAN = QRScanner() - # XXX do not ship like this XXX - ckcc.vcp_enabled(True) - print("REPL enabled") + ckcc.vcp_enabled(True); print("REPL enabled") + + # Setup various hardware features of the Q1 + # - try to continue in case of errors/hardware faults + try: + from scanner import QRScanner + glob.SCAN = QRScanner() + except: pass try: setup_adc() - print('Batt volt: %s' % get_batt_level()) + #print('Batt volt: %s' % get_batt_level()) except BaseException as exc: sys.print_exception(exc) def setup_adc(): - # configure VREF source as internap 2.5v + # configure VREF source as internal 2.5v VREF_LAYOUT = { "CSR": 0 | uctypes.UINT32, "CCR": 4 | uctypes.UINT32, diff --git a/shared/sim_display.py b/shared/sim_display.py index 6e8b294d..d1cbbe90 100644 --- a/shared/sim_display.py +++ b/shared/sim_display.py @@ -3,6 +3,7 @@ # DEBUG ONLY -- only installed for debug builds # Hack to monitor screen contents, as text. # Import this file to install the hacks. +# import ux, version global contents, full_contents, story diff --git a/shared/st7788.py b/shared/st7788.py index 7d25292b..b3282fae 100644 --- a/shared/st7788.py +++ b/shared/st7788.py @@ -15,13 +15,12 @@ CASET = const(0x2a) RASET = const(0x2b) RAMWR = const(0x2c) -# TODO: move fully into C code -# - w/ zlib expansion -# - with window control -# - with font lookups / a text-only layer -# - maybe: with QR module expansion? +# Lots of drawing code now in C code: +# - zlib expansion +# - font lookups / a text-only layer +# - QR module expansion # - clear to pixel value -# - palette + xy/wh + nible-packed palette lookup (for font) +# - (MAYBE NOT) palette + xy/wh + nible-packed palette lookup (for font) # - see stm32/COLDCARD_Q1/modlcd.c for code import lcd @@ -34,8 +33,11 @@ class ST7788(): self.spi = machine.SPI(1, baudrate=60_000_000, polarity=0, phase=0) #reset_pin = Pin('LCD_RESET', Pin.OUT) # not using - self.dc = Pin('LCD_DATA_CMD', Pin.OUT, value=0) - self.cs = Pin('LCD_CS', Pin.OUT, value=1) + #self.dc = Pin('LCD_DATA_CMD', Pin.OUT, value=0) + #self.cs = Pin('LCD_CS', Pin.OUT, value=1) + # do not change careful GPIO setup from bootloader + self.dc = Pin('LCD_DATA_CMD') + self.cs = Pin('LCD_CS') if 0: # BUST - just fades away diff --git a/shared/ux.py b/shared/ux.py index fa040883..a0500a3d 100644 --- a/shared/ux.py +++ b/shared/ux.py @@ -199,13 +199,14 @@ async def ux_show_story(msg, title=None, escape=None, sensitive=False, strict_es top = max(0, len(lines)-(STORY_H//2)) elif ch == '0' or ch == KEY_HOME: top = 0 - elif ch == '7' or ch == KEY_PAGE_UP: + elif ch == '7' or ch == KEY_PAGE_UP or ch == KEY_UP: top = max(0, top-STORY_H) - elif ch == '9' or ch == KEY_PAGE_DOWN: + elif ch == '9' or ch == KEY_PAGE_DOWN or ch == KEY_DOWN: top = min(len(lines)-2, top+STORY_H) - elif ch == '5' or ch == KEY_UP: + elif ch == '5': + # line up/down only on Mk4; too slow w/ Q1's big screen top = max(0, top-1) - elif ch == '8' or ch == KEY_DOWN: + elif ch == '8': top = min(len(lines)-2, top+1) elif not strict_escape: if ch in { KEY_NFC, KEY_QR }: