Skip to content

Conversation

@alan412
Copy link
Collaborator

@alan412 alan412 commented Mar 10, 2025

Here is a quick - what the base class might look like and a sample one. I think by requiring type hints that we might be able to get away with no blocks specific information needed.

@alan412 alan412 requested a review from lizlooney March 10, 2025 20:50
Copy link
Collaborator

@lizlooney lizlooney left a comment

Choose a reason for hiding this comment

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

Looks good. I made a few comments.


class RevTouchSensor(Component):
def __init__(self, ports : list[tuple[PortType, int]]):
self.is_pressed = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like is_pressed should be a boolean, so the value should be False instead of None.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It can't be, because when the system boots up you don't know if the touch sensor is currently pressed or not. If you start out saying it isn't, then you'll get an immediate callback for pressed even though that isn't accurate. So you have to start out before your first read with something that knows it hasn't read hardware yet.

Leaving this comment open to see if you agree or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK. That makes sense.

@alan412 alan412 changed the title Quick pass at external sample Quick pass at sample components Mar 18, 2025
@alan412 alan412 marked this pull request as ready for review March 18, 2025 22:02
@alan412 alan412 requested a review from lizlooney March 18, 2025 22:02
@lizlooney lizlooney merged commit f08c2ab into wpilibsuite:main Mar 19, 2025
1 check passed
@alan412 alan412 deleted the sample_components branch March 21, 2025 17:43
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.

2 participants