Skip to content

Commit

Permalink
Stop using F()
Browse files Browse the repository at this point in the history
Signed-off-by: Evy Bongers <[email protected]>
  • Loading branch information
EvyBongers committed Mar 5, 2024
1 parent 41c6052 commit 5c51f43
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class ColormapEffect : public Plugin,
public LEDModeInterface,
public AccessTransientLEDMode {
public:
ColormapEffect() { led_mode_name_ = F("Colormap"); }
explicit ColormapEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
ColormapEffect() { led_mode_name_ = "Colormap"; }
explicit ColormapEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

void max_layers(uint8_t max_);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace plugin {
//
class FingerPainter : public LEDMode {
public:
FingerPainter() { led_mode_name_ = F("FingerPainter"); }
explicit FingerPainter(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
FingerPainter() { led_mode_name_ = "FingerPainter"; }
explicit FingerPainter(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

void toggle();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "kaleidoscope/plugin/FocusSerial.h"

#include <Arduino.h> // for PSTR, __FlashStringHelper, F, strcmp_P
#include <Arduino.h> // for PSTR, F, strcmp_P
#include <HardwareSerial.h> // for HardwareSerial
#include <string.h> // for memset

Expand Down Expand Up @@ -77,7 +77,7 @@ EventHandlerResult FocusSerial::afterEachCycle() {
return EventHandlerResult::OK;
}

void sendLedModeCallback_(const __FlashStringHelper *name) {
void sendLedModeCallback_(const char *name) {
Runtime.serialPort().println(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Heatmap : public Plugin,
public LEDModeInterface,
public AccessTransientLEDMode {
public:
Heatmap() { led_mode_name_ = F("Heatmap"); }
explicit Heatmap(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
Heatmap() { led_mode_name_ = "Heatmap"; }
explicit Heatmap(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

static uint16_t update_delay;
static const cRGB *heat_colors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class LEDActiveLayerColorEffect : public Plugin,
public LEDModeInterface,
public AccessTransientLEDMode {
public:
LEDActiveLayerColorEffect() { led_mode_name_ = F("ActiveLayerColor"); }
explicit LEDActiveLayerColorEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
LEDActiveLayerColorEffect() { led_mode_name_ = "ActiveLayerColor"; }
explicit LEDActiveLayerColorEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

EventHandlerResult onLayerChange();
void setColormap(const cRGB colormap[]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class LEDActiveLayerKeysEffect : public Plugin,
public LEDModeInterface,
public AccessTransientLEDMode {
public:
LEDActiveLayerKeysEffect() { led_mode_name_ = F("ActiveLayerKeys"); }
explicit LEDActiveLayerKeysEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
LEDActiveLayerKeysEffect() { led_mode_name_ = "ActiveLayerKeys"; }
explicit LEDActiveLayerKeysEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

EventHandlerResult onLayerChange();
template<uint8_t _colormap_size>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class AlphaSquareEffect : public Plugin,
public LEDModeInterface,
public AccessTransientLEDMode {
public:
AlphaSquareEffect() { led_mode_name_ = F("AlphaSquare"); }
explicit AlphaSquareEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
AlphaSquareEffect() { led_mode_name_ = "AlphaSquare"; }
explicit AlphaSquareEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

static uint16_t length;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class StalkerEffect : public Plugin,
public LEDModeInterface,
public AccessTransientLEDMode {
public:
StalkerEffect() { led_mode_name_ = F("Stalker"); }
explicit StalkerEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
StalkerEffect() { led_mode_name_ = "Stalker"; }
explicit StalkerEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

class ColorComputer {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class WavepoolEffect : public Plugin,
public LEDModeInterface,
public AccessTransientLEDMode {
public:
WavepoolEffect() { led_mode_name_ = F("Wavepool"); }
explicit WavepoolEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
WavepoolEffect() { led_mode_name_ = "Wavepool"; }
explicit WavepoolEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

EventHandlerResult onKeyEvent(KeyEvent &event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "kaleidoscope/plugin/LEDBrightnessConfig.h"

#include <Arduino.h> // for PSTR, strcmp_P, F, __FlashStringHelper
#include <Arduino.h> // for PSTR, strcmp_P, F
#include <Kaleidoscope-EEPROM-Settings.h> // for EEPROMSettings
#include <Kaleidoscope-FocusSerial.h> // for Focus, FocusSerial
#include <stdint.h> // for uint8_t, uint16_t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace plugin {
class LEDBreatheEffect : public Plugin,
public LEDModeInterface {
public:
LEDBreatheEffect() { led_mode_name_ = F("Breathe"); }
explicit LEDBreatheEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
LEDBreatheEffect() { led_mode_name_ = "Breathe"; }
explicit LEDBreatheEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

uint8_t hue = 170;
uint8_t saturation = 255;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace plugin {
class LEDChaseEffect : public Plugin,
public LEDModeInterface {
public:
LEDChaseEffect() { led_mode_name_ = F("Chase"); }
explicit LEDChaseEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
LEDChaseEffect() { led_mode_name_ = "Chase"; }
explicit LEDChaseEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

uint8_t update_delay() {
return update_delay_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class LEDDigitalRainEffect : public Plugin,
public LEDModeInterface,
public AccessTransientLEDMode {
public:
LEDDigitalRainEffect() { led_mode_name_ = F("DigitalRain"); }
explicit LEDDigitalRainEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
LEDDigitalRainEffect() { led_mode_name_ = "DigitalRain"; }
explicit LEDDigitalRainEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

/**
* Color channel enum.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace plugin {
class LEDRainbowEffect : public Plugin,
public LEDModeInterface {
public:
LEDRainbowEffect() { led_mode_name_ = F("Rainbow"); }
explicit LEDRainbowEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
LEDRainbowEffect() { led_mode_name_ = "Rainbow"; }
explicit LEDRainbowEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

void brightness(uint8_t);
uint8_t brightness() {
Expand Down Expand Up @@ -71,8 +71,8 @@ class LEDRainbowEffect : public Plugin,

class LEDRainbowWaveEffect : public Plugin, public LEDModeInterface {
public:
LEDRainbowWaveEffect() { led_mode_name_ = F("RainbowWave"); }
explicit LEDRainbowWaveEffect(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
LEDRainbowWaveEffect() { led_mode_name_ = "RainbowWave"; }
explicit LEDRainbowWaveEffect(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

void brightness(uint8_t);
uint8_t brightness() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
led_mode_name_ = F("SolidColor");
led_mode_name_ = "SolidColor";
}

LEDSolidColor(const __FlashStringHelper *led_mode_name, uint8_t r, uint8_t g, uint8_t b)
LEDSolidColor(const char *led_mode_name, uint8_t r, uint8_t g, uint8_t b)
: r_(r), g_(g), b_(b) {
led_mode_name_ = led_mode_name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
#include "kaleidoscope/device/device.h" // for CRGB
#include "kaleidoscope/plugin/TriColor.h" // for TriColor

kaleidoscope::plugin::TriColor JukeboxEffect(F("Jukebox"),
kaleidoscope::plugin::TriColor JukeboxEffect("Jukebox",
CRGB(0xc8, 0xe8, 0xee), /* TM */
CRGB(0xc3, 0xee, 0x8c), /* VCO */
CRGB(0x21, 0x38, 0xd7)); /* RN */

kaleidoscope::plugin::TriColor JukeboxAlternateEffect(F("JukeboxAlternate"),
kaleidoscope::plugin::TriColor JukeboxAlternateEffect("JukeboxAlternate",
CRGB(0xc8, 0xe8, 0xee), /* TM */
CRGB(0x21, 0x38, 0xd7), /* RN */
CRGB(0xc3, 0xee, 0x8c)); /* VCO */
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
#include "kaleidoscope/device/device.h" // for CRGB
#include "kaleidoscope/plugin/TriColor.h" // for TriColor

kaleidoscope::plugin::TriColor MiamiEffect(F("Miami"),
kaleidoscope::plugin::TriColor MiamiEffect("Miami",
CRGB(0x4e, 0xd6, 0xd6), /* Cyan */
CRGB(0xaf, 0x67, 0xfa)); /* Magenta */
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace kaleidoscope {
namespace plugin {

TriColor::TriColor(const __FlashStringHelper *led_mode_name, cRGB base_color, cRGB mod_color, cRGB esc_color) {
TriColor::TriColor(const char *led_mode_name, cRGB base_color, cRGB mod_color, cRGB esc_color) {
led_mode_name_ = led_mode_name;
base_color_ = base_color;
mod_color_ = mod_color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ namespace plugin {
class TriColor : public Plugin,
public LEDModeInterface {
public:
TriColor(const __FlashStringHelper *led_mode_name, cRGB base_color, cRGB mod_color, cRGB esc_color);
TriColor(const char *led_mode_name, cRGB base_color, cRGB mod_color, cRGB esc_color);
TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color)
: TriColor(F("TriColor"), base_color, mod_color, esc_color) {}
TriColor(const __FlashStringHelper *led_mode_name, cRGB base_color, cRGB mod_color)
: TriColor("TriColor", base_color, mod_color, esc_color) {}
TriColor(const char *led_mode_name, cRGB base_color, cRGB mod_color)
: TriColor(led_mode_name, base_color, mod_color, mod_color) {}
TriColor(cRGB base_color, cRGB mod_color)
: TriColor(F("TriColor"), base_color, mod_color, mod_color) {}
: TriColor("TriColor", base_color, mod_color, mod_color) {}

// This class' instance has dynamic lifetime
//
Expand Down
4 changes: 1 addition & 3 deletions src/kaleidoscope/event_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

#pragma once

#include <Arduino.h> // for __FlashStringHelper

// This file defines the names and argument signatures for all event handlers
// in the Kaleidoscope core.
//
Expand All @@ -40,7 +38,7 @@
#define _NOT_ABORTABLE false

// Define the callback for the LED mode hook handler
typedef void (*LedModeCallback)(const __FlashStringHelper*);
typedef void (*LedModeCallback)(const char*);

#define _CURRENT_IMPLEMENTATION

Expand Down
4 changes: 2 additions & 2 deletions src/kaleidoscope/plugin/LEDControl/LED-Off.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace plugin {
//
class LEDOff : public LEDMode {
public:
LEDOff() { led_mode_name_ = F("Off"); }
explicit LEDOff(const __FlashStringHelper *led_mode_name) { led_mode_name_ = led_mode_name; }
LEDOff() { led_mode_name_ = "Off"; }
explicit LEDOff(const char *led_mode_name) { led_mode_name_ = led_mode_name; }

protected:
void onActivate() final;
Expand Down
8 changes: 4 additions & 4 deletions src/kaleidoscope/plugin/LEDModeInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include <Arduino.h> // for __FlashStringHelper, F
#include <Arduino.h> // for PROGMEM

#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult
#include "kaleidoscope/event_handlers.h" // for LedModeCallback
Expand All @@ -28,14 +28,14 @@ class LEDModeInterface {
public:
LEDModeInterface()
: led_mode_name_{0} {}
explicit LEDModeInterface(const __FlashStringHelper *led_mode_name)
explicit LEDModeInterface(const char *led_mode_name)
: led_mode_name_{led_mode_name} {}
void activate();

EventHandlerResult onLedEffectQuery(LedModeCallback callback) {
if (led_mode_name_ == 0) {
// If no name was defined, return a default string
callback(F("[unnamed led mode]"));
callback("[unnamed led mode]");
} else {
callback(led_mode_name_);
}
Expand All @@ -56,7 +56,7 @@ class LEDModeInterface {
typedef NoLEDMode DynamicLEDMode;

protected:
const __FlashStringHelper *led_mode_name_;
const char *led_mode_name_ PROGMEM = {"[unnamed led mode]"};
};

} // namespace plugin
Expand Down

0 comments on commit 5c51f43

Please sign in to comment.