summaryrefslogtreecommitdiff
path: root/wasp/boards/simulator
diff options
context:
space:
mode:
Diffstat (limited to 'wasp/boards/simulator')
-rw-r--r--wasp/boards/simulator/display.py33
-rw-r--r--wasp/boards/simulator/machine.py3
-rw-r--r--wasp/boards/simulator/micropython.py3
-rw-r--r--wasp/boards/simulator/watch.py3
4 files changed, 33 insertions, 9 deletions
diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py
index 3d7d388..c226050 100644
--- a/wasp/boards/simulator/display.py
+++ b/wasp/boards/simulator/display.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
""" Simulated ST7789 display and CST816S touchscreen. """
import sys
@@ -38,7 +41,8 @@ class ST7789Sim(object):
self.y = self.rowclip[0]
elif self.cmd == RAMWR:
- pixelview = sdl2.ext.PixelView(windowsurface)
+ #pixelview = sdl2.ext.PixelView(windowsurface)
+ pixelview = sdl2.ext.pixels2d(windowsurface)
half = False
for d in data:
@@ -49,11 +53,14 @@ class ST7789Sim(object):
rgb |= d
half = False
- pixel = ((rgb & 0xf800) >> 8,
- (rgb & 0x07e0) >> 3,
- (rgb & 0x001f) << 3)
+ #pixel = ((rgb & 0xf800) >> 8,
+ # (rgb & 0x07e0) >> 3,
+ # (rgb & 0x001f) << 3)
+ pixel = (((rgb & 0xf800) << 8) +
+ ((rgb & 0x07e0) << 5) +
+ ((rgb & 0x001f) << 3))
- pixelview[self.y][self.x] = pixel
+ pixelview[self.x][self.y] = pixel
self.x += 1
if self.x > self.colclip[1]:
@@ -83,14 +90,22 @@ class CST816SSim():
self.regs[1] = 0
def handle_key(self, key):
+ """Use key presses to provoke different touchscreen events.
+
+ Note: The Down key provokes an upward swipe and vice versa.
+ Same for left and right. That is because the swipe up
+ gesture means show me the screen the is below me (hence
+ the controls are inverted compared to joystick-like
+ direction control).
+ """
if key.keysym.sym == sdl2.SDLK_DOWN:
- self.regs[1] = 1
- elif key.keysym.sym == sdl2.SDLK_UP:
self.regs[1] = 2
+ elif key.keysym.sym == sdl2.SDLK_UP:
+ self.regs[1] = 1
elif key.keysym.sym == sdl2.SDLK_LEFT:
- self.regs[1] = 3
- elif key.keysym.sym == sdl2.SDLK_RIGHT:
self.regs[1] = 4
+ elif key.keysym.sym == sdl2.SDLK_RIGHT:
+ self.regs[1] = 3
self.regs[3] = 0x80
self.raise_interrupt()
diff --git a/wasp/boards/simulator/machine.py b/wasp/boards/simulator/machine.py
index 62a95c5..2fc9754 100644
--- a/wasp/boards/simulator/machine.py
+++ b/wasp/boards/simulator/machine.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import display
import time
diff --git a/wasp/boards/simulator/micropython.py b/wasp/boards/simulator/micropython.py
index 578a12d..41c30a4 100644
--- a/wasp/boards/simulator/micropython.py
+++ b/wasp/boards/simulator/micropython.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
def const(fn):
return fn
diff --git a/wasp/boards/simulator/watch.py b/wasp/boards/simulator/watch.py
index f38d7a1..ce281f4 100644
--- a/wasp/boards/simulator/watch.py
+++ b/wasp/boards/simulator/watch.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import time
def sleep_ms(ms):
time.sleep(ms / 1000)