EDIT MODE Adjust Black Level bug?

OK, where would be the best place to do that?

After line 1495 maybe?
I’m really not sure where it turns into zeroes. The goal is to get a printout before and one after, then narrow the region as much as possible. If it happens in toHSL, then we need to print out the RGB values going in and the HSL values coming out. We should also print out the HSL and RGB values where we convert it back to RGB, wherever that is.

OK, so pretty sure it’s something in toHSL() BUT when we try to “observe” it, it goes away, kinda like my PC when IT comes by.
I couldn’t get the STDOUT to compile for hsl_ in my prop so I simply added it to the toHSL() function, but doing so fixed the issue and it worked for Magenta. To confirm, I removed the STDOUT (no other changes) and it went back to Black like before. I’m not sure why, but it was repeatable, does this give you any clues?

Here’s the only change I made, and it “fixed”:

  HSL toHSL() const {
    int MAX = std::max(r, std::max(g, b));
    int MIN = std::min(r, std::min(g, b));
    int C = MAX - MIN;
    int H;
    // Note 16384 = 60 degrees.
    if (C == 0) {
      H = 0;
    } else if (r == MAX) {
      // r is biggest
      H = 16384 * (g - b) / C;
    } else if (g == MAX) {
      // g is biggest
      H = 16384 * (b - r) / C + 16384 * 2;
    } else {
      // b is biggest
      H = 16384 * (r - g) / C + 16384 * 4;
    }
    int L = MIN + MAX;
    float S = (MAX*2 - L) / (float)std::min<int>(L, 131072 - L);
// I added this and the issue went away, no idea why though.
    STDOUT << "H = " << H / 98304.0  << " S = " << S << " L = " << L / 131070.0 << "\n";
    return HSL(H / 98304.0, S, L / 131070.0);
  }

While it was in place here’s the print outs for Blue and Magenta and both worked in Edit Black this time, with it removed Blue works and Magenta does not.

argspace = 0,0,65535
r = 0 g = 0 b = 65535
saved_color = #0,0,65535
H = 0.67 S = 1.00 L = 0.50
...
argspace = 65509,0,65535
r = 65509 g = 0 b = 65535
saved_color = #65509,0,65535
H = 0.83 S = 1.00 L = 0.50

I see int division by a float and what seems like implicit conversion, which is a big red flag.

It could be that the log statement is coercing the compiler… removing some edge case where with the magenta the conversion to double doesn’t happen

@Fett263 Ive also seen weird things constructing objects for return… nothing that should cause issues but sometimes the compiler does funny things.

I would be curious if you construct the HSL object before return, then print out its members instead of doing the math yourself for the logging, then return the object.

I have to wait for @profezzorn to look, the toHSL() is from the main OS.

So if it randomly disappears when trying to debug it, then there is a fair chance that it is a compiler bug. Can you try it with the experimental arduino-proffiboard plugin (3.7.0) ? (Or are you maybe using that already?)

Getting an error with the experimental plugin.

Arduino: 1.8.18 (Windows 10), Board: "Proffieboard, Serial, SDCARD (SPI), 80 MHz, Smallest Code"

exec: "C:\\Users\\ferna\\AppData\\Local\\Arduino15\\packages\\proffieboard_experimental\\tools\\arm-none-eabi-gcc\\12-3-rel1/bin/arm-none-eabi-g++": file does not exist

Error compiling for board Proffieboard.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Not sure if you just need to re-install it, or if you need Arduino 2.x to make it work.

Ok, I’ll try 2.x and/or reinstall.

It doesn’t appear to be the compiler, I have Arduino 2.2.1 with Experimental plugin and the issue persists as does the “fix” of trying to look at H, S, L in toHSL(). If I run OS7.13 as is, Magenta still goes black when trying to edit Black. As soon as I add the print out to toHSL() to view it, with no other changes, it works without issue.

Can you have a look in toHSL() to see what would cause?

  HSL toHSL() const {
    int MAX = std::max(r, std::max(g, b));
    int MIN = std::min(r, std::min(g, b));
    int C = MAX - MIN;
    int H;
    // Note 16384 = 60 degrees.
    if (C == 0) {
      H = 0;
    } else if (r == MAX) {
      // r is biggest
      H = 16384 * (g - b) / C;
    } else if (g == MAX) {
      // g is biggest
      H = 16384 * (b - r) / C + 16384 * 2;
    } else {
      // b is biggest
      H = 16384 * (r - g) / C + 16384 * 4;
    }
    int L = MIN + MAX;
    float S = (MAX*2 - L) / (float)std::min<int>(L, 131072 - L);
// just adding this print "fixes" the issue, no other changes anywhere else impacted.
    STDOUT << "H = " << H / 98304.0  << " S = " << S << " L = " << L / 131070.0 << "\n";
    return HSL(H / 98304.0, S, L / 131070.0);
  }

This is the style I’ve tested it does it every time.

  • Go into Edit Mode > Edit Colors > Base Color > Color List > (scroll to Magenta) > Save
  • Go to Edit Black Level > blade turns black (with print out above it works as expected).

If you choose, Blue or Green or other base colors in Color List everything works as expected with or without the print out.

/* 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: Static 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<RgbArg<BASE_COLOR_ARG,Rgb<0,0,255>>,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>>>(),

Ok, I think I found the problem.
I have a fix on github master, please try it.

Seems to work now :slight_smile:

Confirmed, thanks. Will also post in v7.14 thread.