Skip to content

docs/machine/Signal: Clarify constructor behavior.#19342

Open
hlovatt wants to merge 1 commit into
micropython:masterfrom
hlovatt:master
Open

docs/machine/Signal: Clarify constructor behavior.#19342
hlovatt wants to merge 1 commit into
micropython:masterfrom
hlovatt:master

Conversation

@hlovatt

@hlovatt hlovatt commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Signed-off-by: Howard Lovatt howard.lovatt@gmail.com

Summary

The behaviour of the two constructors have a subtle difference that is worth documenting.

Testing

None. It's a doc change only.

Trade-offs and Alternatives

The two constructors could be made to behave the same.
However dpgeorge thought documenting the differences was a superior approach.
See #19263.

Generative AI

I did not use generative AI tools when creating this PR.

I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.

Signed-off-by: Howard Lovatt <howard.lovatt@gmail.com>

.. note::
If the pin is inverted *and* an initial value is given, then the two constructors
behave differently before a subsequent 'set'.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructors themselves don't really behave differently. Rather it's where you put the value=.

Eg if you had two value= then it'd be different again:

Signal(Pin(0, Pin.OUT, value=0), value=0, invert=True)

So I think this needs to be reworded. Something along the lines of "The value of the pin can be set in the Pin constructor and the Signal constructor. If the Signal is also inverted then an value set in the Pin constructor will be opposite".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants