Repository navigation
feat: add a brightness option for direct mode - #6
Merged
Merged
Conversation
Users who do not run the SidePulse service had no way to dim the LEDs. The plugin wrote every program at full brightness. The new `brightness` plugin option takes an integer from 0 to 255. In direct mode, the plugin puts `brightness N` before each LED program. In app mode, the plugin ignores the option, because the service applies its own brightness. The plugin ignores a value outside 0 to 255. OpenCode 2 passes the option in ctx.options. OpenCode 1 passes it as the second argument of server().
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Users who do not run the SidePulse service cannot dim the LEDs. In direct mode, the plugin writes every LED program at full brightness.
This change adds a
brightnessplugin option. The value is an integer from 0 (off) to 255 (full). In direct mode, the plugin puts abrightness Nline before each LED program. The controller then scales the colors.{ "plugins": [{ "package": "opencode-sidepulse", "options": { "brightness": 40 } }] }OpenCode 2 gives the option to the plugin in
ctx.options. OpenCode 1 gives it as the second argument ofserver(). The README shows the configuration for both versions.The plugin ignores the option in app mode, because the SidePulse service applies its own brightness setting. The plugin also ignores a value that is not an integer from 0 to 255, and then uses full brightness.
The version changes to 0.4.0, so the merge publishes the release.
Test
Run these commands from the repository root, on the
brightness-optionbranch:npm test node test/run.mjs brightnessThe first command shows
68 of 68 passed. The second command shows4 of 4 passed.The new tests cover direct mode on OpenCode 1 and OpenCode 2, an invalid value, and app mode. The self-check in
plugin.mjsnow also makes sure that each program stays within the controller limits of 512 bytes and 20 lines with the extrabrightnessline.