One other problem... (button no longer lights up)

When I started to customize the fonts on my new Sabertrio, the button, which normally lights up Green, now doesn’t light up at all. Could someone tell me where I went wrong in the config?

// Sabertrio Proffie Saber - Blade & Sound Font Configuration
#ifdef CONFIG_TOP
#include "proffieboard_v2_config.h"
#define NUM_BLADES 4
#define NUM_BUTTONS 2
#define VOLUME 250
const unsigned int maxLedsPerStrip = 144;
#define CLASH_THRESHOLD_G 3.4
#define ENABLE_AUDIO
#define ENABLE_MOTION
#define ENABLE_WS2811
#define ENABLE_SD
#define ENABLE_SSD1306
#define COLOR_CHANGE_DIRECT
#define IDLE_OFF_TIME 60*2*1000
#define MOTION_TIMEOUT 60*10*1000
#define SHARED_POWER_PINS
#define DISABLE_DIAGNOSTIC_COMMANDS
#define BLADE_DETECT_PIN 17
#define SAVE_PRESET
#endif

#ifdef CONFIG_PROP
#include"../props/s3button_config.h"
#endif

#ifdef CONFIG_PRESETS

Preset no_blade[] = {
   { "0-NO_BLADE","",
    StylePtr<Black>(),
	StylePtr<Black>(),
	StylePtr<Black>(),
	StylePtr<Pulsing<White,Black,1200>>()
	, },

   };
   
   
   Preset blade[] = {

	  { "1-Assassin;common", "common/tracks/mars.wav",
    StylePtr<Layers<
  HumpFlicker<RotateColorsX<Variation,Green>,RotateColorsX<Variation,Rgb<0,128,0>>,50>,
  //Green humpflicker
  AlphaL<Stripes<2500,-2750,RotateColorsX<Variation,Green>,RotateColorsX<Variation,Rgb<25,60,0>>,Pulsing<RotateColorsX<Variation,Rgb<0,30,0>>,Black,800>>,SwingSpeed<375>>,
  //Swing effect, rippling green
  LockupTrL<Layers<
    AlphaL<AudioFlickerL<Rgb<255,240,80>>,Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Int<4000>,Int<26000>>,Int<6000>>,Scale<SwingSpeed<100>,Int<14000>,Int<18000>>>>,
    AlphaL<LemonChiffon,Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Int<4000>,Int<26000>>,Int<6000>>,Int<10000>>>>,TrConcat<TrInstant,White,TrFade<400>>,TrConcat<TrInstant,White,TrFade<400>>,SaberBase::LOCKUP_NORMAL>,
  //Responsive lockup
  ResponsiveLightningBlockL<Strobe<White,AudioFlicker<White,Blue>,50,1>,TrConcat<TrInstant,AlphaL<White,Bump<Int<12000>,Int<18000>>>,TrFade<200>>,TrConcat<TrInstant,HumpFlickerL<AlphaL<White,Int<16000>>,30>,TrSmoothFade<600>>>,
  //Responsive lightning block
  AlphaL<RotateColorsX<Variation,Rgb16<21301,65535,0>>,SmoothStep<Scale<SlowNoise<Int<2500>>,Int<1000>,Int<3000>>,Int<-4000>>>,
  //Sparking emitter flare
  ResponsiveStabL<Red>,
  //Responsive stab
  EffectSequence<EFFECT_BLAST,TransitionEffectL<TrConcat<TrInstant,AlphaL<White,BlastF<200,200>>,TrFade<300>>,EFFECT_BLAST>,ResponsiveBlastL<White,Int<400>,Scale<SwingSpeed<200>,Int<100>,Int<400>>,Int<400>>,ResponsiveBlastWaveL<White,Scale<SwingSpeed<400>,Int<500>,Int<200>>,Scale<SwingSpeed<400>,Int<100>,Int<400>>>,ResponsiveBlastFadeL<White,Scale<SwingSpeed<400>,Int<6000>,Int<12000>>,Scale<SwingSpeed<400>,Int<400>,Int<100>>>,ResponsiveBlastL<White,Scale<SwingSpeed<400>,Int<400>,Int<100>>,Scale<SwingSpeed<400>,Int<200>,Int<100>>,Scale<SwingSpeed<400>,Int<400>,Int<200>>>>,
  //Multi-blast, blaster reflect cycles through different responsive effects
  ResponsiveClashL<TransitionEffect<Rgb<255,240,80>,LemonChiffon,TrInstant,TrFade<100>,EFFECT_CLASH>,TrInstant,TrFade<400>,Scale<BladeAngle<0,16000>,Int<4000>,Int<26000>>,Int<6000>,Int<20000>>,
  //Responsive clash
  TransitionEffectL<TrConcat<TrInstant,Stripes<3000,-3500,RotateColorsX<Variation,Rgb16<38402,65535,3934>>,RandomPerLEDFlicker<Rgb<60,60,60>,Black>,BrownNoiseFlicker<RotateColorsX<Variation,Rgb16<38402,65535,3934>>,Rgb<30,30,30>,200>,RandomPerLEDFlicker<Rgb<80,80,80>,Rgb<30,30,30>>>,TrFade<500>>,EFFECT_IGNITION>,
  //Unstable ignition
  TransitionEffectL<TrConcat<TrInstant,AudioFlickerL<RotateColorsX<Variation,Rgb16<54757,65535,0>>>,TrFade<1000>>,EFFECT_RETRACTION>,
  //Bright retraction
  LockupTrL<AlphaL<BrownNoiseFlickerL<White,Int<300>>,SmoothStep<Int<30000>,Int<5000>>>,TrWipeIn<400>,TrFade<300>,SaberBase::LOCKUP_DRAG>,
  //Drag
  LockupTrL<AlphaL<Mix<TwistAngle<>,Red,Orange>,SmoothStep<Int<28000>,Int<5000>>>,TrWipeIn<600>,TrFade<300>,SaberBase::LOCKUP_MELT>,
  //Responsive melt
  EffectSequence<EFFECT_POWERSAVE,AlphaL<Black,Int<8192>>,AlphaL<Black,Int<16384>>,AlphaL<Black,Int<24576>>,AlphaL<Black,Int<0>>>,
  //Power save, if using fett263's prop file hold Aux and click PWR while ON (pointing up) to dim blade in 25% increments.
  InOutTrL<TrWipeSparkTip<White,250>,TrWipeInSparkTip<White,656>>,
  //Spark tip ignition and retraction
  //TransitionEffectL<TrConcat<TrDelay<1500>,Black,TrFade<1000>,AlphaL<Mix<BatteryLevel,Red,Green>,Bump<Int<0>,Int<6000>>>,TrFade<3000>>,EFFECT_BOOT>,
  //TransitionEffectL<TrConcat<TrInstant,AlphaL<Mix<BatteryLevel,Red,Green>,Bump<Int<0>,Int<6000>>>,TrFade<3000>>,EFFECT_NEWFONT>,
  //Optional/alternate passive battery monitor, on boot (1st line) or font change (2nd line) you will get a visual indicator at the emitter of your current battery level. This also works without a blade if you have a lit emitter or blade plug. Green is Full, Red is Low (the color will blend from Green to Red as the battery is depleted), the indicator will fade out after 3000 ms and not display again until powered down and back up or fonts change.
  TransitionEffectL<TrConcat<TrInstant,AlphaL<Mix<BatteryLevel,Red,Green>,Bump<BatteryLevel,Int<10000>>>,TrDelay<2000>,AlphaL<Mix<BatteryLevel,Red,Green>,Bump<BatteryLevel,Int<10000>>>,TrFade<1000>>,EFFECT_BATTERY_LEVEL>
  //On demand battery level, if using fett263's prop file Hold AUX and click PWR while OFF, the battery level is represented by the location on the blade; tip = full, hilt = low and color; green = full, yellow = half, red = low
  >>(),
  },
      
   
   
   
   
   
   
   
	
	
   
   
};



BladeConfig blades[] = {
 { 0, WS281XBladePtr<144, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
  WS281XBladePtr<20, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin4> >(),
    WS281XBladePtr<20, blade4Pin, Color8::GRB, PowerPINS<bladePowerPin5> >(),
    SimpleBladePtr<CreeXPE2WhiteTemplate<550>, NoLED, NoLED, NoLED, bladePowerPin1, -1, -1, -1>()
  , CONFIGARRAY(blade) },
 
 { NO_BLADE, WS281XBladePtr<115, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
  WS281XBladePtr<20, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin4> >(),
    WS281XBladePtr<20, blade4Pin, Color8::GRB, PowerPINS<bladePowerPin5> >(),
SimpleBladePtr<CreeXPE2WhiteTemplate<550>, NoLED, NoLED, NoLED, bladePowerPin1, -1, -1, -1>()
  , CONFIGARRAY(no_blade) },
};
#endif

#ifdef CONFIG_BUTTONS
Button PowerButton(BUTTON_POWER, powerButtonPin, "pow");
Button AuxButton(BUTTON_AUX, auxPin, "aux");
#endif

Does this config compiles ? I don’t think it will, because your “1-Assassin;common”
preset has only one blade style but you have 4 blades in your NUM_BLADES and BladeConfig blades also has 4 blades (anything that lights-up is a blade, light-up buttons included).

These are your blades, do you know which is which ?
The 144 is your main blade.
The 20 & 20 are from your inner & outer ring blade connector ? or accent leds ?
The SimpleBladePtr is probably your button ? (just guessing)

It does compile, but the button light obviously isn’t working. Hmm…

Looking at the bottom of the config, I actually never noticed those blade settings. I honestly don’t know why the saber says it has 4 blades. It just came that way when I bought it. I honestly don’t know what those 4 blades are that are listed in the config.

The saber only has the one blade and the light-up button, so I don’t know what to do with that code. How would I rewrite that to make sense? Because when I change the 4 blades to something like 2, or if I remove any of the blades listed, it doesn’t compile.

If you change NUM_BLADE, you need to change the blade styles to match and the blade definition so the numbers match.

If you remove your blade (unscrew it physically) do you have leds inside your emitter? (this is the blade connector, some have leds there, some don’t)

Do you lights in there like the photo?

You should probably start by figuring that out.

And you are right, it does compile but it shouldn’t (because of the missing blade styles). @profezzorn @NoSloppy any idea why this config compiles ?

Because you don’t have a style for it!

add this to “1-Assassin;common”:
between line 79 & 80 as you posted above

	StylePtr<Black>(),
	StylePtr<Black>(),
	StylePtr<Pulsing<White,Black,1200>>(),

Is the button working now?

I wrote this a while back so thankfully I can copy/paste.
Should probably add some form of it to the POD.


Some info regarding NUM_BLADES matching number of styles and number of blades:

A proffieboard can have multiple “blades” . A blade being any set of LEDs wired to data pads on the board. They can be main actual blade, accent LEDs, crystal chamber illumination LEDs, pogo pin connector PCB LEDs, etc. This also includes the illuminated switch button LED.

Every blade needs to have a blade style assigned to it.
Each preset contains blade styles for all blades that it uses when that preset is active.
So if you have 4 “blades” , you need to have the NUM_BLADES line up top set to 4, you need 4 blade styles per preset, and the BladeConfig array should define 4 different blades as far as which type, data pad, and power pads they use.

So to sum that up, there are 3 places that the number of blades need to match.

  • NUM_BLADES declared up top.

  • The number of styles in each preset

  • The number of blades in the BladeConfig array.

If this is not set up correctly, the typical error in Arduino will say “error: too many initializers for 'Preset’”

The “name/message” argument:

It’s best to provide the “name” argument at the end of presets, so it really shouldn’t be considered optional.

The short version:

Without the “name”, it’s possible to have a mismatch of the same amount of NUM_BLADES, number of styles per preset, and number of blades configured in the BladeConfig array. If you have less styles than blades, you’ll be sending NULL data to blade LEDs, and avoiding some useful errors ( not preventing errors in a good way). It also won’t display anything in Serial Monitor where it would show you the current preset name, OLED displays will be blank when the preset is loaded, and ProffieOS Workbench in a browser window won’t have a name for your preset.

The longer version:

If you don’t have a message in quotes at the end of the preset, like

.....>(),"blue"}

or something similar, You can “get away” with not having something you should: the same number of blade styles in the preset as NUM_BLADES and number of blades in BladeConfig.
It will compile successfully, but that’s not how it’s really meant to work.
The reason this happens at all is because struct initializations in C++ are allowed to NOT provide all values, and any value not provided is assumed to be NULL.
NULL is an acceptable style pointer and also an acceptable “message”.

So if NUM_BLADES is 4, and you have a preset like
{"font", "track", SOMESTYLE}
it is the same as

{“font”, “track”, SOMESTYLE, NULL, NULL, NULL }…the missing styles get filled in with NULL by the compiler, so it doesn’t consider your presets to be a mismatched number compared to NUM_BLADES and # of blades configured. The best way is to provide matching number of styles in the presets so you don’t send NULL data to any LEDs, and keeps things organized and proper.

So this is similar to the way a blade style can have omitted values and use defaults, but can’t “skip over” non-provided arguments. All arguments need to be provided up to the modified argument.

Example.

The full template for Blast<> is:

Blast<BASE_COLOR, BLAST_COLOR, FADEOUT_TIME, WAVE_SIZE, WAVE_SPEED, EFFECT>

However, just
Blast<Blue,White>
is acceptable while the template uses defaults for fadeout time, wave size, wave speed, and EFFECT.

If you wanted to change the wave size (4th argument) to 150 instead of the default 100 though, you could not “skip” the fadeout time (3rd argument, default is 200) and would need to provide something for that argument place UP TO the changed default argument, such as:

Blast<Blue,White,200,150>

while here we’re still omitting the trailing arguments of wave speed and EFFECT.

So coming back to presets, by adding the “message” at the end, you are creating that “non-skippable” scenario for the missing blade style, and therefore get an error.

Hope that makes sense.

I know, but the config posted above doesn’t match in all 3 places but it still compiles, I tried it myself :upside_down_face:

Edit: disregard, I didn’t read it all the way through. Because @Streen doesn’t have “text” at the end of his preset, it will compile anyways.

@Streen

Your button stays off because you do not have a style for it.
So if you want your button to light-up and since your button is your fourth blade, you need 4 styles per preset. Since you don’t know what are the 2 blades in the middle, you can use 2 StylePtr<Black>(), until you figure out what those blades are.