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 (8)
Showing
with 155 additions and 28 deletions
......@@ -107,6 +107,7 @@ set(IDF_COMPONENTS
heap
log
lwip
mbedtls
newlib
nvs_flash
sdmmc
......
......@@ -75,7 +75,7 @@ STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg);
#if MICROPY_SSL_MBEDTLS
#if MBEDTLS_VERSION_NUMBER < 0x02070000
#if MBEDTLS_VERSION_NUMBER < 0x02070000 || MBEDTLS_VERSION_NUMBER >= 0x03000000
#define mbedtls_sha256_starts_ret mbedtls_sha256_starts
#define mbedtls_sha256_update_ret mbedtls_sha256_update
#define mbedtls_sha256_finish_ret mbedtls_sha256_finish
......@@ -203,7 +203,7 @@ STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) {
#if MICROPY_SSL_MBEDTLS
#if MBEDTLS_VERSION_NUMBER < 0x02070000
#if MBEDTLS_VERSION_NUMBER < 0x02070000 || MBEDTLS_VERSION_NUMBER >= 0x03000000
#define mbedtls_sha1_starts_ret mbedtls_sha1_starts
#define mbedtls_sha1_update_ret mbedtls_sha1_update
#define mbedtls_sha1_finish_ret mbedtls_sha1_finish
......
......@@ -225,7 +225,11 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
size_t key_len;
const byte *key = (const byte *)mp_obj_str_get_data(args->key.u_obj, &key_len);
// len should include terminating null
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
ret = mbedtls_pk_parse_key(&o->pkey, key, key_len + 1, NULL, 0, mbedtls_ctr_drbg_random, &o->ctr_drbg);
#else
ret = mbedtls_pk_parse_key(&o->pkey, key, key_len + 1, NULL, 0);
#endif
if (ret != 0) {
ret = MBEDTLS_ERR_PK_BAD_INPUT_DATA; // use general error for all key errors
goto cleanup;
......
......@@ -131,7 +131,7 @@
#define MICROPY_HW_SOFTSPI_MIN_DELAY (0)
#define MICROPY_HW_SOFTSPI_MAX_BAUDRATE (ets_get_cpu_frequency() * 1000000 / 200) // roughly
#define MICROPY_PY_USSL (1)
#define MICROPY_SSL_MBEDTLS (0)
#define MICROPY_SSL_MBEDTLS (1)
#define MICROPY_PY_USSL_FINALISER (1)
#define MICROPY_PY_UWEBSOCKET (1)
#define MICROPY_PY_WEBREPL (1)
......
......@@ -584,8 +584,9 @@ flow3r and it should pick up your new application.
Distributing applications
-------------------------
*TODO*
We have an "App Store" where you can submit your applications: https://flow3r.garden/apps/
To add your application, follow the guide in this repository: https://git.flow3r.garden/flow3r/flow3r-apps
Using the simulator
-------------------
......@@ -612,6 +613,13 @@ environment with the required packages:
$ python3 -m venv venv
$ venv/bin/pip install pygame wasmer wasmer-compiler-cranelift
.. note::
The wasmer python module `doesn't work with Python versions 3.10 or 3.11
<https://github.com/wasmerio/wasmer-python/issues/539>`_, use Python 3.9
instead. You will get
``ImportError: Wasmer is not available on this system`` when trying to run
the Simulator.
*TODO: set up a pyproject/poetry/... file?*
You can then run the simulator:
......
......@@ -41,21 +41,26 @@ You can plug in a pair of headphones to the 3.5mm jack on the bottom-left petal.
The built-in speakers will then turn off and audio will go out through the
headphones. You can adjust their volume in the same way.
Showing your nick
-----------------
Showing your nick and pronouns
------------------------------
You can navigate to Badge |rarr| Nick to display your nick. If your nick is
``flow3r``, congratulations! You're ready to go. Otherwise, you'll have to
connect your badge to a computer and edit a file to change your nick.
You can navigate to Badge |rarr| Nick to display your nick and pronouns. If
your nick is ``flow3r``, and you have no pronouns, congratulations! You're
ready to go. Otherwise, you'll have to connect your badge to a computer and
edit a file to change your nick and pronouns.
From the main menu, navigate to System |rarr| Disk Mode (Flash). Connect your badge
to a computer, and it will appear as a mass storage device (a.k.a. pendrive).
Open the file ```nick.json`` in a text editor and change your nick, the size of
the font, and whatever else you wish.
From the main menu, navigate to System |rarr| Disk Mode (Flash). Connect your
badge to a computer, and it will appear as a mass storage device (a.k.a.
pendrive). Open the file ```nick.json`` in a text editor and change your nick,
pronouns, font sizes for nick and pronouns, and whatever else you wish. Please
note that ``pronouns`` is a list, and should be formatted as such. for example:
``"pronouns": ["aa/bb", "cc/dd"],``
For the ``nick.json`` file to appear, you must have started the Nick app at
least once.
Use ``"color": "0xffffff",`` to color your name and pronouns.
When you're done editing, unmount/eject the badge from your computer
(``umount`` on Linux is enough) and press the left shoulder button to exit Disk
Mode. Then, go to Badge |rarr| Nick to see your changes!
......@@ -97,4 +102,4 @@ Toy synthesizer. Bottom three petals select octave, Top 7 petals play a note fro
Harmonic
^^^^^^^^
Toy synthesizer. White petals select chord, pink petals play note.
\ No newline at end of file
Toy synthesizer. White petals select chord, pink petals play note.
......@@ -59,5 +59,6 @@ class Clouds(Application):
c.draw(ctx)
# uncomment to make runnable via mpremote
# st3m.run.run_view(Clouds(ApplicationContext()))
# For running with `mpremote run`:
if __name__ == "__main__":
st3m.run.run_view(Clouds(ApplicationContext()))
......@@ -80,3 +80,10 @@ class CapTouchDemo(Application):
# log.info("Performing captouch autocalibration")
# captouch.calibration_request()
# self.last_calib = 50
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(CapTouchDemo(ApplicationContext()))
......@@ -79,3 +79,10 @@ class HarmonicApp(Application):
k = int(i / 2)
self.synths[k].signals.trigger.stop()
self.cp_prev = cts
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(HarmonicApp(ApplicationContext()))
......@@ -37,3 +37,10 @@ class IMUDemo(Application):
else:
self.v_x = 0
self.v_y = 0
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(IMUDemo(ApplicationContext()))
......@@ -112,3 +112,10 @@ class MelodicApp(Application):
def think(self, ins: InputState, delta_ms: int) -> None:
super().think(ins, delta_ms)
run(self.input)
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(MelodicApp(ApplicationContext()))
......@@ -70,3 +70,10 @@ class ScrollDemo(Application):
def think(self, ins: InputState, delta_ms: int) -> None:
super().think(ins, delta_ms)
self.scroll.update(self.input.captouch.petals[self.PETAL_NO].gesture, delta_ms)
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(ScrollDemo(ApplicationContext()))
......@@ -140,3 +140,10 @@ class Worm:
self.direction = -math.atan2(dy, dx)
self.mutate()
self._lastdist = dist
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(AppWorms(ApplicationContext()))
......@@ -194,6 +194,8 @@ class LEDPainter(Application):
self.b = 255
# if __name__ == '__main__':
# # Continue to make runnable via mpremote run.
# st3m.run.run_view(LEDPainter(ApplicationContext()))
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(LEDPainter(ApplicationContext()))
from st3m.application import Application, ApplicationContext
from st3m.ui.colours import PUSH_RED, GO_GREEN, BLACK
from st3m.goose import Dict, Any
from st3m.goose import Dict, Any, Tuple
from st3m.input import InputState
from ctx import Context
import leds
import st3m.run
import json
import math
......@@ -14,6 +13,9 @@ class Configuration:
self.name = "flow3r"
self.size: int = 75
self.font: int = 5
self.pronouns: list[str] = []
self.pronouns_size: int = 25
self.color = "0x40ff22"
@classmethod
def load(cls, path: str) -> "Configuration":
......@@ -33,6 +35,25 @@ class Configuration:
res.size = data["size"]
if "font" in data and type(data["font"]) == int:
res.font = data["font"]
# type checks don't look inside collections
if (
"pronouns" in data
and type(data["pronouns"]) == list
and set([type(x) for x in data["pronouns"]]) == {str}
):
res.pronouns = data["pronouns"]
if "pronouns_size" in data:
if type(data["pronouns_size"]) == float:
res.pronouns_size = int(data["pronouns_size"])
if type(data["pronouns_size"]) == int:
res.pronouns_size = data["pronouns_size"]
if (
"color" in data
and type(data["color"]) == str
and data["color"][0:2] == "0x"
and len(data["color"]) == 8
):
res.color = data["color"]
return res
def save(self, path: str) -> None:
......@@ -40,21 +61,33 @@ class Configuration:
"name": self.name,
"size": self.size,
"font": self.font,
"pronouns": self.pronouns,
"pronouns_size": self.pronouns_size,
"color": self.color,
}
jsondata = json.dumps(d)
with open(path, "w") as f:
f.write(jsondata)
f.close()
def to_normalized_tuple(self) -> Tuple[float, float, float]:
return (
int(self.color[2:4], 16) / 255.0,
int(self.color[4:6], 16) / 255.0,
int(self.color[6:8], 16) / 255.0,
)
class NickApp(Application):
def __init__(self, app_ctx: ApplicationContext) -> None:
super().__init__(app_ctx)
self._scale = 1.0
self._scale_name = 1.0
self._scale_pronouns = 1.0
self._led = 0.0
self._phase = 0.0
self._filename = "/flash/nick.json"
self._config = Configuration.load(self._filename)
self._pronouns_serialized = " ".join(self._config.pronouns)
def draw(self, ctx: Context) -> None:
ctx.text_align = ctx.CENTER
......@@ -63,15 +96,23 @@ class NickApp(Application):
ctx.font = ctx.get_font_name(self._config.font)
ctx.rgb(0, 0, 0).rectangle(-120, -120, 240, 240).fill()
ctx.rgb(*GO_GREEN)
ctx.rgb(*self._config.to_normalized_tuple())
ctx.move_to(0, 0)
ctx.save()
ctx.scale(self._scale, 1)
ctx.scale(self._scale_name, 1)
ctx.text(self._config.name)
ctx.restore()
leds.set_hsv(int(self._led), abs(self._scale) * 360, 1, 0.2)
if self._pronouns_serialized:
ctx.move_to(0, -60)
ctx.font_size = self._config.pronouns_size
ctx.save()
ctx.scale(1, self._scale_pronouns)
ctx.text(self._pronouns_serialized)
ctx.restore()
leds.set_hsv(int(self._led), abs(self._scale_name) * 360, 1, 0.2)
leds.update()
# ctx.fill()
......@@ -83,11 +124,15 @@ class NickApp(Application):
super().think(ins, delta_ms)
self._phase += delta_ms / 1000
self._scale = math.sin(self._phase)
self._scale_name = math.sin(self._phase)
self._scale_pronouns = math.cos(self._phase)
self._led += delta_ms / 45
if self._led >= 40:
self._led = 0
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(NickApp(ApplicationContext()))
......@@ -240,3 +240,10 @@ class ShoegazeApp(Application):
if self.blm is not None:
self.blm.free = True # yeeting the channel in the backend
self.blm = None
# For running with `mpremote run`:
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(ShoegazeApp(ApplicationContext()))
......@@ -320,13 +320,25 @@ def load_all() -> None:
setting.load(data)
def _update(d: Dict[str, Any], u: Dict[str, Any]) -> Dict[str, Any]:
"""
Recursive update dictionary.
"""
for k, v in u.items():
if type(v) == type({}):
d[k] = _update(d.get(k, {}), v)
else:
d[k] = v
return d
def save_all() -> None:
"""
Save all settings to flash.
"""
res = {}
res: Dict[str, Any] = {}
for setting in all_settings:
res.update(setting.save())
res = _update(res, setting.save())
try:
with open("/flash/settings.json", "w") as f:
json.dump(res, f)
......