GPU take/give/animating

This commit is contained in:
Peter D. Gray 2024-01-26 10:51:04 -05:00
parent cd8733e5c8
commit 5f41a73938
No known key found for this signature in database
GPG Key ID: A2DCD558C2BE5D7C
3 changed files with 20 additions and 11 deletions

View File

@ -25,6 +25,7 @@ wallet (on testnet, always with the same seed). But there are other options:
- `-q` => boot and drop into REPL; does nothing else, no setup
- `-f -w` => boot like a unit that hasn't left factory yet
- `-p` => pretend we don't know the seed words (xprv import) and so menus are different
- `-g` => don't skip login sequence
- `--ms` => define a 2-of-4 multisig wallet, and start off in multisig wallet menu; cosigners are
"Me", "Myself", "And I" and empty string. BIP45 path.
- add `--p2wsh` or `--wrap` for the other two address types
@ -33,7 +34,6 @@ wallet (on testnet, always with the same seed). But there are other options:
- `--mk3` => emulate mark3 hardware
- `--mk4` => emulate mark4 hardware
- `--q1` => emulate Q1 hardware
- `-g` => don't skip login sequence
- `--addr` => go to the address explorer at startup
- `--xw` => go to the wallet export submenu
- `--paper` => go to the Paper Wallet menu at startup

View File

@ -89,7 +89,7 @@ class SimulatedScreen:
self.movie.append((dt, img))
def vsync_handler(self, sr, w):
# called at 61Hz, just like the real LCD's TEAR output signal
# subclass thing
return
class LCDSimulator(SimulatedScreen):
@ -137,6 +137,7 @@ class LCDSimulator(SimulatedScreen):
self.busy_bar = False
self.cursor = None
self.phase = 0
self.animate = False
# GPU stuff needs to know implementation details... because it re-implements
self.COL_BLACK = 0
@ -146,7 +147,7 @@ class LCDSimulator(SimulatedScreen):
def vsync_handler(self, spriterenderer, window):
# will be called at 61Hz, just like the real LCD's TEAR output signal
if not (self.busy_bar or self.cursor):
if not self.animate:
return
activity = False
@ -165,6 +166,8 @@ class LCDSimulator(SimulatedScreen):
# maybe save
if self.movie is not None:
# problem: other stuff may be in mid-update; should look at
# time since last save, and if longer than 60Hz, save then?
self.new_frame()
# draw to screen
@ -230,7 +233,7 @@ class LCDSimulator(SimulatedScreen):
cell_w = CELL_W + (CELL_W if dbl_wide else 0)
# make some pixels big enough for either vert or horz lines
colour = self.COL_FOREGROUND if phase else self.COL_BLACK
colour = self.COL_FOREGROUND if not phase else self.COL_BLACK
def fill_solid(X,Y, w, h, col):
for x in range(X, X+w):
@ -359,23 +362,27 @@ class LCDSimulator(SimulatedScreen):
for x in range(X, X+w):
self.mv[x][y] = px
elif mode in 'TPBC':
elif mode in 'TPBCG':
# emulated GPU commands
# see vsync_handler() for implementation
if mode == 'T':
# stop animating: "taking" the SPI bus away from GPU
self.cursor = None
self.busy_bar = False
self.animate = False
elif mode == 'G':
# continue animating
self.animate = True
elif mode == 'P':
# test pattern: a fixed bar code is shown in real deal
pass
elif mode == 'B':
# show busy bar (infinite progress bar)
self.busy_bar = True
self.animate = True
elif mode == 'C':
# show a cursor
self.cursor = self.CursorSpec(X,Y, cur_type=w)
self.phase = 0 # make update happen immediately
self.animate = True
else:
raise ValueError(mode)

View File

@ -24,13 +24,15 @@ class GPUAccess:
def take_spi(self):
# stop any on-going animation
if self.i_have_spi:
return
return False
glob.dis.dis.gpu_send('T')
self.i_have_spi = True
return True
def give_spi(self):
# not used, implicit in other cmds
raise NotImplementedError
# continue previously on-going animation
self.i_have_spi = False
glob.dis.dis.gpu_send('G')
def have_spi(self):
# do we control the display?
@ -50,7 +52,7 @@ class GPUAccess:
self.take_spi()
def cursor_at(self, x, y, cur_type):
# use outline to leave most of the cell unaffects (just 1px inside border)
# show a cursor, there are several types and sizes
glob.dis.dis.gpu_send('C', x, y, cur_type)
self.i_have_spi = False