File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
adafruit_blinka/microcontroller/starfive/JH7110/pwmio Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -87,27 +87,26 @@ def period(self, period):
87
87
@property
88
88
def duty_cycle (self ):
89
89
"""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
91
91
92
92
Raises:
93
93
PWMError: if an I/O or OS error occurs.
94
94
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.
96
96
97
97
:type: int, float
98
98
"""
99
- return int (self ._duty_cycle )
99
+ return int (self ._duty_cycle * 65535 )
100
100
101
101
@duty_cycle .setter
102
102
def duty_cycle (self , duty_cycle ):
103
103
if not isinstance (duty_cycle , (int , float )):
104
104
raise TypeError ("Invalid duty cycle type, should be int or float." )
105
105
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" )
110
108
109
+ duty_cycle = duty_cycle / 655.35
111
110
self ._duty_cycle = duty_cycle
112
111
self ._pwmpin .ChangeDutyCycle (round (self ._duty_cycle ))
113
112
Original file line number Diff line number Diff line change 31
31
from adafruit_blinka .microcontroller .am65xx .pin import Pin
32
32
elif detector .chip .JH71X0 :
33
33
from adafruit_blinka .microcontroller .starfive .JH71x0 .pin import Pin
34
+ elif detector .chip .JH7110 :
35
+ from adafruit_blinka .microcontroller .starfive .JH7110 .pin import Pin
34
36
elif detector .chip .DRA74X :
35
37
from adafruit_blinka .microcontroller .dra74x .pin import Pin
36
38
elif detector .chip .SUN4I :
You can’t perform that action at this time.
0 commit comments