Skip to content
Snippets Groups Projects
Verified Commit ce381c13 authored by dos's avatar dos
Browse files

sim: fakes: Add more stubs

parent deb46650
No related branches found
No related tags found
1 merge request!600Simulator improvements
......@@ -25,6 +25,23 @@ SCREENSHOT = False
SCREENSHOT_DELAY = 5
def path_replace(p):
simpath = "/tmp/flow3r-sim"
projectpath = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
)
if p.startswith("/flash/sys"):
p = p[len("/flash/sys") :]
p = projectpath + "/python_payload" + p
return p
if p.startswith("/flash"):
p = p[len("/flash") :]
p = simpath + p
return p
return p
class Input:
"""
Input implements an input overlay (for petals or buttons) that can be
......
_volume = 0
_muted = False
INPUT_SOURCE_NONE = None
INPUT_SOURCE_AUTO = None
INPUT_SOURCE_HEADSET_MIC = None
INPUT_SOURCE_LINE_IN = None
INPUT_SOURCE_ONBOARD_MIC = None
def set_volume_dB(v: float) -> None:
global _volume
......@@ -13,7 +19,7 @@ def get_volume_dB() -> float:
def get_volume_relative() -> float:
return 0
return (_volume + 47) / (47 + 14)
def headphones_set_volume_dB(v: float) -> None:
......@@ -125,3 +131,19 @@ def line_in_get_allowed() -> bool:
def onboard_mic_to_speaker_get_allowed() -> bool:
return False
def input_thru_set_source(source):
pass
def input_thru_get_source():
return None
def input_engines_get_source_avail(source):
return False
def headset_mic_get_allowed():
return False
......@@ -134,6 +134,14 @@ class Context:
def text_baseline(self, v):
self._emit(f"textBaseline {v}")
@property
def compositing_mode(self):
return None
@compositing_mode.setter
def compositing_mode(self, v):
self._emit(f"compositingMode {v}")
@property
def line_width(self):
return None
......
......@@ -37,10 +37,19 @@ def set_hsv(ix, h, s, v):
set_rgb(ix, color.r / 255, color.g / 255, color.b / 255)
def set_all_hsv(h, s, v):
for i in range(40):
set_hsv(i, h, s, v)
def set_slew_rate(b: int):
pass # Better a no-op than not implemented at all.
def get_slew_rate():
return 255
def update():
_sim.leds_update()
pygame.event.post(pygame.event.Event(pygame.USEREVENT, {}))
......
......@@ -22,6 +22,14 @@ class ADC:
return 3.8e6 / 2
class I2C:
def __init__(self, chan, freq=None):
pass
def scan(self):
return []
def reset():
print("beep boop i have reset")
sys.exit(0)
......
STA_IF = 1
STAT_CONNECTING = 0
def hostname(hostname: str) -> None:
......@@ -9,7 +10,7 @@ class WLAN:
def __init__(self, mode):
pass
def active(self, active):
def active(self, active=True):
return True
def scan(self):
......@@ -18,5 +19,14 @@ class WLAN:
def connect(self, ssid, key=None):
pass
def disconnect(self):
pass
def isconnected(self):
return True
def status(self, mode=None):
return STAT_CONNECTING
def config(self, a):
return None
from typing import Tuple
def hsv_to_rgb(h: float, s: float, v: float) -> Tuple[float, float, float]:
"""
Not implemented in sim.
"""
return (0.0, 0.0, 0.0)
def rgb_to_hsv(r: float, g: float, b: float) -> Tuple[float, float, float]:
"""
Not implemented in sim.
"""
return (0.0, 0.0, 0.0)
from colorsys import hsv_to_rgb, rgb_to_hsv
......@@ -21,6 +21,22 @@ def set_mode(no):
pass
def set_default_mode(no):
pass
def set_palette(pal):
pass
def fb(mode):
return (bytearray(240 * 240 * 4), 240, 240, 240 * 4)
def fps():
return 60.0
update = _sim.display_update
get_ctx = _sim.get_ctx
get_overlay_ctx = _sim.get_overlay_ctx
......@@ -33,3 +49,28 @@ def ctx(foo):
def set_backlight(a):
pass
def fbconfig(a, b, c, d):
pass
default = 0
rgb332 = 0
sepia = 0
cool = 0
low_latency = 0
direct_ctx = 0
lock = 0
EXPERIMENTAL_think_per_draw = 0
smart_redraw = 0
x2 = 0
x3 = 0
x4 = 0
bpp1 = 0
bpp2 = 0
bpp4 = 0
bpp8 = 0
bpp16 = 0
bpp24 = 0
palette = 0
......@@ -35,3 +35,20 @@ def i2c_scan():
def battery_charging():
return True
def firmware_version():
return "v0-dev"
def hardware_version():
return "simulator"
class FakeSchedulerSnapshot:
def __init__(self):
self.tasks = []
def scheduler_snapshot():
return FakeSchedulerSnapshot()
from st3m.goose import Optional
def get_buffer_x() -> Optional[memoryview]:
return None
return memoryview(b"")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment