diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-11 19:15:20 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-11 19:15:20 (GMT) |
| commit | af1379806c5ccd938b8f310b949ef265a6d8def0 (patch) | |
| tree | ff909ec0e7162e29a642ad226cef3b99d4c7c019 /wasp/boards/simulator/display.py | |
| parent | f68eb610c5d77bb71d3952e0dc9ca70a472ebfae (diff) | |
wasp: simulator: Use Tab to replicate the physical button
Diffstat (limited to 'wasp/boards/simulator/display.py')
| -rw-r--r-- | wasp/boards/simulator/display.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py index c226050..bafb632 100644 --- a/wasp/boards/simulator/display.py +++ b/wasp/boards/simulator/display.py @@ -77,8 +77,8 @@ class CST816SSim(): def __init__(self): self.regs = bytearray(64) - def readfrom_mem_into(self, addr, reg, dbuf): - tick() + def readfrom_mem_into(self, addr, reg, dbuf, pins): + tick(pins) if not self.regs[1]: raise OSError @@ -127,7 +127,7 @@ sdl2.ext.fill(windowsurface, (0, 0, 0)) spi_st7789_sim = ST7789Sim() i2c_cst816s_sim = CST816SSim() -def tick(): +def tick(pins): events = sdl2.ext.get_events() for event in events: if event.type == sdl2.SDL_QUIT: @@ -136,7 +136,13 @@ def tick(): elif event.type == sdl2.SDL_MOUSEBUTTONDOWN: i2c_cst816s_sim.handle_mousebutton(event.button) elif event.type == sdl2.SDL_KEYDOWN: - i2c_cst816s_sim.handle_key(event.key) + if event.key.keysym.sym == sdl2.SDLK_TAB: + pins['BUTTON'].value(0) + else: + i2c_cst816s_sim.handle_key(event.key) + elif event.type == sdl2.SDL_KEYUP: + if event.key.keysym.sym == sdl2.SDLK_TAB: + pins['BUTTON'].value(1) else: #print(event) pass |
