commit 4baecb11474d023760d29bd05989f564e9dc1a95 Author: Félix Baylac Jacqué Date: Thu Aug 17 22:37:57 2023 +0200 Init diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..315f6a8 --- /dev/null +++ b/__init__.py @@ -0,0 +1,45 @@ +from st3m.application import Application, ApplicationContext +from st3m.goose import Dict, Any +from st3m.reactor import Responder +from st3m.ui.view import BaseView, ViewManager +from st3m.input import InputState +from ctx import Context +import st3m.run +import leds +import json +import math + +class AlternativebitNick(Application): + def __init__(self, app_ctx: ApplicationContext) -> None: + super().__init__(app_ctx) + self._led = 0.0 + self._filename = "/flash/nick.json" + self._scale = 1.0 + self._phase = 0.0 + + def draw(self, ctx: Context) -> None: + # Paint the background black + ctx.save() + ctx.scale(self._scale, 1) + ctx.rgb(0, 0, 0).rectangle(-120, -120, 240, 240).fill() + ctx.rgb(1,1,1).round_rectangle(10,0,70,70,2).fill() + ctx.rgb(1,1,1).round_rectangle(-80,0,70,70,2).fill() + ctx.rgb(1,1,1).round_rectangle(10,-90,70,70,2).fill() + ctx.restore() + + leds.set_hsv(int(self._led), abs(self._scale) * 360, 1, 0.2) + leds.update() + + + def think(self, ins: InputState, delta_ms: int) -> None: + super().think(ins, delta_ms) # Let Application do its thing + self._led += delta_ms / 45 + self._phase += delta_ms / 1000 + self._scale = math.sin(self._phase) + if self._led >= 40: + self._led = 0 + + +if __name__ == '__main__': + # Continue to make runnable via mpremote run. + st3m.run.run_view(AlternativebitNick(ApplicationContext)) diff --git a/alternativebit-logo.toml b/alternativebit-logo.toml new file mode 100644 index 0000000..e09a185 --- /dev/null +++ b/alternativebit-logo.toml @@ -0,0 +1,11 @@ +[app] +name = "Alternativebit Logo" +menu = "Badge" + +[entry] +class = "AlternativebitNick" + +[metadata] +author = "Flow3r Badge Authors & spike_punk" +license = "LGPL-3.0-only" +url = "https://git.flow3r.garden/flow3r/flow3r-firmware" diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..4b183bf --- /dev/null +++ b/default.nix @@ -0,0 +1,25 @@ +{ pkgs ? import {} }: + +let + custom-packages = ps: with ps; [ + ( + buildPythonPackage rec { + pname = "mpremote"; + version = "1.20.0"; + src = fetchPypi { + inherit pname version; + sha256 = "sha256-XDQnYqBHkTCd1JvOY8cKB1qnxUixwAdiYrlvnMw5jKI="; + }; + doCheck = false; + postPatch = '' + ln -s ${./setup-mpremote.py} setup.py + ''; + propagatedBuildInputs = [ + pyserial + importlib-metadata + ]; + } + ) + ]; + my-python = pkgs.python3.withPackages custom-packages; +in my-python \ No newline at end of file diff --git a/setup-mpremote.py b/setup-mpremote.py new file mode 100644 index 0000000..a8b2c96 --- /dev/null +++ b/setup-mpremote.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +from setuptools import setup, find_packages + +setup(name='mpremote', + version='1.20.0', + # Modules to import from other scripts: + packages=find_packages(), + # Executables + scripts=["mpremote/main.py"], + )