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

Add documentation for the LEDControl plugin #1405

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 118 additions & 1 deletion plugins/Kaleidoscope-LEDControl/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,123 @@
# Kaleidoscope-LEDControl

This is a plugin for [Kaleidoscope][fw], for controlling the LEDs, and LED
effects.
effects. It is also a building block for plugins that control LEDs.

[fw]: https://github.com/keyboardio/Kaleidoscope

## Using the extension

## Plugin methods

### `.next_mode(void)`

> Activates the next LED mode. Cycles to the first LED mode if the current LED
> mode is the last one.

### `.prev_mode(void)`

> Activates the previous LED mode. Cycles to the last LED mode if the current
> LED mode is the first one.

### `.get_mode()`
EvyBongers marked this conversation as resolved.
Show resolved Hide resolved

> Returns the current LED mode.

### `.get_mode<typename>()`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know how to properly explain this. Having looked at the commit you mentioned on discord I understand what it does, but I don't know the words to explain it.



### `.set_mode(uint8_t mode_id)`

> Activates a LED mode by its index in the firmware. If the index exceeds the
> numer of led modes, the method returns early.

### `.get_mode_index()`

> Returns the index of the currently active LED mode.

### `.refreshAll()`

> If the hardware has LEDs and LEDs are enabled, turn all LEDs off and then
> trigger the current LED mode to refresh.

### `.setCrgbAt(uint8_t led_index, cRGB crgb)`

> Sets the specified LED to the provided color.

### `.setCrgbAt(KeyAddr key_addr, cRGB color)`

> Sets the LED for the specified key to the provided color.

### `.getCrgbAt(uint8_t led_index)`

> Get the LED color of the specified LED.

### `.getCrgbAt(KeyAddr key_addr)`

> Get the LED color of the LED for the specified key.

### `.syncLeds(void)`
EvyBongers marked this conversation as resolved.
Show resolved Hide resolved

> Force an update of all LEDs.

### `.set_all_leds_to(uint8_t r, uint8_t g, uint8_t b)`

> Set all LEDs using the provided rgb values.

### `.set_all_leds_to(cRGB color)`

> Set all LEDs to the specified color.

### `.setSyncInterval(uint8_t interval)`

> Set the interval at which the LEDs should sync, in milliseconds.
>
> Note: LED updates are considered on each cycle of the runtime. Because of
> that, the interval effectively means that _at least_ `interval` milliseconds
> has passed before LEDs are synced.

### `.setBrightness(uint8_t brightness)`

> Set the brightness for all LEDs.

### `.getBrightness()`

> Returns the current brightness of the LEDs as a uint8_t.

### `.onSetup()`

> See [[event-handler-hooks]]

### `.setup(void)`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to explain this one. I half expect it to be documented elsewhere and that I should refer to that, but I failed to find it.

### `.onKeyEvent(KeyEvent &event)`

> See [[event-handler-hooks]]

### `.afterEachCycle()`

> See [[event-handler-hooks]]

### `.update(void)`

> Triggers the currently active LED mode to update. It is up to the LED mode to
> handle this correctly.

### `.refreshAt(KeyAddr key_addr)`

> Triggers the currently active LED mode to refresh the LED at the specified key
> address.

### `.activate(LEDModeInterface *plugin)`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was about to write something along the lines of "Activates the specified LED mode." However, that would not prevent the judgement error recently pointed out to me that this actually invokes and depends on PROGMEM and/or EEPROM.



### `.disable()`

> Turn off all LEDs and disables updating LEDs

### `.enable()`

> Enables updating LEDs and calls `refreshAll()`

### `.isEnabled()`

> Returns a bool value reflecting whether LEDs are currently enabled.
Loading