Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • flow3r/flow3r-firmware
  • Vespasian/flow3r-firmware
  • alxndr42/flow3r-firmware
  • pl/flow3r-firmware
  • Kari/flow3r-firmware
  • raimue/flow3r-firmware
  • grandchild/flow3r-firmware
  • mu5tach3/flow3r-firmware
  • Nervengift/flow3r-firmware
  • arachnist/flow3r-firmware
  • TheNewCivilian/flow3r-firmware
  • alibi/flow3r-firmware
  • manuel_v/flow3r-firmware
  • xeniter/flow3r-firmware
  • maxbachmann/flow3r-firmware
  • yGifoom/flow3r-firmware
  • istobic/flow3r-firmware
  • EiNSTeiN_/flow3r-firmware
  • gnudalf/flow3r-firmware
  • 999eagle/flow3r-firmware
  • toerb/flow3r-firmware
  • pandark/flow3r-firmware
  • teal/flow3r-firmware
  • x42/flow3r-firmware
  • alufers/flow3r-firmware
  • dos/flow3r-firmware
  • yrlf/flow3r-firmware
  • LuKaRo/flow3r-firmware
  • ThomasElRubio/flow3r-firmware
  • ai/flow3r-firmware
  • T_X/flow3r-firmware
  • highTower/flow3r-firmware
  • beanieboi/flow3r-firmware
  • Woazboat/flow3r-firmware
  • gooniesbro/flow3r-firmware
  • marvino/flow3r-firmware
  • kressnerd/flow3r-firmware
  • quazgar/flow3r-firmware
  • aoid/flow3r-firmware
  • jkj/flow3r-firmware
  • naomi/flow3r-firmware
41 results
Show changes
Commits on Source (13)
......@@ -15,6 +15,7 @@ __pycache__
# Python
.venv
/venv/
# sphinx
docs/_build/
......@@ -55,7 +55,7 @@ build:
simulate:
stage: build
script:
- python3 sim/run.py screenshot
- python3 sim/run.py --screenshot
artifacts:
expose_as: 'Smulator Screenshot'
paths: ['flow3r.png']
......
......@@ -53,8 +53,8 @@ For running the simulator, you'll need Python 3 with pygame and wasmer:
::
$ python3 -m venv venv
$ . venv/bin/activate
$ pip install pygame wasmer wasmer-compiler-cranelift
$ venv/bin/pip install pygame requests
$ venv/bin/pip install wasmer wasmer-compiler-cranelift
.. warning::
......
......@@ -644,7 +644,8 @@ environment with the required packages:
$ git clone https://git.flow3r.garden/flow3r/flow3r-firmware
$ cd flow3r-firmware
$ python3 -m venv venv
$ venv/bin/pip install pygame wasmer wasmer-compiler-cranelift
$ venv/bin/pip install pygame requests
$ venv/bin/pip install wasmer wasmer-compiler-cranelift
.. warning::
......
......@@ -6,7 +6,8 @@ from ctx import Context
class Cloud:
def __init__(self, x: float, y: float, z: float) -> None:
def __init__(self, path: str, x: float, y: float, z: float) -> None:
self.path = path
self.x = x
self.y = y
self.z = z
......@@ -14,10 +15,10 @@ class Cloud:
def draw(self, ctx: Context) -> None:
x = self.x / self.z * 120
y = self.y / self.z * 120
width = 200.0 / self.z * 120
height = 100.0 / self.z * 120
width = 200.0 / self.z * 160
height = 100.0 / self.z * 160
ctx.image(
"/flash/sys/apps/clouds/cloud.png",
self.path,
x - width / 2,
y - height / 2,
width,
......@@ -29,11 +30,15 @@ class Clouds(Application):
def __init__(self, app_ctx: ApplicationContext) -> None:
super().__init__(app_ctx)
self.clouds = []
bundle_path = app_ctx.bundle_path
if bundle_path == "":
bundle_path = "/flash/sys/apps/clouds"
for i in range(10):
self.clouds.append(
Cloud(
bundle_path + "/cloud.png",
((random.getrandbits(16) - 32767) / 32767.0) * 200,
((random.getrandbits(16)) / 65535.0) * 50 - 5,
((random.getrandbits(16)) / 65535.0) * 60 - 10,
((random.getrandbits(16)) / 65535.0) * 200 + 5,
)
)
......@@ -41,9 +46,18 @@ class Clouds(Application):
def think(self, ins: InputState, delta_ms: int) -> None:
super().think(ins, delta_ms)
for c in self.clouds:
c.z -= 40 * delta_ms / 1000.0
c.x -= (delta_ms / 1000.0) * ins.imu.acc[1] * 10
c.z -= (delta_ms / 1000.0) * (ins.imu.acc[2] - 5) * 20
# wrap x and z coordinates around
if c.z < 10:
c.z = 300
elif c.z > 300:
c.z = 10
if c.x < -200:
c.x = 200
elif c.x > 200:
c.x = -200
self.clouds = sorted(self.clouds, key=lambda c: -c.z)
def draw(self, ctx: Context) -> None:
......
[app]
name = "Clouds"
menu = "Apps"
menu = "Badge"
[entry]
class = "Clouds"
......
......@@ -75,6 +75,9 @@ class Input:
self._mouse_held = self._mouse_hover
if ev.type == pygame.KEYUP:
self._mouse_held = None
if ev.type == pygame.QUIT:
pygame.quit()
sys.exit()
if prev_hover != self._mouse_hover:
return True
......@@ -148,40 +151,40 @@ class PetalsInput(Input):
]
)
)
PETAL_MAP = {
(0, 1): 2,
(0, 2): 1,
(0, 3): 0,
(9, 0): 15,
(9, 3): 16,
(8, 1): 5,
(8, 2): 4,
(8, 3): 3,
(7, 0): 17,
(7, 3): 18,
(6, 1): 8,
(6, 2): 7,
(6, 3): 6,
(5, 0): 19,
(5, 3): 20,
(4, 1): 11,
(4, 2): 10,
(4, 3): 9,
(3, 0): 21,
(3, 3): 22,
(2, 1): 14,
(2, 2): 13,
(2, 3): 12,
(1, 0): 23,
(1, 3): 24,
}
MARKER_SIZE = 40
def _index_for_petal_pad(self, petal, pad):
if petal >= 10:
raise ValueError("petal cannot be > 10")
# convert from st3m/bsp index into input state index
top = False
if petal % 2 == 0:
top = True
res = petal // 2
if top:
res *= 3
else:
res *= 2
res += 3 * 5
if top:
if pad == 1: # ccw
res += 2
elif pad == 2: # cw
res += 1
elif pad == 3: # base
res += 0
else:
raise ValueError("invalid pad number")
else:
if pad == 0: # tip
res += 0
elif pad == 3: # base
res += 1
else:
raise ValueError("invalid pad number")
return res
return self.PETAL_MAP[(petal, pad)]
def state_for_petal_pad(self, petal, pad):
ix = self._index_for_petal_pad(petal, pad)
......
......@@ -297,6 +297,7 @@ class Context:
"Camp Font 2",
"Camp Font 3",
"Material Icons",
"Comic Mono",
][i]
def scope(self):
......
def mem_free():
return 1337
def isenabled():
return True
def enable():
pass
def disable():
pass
def collect():
pass
......@@ -8,6 +8,9 @@ class WLAN:
def active(self, active):
return True
def scan(self):
return []
def connect(self, ssid, key=None):
pass
......
......@@ -24,9 +24,9 @@ def usb_console_active():
def freertos_sleep(ms):
import _time
import time
_time.sleep(ms / 1000.0)
time.sleep(ms / 1000.0)
def i2c_scan():
......
from typing import Any
class Response:
text: str
content: bytes
status_code: int
def close(self) -> None:
...
def json(self) -> Any:
...
def request(
method: str, url: str, data: Any, json: Any, headers: dict[str, str]
) -> Response:
...
def head(url: str, **kw: Any) -> Response:
...
def get(url: str, **kw: Any) -> Response:
...
def post(url: str, **kw: Any) -> Response:
...
def put(url: str, **kw: Any) -> Response:
...
def patch(url: str, **kw: Any) -> Response:
...
def delete(url: str, **kw: Any) -> Response:
...
from requests import Response, request, head, get, post, put, patch, delete
......@@ -6,6 +6,7 @@ import importlib.util
import os
import sys
import builtins
import argparse
projectpath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
......@@ -16,6 +17,11 @@ import cmath
import wasmer
import wasmer_compiler_cranelift
try:
import requests
except ImportError:
print("Warning: `requests` is missing so no `urequests` mock will exist")
sys_path_orig = sys.path
......@@ -102,18 +108,39 @@ orig_stat = os.stat
def _stat(path):
res = orig_stat(path)
# lmao
return (res.st_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0)
return os.stat_result((res.st_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0))
os.stat = _stat
if len(sys.argv) >= 2 and sys.argv[1] == "screenshot":
def sim_main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--screenshot",
action="store_true",
default=False,
help="Generate a flow3r.png screenshot.",
)
parser.add_argument(
"override_app",
nargs="?",
help="Bundle to start instead of the main menu. "
+ "This is the `app.name` from flow3r.toml.",
)
args = parser.parse_args()
import _sim
_sim.SCREENSHOT = True
elif len(sys.argv) == 2:
import st3m.run
_sim.SCREENSHOT = args.screenshot
if args.override_app is not None:
import st3m.run
st3m.run.override_main_app = args.override_app
import main
st3m.run.override_main_app = sys.argv[1]
import main
if __name__ == "__main__":
sim_main()