]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
added JH71110 to digitalio
authorDarkMechanikum <v.shtarev08@gmail.com>
Wed, 3 Jul 2024 19:38:18 +0000 (22:38 +0300)
committerDarkMechanikum <v.shtarev08@gmail.com>
Wed, 3 Jul 2024 19:38:18 +0000 (22:38 +0300)
src/adafruit_blinka/microcontroller/starfive/JH7110/pwmio/PWMOut.py
src/digitalio.py

index ececc8022ef2a5b94fa73b954b8ac2fd45d8fde1..39cbb9b481f71540e00e5833c9c1df4154339922 100644 (file)
@@ -87,27 +87,26 @@ class PWMOut:
     @property
     def duty_cycle(self):
         """Get or set the PWM's output duty cycle which is the fraction of
     @property
     def duty_cycle(self):
         """Get or set the PWM's output duty cycle which is the fraction of
-        each pulse which is high.
+        each pulse which is high. 16-bit
 
         Raises:
             PWMError: if an I/O or OS error occurs.
             TypeError: if value type is not int or float.
 
         Raises:
             PWMError: if an I/O or OS error occurs.
             TypeError: if value type is not int or float.
-            ValueError: if value is out of bounds of 0.0 to 100.0.
+            ValueError: if value is out of bounds of 0.0 to 1.0.
 
         :type: int, float
         """
 
         :type: int, float
         """
-        return int(self._duty_cycle)
+        return int(self._duty_cycle * 65535)
 
     @duty_cycle.setter
     def duty_cycle(self, duty_cycle):
         if not isinstance(duty_cycle, (int, float)):
             raise TypeError("Invalid duty cycle type, should be int or float.")
 
 
     @duty_cycle.setter
     def duty_cycle(self, duty_cycle):
         if not isinstance(duty_cycle, (int, float)):
             raise TypeError("Invalid duty cycle type, should be int or float.")
 
-        if not 0 <= duty_cycle <= 100:
-            raise ValueError(
-                "Invalid duty cycle value, should be between 0.0 and 100.0"
-            )
+        if not 0 <= duty_cycle <= 65535:
+            raise ValueError("Invalid duty cycle value, should be between 0 and 65535")
 
 
+        duty_cycle = duty_cycle / 655.35
         self._duty_cycle = duty_cycle
         self._pwmpin.ChangeDutyCycle(round(self._duty_cycle))
 
         self._duty_cycle = duty_cycle
         self._pwmpin.ChangeDutyCycle(round(self._duty_cycle))
 
index e215047b60004f2257b47871b9d3d892db6815f7..800947ea4520598aedb35e9c3482175587f6b31b 100644 (file)
@@ -31,6 +31,8 @@ elif detector.chip.AM65XX:
     from adafruit_blinka.microcontroller.am65xx.pin import Pin
 elif detector.chip.JH71X0:
     from adafruit_blinka.microcontroller.starfive.JH71x0.pin import Pin
     from adafruit_blinka.microcontroller.am65xx.pin import Pin
 elif detector.chip.JH71X0:
     from adafruit_blinka.microcontroller.starfive.JH71x0.pin import Pin
+elif detector.chip.JH7110:
+    from adafruit_blinka.microcontroller.starfive.JH7110.pin import Pin
 elif detector.chip.DRA74X:
     from adafruit_blinka.microcontroller.dra74x.pin import Pin
 elif detector.chip.SUN4I:
 elif detector.chip.DRA74X:
     from adafruit_blinka.microcontroller.dra74x.pin import Pin
 elif detector.chip.SUN4I: