-
Notifications
You must be signed in to change notification settings - Fork 8
Add sample component for SparkFun LED Stick #99
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
lizlooney
merged 21 commits into
wpilibsuite:main
from
lizlooney:pr_sample_component_led_stick
Mar 26, 2025
Merged
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3696cd5
Added sample implementation for SparkFun LED Stick.
lizlooney c6d495c
Add md file to show the blocks for the SparkFun LED Stick.
lizlooney 20a4078
Added toolbox for SparkFun LED Stick.
lizlooney 8338151
Fixed typos.
lizlooney c8d7b7d
Specify the type of the color arguments.
lizlooney 0138dc9
Merge branch 'main' of github.com:wpilibsuite/systemcore-blocks-inter…
lizlooney d3ec222
Merge branch 'main' of github.com:wpilibsuite/systemcore-blocks-inter…
lizlooney de754dd
Added support for calling component methods to the mrc_call_python_fu…
lizlooney 0d1464e
Show the component name in the instance method call tooltip.
lizlooney 7a0d635
Pass robot to OpMode.__init__.
lizlooney 9c8e04e
Removed wpilib from the component names shown in the tooltips.
lizlooney 0f3a9bb
Where component methods are called, generate self.robot.<component na…
lizlooney 00e779a
Put toolbox categories in alphabetical order.
lizlooney c5d1374
Updated md file.
lizlooney 56a64aa
more edits
lizlooney fd79e2a
Changed tooltip to use the word method instead of function.
lizlooney 784159c
Specify widths of images.
lizlooney 37125b9
Set image widths to 50%.
lizlooney 87b928d
More f'ing around with image sizes.
lizlooney f119f8c
Renamed file to index.md.
lizlooney 6705dfb
Merge branch 'main' of github.com:wpilibsuite/systemcore-blocks-inter…
lizlooney 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
# SparkFun LED Stick | ||
|
||
<img src="SparkFunLEDStick_set_color_1.png"> | ||
|
||
<img src="SparkFunLEDStick_set_brightness_1.png"> | ||
|
||
<img src="SparkFunLEDStick_set_brightness_2.png"> | ||
|
||
<img src="SparkFunLEDStick_set_color_2.png"> | ||
|
||
<img src="SparkFunLEDStick_set_colors.png"> | ||
|
||
<img src="SparkFunLEDStick_turn_all_off.png"> |
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,65 @@ | ||
from component import Component, PortType, InvalidPortException | ||
from enum import Enum | ||
import wpilib | ||
|
||
class SparkFunLEDStick(Component): | ||
def __init__(self, ports : list[tuple[PortType, int]]): | ||
portType, port = ports[0] | ||
if portType != PortType.I2C_PORT: | ||
raise InvalidPortException | ||
self.port = port | ||
|
||
# Component methods | ||
|
||
def get_manufacturer(self) -> str: | ||
return "SparkFun" | ||
|
||
def get_name(self) -> str: | ||
return "SparkFun Qwiic LED Strip" | ||
|
||
def get_part_number(self) -> str: | ||
return "COM-18354" | ||
|
||
def get_url(self) -> str: | ||
return "https://www.sparkfun.com/sparkfun-qwiic-led-stick-apa102c.html" | ||
|
||
def get_version(self) -> tuple[int, int, str]: | ||
return (1, 0, "") | ||
|
||
def stop(self) -> None: | ||
self.turn_all_off() | ||
|
||
def reset(self) -> None: | ||
pass | ||
|
||
def get_connection_port_type(self) -> list[PortType]: | ||
return [PortType.I2C_PORT] | ||
|
||
def periodic(self) -> None: | ||
pass | ||
|
||
# SparkFunLEDStick methods | ||
|
||
def set_color(self, position: int, color: wpilib.Color) -> None: | ||
'''Change the color of an individual LED.''' | ||
pass # TODO: implement | ||
|
||
def set_color(self, color: wpilib.Color) -> None: | ||
'''Change the color of all LEDs to a single color.''' | ||
pass # TODO: implement | ||
|
||
def set_colors(self, colors: list[int]) -> None: | ||
'''Change the color of all LEDs using a list.''' | ||
pass # TODO: implement | ||
|
||
def set_brightness(self, position: int, brightness: int) -> None: | ||
'''Set the brightness of an individual LED.''' | ||
pass # TODO: implement | ||
|
||
def set_brightness(self, brightness: int) -> None: | ||
'''Set the brightness of all LEDs.''' | ||
pass # TODO: implement | ||
|
||
def turn_all_off(self) -> None: | ||
'''Turn all LEDs off.''' | ||
pass # TODO: implement |
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
Oops, something went wrong.
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.