Skip to content

Commit

Permalink
Added remote call capabilities for some LED-Palette-Theme features
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Fleissner <[email protected]>
  • Loading branch information
Florian Fleissner committed Jan 16, 2020
1 parent 60372b7 commit f785d8f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/kaleidoscope/plugin/LED-Palette-Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ const cRGB LEDPaletteTheme::lookupPaletteColor(uint8_t color_index) {
return color;
}

void LEDPaletteTheme::setPaletteColor(uint8_t palette_index, cRGB color) {
color.r ^= 0xff;
color.g ^= 0xff;
color.b ^= 0xff;
Runtime.storage().put(palette_base_ + palette_index * sizeof(color), color);
}

void LEDPaletteTheme::updateColorIndexAtPosition(uint16_t map_base, uint16_t position, uint8_t color_index) {
uint8_t indexes;

Expand Down
37 changes: 37 additions & 0 deletions src/kaleidoscope/plugin/LED-Palette-Theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "kaleidoscope/Runtime.h"
#include <Kaleidoscope-LEDControl.h>
#include "kaleidoscope/remote_call.h"

namespace kaleidoscope {
namespace plugin {
Expand All @@ -39,6 +40,7 @@ class LEDPaletteTheme : public kaleidoscope::Plugin {
static void updateColorIndexAtPosition(uint16_t theme_base, uint16_t position, uint8_t color_index);

static const cRGB lookupPaletteColor(uint8_t palette_index);
static void setPaletteColor(uint8_t palette_index, cRGB color);

EventHandlerResult onFocusEvent(const char *command);
EventHandlerResult themeFocusEvent(const char *command,
Expand All @@ -53,3 +55,38 @@ class LEDPaletteTheme : public kaleidoscope::Plugin {
}

extern kaleidoscope::plugin::LEDPaletteTheme LEDPaletteTheme;

KALEIDOSCOPE_REMOTE_CALL(
KRC_ROOT_PACKAGE(plugin,
KRC_PACKAGE(LEDPaletteTheme,
KRC_F(getPaletteColor,
((uint8_t, red), (uint8_t, green), (uint8_t, blue)),
((uint8_t, palette_index)),
(
cRGB color;
color = LEDPaletteTheme.lookupPaletteColor(args->palette_index);
results->red = color.r;
results->green = color.g;
results->blue = color.b;
),
KRC_DESCRIPTION("Retrieves the RGB value of a palette color")
)
KRC_F(setPaletteColor, KRC_NO_RESULTS,
((uint8_t, palette_index), (uint8_t, red), (uint8_t, green), (uint8_t, blue)),
(
LEDPaletteTheme.setPaletteColor(args->palette_index,
cRGB{args->red, args->green, args->blue});
),
KRC_DESCRIPTION("Sets the RGB value of a palette color")
)
KRC_F(commitPalette, KRC_NO_RESULTS, KRC_NO_ARGS,
(
Runtime.storage().commit();
::LEDControl.refreshAll();
),
KRC_DESCRIPTION("Sets the RGB value of a palette color")
)
)
)
)

0 comments on commit f785d8f

Please sign in to comment.