diff --git a/plugins/Kaleidoscope-Colormap/src/kaleidoscope/plugin/Colormap.h b/plugins/Kaleidoscope-Colormap/src/kaleidoscope/plugin/Colormap.h index 1fcf480b9f..3a34aed024 100644 --- a/plugins/Kaleidoscope-Colormap/src/kaleidoscope/plugin/Colormap.h +++ b/plugins/Kaleidoscope-Colormap/src/kaleidoscope/plugin/Colormap.h @@ -32,8 +32,8 @@ class ColormapEffect : public Plugin, public LEDModeInterface, public AccessTransientLEDMode { public: - ColormapEffect() { ledModeName = "Colormap"; } - explicit ColormapEffect(char *customName) { ledModeName = customName; } + ColormapEffect() { ledModeName = F("Colormap"); } + explicit ColormapEffect(__FlashStringHelper *customName) { ledModeName = customName; } void max_layers(uint8_t max_); diff --git a/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.h b/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.h index d490277c27..c80096f788 100644 --- a/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.h +++ b/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.h @@ -33,8 +33,8 @@ namespace plugin { // class FingerPainter : public LEDMode { public: - FingerPainter() { ledModeName = "FingerPainter"; } - explicit FingerPainter(char *customName) { ledModeName = customName; } + FingerPainter() { ledModeName = F("FingerPainter"); } + explicit FingerPainter(__FlashStringHelper *customName) { ledModeName = customName; } void toggle(); diff --git a/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp b/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp index b0cc67f90f..76113e5d93 100644 --- a/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp +++ b/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp @@ -77,7 +77,7 @@ EventHandlerResult FocusSerial::afterEachCycle() { return EventHandlerResult::OK; } -void ledModeHandler_(const char *name) { +void ledModeHandler_(const __FlashStringHelper *name) { Runtime.serialPort().println(name); } diff --git a/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.h b/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.h index 093a99bb12..179c06675c 100644 --- a/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.h +++ b/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.h @@ -17,7 +17,7 @@ #pragma once -#include // for delayMicroseconds +#include // for __FlashStringHelper, delayMicroseconds #include // for HardwareSerial #include // for uint8_t, uint16_t diff --git a/plugins/Kaleidoscope-Heatmap/src/kaleidoscope/plugin/Heatmap.h b/plugins/Kaleidoscope-Heatmap/src/kaleidoscope/plugin/Heatmap.h index f37f7bb6af..e2c976cbae 100644 --- a/plugins/Kaleidoscope-Heatmap/src/kaleidoscope/plugin/Heatmap.h +++ b/plugins/Kaleidoscope-Heatmap/src/kaleidoscope/plugin/Heatmap.h @@ -34,8 +34,8 @@ class Heatmap : public Plugin, public LEDModeInterface, public AccessTransientLEDMode { public: - Heatmap() { ledModeName = "Heatmap"; } - explicit Heatmap(char *customName) { ledModeName = customName; } + Heatmap() { ledModeName = F("Heatmap"); } + explicit Heatmap(__FlashStringHelper *customName) { ledModeName = customName; } static uint16_t update_delay; static const cRGB *heat_colors; diff --git a/plugins/Kaleidoscope-LED-ActiveLayerColor/src/kaleidoscope/plugin/LED-ActiveLayerColor.h b/plugins/Kaleidoscope-LED-ActiveLayerColor/src/kaleidoscope/plugin/LED-ActiveLayerColor.h index 7e3d153cca..b5b8869477 100644 --- a/plugins/Kaleidoscope-LED-ActiveLayerColor/src/kaleidoscope/plugin/LED-ActiveLayerColor.h +++ b/plugins/Kaleidoscope-LED-ActiveLayerColor/src/kaleidoscope/plugin/LED-ActiveLayerColor.h @@ -31,8 +31,8 @@ class LEDActiveLayerColorEffect : public Plugin, public LEDModeInterface, public AccessTransientLEDMode { public: - LEDActiveLayerColorEffect() { ledModeName = "ActiveLayerColor"; } - explicit LEDActiveLayerColorEffect(char *customName) { ledModeName = customName; } + LEDActiveLayerColorEffect() { ledModeName = F("ActiveLayerColor"); } + explicit LEDActiveLayerColorEffect(__FlashStringHelper *customName) { ledModeName = customName; } EventHandlerResult onLayerChange(); void setColormap(const cRGB colormap[]); diff --git a/plugins/Kaleidoscope-LED-ActiveLayerKeys/src/kaleidoscope/plugin/LED-ActiveLayerKeys.h b/plugins/Kaleidoscope-LED-ActiveLayerKeys/src/kaleidoscope/plugin/LED-ActiveLayerKeys.h index e94cc5dab5..df47d0a43a 100644 --- a/plugins/Kaleidoscope-LED-ActiveLayerKeys/src/kaleidoscope/plugin/LED-ActiveLayerKeys.h +++ b/plugins/Kaleidoscope-LED-ActiveLayerKeys/src/kaleidoscope/plugin/LED-ActiveLayerKeys.h @@ -31,11 +31,10 @@ class LEDActiveLayerKeysEffect : public Plugin, public LEDModeInterface, public AccessTransientLEDMode { public: - LEDActiveLayerKeysEffect() { ledModeName = "ActiveLayerKeys"; } - explicit LEDActiveLayerKeysEffect(char *customName) { ledModeName = customName; } + LEDActiveLayerKeysEffect() { ledModeName = F("ActiveLayerKeys"); } + explicit LEDActiveLayerKeysEffect(__FlashStringHelper *customName) { ledModeName = customName; } EventHandlerResult onLayerChange(); - template void setColormap(cRGB const (&colormap)[_colormap_size]) { colormap_ = colormap; diff --git a/plugins/Kaleidoscope-LED-AlphaSquare/src/kaleidoscope/plugin/LED-AlphaSquare/Effect.h b/plugins/Kaleidoscope-LED-AlphaSquare/src/kaleidoscope/plugin/LED-AlphaSquare/Effect.h index 087b956889..1aea766aec 100644 --- a/plugins/Kaleidoscope-LED-AlphaSquare/src/kaleidoscope/plugin/LED-AlphaSquare/Effect.h +++ b/plugins/Kaleidoscope-LED-AlphaSquare/src/kaleidoscope/plugin/LED-AlphaSquare/Effect.h @@ -34,8 +34,8 @@ class AlphaSquareEffect : public Plugin, public LEDModeInterface, public AccessTransientLEDMode { public: - AlphaSquareEffect() { ledModeName = "AlphaSquare"; } - explicit AlphaSquareEffect(char *customName) { ledModeName = customName; } + AlphaSquareEffect() { ledModeName = F("AlphaSquare"); } + explicit AlphaSquareEffect(__FlashStringHelper *customName) { ledModeName = customName; } static uint16_t length; diff --git a/plugins/Kaleidoscope-LED-Stalker/src/kaleidoscope/plugin/LED-Stalker.h b/plugins/Kaleidoscope-LED-Stalker/src/kaleidoscope/plugin/LED-Stalker.h index 6f81b2ad61..d1827e2ae5 100644 --- a/plugins/Kaleidoscope-LED-Stalker/src/kaleidoscope/plugin/LED-Stalker.h +++ b/plugins/Kaleidoscope-LED-Stalker/src/kaleidoscope/plugin/LED-Stalker.h @@ -36,8 +36,8 @@ class StalkerEffect : public Plugin, public LEDModeInterface, public AccessTransientLEDMode { public: - StalkerEffect() { ledModeName = "Stalker"; } - explicit StalkerEffect(char *customName) { ledModeName = customName; } + StalkerEffect() { ledModeName = F("Stalker"); } + explicit StalkerEffect(__FlashStringHelper *customName) { ledModeName = customName; } class ColorComputer { public: diff --git a/plugins/Kaleidoscope-LED-Wavepool/src/kaleidoscope/plugin/LED-Wavepool.h b/plugins/Kaleidoscope-LED-Wavepool/src/kaleidoscope/plugin/LED-Wavepool.h index 69b07fd304..d24629d31d 100644 --- a/plugins/Kaleidoscope-LED-Wavepool/src/kaleidoscope/plugin/LED-Wavepool.h +++ b/plugins/Kaleidoscope-LED-Wavepool/src/kaleidoscope/plugin/LED-Wavepool.h @@ -41,8 +41,8 @@ class WavepoolEffect : public Plugin, public LEDModeInterface, public AccessTransientLEDMode { public: - WavepoolEffect() { ledModeName = "Wavepool"; } - explicit WavepoolEffect(char *customName) { ledModeName = customName; } + WavepoolEffect() { ledModeName = F("Wavepool"); } + explicit WavepoolEffect(__FlashStringHelper *customName) { ledModeName = customName; } EventHandlerResult onKeyEvent(KeyEvent &event); diff --git a/plugins/Kaleidoscope-LEDEffect-Breathe/src/kaleidoscope/plugin/LEDEffect-Breathe.h b/plugins/Kaleidoscope-LEDEffect-Breathe/src/kaleidoscope/plugin/LEDEffect-Breathe.h index 1a3a2333bd..cfd9d05c6a 100644 --- a/plugins/Kaleidoscope-LEDEffect-Breathe/src/kaleidoscope/plugin/LEDEffect-Breathe.h +++ b/plugins/Kaleidoscope-LEDEffect-Breathe/src/kaleidoscope/plugin/LEDEffect-Breathe.h @@ -27,8 +27,8 @@ namespace plugin { class LEDBreatheEffect : public Plugin, public LEDModeInterface { public: - LEDBreatheEffect() { ledModeName = "Breathe"; } - explicit LEDBreatheEffect(char *customName) { ledModeName = customName; } + LEDBreatheEffect() { ledModeName = F("Breathe"); } + explicit LEDBreatheEffect(__FlashStringHelper *customName) { ledModeName = customName; } uint8_t hue = 170; uint8_t saturation = 255; diff --git a/plugins/Kaleidoscope-LEDEffect-Chase/src/kaleidoscope/plugin/LEDEffect-Chase.h b/plugins/Kaleidoscope-LEDEffect-Chase/src/kaleidoscope/plugin/LEDEffect-Chase.h index 1f4adadb2c..d16366091f 100644 --- a/plugins/Kaleidoscope-LEDEffect-Chase/src/kaleidoscope/plugin/LEDEffect-Chase.h +++ b/plugins/Kaleidoscope-LEDEffect-Chase/src/kaleidoscope/plugin/LEDEffect-Chase.h @@ -28,8 +28,8 @@ namespace plugin { class LEDChaseEffect : public Plugin, public LEDModeInterface { public: - LEDChaseEffect() { ledModeName = "Chase"; } - explicit LEDChaseEffect(char *customName) { ledModeName = customName; } + LEDChaseEffect() { ledModeName = F("Chase"); } + explicit LEDChaseEffect(__FlashStringHelper *customName) { ledModeName = customName; } uint8_t update_delay() { return update_delay_; diff --git a/plugins/Kaleidoscope-LEDEffect-DigitalRain/src/kaleidoscope/plugin/LEDEffect-DigitalRain.h b/plugins/Kaleidoscope-LEDEffect-DigitalRain/src/kaleidoscope/plugin/LEDEffect-DigitalRain.h index d53ddb8977..0b333b7fc3 100644 --- a/plugins/Kaleidoscope-LEDEffect-DigitalRain/src/kaleidoscope/plugin/LEDEffect-DigitalRain.h +++ b/plugins/Kaleidoscope-LEDEffect-DigitalRain/src/kaleidoscope/plugin/LEDEffect-DigitalRain.h @@ -26,8 +26,8 @@ class LEDDigitalRainEffect : public Plugin, public LEDModeInterface, public AccessTransientLEDMode { public: - LEDDigitalRainEffect() { ledModeName = "DigitalRain"; } - explicit LEDDigitalRainEffect(char *customName) { ledModeName = customName; } + LEDDigitalRainEffect() { ledModeName = F("DigitalRain"); } + explicit LEDDigitalRainEffect(__FlashStringHelper *customName) { ledModeName = customName; } /** * Color channel enum. diff --git a/plugins/Kaleidoscope-LEDEffect-Rainbow/src/kaleidoscope/plugin/LEDEffect-Rainbow.h b/plugins/Kaleidoscope-LEDEffect-Rainbow/src/kaleidoscope/plugin/LEDEffect-Rainbow.h index 9ddf453e78..957e339d2c 100644 --- a/plugins/Kaleidoscope-LEDEffect-Rainbow/src/kaleidoscope/plugin/LEDEffect-Rainbow.h +++ b/plugins/Kaleidoscope-LEDEffect-Rainbow/src/kaleidoscope/plugin/LEDEffect-Rainbow.h @@ -27,8 +27,8 @@ namespace plugin { class LEDRainbowEffect : public Plugin, public LEDModeInterface { public: - LEDRainbowEffect() { ledModeName = "Rainbow"; } - explicit LEDRainbowEffect(char *customName) { ledModeName = customName; } + LEDRainbowEffect() { ledModeName = F("Rainbow"); } + explicit LEDRainbowEffect(__FlashStringHelper *customName) { ledModeName = customName; } void brightness(uint8_t); uint8_t brightness() { @@ -71,8 +71,8 @@ class LEDRainbowEffect : public Plugin, class LEDRainbowWaveEffect : public Plugin, public LEDModeInterface { public: - LEDRainbowWaveEffect() { ledModeName = "RainbowWave"; } - explicit LEDRainbowWaveEffect(char *customName) { ledModeName = customName; } + LEDRainbowWaveEffect() { ledModeName = F("RainbowWave"); } + explicit LEDRainbowWaveEffect(__FlashStringHelper *customName) { ledModeName = customName; } void brightness(uint8_t); uint8_t brightness() { diff --git a/plugins/Kaleidoscope-LEDEffect-SolidColor/src/kaleidoscope/plugin/LEDEffect-SolidColor.h b/plugins/Kaleidoscope-LEDEffect-SolidColor/src/kaleidoscope/plugin/LEDEffect-SolidColor.h index c233fa626e..9dedeb1175 100644 --- a/plugins/Kaleidoscope-LEDEffect-SolidColor/src/kaleidoscope/plugin/LEDEffect-SolidColor.h +++ b/plugins/Kaleidoscope-LEDEffect-SolidColor/src/kaleidoscope/plugin/LEDEffect-SolidColor.h @@ -30,10 +30,10 @@ class LEDSolidColor : public Plugin, public: LEDSolidColor(uint8_t r, uint8_t g, uint8_t b) : r_(r), g_(g), b_(b) { - ledModeName = "SolidColor"; + ledModeName = F("SolidColor"); } - LEDSolidColor(char *customName, uint8_t r, uint8_t g, uint8_t b) + LEDSolidColor(__FlashStringHelper *customName, uint8_t r, uint8_t g, uint8_t b) : r_(r), g_(g), b_(b) { ledModeName = customName; } diff --git a/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Jukebox.cpp b/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Jukebox.cpp index ba202da9c4..ebdc2440d6 100644 --- a/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Jukebox.cpp +++ b/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Jukebox.cpp @@ -20,12 +20,12 @@ #include "kaleidoscope/device/device.h" // for CRGB #include "kaleidoscope/plugin/TriColor.h" // for TriColor -kaleidoscope::plugin::TriColor JukeboxEffect("Jukebox", +kaleidoscope::plugin::TriColor JukeboxEffect(F("Jukebox"), CRGB(0xc8, 0xe8, 0xee), /* TM */ CRGB(0xc3, 0xee, 0x8c), /* VCO */ CRGB(0x21, 0x38, 0xd7)); /* RN */ -kaleidoscope::plugin::TriColor JukeboxAlternateEffect("JukeboxAlternate", +kaleidoscope::plugin::TriColor JukeboxAlternateEffect(F("JukeboxAlternate"), CRGB(0xc8, 0xe8, 0xee), /* TM */ CRGB(0x21, 0x38, 0xd7), /* RN */ CRGB(0xc3, 0xee, 0x8c)); /* VCO */ diff --git a/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Miami.cpp b/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Miami.cpp index f553a3803c..7396dce408 100644 --- a/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Miami.cpp +++ b/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Miami.cpp @@ -20,6 +20,6 @@ #include "kaleidoscope/device/device.h" // for CRGB #include "kaleidoscope/plugin/TriColor.h" // for TriColor -kaleidoscope::plugin::TriColor MiamiEffect("Miami", +kaleidoscope::plugin::TriColor MiamiEffect(F("Miami"), CRGB(0x4e, 0xd6, 0xd6), /* Cyan */ CRGB(0xaf, 0x67, 0xfa)); /* Magenta */ diff --git a/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/TriColor.cpp b/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/TriColor.cpp index e67c907a2f..a012ae7d9a 100644 --- a/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/TriColor.cpp +++ b/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/TriColor.cpp @@ -26,7 +26,7 @@ namespace kaleidoscope { namespace plugin { -TriColor::TriColor(char *customName, cRGB base_color, cRGB mod_color, cRGB esc_color) { +TriColor::TriColor(__FlashStringHelper *customName, cRGB base_color, cRGB mod_color, cRGB esc_color) { ledModeName = customName; base_color_ = base_color; mod_color_ = mod_color; diff --git a/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/TriColor.h b/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/TriColor.h index 352e2f5a38..ca3d58ea77 100644 --- a/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/TriColor.h +++ b/plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/TriColor.h @@ -27,13 +27,13 @@ namespace plugin { class TriColor : public Plugin, public LEDModeInterface { public: - TriColor(char *customName, cRGB base_color, cRGB mod_color, cRGB esc_color); + TriColor(__FlashStringHelper *customName, cRGB base_color, cRGB mod_color, cRGB esc_color); TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color) - : TriColor("TriColor", base_color, mod_color, esc_color) {} - TriColor(char *customName, cRGB base_color, cRGB mod_color) + : TriColor(F("TriColor"), base_color, mod_color, esc_color) {} + TriColor(__FlashStringHelper *customName, cRGB base_color, cRGB mod_color) : TriColor(customName, base_color, mod_color, mod_color) {} TriColor(cRGB base_color, cRGB mod_color) - : TriColor("TriColor", base_color, mod_color, mod_color) {} + : TriColor(F("TriColor"), base_color, mod_color, mod_color) {} // This class' instance has dynamic lifetime // diff --git a/src/kaleidoscope/event_handlers.h b/src/kaleidoscope/event_handlers.h index 21eb9e7770..5a7c1f946c 100644 --- a/src/kaleidoscope/event_handlers.h +++ b/src/kaleidoscope/event_handlers.h @@ -18,6 +18,8 @@ #pragma once +#include // for __FlashStringHelper + // This file defines the names and argument signatures for all event handlers // in the Kaleidoscope core. // @@ -38,7 +40,7 @@ #define _NOT_ABORTABLE false // Define the callback for the LED mode hook handler -typedef void (*LedModeCallback)(const char*); +typedef void (*LedModeCallback)(const __FlashStringHelper*); #define _CURRENT_IMPLEMENTATION diff --git a/src/kaleidoscope/plugin/LEDControl/LED-Off.h b/src/kaleidoscope/plugin/LEDControl/LED-Off.h index 0936d1dbe0..d1fbb229eb 100644 --- a/src/kaleidoscope/plugin/LEDControl/LED-Off.h +++ b/src/kaleidoscope/plugin/LEDControl/LED-Off.h @@ -27,8 +27,8 @@ namespace plugin { // class LEDOff : public LEDMode { public: - LEDOff() { ledModeName = "Off"; } - explicit LEDOff(char *customName) { ledModeName = customName; } + LEDOff() { ledModeName = F("Off"); } + explicit LEDOff(__FlashStringHelper *customName) { ledModeName = customName; } protected: void onActivate() final; diff --git a/src/kaleidoscope/plugin/LEDModeInterface.h b/src/kaleidoscope/plugin/LEDModeInterface.h index 78e77e95c1..9e1ef51255 100644 --- a/src/kaleidoscope/plugin/LEDModeInterface.h +++ b/src/kaleidoscope/plugin/LEDModeInterface.h @@ -16,6 +16,8 @@ #pragma once +#include // for __FlashStringHelper, F + #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/event_handlers.h" // for LedModeCallback @@ -26,14 +28,14 @@ class LEDModeInterface { public: LEDModeInterface() : ledModeName{0} {} - explicit LEDModeInterface(const char *_ledModeName) + explicit LEDModeInterface(const __FlashStringHelper *_ledModeName) : ledModeName{_ledModeName} {} void activate(); EventHandlerResult onLedEffectQuery(LedModeCallback callback) { if (ledModeName == 0) { // If no name was defined, return a default string - callback(const_cast("[unnamed led mode]")); + callback(F("[unnamed led mode]")); } else { callback(ledModeName); } @@ -54,7 +56,7 @@ class LEDModeInterface { typedef NoLEDMode DynamicLEDMode; protected: - const char *ledModeName; + const __FlashStringHelper *ledModeName; }; } // namespace plugin