EDIT MODE Adjust Black Level bug?

I’m encountering an issue when using Adjust Black Level / Adjust White Level with certain colors.

Red/Green/Blue work fine, but when I select from the color list Magenta or Deep Pink, then try to use Adjust Black Level or Adjust White Level to lighten/darken it, the preview for the adjustment starts out full black (0, 0, 0) and if I save the setting for the brightness I want, it stays white/black, it loses the color. Trying adjust HUE doesn’t do anything after I save the white/black adjustments.

Any ideas? Is this a bug?

Need the style code and which color argument you’re attempting to edit.

Ok, tested it in a SIMPLE style, still buggered up. Here’s the style test I just used, and the steps I took in EDIT MODE.

StylePtr <
		Layers <
			ColorSelect <
				IntArg<STYLE_OPTION_ARG, 0>,
				TrInstant,

				Layers <
					AudioFlicker<
						RgbArg<BASE_COLOR_ARG, Rgb<127, 0, 0>>,
						RgbArg<ALT_COLOR_ARG, Rgb<0, 127, 0>>
					>
				>

			>,

			LockupTrL<Layers<AlphaL<AudioFlickerL<White>,Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Int<4000>,Int<26000>>,Int<6000>>,Scale<SwingSpeed<100>,Int<14000>,Int<18000>>>>,AlphaL<White,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>,
			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>>>,
			ResponsiveStabL<Red,TrWipeIn<600>,TrWipe<600>>,ResponsiveBlastFadeL<White,Scale<SwingSpeed<200>,Int<8000>,Int<16000>>,Int<400>>,
			ResponsiveClashL<White,TrInstant,TrFade<400>,Scale<BladeAngle<0,16000>,Int<4000>,Int<26000>>,Int<6000>,Int<20000>>,
			LockupTrL<AlphaL<BrownNoiseFlickerL<White,Int<300>>,SmoothStep<Int<30000>,Int<5000>>>,TrWipeIn<400>,TrFade<300>,SaberBase::LOCKUP_DRAG>,
			LockupTrL<AlphaL<Mix<TwistAngle<>,Red,Orange>,SmoothStep<Int<28000>,Int<5000>>>,TrWipeIn<600>,TrFade<300>,SaberBase::LOCKUP_MELT>,
			InOutTrL<TrWipe<300>,TrWipeInX<RetractionTime<0>>,Black>>
		> 
	(),

EDIT MODE > EDIT COLOR > COLOR OPTIONS:

BASE COLOR > COLOR LIST > DEEP PINK > SELECT
ADJUST WHITE LEVEL > BUG OCCURRED

BACK > to COLOR OPTIONS:

ALT COLOR > COLOR LIST > MAGENTA > SELECT
ADJUST BLACK LEVEL > BUG OCCURRED.

After the BUG OCCURRED (Black blade, no color/light in preview for Black/White mode), saving a change results in the color saving like it did in the bugged preview state.

Where’d this come from? ‘RotateColorsX<Variation,…>’ does not ‘play nice’ with RgbArg as they are very different approaches to handling colors.

I’d test with a style generated from my library to compare. The library generates the code to line up with Color List and Color Editing correctly. You may be introducing conflicts like above that are causing what you are encountering.

I added it because I wanted a slight variation in the color. I kindof put it around all my colors in my style, like hot sauce XD. I can test without that in there, one sec.

Bug still happens, I updated the code above to not use RotateColors<> to reflect my most recent test. “MAGENTA” still bugs out when trying to adjust Black/White level, for example.

Other colors, like Red, Blue, work fine. I haven’t tested all the colors, but when setting up the fonts I found 2 so far that are buggy. Idk if the bug is per-color, or a generic bug in Black/White adjust that’ll fix all of them once found/fixed.

RotateColorsX<Variation,…> shouldn’t be used with RgbArg<>, if you need to apply a color shift or movement you should use a different function in RotateColorsX, like Int<>, etc. Variation is a universal application from the ColorWheel, it’s very different from Color Editing and can cause all kinds of odd behavior in Edit Mode, so they aren’t intended to be mixed together.

I would test a style from my library to rule out anything you have added that may be causing a conflict. If it still occurs with a clean library style post the library code and exactly what you did and I’ll see if I can recreate when I get a chance.

If the library style works as expected you most likely have something causing a conflict in what you’ve modded, but tracking that down can very tricky so I’d backtrack from code that works to isolate what is causing.

Repeated with the same test as above using your OS7 Alpha library’s 2 color AudioFlicker, still bugged.

Test Steps:

EDIT MODE > EDIT COLOR > COLOR OPTIONS > BASE COLOR > COLOR LIST > MAGENTA > SELECT
ADJUST BLACK LEVEL > Blade then turned pure black, color was lost.

here’s my entire config used for testing. This is for a 1 button saber, single blade., using Kyberphonic’s free BLUE font pack font.

#ifdef CONFIG_TOP
#include "proffieboard_config.h"
#define NUM_BLADES 1
#define NUM_BUTTONS 1
#define VOLUME 1700
const unsigned int maxLedsPerStrip = 144;
#define CLASH_THRESHOLD_G 17.0
#define MOTION_TIMEOUT 60 * 10 * 1000
#define IDLE_OFF_TIME 60 * 10 * 1000
#define ENABLE_AUDIO
#define ENABLE_MOTION
#define ENABLE_WS2811
#define ENABLE_SD
#define ENABLE_SERIAL
#define COLOR_CHANGE_DIRECT
#define DISABLE_DIAGNOSTIC_COMMANDS
#define FEMALE_TALKIE_VOICE
#define NO_REPEAT_RANDOM
#define KILL_OLD_PLAYERS
#define FETT263_SWING_ON
#define FETT263_SWING_ON_NO_BM
#define FETT263_SWING_ON_SPEED 600
#define FETT263_THRUST_ON
#define FETT263_THRUST_ON_NO_BM
#define FETT263_STAB_ON
#define FETT263_STAB_ON_NO_BM
#define FETT263_BATTLE_MODE
#define FETT263_LOCKUP_DELAY 200
#define FETT263_FORCE_PUSH
#define FETT263_SAY_BATTERY_PERCENT
#define FETT263_SPECIAL_ABILITIES
// Edit Mode
#define FETT263_EDIT_MODE_MENU
#define ENABLE_ALL_EDIT_OPTIONS
#define DISABLE_BASIC_PARSER_STYLES
//#define KEEP_SAVEFILES_WHEN_PROGRAMMING
#define FETT263_SAY_COLOR_LIST
#define FETT263_SAY_COLOR_LIST_CC
#endif

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

#ifdef CONFIG_PRESETS

Preset presets[] = {

{ "BLUE;common", "tracks/",
/* copyright Fett263 Simple (Primary Blade) OS7 Style
https://fett263.com/fett263-proffieOS7-style-library.html#Simple
OS7.13 v1.018-p
Single Style
Base Style: AudioFlicker (Two Color)

Base Color: BaseColorArg (0)

--Effects Included--
Ignition Effect: Standard Ignition [Color: IgnitionColorArg]
Retraction Effect: Standard Retraction [Color: RetractionColorArg]
Lockup Effect: Intensity Lockup V1, Begin Effect: Real Clash, End Effect: Full Blade Absorb [Color: LockupColorArg]
LightningBlock Effect: Responsive Lightning Block [Color: LBColorArg]
Drag Effect: Intensity Sparking Drag [Color: DragColorArg]
Melt Effect: Intensity Melt [Color: StabColorArg]
Blast Effect: Blast Wave (Random) [Color: BlastColorArg]
Clash Effect: Real Clash V1 [Color: ClashColorArg]
*/
StylePtr<Layers<AudioFlicker<RgbArg<BASE_COLOR_ARG,Rgb<0,0,255>>,RgbArg<ALT_COLOR_ARG,Rgb<0,255,0>>>,TransitionEffectL<TrWaveX<RgbArg<BLAST_COLOR_ARG,Rgb<255,255,255>>,Scale<EffectRandomF<EFFECT_BLAST>,Int<100>,Int<400>>,Int<100>,Scale<EffectPosition<EFFECT_BLAST>,Int<100>,Int<400>>,Scale<EffectPosition<EFFECT_BLAST>,Int<28000>,Int<8000>>>,EFFECT_BLAST>,Mix<IsLessThan<ClashImpactF<>,Int<26000>>,TransitionEffectL<TrConcat<TrInstant,AlphaL<RgbArg<CLASH_COLOR_ARG,Rgb<255,255,255>>,Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-12000>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<10000>>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-10000>>>,Scale<ClashImpactF<>,Int<12000>,Int<60000>>>>,TrFadeX<Scale<ClashImpactF<>,Int<200>,Int<400>>>>,EFFECT_CLASH>,TransitionEffectL<TrWaveX<RgbArg<CLASH_COLOR_ARG,Rgb<255,255,255>>,Scale<ClashImpactF<>,Int<100>,Int<400>>,Int<100>,Scale<ClashImpactF<>,Int<100>,Int<400>>,Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-12000>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<10000>>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-10000>>>>,EFFECT_CLASH>>,LockupTrL<TransitionEffect<AlphaMixL<Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-12000>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<10000>>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-10000>>>,Scale<SwingSpeed<100>,Int<14000>,Int<18000>>>,BrownNoiseFlickerL<RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>,Int<200>>,StripesX<Int<1800>,Scale<NoisySoundLevel,Int<-3500>,Int<-5000>>,Mix<Int<6425>,Black,RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>>,RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>,Mix<Int<12850>,Black,RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>>>>,AlphaL<AudioFlicker<RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>,Mix<Int<10280>,Black,RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>>>,Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-12000>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<10000>>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-10000>>>,Int<13000>>>,TrJoin<TrDelay<8000>,TrInstant>,TrFade<3000>,EFFECT_LOCKUP_BEGIN>,TrConcat<TrJoin<TrDelay<50>,TrInstant>,Mix<IsLessThan<ClashImpactF<>,Int<26000>>,RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>,AlphaL<RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>,Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-12000>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<10000>>>,Sum<IntArg<LOCKUP_POSITION_ARG,16000>,Int<-10000>>>,Scale<ClashImpactF<>,Int<20000>,Int<60000>>>>>,TrFade<300>>,TrConcat<TrInstant,RgbArg<LOCKUP_COLOR_ARG,Rgb<255,255,255>>,TrFade<400>>,SaberBase::LOCKUP_NORMAL>,ResponsiveLightningBlockL<Strobe<RgbArg<LB_COLOR_ARG,Rgb<255,255,255>>,AudioFlicker<RgbArg<LB_COLOR_ARG,Rgb<255,255,255>>,Blue>,50,1>,TrConcat<TrInstant,AlphaL<RgbArg<LB_COLOR_ARG,Rgb<255,255,255>>,Bump<Int<12000>,Int<18000>>>,TrFade<200>>,TrConcat<TrInstant,HumpFlickerL<AlphaL<RgbArg<LB_COLOR_ARG,Rgb<255,255,255>>,Int<16000>>,30>,TrSmoothFade<600>>>,LockupTrL<AlphaL<RandomPerLEDFlickerL<RgbArg<DRAG_COLOR_ARG,Rgb<255,255,255>>>,SmoothStep<IntArg<DRAG_SIZE_ARG,28000>,Int<3000>>>,TrConcat<TrJoin<TrDelay<4000>,TrWipeIn<200>>,AlphaL<BrownNoiseFlickerL<RgbArg<DRAG_COLOR_ARG,Rgb<255,255,255>>,Int<300>>,SmoothStep<IntArg<DRAG_SIZE_ARG,28000>,Int<3000>>>,TrFade<4000>>,TrFade<300>,SaberBase::LOCKUP_DRAG>,LockupTrL<AlphaL<Remap<Scale<RampF,Int<65536>,Int<0>>,StaticFire<Mix<TwistAngle<>,RgbArg<STAB_COLOR_ARG,Rgb<255,68,0>>,RotateColorsX<Int<3000>,RgbArg<STAB_COLOR_ARG,Rgb<255,68,0>>>>,Mix<TwistAngle<>,RotateColorsX<Int<3000>,RgbArg<STAB_COLOR_ARG,Rgb<255,68,0>>>,RotateColorsX<Int<3000>,Mix<Int<12000>,Black,RgbArg<STAB_COLOR_ARG,Rgb<255,68,0>>>>>,0,3,5,3000,10>>,SmoothStep<IntArg<MELT_SIZE_ARG,28000>,Int<4000>>>,TrConcat<TrWipeIn<100>,AlphaL<RgbArg<STAB_COLOR_ARG,Rgb<255,68,0>>,SmoothStep<IntArg<MELT_SIZE_ARG,28000>,Int<4000>>>,TrJoin<TrDelay<4000>,TrFade<300>>,AlphaL<Mix<TwistAngle<>,RgbArg<STAB_COLOR_ARG,Rgb<255,68,0>>,RotateColorsX<Int<3000>,RgbArg<STAB_COLOR_ARG,Rgb<255,68,0>>>>,SmoothStep<IntArg<MELT_SIZE_ARG,28000>,Int<4000>>>,TrFade<4000>>,TrWipe<200>,SaberBase::LOCKUP_MELT>,InOutTrL<TrWipeX<BendTimePowInvX<IgnitionTime<300>,Mult<IntArg<IGNITION_OPTION2_ARG,10992>,Int<98304>>>>,TrWipeInX<BendTimePowInvX<RetractionTime<0>,Mult<IntArg<RETRACTION_OPTION2_ARG,10992>,Int<98304>>>>,Black>>>(),
},

};

BladeConfig blades[] = {
 { 0, WS2811BladePtr<132, WS2811_ACTUALLY_800kHz | WS2811_GRB>(), CONFIGARRAY(presets) },
  };
#endif

#ifdef CONFIG_BUTTONS
Button PowerButton(BUTTON_POWER, powerButtonPin, "pow");
#endif

Ok, I’ll check it out when I get a chance.

Well, there’s something going on, but only certain colors which is odd. Now to figure out why.

@profezzorn I “think” I narrowed it down to this function, is there anything here that would cause certain colors, like Magenta, to not convert (maybe they are too large for the char argspace[32])?

Otherwise, any ideas on why some colors work fine but others wouldn’t. I believe I tracked it down to the above function where it is setting up the color for the blade preview, it’s either returning null or as 0, but only on certain colors, which is a bit confusing.

I don’t see anything obviously wrong here.
When it doesn’t work, does it return red? black? something else?
What’s actually in “argspace” when it fails?

It saves as “0,0,0”, however it also doesn’t actually increase from 0,0,0 where it would normally in the menu, for example, the dial to increase from Black should let me at least brighten, but doesn’t. Even though the menu determines “Maximum” value for black (which is full color), it stays as “0,0,0”, so I was thinking maybe it’s null or something else is going on? It is definitely color specific, everything works fine on some colors and always fails on others.

if it makes any sense, Adjust White level does increase and can save as any grayscale value from black to white. But it still loses the original color values so the color saves as white.

Thanks, when you change modes it’s “starting over” as Black (0,0,0) so it can add White values, the issue is arising in the initial setting of the color and is not resolving until we save the value of 0,0,0 so we need to determine why it’s not getting the color correctly going into these modes for certain colors.

We need to add some log statements and check the serial monitor.
First one would be to print out “argspace” to see what is actually in it.
Second one would be to print out current_preset_.GetStyle(blade) and “arg” so that we can see what it should be.

OK, I’ll give a whirl in the morning, tied up tonight.

EDIT:
OK, so ‘argspace’ is printing the correct value when we enter ShowFull so it’s not the cause. It looks like it’s coming from here, the print on saved_color_ has a “#” added in front, but not sure where that would come in from.

I added a print to it and here’s the arspace value and then the saved_color_ value:

Style RAM = 1132
argspace = 65535,0,65535
Style RAM = 1132
argspace = 65535,0,65535
saved_color = #65535,0,65535

What would cause the “#” to be appended to that value?

It definite appears to be tied to saved_color_ somehow getting a “#” appended. I added additional prints on the r, g, b values for GetColor()

  Color16 GetColorArg(int blade, int arg) {
    char argspace[32];
    if (style_parser.GetArgument(current_preset_.GetStyle(blade), arg + 2, argspace)) {
      STDOUT << "argspace = " << argspace << "\n";
      char* tmp;
      int r = strtol(argspace, &tmp, 0);
      int g = strtol(tmp+1, &tmp, 0);
      int b = strtol(tmp+1, NULL, 0);
      STDOUT << "r = " << r << " g = " << g << " b = " << b << "\n";
      return Color16(r,g,b);
    }
    return Color16(65535,0,0);
  }

The thing is the “#” is actually there for colors that work and those that don’t, so if we select Blue, for example, the color actually shows in the preview but saved_color_ still has the “#” added in Serial Monitor.

argspace = 65535,0,65535
r = 65535 g = 0 b = 65535
Style RAM = 1132
argspace = 65535,0,65535
r = 65535 g = 0 b = 65535
saved_color = #65535,0,65535

But then here is Magenta, and the color gets kicked to 0,0,0. So it seems the “#” messes up the longer color strings? But not sure where that # comes in from.

argspace = 65535,0,65535
r = 65535 g = 0 b = 65535
Style RAM = 1132
argspace = 65535,0,65535
r = 65535 g = 0 b = 65535
saved_color = #65535,0,65535

It comes from here:

You’ll get one any time you print out a Color16 value.

This doesn’t show any 0,0,0 though.
It looks like whatever is causing it to go black happens after this.

Ah, ok so then the saved_color_ with the “#” goes here to start the editing in HSL. So maybe this function can’t handle that “#” being there?

From here:

We convert the saved_color_ to HSL and then edit hsl_.L for the White and Black Editing. So maybe the “#” is interfering with that?

No, the ‘#’ is only in the printout.
It’s not a problem.

It could be an overflow in the RGB->HSL or HSL->RGB calculations though.
To print out the HSL values you’ll need to print out the H, S and L values individually since the HSL class doesn’t have a printTo method.