Skip to content
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

pybricks.common: Refactored Speaker API to be hub specific. #91

Merged
merged 1 commit into from
Jan 5, 2022
Merged

pybricks.common: Refactored Speaker API to be hub specific. #91

merged 1 commit into from
Jan 5, 2022

Conversation

lobodpav
Copy link
Contributor

@lobodpav lobodpav commented Jan 5, 2022

The Prime/Inventor Hub Speaker allows only a subset of EV3 Speaker API. Hence, splitting the API up.

@lobodpav
Copy link
Contributor Author

lobodpav commented Jan 5, 2022

Wasn't quite sure about the right package structure and naming. Any advice?

Also, what's the purpose of from pybricks._common import Speaker # noqa E402 in the doc/common/conf.py causing the build to fail? Without that line the docs build passes.

Copy link
Member

@dlech dlech 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, thanks!

The module for the EV3 Speaker class doesn't really matter since it doesn't exist in MicroPython, so what you have done is fine. But for the SPIKE Prime version, lets just leave it where it was.

The stuff in conf.py might have been from some old hacks that we aren't using anymore. If removing all 3 lines there doesn't affect how the EV3 pages look when built, then I guess it is safe to remove, but we can address that separately.

@@ -370,116 +370,6 @@ def dc(self, duty):
"""


class Speaker:
Copy link
Member

Choose a reason for hiding this comment

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

This class should stay here and be modified to reflect what is implemented on SPIKE Prime.

@@ -80,20 +79,6 @@ class Motor(DCMotor):
) -> int: ...
def track_target(self, target_angle: int) -> None: ...

class Speaker:
Copy link
Member

Choose a reason for hiding this comment

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

This class should stay here and be modified to reflect what is implemented on SPIKE Prime.

@lobodpav
Copy link
Contributor Author

lobodpav commented Jan 5, 2022

But for the SPIKE Prime version, lets just leave it where it was.

Just wondering, why do you want to keep Prime Speaker in _common? The speaker only works for Prime Hub, so it does not seem common to me 😊

The stuff in conf.py might have been from some old hacks that we aren't using anymore. If removing all 3 lines there doesn't affect how the EV3 pages look when built, then I guess it is safe to remove, but we can address that separately.

I might be blind, but when looking at the doc built by poetry run make -C doc html, I see no EV3 doc whatsoever.

@dlech
Copy link
Member

dlech commented Jan 5, 2022

Just wondering, why do you want to keep Prime Speaker in _common? The speaker only works for Prime Hub, so it does not seem common to me blush

As I mentioned in the other issue, if we ever add support for NXT or if LEGO comes out with a new hub with a speaker, then it will be common.

I might be blind, but when looking at the doc built by poetry run make -C doc html, I see no EV3 doc whatsoever.

It does look like the EV3 build was removed, so I guess it doesn't matter.

@lobodpav
Copy link
Contributor Author

lobodpav commented Jan 5, 2022

@dlech How about now?

Copy link
Member

@dlech dlech 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 to me. Just one small nitpick (see inline comment).

from .geometry import Axis as _Axis
from .ev3dev._speaker import Speaker as _EV3Speaker
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to keep these in alphabetical order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, no problem. Forgot to hit the import optimisation shortcut. Fixed now.

The Prime/Inventor Hub Speaker allows only a subset of EV3 Speaker API. Hence, splitting the API up.
@dlech dlech merged commit 9700294 into pybricks:master Jan 5, 2022
@dlech
Copy link
Member

dlech commented Jan 5, 2022

Thanks!

@lobodpav lobodpav deleted the feature/speaker-api-refactoring branch January 5, 2022 18:12
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