-
Notifications
You must be signed in to change notification settings - Fork 53
Restrict set_mode/get_mode to supported variants only #121
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
Open
robberwick
wants to merge
9
commits into
arvydas:release/2.0-dev
Choose a base branch
from
robberwick:release/bs-pro-set-mode
base: release/2.0-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
db4f18a
feat: add Configuration dataclass for BlinkStick configuration repres…
robberwick e8faa71
feat: add configuration mappings for BlinkStick variants
robberwick fcb60f5
feat: add UnsupportedOperation exception for BlinkStick operations
robberwick 349f13f
test: add tests for set_mode and get_mode on supported BlinkStick var…
robberwick 6448402
test: refactor test_all_methods_require_backend to use parameterized …
robberwick 26eeade
feat: add cached property for device configuration and handle Unsuppo…
robberwick f16cc14
feat: handle UnsupportedOperation in print_info for BlinkStick mode r…
robberwick a463b96
refactor: remove unused imports in test_blinkstick.py
robberwick 9b42a2b
test: refactor test_set_mode_raises_on_invalid_mode to use mock for v…
robberwick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from blinkstick.enums import BlinkStickVariant | ||
from blinkstick.models import Configuration | ||
|
||
_VARIANT_CONFIGS: dict[BlinkStickVariant, Configuration] = { | ||
BlinkStickVariant.BLINKSTICK: Configuration( | ||
mode_change_support=False, | ||
), | ||
BlinkStickVariant.BLINKSTICK_PRO: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.BLINKSTICK_NANO: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.BLINKSTICK_SQUARE: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.BLINKSTICK_STRIP: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.BLINKSTICK_FLEX: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.UNKNOWN: Configuration( | ||
mode_change_support=False, | ||
), | ||
} | ||
|
||
|
||
def _get_device_config(variant: BlinkStickVariant) -> Configuration: | ||
"""Get the configuration for a BlinkStick variant""" | ||
return _VARIANT_CONFIGS.get(variant, _VARIANT_CONFIGS[BlinkStickVariant.UNKNOWN]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arvydas Is this correct? It wasn't clear to me if the non-pro multi addressable LED models (e.g. square, strip etc.) also supported mode change.. I figure they can't do mode 0 for a single RGB LED, but I wasn't clear on whether mode 1 (inverse mode) was supported in addressable mode, or what modes were available for variants that were not BS/BSPro.