diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..2a27a40 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "docopt" +version = "0.6.2" +description = "Pythonic argument parser, that will make you smile" +optional = false +python-versions = "*" +files = [ + {file = "docopt-0.6.2.tar.gz", hash = "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.11" +content-hash = "020d3e03335e70ca8b1cfd769838e50546a63b9ed4e4034ba584fd3a3ec497fd" diff --git a/pulses/methods.py b/pulses/methods.py index b08f23a..d3bfb55 100644 --- a/pulses/methods.py +++ b/pulses/methods.py @@ -54,9 +54,21 @@ def value_linear(obj, step): return delta * (100-step)/50 + obj.min +def value_vshape(obj, step): + """ + V-shape value, 1-0-1 + """ + + delta = obj.max - obj.min + if step < 50: + return delta * (100-step)/50 + obj.min + else: + return delta*step/50 + obj.min + + def value_sin(obj, step): """ - Sinusoidal values, 0-1-0 /\ + Sinusoidal values, 0-1-0 """ delta = obj.max - obj.min @@ -66,7 +78,7 @@ def value_sin(obj, step): def value_cos(obj, step): """ - Absolute Cosinusoidal values, 1-0-1 \\// + Absolute Cosinusoidal values, 1-0-1 """ delta = obj.max - obj.min diff --git a/pulses/pulses.py b/pulses/pulses.py index 399bf01..7d08ba4 100644 --- a/pulses/pulses.py +++ b/pulses/pulses.py @@ -10,7 +10,7 @@ from .methods import * # NOQA class ledPulse(threading.Thread): delayMethods = ['constant', 'sin', 'cos'] - valueMethods = ['on', 'off', 'linear', 'sin', 'cos'] + valueMethods = ['on', 'off', 'linear', 'vshape', 'sin', 'cos'] methods = {'delay': {}, 'value': {}} defaultSet = { @@ -69,7 +69,7 @@ class ledPulse(threading.Thread): self.model = sys.platform try: with open('/sys/firmware/devicetree/base/model', 'r') as m: - model = m.read() + model = m.read().strip() if model.lower().startswith('raspberry pi'): self.supported = True self.model = model diff --git a/pyproject.toml b/pyproject.toml index 9a05d02..51fbd0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,15 @@ -[build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" +[tool.poetry] +name = "pulses" +version = "0.90" +description = "Pulse LEDs on RPi" +authors = ["Andrea Mistrali "] +readme = "README.md" -[tool.pyright] -reportMissingImports = "information" +[tool.poetry.dependencies] +python = "^3.11" +docopt = "^0.6.2" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"