-
Notifications
You must be signed in to change notification settings - Fork 290
Add support for Green/Yellow status LEDs, like is used on some Limelights #2287
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
thatcomputerguy0101
wants to merge
11
commits into
PhotonVision:main
Choose a base branch
from
thatcomputerguy0101:limelight-leds
base: main
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
11 commits
Select commit
Hold shift + click to select a range
21c5a80
Add support for LL-style status LEDs
thatcomputerguy0101 a71673d
Rename LL led type to GY/Green-Yellow
thatcomputerguy0101 0b20432
Fix Windows lazy device factory initialization
thatcomputerguy0101 74f00d0
Add status LED documentation
thatcomputerguy0101 f8602e5
Remove unused sphinx-tabs dependency
thatcomputerguy0101 3b3f7e1
Add link to status LED table from custom hardware docs
thatcomputerguy0101 6471ba2
Center LED indicators
thatcomputerguy0101 60e5a2e
Fix LED dark mode rendering
thatcomputerguy0101 eda178a
Reword LED used on message
thatcomputerguy0101 52a71cc
Fix GY yellow led documentation and update solid color LEDs to actual…
thatcomputerguy0101 004933e
Merge branch 'main' into limelight-leds
thatcomputerguy0101 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
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
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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| common-errors | ||
| logging | ||
| status-leds | ||
| camera-troubleshooting | ||
| networking-troubleshooting | ||
| unix-commands | ||
|
|
||
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,92 @@ | ||
| --- | ||
| myst: | ||
| substitutions: | ||
| led_loader: | | ||
| ```{image} images/led.svg | ||
| :height: 0 | ||
| ``` | ||
| led_green: | | ||
| ```{raw} html | ||
| <object data="../../_images/led.svg"> | ||
| <param name="onColor" value="limegreen"/> | ||
| </object> | ||
| ``` | ||
| led_solid_blue: | | ||
| ```{raw} html | ||
| <object data="../../_images/led.svg"> | ||
| <param name="onColor" value="blue"/> | ||
| <param name="onTime" value="indefinite"/> | ||
| </object> | ||
| ``` | ||
| led_yellow: | | ||
| ```{raw} html | ||
| <object data="../../_images/led.svg"> | ||
| <param name="onColor" value="yellow"/> | ||
| </object> | ||
| ``` | ||
| led_blue: | | ||
| ```{raw} html | ||
| <object data="../../_images/led.svg"> | ||
| <param name="onColor" value="blue"/> | ||
| </object> | ||
| ``` | ||
| led_red: | | ||
| ```{raw} html | ||
| <object data="../../_images/led.svg"> | ||
| <param name="onColor" value="red"/> | ||
| </object> | ||
| ``` | ||
| led_off: | | ||
| ```{raw} html | ||
| <object data="../../_images/led.svg"> | ||
| <param name="onColor" value="transparent"/> | ||
| <param name="onTime" value="indefinite"/> | ||
| </object> | ||
| ``` | ||
| led_fast_green: | | ||
| ```{raw} html | ||
| <object data="../../_images/led.svg"> | ||
| <param name="onColor" value="limegreen"/> | ||
| <param name="onTime" value="75ms"/> | ||
| <param name="offTime" value="75ms"/> | ||
| </object> | ||
| ``` | ||
| led_solid_yellow: | | ||
| ```{raw} html | ||
| <object data="../../_images/led.svg"> | ||
| <param name="onColor" value="yellow"/> | ||
| <param name="onTime" value="indefinite"/> | ||
| </object> | ||
| ``` | ||
| --- | ||
|
|
||
| # Status LEDs | ||
|
|
||
| PhotonVision has support for multiple kinds of status LEDs. Make sure you reference the correct table for the type present on your hardware. | ||
|
|
||
| ## RGB LED | ||
|
|
||
| Color | Flashing | Preview | Status | ||
| --------|----------|:--------------------:|----------------------------------------------- | ||
| Green | Yes | {{ led_green }} | Running normally, no targets visible | ||
| Blue | No | {{ led_solid_blue }} | Running normally, targets visible | ||
| Yellow | Yes | {{ led_yellow }} | NT Disconnected, no targets visible | ||
| Blue | Yes | {{ led_blue }} | NT Disconnected, targets visible | ||
| Red | Yes | {{ led_red }} | Initializing or faulted, not running | ||
| Off | No | {{ led_off }} | No power or initialization fault, not running | ||
|
|
||
| ## Green and Yellow LEDs | ||
|
|
||
| Used on Limelight 1, 2, 2+, 3, 3G, and 3A | ||
|
|
||
| Green and Yellow LED patterns may be active at the same time | ||
|
|
||
| Color | Pattern | Preview | Status | ||
| --------|----------------|:------------------------------------:|------------------------------------------------- | ||
| Green | Slow Flashing | {{ led_green }} {{ led_off }} | No targets visible | ||
| Green | Quick Flashing | {{ led_fast_green }} {{ led_off }} | Targets visible | ||
| Yellow | Flashing | {{ led_off }} {{ led_yellow }} | NT Disconnected | ||
| Yellow | Solid | {{ led_off }} {{ led_solid_yellow }} | NT Connected | ||
| Both | Off | {{ led_off }} {{ led_off }} | No power, initializing, or faulted, not running | ||
|
|
||
| {{ led_loader }} |
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
91 changes: 91 additions & 0 deletions
91
photon-core/src/main/java/org/photonvision/common/hardware/statusLED/GYStatusLED.java
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,91 @@ | ||
| /* | ||
| * Copyright (C) Photon Vision. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package org.photonvision.common.hardware.statusLED; | ||
|
|
||
| import com.diozero.devices.LED; | ||
| import com.diozero.internal.spi.NativeDeviceFactoryInterface; | ||
| import java.util.List; | ||
| import org.photonvision.common.hardware.PhotonStatus; | ||
| import org.photonvision.common.util.TimedTaskManager; | ||
|
|
||
| /** A pair of green and yellow LEDs, as used on the Limelight cameras */ | ||
| public class GYStatusLED implements StatusLED { | ||
| public final LED greenLED; | ||
| public final LED yellowLED; | ||
| protected int blinkCounter; | ||
|
|
||
| protected PhotonStatus status = PhotonStatus.GENERIC_ERROR; | ||
|
|
||
| public GYStatusLED( | ||
| NativeDeviceFactoryInterface deviceFactory, List<Integer> statusLedPins, boolean activeHigh) { | ||
| // fill unassigned pins with -1 to disable | ||
| if (statusLedPins.size() != 3) { | ||
| for (int i = 0; i < 3 - statusLedPins.size(); i++) { | ||
| statusLedPins.add(-1); | ||
| } | ||
| } | ||
|
|
||
| // Outputs are active-low for a common-anode RGB LED | ||
| greenLED = new LED(deviceFactory, statusLedPins.get(0), activeHigh, false); | ||
| yellowLED = new LED(deviceFactory, statusLedPins.get(1), activeHigh, false); | ||
|
|
||
| TimedTaskManager.getInstance().addTask("StatusLEDUpdate", this::updateLED, 75); | ||
| } | ||
|
|
||
| protected void setLEDs(boolean green, boolean yellow) { | ||
| greenLED.setOn(green); | ||
| yellowLED.setOn(yellow); | ||
| } | ||
|
|
||
| @Override | ||
| public void setStatus(PhotonStatus status) { | ||
| this.status = status; | ||
| } | ||
|
|
||
| protected void updateLED() { | ||
| boolean slowBlink = blinkCounter > 1; | ||
| boolean fastBlink = (blinkCounter % 2) > 0; | ||
|
|
||
| switch (status) { | ||
| case NT_CONNECTED_TARGETS_VISIBLE -> | ||
| // Green fast, yellow on | ||
| setLEDs(fastBlink, true); | ||
| case NT_CONNECTED_TARGETS_MISSING -> | ||
| // Green slow, yellow on | ||
| setLEDs(slowBlink, true); | ||
| case NT_DISCONNECTED_TARGETS_VISIBLE -> | ||
| // Green fast, yellow slow | ||
| setLEDs(fastBlink, slowBlink); | ||
| case NT_DISCONNECTED_TARGETS_MISSING -> | ||
| // Green slow, yellow slow | ||
| setLEDs(slowBlink, slowBlink); | ||
| case GENERIC_ERROR -> | ||
| // No lights | ||
| setLEDs(false, false); | ||
|
Comment on lines
+77
to
+79
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am debating between no lights and a slow green blink with no yellow. There is no precedent from Limelight on this case. |
||
| } | ||
|
|
||
| blinkCounter++; | ||
| blinkCounter %= 6; | ||
| } | ||
|
|
||
| @Override | ||
| public void close() throws Exception { | ||
| greenLED.close(); | ||
| yellowLED.close(); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
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.
With more LED support added to these hardware configuration files, I'm not sure hidden in the documentation is the best spot for them anymore. It feels more appropriate to install them in the images available for download, like is done for Luma P1. However, I'm also not sure if I like the sqlite database being committed for just hardware config, since it is a lot harder to view the contents of a sqlite than it is for JSON.
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.
Absolutely agree. Maybe for 27. Let's talk about committing Jason files but converting them using some sort of Java tool?