Skip to content

Support for inverted clocks #27

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 4 commits into from
May 2, 2022
Merged

Conversation

mfhepp
Copy link
Contributor

@mfhepp mfhepp commented May 2, 2022

See #26

This adds support for inverted clock outputs, which is an easy way of obtaining a pair of 0° and 180° phase shifted signals from the same clock.

I added the parameter inverted=False to the two methods for configuring clocks.

So you can now create a pair of clocks like so

    si5351.clock_0.configure_fractional(si5351.pll_a, int_divider, numerator, denominator,
                                        inverted=False)
    si5351.clock_1.configure_fractional(si5351.pll_a, int_divider, numerator, denominator,
                                        inverted=True)

The default behavior is unchanged.

@ladyada
Copy link
Member

ladyada commented May 2, 2022

hiya! thanks so much for submitting a PR! we can review & merge PRs once they have passed continuous integration (CI). that means that code is 'linted' - that means it is formatted and passes basic structure tests, so that we maintain the same text formatting for all new code
if your code isnt passing, check the CI output (click on the red X next to the PR to scroll through the log and find where the error is

here is a tutorial on pylint and black: https://learn.adafruit.com/improve-your-code-with-pylint

and overall how to contribute PRs to circuitpython: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

once you get that green checkmark that indicates CI has passed, please comment reply to this post so we know its time for another review (we may not get notified on CI pass and miss that its time to look!)

@mfhepp
Copy link
Contributor Author

mfhepp commented May 2, 2022

Thanks! The CI test fails because it does not want more than five arguments for a method. However, I do not see an elegant way of avoiding that in this case:

def configure_fractional(self, pll, divider, numerator, denominator, inverted=False):
          """Configure the clock output with the specified PLL source ...

because pll, divider, numerator, denominator are mandatory for this functionality, and the inverted option is IMO best handled via an optional argument. Adding a method or attribute does not work well, because you need to reset the SI5351 PLL when changing the phase, and an intransparent PLL reset seems bad to me.

@dhalbert
Copy link
Contributor

dhalbert commented May 2, 2022

Add a # pylint: disable=too-many-arguments to the routine in question. It's fine to override these guidelines as necessary.

@tekktrik
Copy link
Member

tekktrik commented May 2, 2022

@mfhepp Looks like black is angry again, running pre-commit run --all-files again should fix it!

@mfhepp
Copy link
Contributor Author

mfhepp commented May 2, 2022

@mfhepp Looks like black is angry again, running pre-commit run --all-files again should fix it!

Thanks - but even after running pre-commit run --all-files, it does not pass.

@dhalbert
Copy link
Contributor

dhalbert commented May 2, 2022

Thanks - but even after running pre-commit run --all-files, it does not pass.

If it is black that was complaining, it will reformat the files, and you can then push a new commit.

If that is what you already did, then there may be a version difference between the black you are using the the one that the CI is using.

@tekktrik tekktrik merged commit c1049b8 into adafruit:main May 2, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 3, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_AHTx0 to 1.0.11 from 1.0.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_AHTx0#13 from sabadam32/fix_typeing_9
  > change discord badge
  > Patch: Replaced discord badge image
  > Update .gitignore
  > Update Black to latest.

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS to 4.5.0 from 4.4.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM6DS#56 from Edrig/main
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore

Updating https://github.com/adafruit/Adafruit_CircuitPython_MONSTERM4SK to 0.3.3 from 0.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MONSTERM4SK#12 from Neradoc/patch-1
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.10.14 from 3.10.13:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#107 from FoamyGuy/debounce_buttons_gif_example
  > change discord badge

Updating https://github.com/adafruit/Adafruit_CircuitPython_SI5351 to 1.3.0 from 1.2.11:
  > Merge pull request adafruit/Adafruit_CircuitPython_SI5351#27 from mfhepp/inverted_outputs
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7789 to 1.5.8 from 1.5.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_ST7789#32 from rmblau/main
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.

Updating https://github.com/adafruit/Adafruit_CircuitPython_TPA2016 to 1.1.8 from 1.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_TPA2016#10 from adafruit/doc/add-typing
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO to 5.6.6 from 5.6.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_AdafruitIO#90 from Vsaggiomo/main
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore

Updating https://github.com/adafruit/Adafruit_CircuitPython_binascii to 1.2.10 from 1.2.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_binascii#15 from tekktrik/dod/typing-correction-just-blinka
  > change discord badge
  > Patch: Replaced discord badge image
  > Update .gitignore
  > Update Black to latest.

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Radio to 0.5.2 from 0.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Radio#23 from ktkinsey37/typing
  > change discord badge
  > Patch: Replaced discord badge image
  > Update .gitignore
  > Update Black to latest.

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_BerryMed_Pulse_Oximeter to 2.0.9 from 2.0.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_BerryMed_Pulse_Oximeter#10 from awordforthat/add-type-annotations
  > change discord badge
  > Patch: Replaced discord badge image
  > Update .gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Magic_Light to 0.9.11 from 0.9.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Magic_Light#10 from ktkinsey37/typing
  > change discord badge
  > Patch: Replaced discord badge image
  > Update .gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.7.1 from 0.7.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#41 from jepler/pulsegroup
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#42 from jepler/diverse-integers
  > change discord badge
  > Patch: Replaced discord badge image
  > Update .gitignore

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyBadger to 3.7.0 from 3.6.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyBadger#58 from adafruit/updates
  > change discord badge
  > Patch: Replaced discord badge image
  > Update .gitignore
@mfhepp mfhepp deleted the inverted_outputs branch June 29, 2022 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants