Skip to content
Snippets Groups Projects
Commit 70197e23 authored by iggy's avatar iggy Committed by q3k
Browse files

py: st4m experimets wip

parent 00eea71f
No related branches found
No related tags found
No related merge requests found
# Define a few RGB (0.0 to 1.0) colors
BLACK = (0, 0, 0)
RED = (1, 0, 0)
GREEN = (0, 1, 0)
BLUE = (0, 0, 1)
WHITE = (1, 1, 1)
GREY = (0.5, 0.5, 0.5)
GO_GREEN = (63 / 255, 255 / 255, 33 / 255)
PUSH_RED = (251 / 255, 72 / 255, 196 / 255)
......@@ -14,7 +14,11 @@ class InputState:
"""
def __init__(
self, petal_pressed: List[bool], left_button: int, right_button: int
self,
petal_pressed: List[bool],
petal_pads: List[List[int]],
left_button: int,
right_button: int,
) -> None:
self.petal_pressed = petal_pressed
self.left_button = left_button
......@@ -28,10 +32,14 @@ class InputState:
"""
cts = captouch.read()
petal_pressed = [cts.petals[i].pressed for i in range(10)]
petal_pads = [
[0, 0, 0]
for petal_ix in range(10)
]
left_button = hardware.left_button_get()
right_button = hardware.right_button_get()
return InputState(petal_pressed, left_button, right_button)
return InputState(petal_pressed, petal_pads, left_button, right_button)
class RepeatSettings:
......@@ -40,6 +48,10 @@ class RepeatSettings:
self.subsequent = subsequent
class Slideable:
pass
class Pressable:
"""
A pressable button or button-acting object (like captouch petal in button
......@@ -275,3 +287,16 @@ class InputController:
self.captouch._ignore_pressed()
self.left_shoulder._ignore_pressed()
self.right_shoulder._ignore_pressed()
class PetalSlideController:
def __init__(self, ix):
self._ts = 0
self._input = PetalState(ix)
def think(self, hr: InputState, delta_ms: int) -> None:
self._ts += delta_ms
self._input._update(self._ts, hr)
def _ignore_pressed(self) -> None:
self._input._ignore_pressed()
class Property:
pass
class PropertyFloat(Property):
def __init__(self):
self.min = 0.0
self.max = 1.0
def set_value(self, value):
self._value = value
def mod_value(self, delta):
self._value += delta_ms
def get_value(self):
return self._value
# Define a few RGB (0.0 to 1.0) colors
BLACK = (0, 0, 0)
RED = (1, 0, 0)
GREEN = (0, 1, 0)
BLUE = (0, 0, 1)
WHITE = (1, 1, 1)
GREY = (0.5, 0.5, 0.5)
GO_GREEN = (63 / 255, 255 / 255, 33 / 255)
PUSH_RED = (251 / 255, 72 / 255, 196 / 255)
class Color:
@classmethod
def from_rgb888(cls, r: int = 0, g: int = 0, b: int = 0):
return cls(r / 255, g / 255, b / 255)
def __init__(self, r: float = 0.0, g: float = 0.0, b: float = 0.0) -> None:
self.r = r
self.g = g
self.b = b
def as_normal_tuple(self) -> tuple[float]:
return (self.r, self.g, self.b)
print(Color.from_rgb888(255, 255, 128).as_normal_tuple())
......@@ -126,7 +126,11 @@ class FlowerIcon(Responder):
ctx.text_baseline = ctx.MIDDLE
ctx.font_size = self.size / 3
ctx.line_width = 5
try:
ctx.font = ctx.get_font_name(6)
except AttributeError:
pass
if self.rotation_time:
phi_rotate = tau * ((self.ts % self.rotation_time) / self.rotation_time)
else:
......
......@@ -162,3 +162,4 @@ class ScrollController(st4m.Responder):
self._current_position = (
self._current_position + self._velocity * delta
) % self._nitems
......@@ -42,6 +42,8 @@ class ViewWithInputState(View):
def think(self, ins: InputState, delta_ms: int) -> None:
self.input.think(ins, delta_ms)
class ViewWithSingleInputState(ViewWithInputState()):
def __
class ViewTransition(ABCBase):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment