Skip to content

Updated tune_cap property to take/resturn pf values #2

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 10, 2019
Merged
Show file tree
Hide file tree
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: 6 additions & 6 deletions examples/example3_tune_antenna_i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
# 16 by default but can be 32, 64, or 128, depending on what value you set.
print ('Division Ratio is set to: ', str(lightning.division_ratio))

# Here you give a value of 0-15, which increases the capacitance on
# the RLC circuit in steps of 8pF, up to 120pF. For example giving a
# paramater of 2: 2 * 8pF = 16pF. # The change in frequency is very modest.
# At 15 (max - 120pF), the frequency is around 490kHz down from 512kHz.
# The equation for calculating frequency in an RLC circuit is:
# f = 1/(2pi*sqrt(LC)). To change the capacitance, uncomment the line below.
# Here you can set a value of 0-120, which increases the capacitance on
# the RLC circuit in steps of 8pF, up to 120pF. The change in frequency is
# very modest. At 15 (max - 120pF), the frequency is around 490kHz down from
# 512kHz. The equation for calculating frequency in an RLC circuit is:
# f = 1/(2pi*sqrt(LC))
# To change the capacitance, uncomment the line below.
# lightning.tune_cap = 0

# When reading the internal capcitor value, it will return the value in pF.
Expand Down
12 changes: 6 additions & 6 deletions examples/example3_tune_antenna_spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
# 16 by default but can be 32, 64, or 128, depending on what value you set.
print ('Division Ratio is set to: ', str(lightning.division_ratio))

# Here you give a value of 0-15, which increases the capacitance on
# the RLC circuit in steps of 8pF, up to 120pF. For example giving a
# paramater of 2: 2 * 8pF = 16pF. # The change in frequency is very modest.
# At 15 (max - 120pF), the frequency is around 490kHz down from 512kHz.
# The equation for calculating frequency in an RLC circuit is:
# f = 1/(2pi*sqrt(LC)). To change the capacitance, uncomment the line below.
# Here you can set a value of 0-120, which increases the capacitance on
# the RLC circuit in steps of 8pF, up to 120pF. The change in frequency is
# very modest. At 15 (max - 120pF), the frequency is around 490kHz down from
# 512kHz. The equation for calculating frequency in an RLC circuit is:
# f = 1/(2pi*sqrt(LC))
# To change the capacitance, uncomment the line below.
# lightning.tune_cap = 0

# When reading the internal capcitor value, it will return the value in pF.
Expand Down
18 changes: 10 additions & 8 deletions sparkfun_qwiicas3935.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,8 @@ def division_ratio(self, value):

@property
def tune_cap(self):
"""This setting will return the capacitance of the internal capacitors. It will
return a value from one to 15 multiplied by the 8pF steps of the internal
capacitance."""
"""This setting will return the capacitance of the internal capacitor.
It will return a value from 0 to 120pF, in 8pF steps."""
# REG0x08, bits [3:0], manufacturer default: 0.

value = self._read_register(_FREQ_DISP_IRQ)
Expand All @@ -500,13 +499,16 @@ def tune_cap(self):
@tune_cap.setter
def tune_cap(self, value):
"""This setting will add capacitance to the series RLC antenna on the
product. It's possible to add 0-120pF in steps of 8pF to the antenna.
The Tuning Cap value must be between 0 and 15."""
product. It's possible to add 0-120pF in steps of 8pF to the antenna.
The Tuning Cap value will be set between 0 and 120pF, in steps of 8pF.
If necessary, the input value is rounded down to the nearest 8pF."""
# REG0x08, bits [3:0], manufacturer default: 0.
if value < 0 or value > 15:
raise ValueError('The Tuning Cap value must be between 0 and 15.')
# Divide down to integer 0 - 15, rounding down
reg_value = value // 8
if reg_value < 0 or reg_value > 15:
raise ValueError('The Tuning Cap value must be between 0 and 120pF.')

self._write_register_bits(_FREQ_DISP_IRQ, _CAP_MASK, value, 0)
self._write_register_bits(_FREQ_DISP_IRQ, _CAP_MASK, reg_value, 0)

# abstract methods
@abstractmethod
Expand Down