Skip to content

Commit ee1b8a1

Browse files
authored
Merge pull request #14 from dhalbert/notimpl-freq-setter
raise explanatory exception when trying to set channel frequency
2 parents fd37a8d + 65f0e2c commit ee1b8a1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

adafruit_pca9685.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ def __init__(self, pca, index):
6565

6666
@property
6767
def frequency(self):
68-
"""The overall PWM frequency in herz."""
68+
"""The overall PWM frequency in Hertz (read-only).
69+
A PWMChannel's frequency cannot be set individually.
70+
All channels share a common frequency, set by PCA9685.frequency."""
6971
return self._pca.frequency
7072

73+
@frequency.setter
74+
def frequency(self, _):
75+
raise NotImplementedError("frequency cannot be set on individual channels")
76+
7177
@property
7278
def duty_cycle(self):
7379
"""16 bit value that dictates how much of one cycle is high (1) versus low (0). 0xffff will
@@ -114,7 +120,7 @@ class PCA9685:
114120
115121
:param ~busio.I2C i2c_bus: The I2C bus which the PCA9685 is connected to.
116122
:param int address: The I2C address of the PCA9685.
117-
:param int reference_clock_speed: The frequency of the internal reference clock in Herz.
123+
:param int reference_clock_speed: The frequency of the internal reference clock in Hertz.
118124
"""
119125
# Registers:
120126
mode1_reg = UnaryStruct(0x00, '<B')
@@ -135,7 +141,7 @@ def reset(self):
135141

136142
@property
137143
def frequency(self):
138-
"""The overall PWM frequency in herz."""
144+
"""The overall PWM frequency in Hertz."""
139145
return self.reference_clock_speed / 4096 / self.prescale_reg
140146

141147
@frequency.setter

0 commit comments

Comments
 (0)