Skip to content

Commit f785d8f

Browse files
author
Florian Fleissner
committed
Added remote call capabilities for some LED-Palette-Theme features
Signed-off-by: Florian Fleissner <[email protected]>
1 parent 60372b7 commit f785d8f

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/kaleidoscope/plugin/LED-Palette-Theme.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ const cRGB LEDPaletteTheme::lookupPaletteColor(uint8_t color_index) {
8484
return color;
8585
}
8686

87+
void LEDPaletteTheme::setPaletteColor(uint8_t palette_index, cRGB color) {
88+
color.r ^= 0xff;
89+
color.g ^= 0xff;
90+
color.b ^= 0xff;
91+
Runtime.storage().put(palette_base_ + palette_index * sizeof(color), color);
92+
}
93+
8794
void LEDPaletteTheme::updateColorIndexAtPosition(uint16_t map_base, uint16_t position, uint8_t color_index) {
8895
uint8_t indexes;
8996

src/kaleidoscope/plugin/LED-Palette-Theme.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "kaleidoscope/Runtime.h"
2121
#include <Kaleidoscope-LEDControl.h>
22+
#include "kaleidoscope/remote_call.h"
2223

2324
namespace kaleidoscope {
2425
namespace 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

5557
extern 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

Comments
 (0)