summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2021-08-15 10:23:54 +0300
committerMaxim Devaev <[email protected]>2021-08-15 10:26:13 +0300
commita340fc6053b08ec9564d5834130beadc278af186 (patch)
tree1ec63c3ea644de8580af560a67b0e0bfd6cdb557 /kvmd
parentc644a9f6e1be50888b5973e561c8fdce63fd2604 (diff)
minor servo fixes
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/plugins/ugpio/servo.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/kvmd/plugins/ugpio/servo.py b/kvmd/plugins/ugpio/servo.py
index daa29293..448cfdb1 100644
--- a/kvmd/plugins/ugpio/servo.py
+++ b/kvmd/plugins/ugpio/servo.py
@@ -44,15 +44,14 @@ class Plugin(PwmPlugin):
period: int,
duty_cycle_min: int,
duty_cycle_max: int,
- angle_min: int,
- angle_max: int,
- angle_push: int,
- angle_release: int,
+ angle_min: float,
+ angle_max: float,
+ angle_push: float,
+ angle_release: float,
) -> None:
- #FIXME - Should we implement check for angles to be between the rangle ranges
- #FIXME - Same for duty_cycle_push and release to be in ranges (maybe in pwm.py)
-
+ angle_push = min(max(angle_push, angle_min), angle_max)
+ angle_release = min(max(angle_release, angle_min), angle_max)
duty_cycle_per_degree = (duty_cycle_max - duty_cycle_min) / (angle_max - angle_min)
@@ -71,19 +70,19 @@ class Plugin(PwmPlugin):
@classmethod
def get_plugin_options(cls) -> Dict:
- valid_angle = (lambda arg: valid_number(arg, min=-360, max=360, type=float))
+ valid_angle = (lambda arg: valid_number(arg, min=-360.0, max=360.0, type=float))
return {
"chip": Option(0, type=valid_int_f0),
"period": Option(20000000, type=valid_int_f0),
- "duty_cycle_min": Option(1000000, type=valid_int_f0),
- "duty_cycle_max": Option(2000000, type=valid_int_f0),
- "angle_min": Option(0, type=valid_angle),
- "angle_max": Option(180, type=valid_angle),
- "angle_push": Option(100, type=valid_angle),
- "angle_release": Option(120, type=valid_angle),
+ "duty_cycle_min": Option(1000000, type=valid_int_f0),
+ "duty_cycle_max": Option(2000000, type=valid_int_f0),
+ "angle_min": Option(0.0, type=valid_angle),
+ "angle_max": Option(180.0, type=valid_angle),
+ "angle_push": Option(100.0, type=valid_angle),
+ "angle_release": Option(120.0, type=valid_angle),
}
def __str__(self) -> str:
return f"Servo({self._instance_name})"
- __repr__ = __str__ \ No newline at end of file
+ __repr__ = __str__