1919
2020#include " kaleidoscope/Runtime.h"
2121#include < Kaleidoscope-LEDControl.h>
22+ #include " kaleidoscope/remote_call.h"
2223
2324namespace kaleidoscope {
2425namespace plugin {
@@ -39,6 +40,7 @@ class LEDPaletteTheme : public kaleidoscope::Plugin {
3940 static void updateColorIndexAtPosition (uint16_t theme_base, uint16_t position, uint8_t color_index);
4041
4142 static const cRGB lookupPaletteColor (uint8_t palette_index);
43+ static void setPaletteColor (uint8_t palette_index, cRGB color);
4244
4345 EventHandlerResult onFocusEvent (const char *command);
4446 EventHandlerResult themeFocusEvent (const char *command,
@@ -53,3 +55,38 @@ class LEDPaletteTheme : public kaleidoscope::Plugin {
5355}
5456
5557extern kaleidoscope::plugin::LEDPaletteTheme LEDPaletteTheme;
58+
59+ KALEIDOSCOPE_REMOTE_CALL (
60+ KRC_ROOT_PACKAGE (plugin,
61+ KRC_PACKAGE (LEDPaletteTheme,
62+ KRC_F (getPaletteColor,
63+ ((uint8_t , red), (uint8_t , green), (uint8_t , blue)),
64+ ((uint8_t , palette_index)),
65+ (
66+ cRGB color;
67+ color = LEDPaletteTheme.lookupPaletteColor(args->palette_index);
68+ results->red = color.r;
69+ results->green = color.g;
70+ results->blue = color.b;
71+ ),
72+ KRC_DESCRIPTION(" Retrieves the RGB value of a palette color" )
73+ )
74+ KRC_F(setPaletteColor, KRC_NO_RESULTS,
75+ ((uint8_t , palette_index), (uint8_t , red), (uint8_t , green), (uint8_t , blue)),
76+ (
77+ LEDPaletteTheme.setPaletteColor(args->palette_index,
78+ cRGB{args->red , args->green , args->blue });
79+ ),
80+ KRC_DESCRIPTION(" Sets the RGB value of a palette color" )
81+ )
82+ KRC_F(commitPalette, KRC_NO_RESULTS, KRC_NO_ARGS,
83+ (
84+ Runtime.storage().commit();
85+ ::LEDControl.refreshAll();
86+ ),
87+ KRC_DESCRIPTION (" Sets the RGB value of a palette color" )
88+ )
89+ )
90+ )
91+ )
92+
0 commit comments