summaryrefslogtreecommitdiff
path: root/kvmd/plugins/ugpio
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2021-08-14 03:08:28 +0300
committerMaxim Devaev <[email protected]>2021-08-14 03:08:28 +0300
commitc6c4592dfb8f5213a2668e392870011b5c2738f4 (patch)
tree3234aa14529dc5b364305cd74b661dd8f075b7f5 /kvmd/plugins/ugpio
parent7d89a54572f24082d8f5e8601e1d0d2ab1517b4c (diff)
servo template
Diffstat (limited to 'kvmd/plugins/ugpio')
-rw-r--r--kvmd/plugins/ugpio/servo.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/kvmd/plugins/ugpio/servo.py b/kvmd/plugins/ugpio/servo.py
new file mode 100644
index 00000000..5a3c9a20
--- /dev/null
+++ b/kvmd/plugins/ugpio/servo.py
@@ -0,0 +1,83 @@
+# ========================================================================== #
+# #
+# KVMD - The main Pi-KVM daemon. #
+# #
+# Copyright (C) 2018-2021 Maxim Devaev <[email protected]> #
+# Shantur Rathore <[email protected]> #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <https://www.gnu.org/licenses/>. #
+# #
+# ========================================================================== #
+
+
+from typing import Dict
+
+from ... import aiotools
+
+from ...yamlconf import Option
+
+from ...validators.basic import valid_number
+from ...validators.basic import valid_int_f0
+
+from .pwm import Plugin as PwmPlugin
+
+
+# =====
+class Plugin(PwmPlugin):
+ def __init__( # pylint: disable=super-init-not-called,too-many-arguments
+ self,
+ instance_name: str,
+ notifier: aiotools.AioNotifier,
+
+ chip: int,
+ period: int,
+ duty_cycle_min: int,
+ duty_cycle_max: int,
+ angle_min: int,
+ angle_max: int,
+ angle_push: int,
+ angle_release: int,
+ ) -> None:
+
+ duty_cycle_push = 0 # FIXME
+ duty_cycle_release = 0 # FIXME
+
+ super().__init__(
+ instance_name=instance_name,
+ notifier=notifier,
+
+ chip=chip,
+ period=period,
+ duty_cycle_push=duty_cycle_push,
+ duty_cycle_release=duty_cycle_release,
+ )
+
+ @classmethod
+ def get_plugin_options(cls) -> Dict:
+ valid_angle = (lambda arg: valid_number(arg, min=0, max=360))
+ return {
+ "chip": Option(0, type=valid_int_f0),
+ "period": Option(20000000, type=valid_int_f0),
+ "duty_cycle_min": Option(0, type=valid_int_f0), # FIXME
+ "duty_cycle_max": Option(0, type=valid_int_f0), # FIXME
+ "angle_min": Option(0, type=valid_angle), # FIXME
+ "angle_max": Option(0, type=valid_angle), # FIXME
+ "angle_push": Option(0, type=valid_angle), # FIXME
+ "angle_release": Option(0, type=valid_angle), # FIXME
+ }
+
+ def __str__(self) -> str:
+ return f"Servo({self._instance_name})"
+
+ __repr__ = __str__