Undim on button press rather than tmp value

This commit is contained in:
Edgar P. Burkhart 2024-12-14 10:18:40 +01:00
parent 1ed22e8aa8
commit 57346674df
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 24 additions and 8 deletions

View file

@ -41,6 +41,7 @@ class Screen:
self._held = False
self.sense.stick.direction_middle = self.stick_click
self.sense.stick.direction_any = self.auto_dim.undim
@property
def value(self) -> None | str:
@ -161,11 +162,11 @@ class AutoDim(Thread):
def auto_dim(self) -> None:
accel_z = self.sense.get_accelerometer_raw()["z"]
if not self.switching and accel_z < 0.9:
if not self.switching and accel_z < 0.2:
self.switching = True
self.dim = not self.dim
elif self.switching and accel_z > 0.98:
elif self.switching and accel_z > 0.9:
self.switching = False
@property
@ -180,6 +181,9 @@ class AutoDim(Thread):
self.sense.gamma_reset()
self._dim = value
def undim(self) -> None:
self.dim = False
def format_value(value: float) -> str:
v = math.trunc(value)

View file

@ -68,7 +68,9 @@ class SenseStick:
"""
...
@direction_up.setter
def direction_up(self, value: Callable[[InputEvent], Any]) -> None: ...
def direction_up(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
@property
def direction_down(self): # -> None:
"""
@ -80,7 +82,9 @@ class SenseStick:
"""
...
@direction_down.setter
def direction_down(self, value: Callable[[InputEvent], Any]) -> None: ...
def direction_down(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
@property
def direction_left(self): # -> None:
"""
@ -92,7 +96,9 @@ class SenseStick:
"""
...
@direction_left.setter
def direction_left(self, value: Callable[[InputEvent], Any]) -> None: ...
def direction_left(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
@property
def direction_right(self): # -> None:
"""
@ -104,7 +110,9 @@ class SenseStick:
"""
...
@direction_right.setter
def direction_right(self, value: Callable[[InputEvent], Any]) -> None: ...
def direction_right(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
@property
def direction_middle(self): # -> None:
"""
@ -116,7 +124,9 @@ class SenseStick:
"""
...
@direction_middle.setter
def direction_middle(self, value: Callable[[InputEvent], Any]) -> None: ...
def direction_middle(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
@property
def direction_any(self): # -> None:
"""
@ -129,4 +139,6 @@ class SenseStick:
"""
...
@direction_any.setter
def direction_any(self, value: Callable[[InputEvent], Any]) -> None: ...
def direction_any(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...