Skip to content

raise explanatory exception when trying to set channel frequency #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions adafruit_pca9685.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ def __init__(self, pca, index):

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

@frequency.setter
def frequency(self, _):
raise NotImplementedError("frequency cannot be set on individual channels")

@property
def duty_cycle(self):
"""16 bit value that dictates how much of one cycle is high (1) versus low (0). 0xffff will
Expand Down Expand Up @@ -114,7 +120,7 @@ class PCA9685:

:param ~busio.I2C i2c_bus: The I2C bus which the PCA9685 is connected to.
:param int address: The I2C address of the PCA9685.
:param int reference_clock_speed: The frequency of the internal reference clock in Herz.
:param int reference_clock_speed: The frequency of the internal reference clock in Hertz.
"""
# Registers:
mode1_reg = UnaryStruct(0x00, '<B')
Expand All @@ -135,7 +141,7 @@ def reset(self):

@property
def frequency(self):
"""The overall PWM frequency in herz."""
"""The overall PWM frequency in Hertz."""
return self.reference_clock_speed / 4096 / self.prescale_reg

@frequency.setter
Expand Down