Skip to content

Commit 087ad0f

Browse files
added JH71110 to digitalio
1 parent cb5192a commit 087ad0f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/adafruit_blinka/microcontroller/starfive/JH7110/pwmio/PWMOut.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,26 @@ def period(self, period):
8787
@property
8888
def duty_cycle(self):
8989
"""Get or set the PWM's output duty cycle which is the fraction of
90-
each pulse which is high.
90+
each pulse which is high. 16-bit
9191
9292
Raises:
9393
PWMError: if an I/O or OS error occurs.
9494
TypeError: if value type is not int or float.
95-
ValueError: if value is out of bounds of 0.0 to 100.0.
95+
ValueError: if value is out of bounds of 0.0 to 1.0.
9696
9797
:type: int, float
9898
"""
99-
return int(self._duty_cycle)
99+
return int(self._duty_cycle * 65535)
100100

101101
@duty_cycle.setter
102102
def duty_cycle(self, duty_cycle):
103103
if not isinstance(duty_cycle, (int, float)):
104104
raise TypeError("Invalid duty cycle type, should be int or float.")
105105

106-
if not 0 <= duty_cycle <= 100:
107-
raise ValueError(
108-
"Invalid duty cycle value, should be between 0.0 and 100.0"
109-
)
106+
if not 0 <= duty_cycle <= 65535:
107+
raise ValueError("Invalid duty cycle value, should be between 0 and 65535")
110108

109+
duty_cycle = duty_cycle / 655.35
111110
self._duty_cycle = duty_cycle
112111
self._pwmpin.ChangeDutyCycle(round(self._duty_cycle))
113112

src/digitalio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from adafruit_blinka.microcontroller.am65xx.pin import Pin
3232
elif detector.chip.JH71X0:
3333
from adafruit_blinka.microcontroller.starfive.JH71x0.pin import Pin
34+
elif detector.chip.JH7110:
35+
from adafruit_blinka.microcontroller.starfive.JH7110.pin import Pin
3436
elif detector.chip.DRA74X:
3537
from adafruit_blinka.microcontroller.dra74x.pin import Pin
3638
elif detector.chip.SUN4I:

0 commit comments

Comments
 (0)