Răsfoiți Sursa

[add] PWM module

SummerGift 6 ani în urmă
părinte
comite
cffc907749
1 a modificat fișierele cu 41 adăugiri și 1 ștergeri
  1. 41 1
      docs/code-completion/machine.py

+ 41 - 1
docs/code-completion/machine.py

@@ -681,7 +681,7 @@ class Timer(object):
         Deinitialises the timer. Stops the timer, and disables the timer peripheral.
         """
         ...
-
+  
 class ADC(object):
     """
     - id:使用的 ADC 设备编号,id = 1 表示编号为 1 的 ADC 设备;
@@ -711,6 +711,46 @@ class ADC(object):
         """
         ...
 
+class PWM(object):
+    """
+    在给定的总线上构建一个 PWM 对象,参数介绍如下:
+
+    - id:使用的 PWM 设备编号,如  id = 1 表示编号为 1 的 PWM 设备;
+    - channel:使用的 PWM 设备通道号,每个 PWM 设备包含多个通道,范围为 [0, 4];
+    - freq:初始化频率,范围 [1, 156250];
+    - duty:初始化占空比数值,范围 [0 255];
+
+    例如:PWM(1,4,100,100) 表示当前使用 编号为 1 的 PWM 设备的 4 通道,初始化频率为 1000 Hz,初始化占空比的数值为 100。
+    """
+
+    def __init__(self, id: int, channel: int, freq: int, duty: int) -> None:
+        """
+        """
+
+    def init(channel, freq, duty) -> None:
+        """
+        根据输入的参数初始化 PWM 对象。
+        """
+        ...
+
+    def deinit(self) -> None:
+        """
+        用于关闭 PWM 对象,对象 deinit 之后需要重新 init 才能使用。
+        """
+        ...
+
+    def freq(freq)-> None:
+        """
+        用于获取或者设置 PWM 对象的频率,频率的范围为 [1, 156250]。如果参数为空,返回当前 PWM 对象的频率;如果参数非空,则使用该参数设置当前 PWM 对象的频率。
+        """
+        ...
+
+    def duty(duty) -> None:
+        """
+        用于获取或者设置 PWM 对象的占空比数值,占空比数值的范围为 [0, 255],例如 duty = 100,表示当前设备占空比为 100/255 = 39.22% 。如果参数为空,返回当前 PWM 对象的占空比数值;如果参数非空,则使用该参数设置当前 PWM 对象的占空比数值。
+        """
+        ...
+
 def reset() -> None:
     """Resets the device in a manner similar to pushing the external RESET button."""
     ...