Hello! I’m trying to create a blade style that modifies an arg through a special ability (single button crossguard saber, want to be able to change the ignition delay of the side blades through EFFECT_USER7 and EFFECT_USER8) but I can’t find anything that seems to facilitate that. Am I missing something or is it not currently possible?
There aren’t any style templates that can do that, but it’s not overly difficult to do in C++.
@profezzorn So, helping crazy I put together this sort of deal:
template<
unsigned INITIAL,
unsigned INC,
BladeEffectType EFFECT_UP,
BladeEffectType EFFECT_DOWN
>
struct EffectDialF {
// Since it makes the bottom handling simpler, though I guess you could
// add funky logic to handle non-multiples
static_assert(INITIAL % INC == 0);
void run(BladeBase *blade) {
if (mEffectUp.Detect(blade)) {
// You’re not reasonably overflowing this… right?
mValue += INC;
STDOUT.print("Detected Up: ");
STDOUT.println(mValue);
} else if (mEffectDown.Detect(blade)) {
if (mValue != 0)
mValue -= INC;
STDOUT.print("Detected Down: ");
STDOUT.println(mValue);
}
}
int getInteger(int /* led */) {
return static_cast<int>(mValue);
}
private:
unsigned mValue{INITIAL};
OneshotEffectDetector<EFFECT_UP> mEffectUp;
OneshotEffectDetector<EFFECT_DOWN> mEffectDown;
};
Which is based off the way EffectRandomF and EffectIncrementF are done.
However, the effect only seems to be detected (going by the prints in the serial monitor) once, until the saber is ignited and retracted, then it’s detected once again.
message-2.txt (9.4 KB)
Other effects triggered by, in this case, EFFECT_USER7 and EFFECT_USER8 play (both visual and sound), but no more print outs, and it’s not incremented anymore.
Reading through OneshotEffectDetector I don’t see an obvious reason for why that’d occur, but I’m not really all that familiar with ProffieOS and what you’ve setup there.
@crazy Can you post that style also?
I’d appreciate a more knowledgeable set of eyes on it :). The fact it detects it again after ignite/retract is even more vexing from my POV, but probably I just misunderstand something.
Here’s the sideblade stylecode I’m using:
StylePtr<
Layers<
ColorSelect<
AltF,
TrInstant,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<8000>,
Int<3000>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<-2600>,
Int<-3600>
>,
RgbArg<BASE_COLOR_ARG,Blue>,
Mix<Int<12000>,Black,RgbArg<BASE_COLOR_ARG,Blue>>,
Pulsing<
RgbArg<BASE_COLOR_ARG,Blue>,
Mix<Int<8000>,Black,RgbArg<BASE_COLOR_ARG,Blue>>,
1400
>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<10000>,
Int<5000>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<-2000>,
Int<-3000>
>,
RgbArg<ALT_COLOR_ARG,Cyan>,
Mix<Int<12000>,Black,RgbArg<ALT_COLOR_ARG,Cyan>>,
Pulsing<
RgbArg<ALT_COLOR_ARG,Cyan>,
Mix<Int<8000>,Black,RgbArg<ALT_COLOR_ARG,Cyan>>,
1400
>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<4000>,
Int<1800>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<2000>,
Int<4000>
>,
Int<-2800>,
Int<-4000>
>,
Mix<Int<16000>,Black,RgbArg<ALT_COLOR2_ARG,Green>>,
Mix<
Sin<Int<20>,Int<22000>,Int<32768>>,
Black,
RgbArg<ALT_COLOR2_ARG,Green>
>,
Mix<Int<8000>,Black,RgbArg<ALT_COLOR2_ARG,Green>>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<9000>,
Int<4000>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<-2400>,
Int<-3000>
>,
RgbArg<ALT_COLOR3_ARG,Rgb<80,50,210>>,
Mix<Int<15000>,Black,RgbArg<ALT_COLOR3_ARG,Rgb<80,50,210>>>,
Pulsing<
RgbArg<ALT_COLOR3_ARG,Rgb<80,50,210>>,
Mix<Int<10000>,Black,RgbArg<ALT_COLOR3_ARG,Rgb<80,50,210>>>,
600
>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<9000>,
Int<4000>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<-2000>,
Int<-3000>
>,
Magenta,
Mix<Int<12000>,Black,Magenta>,
Pulsing<Magenta,Mix<Int<8000>,Black,Magenta>,800>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<4000>,
Int<1800>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<2000>,
Int<4000>
>,
Int<-2800>,
Int<-4000>
>,
Mix<Int<16000>,Black,DarkOrange>,
Mix<Sin<Int<20>,Int<20000>,Int<32768>>,Black,DarkOrange>,
Mix<Int<10000>,Black,DarkOrange>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Sin<Int<20>,Int<10000>,Int<7000>>,
Int<3000>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<2000>,
Int<4000>
>,
Int<-2300>,
Int<-4000>
>,
Rgb<115,15,240>,
Mix<Int<12000>,Black,Rgb<115,15,240>>,
Pulsing<
Rgb<115,15,240>,
Mix<Int<20000>,Black,Rgb<115,15,240>>,
2000
>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<4000>,
Int<1800>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<2000>,
Int<4000>
>,
Int<-3000>,
Int<-4500>
>,
Mix<Int<16000>,Black,Rgb<100,100,150>>,
Mix<Sin<Int<20>,Int<22000>,Int<32768>>,Black,Rgb<100,100,150>>,
Mix<Int<8000>,Black,Rgb<100,100,150>>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<3000>
>,
Int<3600>,
Int<1600>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<2000>,
Int<4000>
>,
Int<-2700>,
Int<-4100>
>,
Mix<Int<16000>,Black,Rgb<180,130,0>>,
Mix<Sin<Int<20>,Int<22000>,Int<32768>>,Black,Rgb<180,130,0>>,
Mix<Int<8000>,Black,Rgb<180,130,0>>
>,
StripesX<
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<2000>
>,
Int<6000>,
Int<2000>
>,
Scale<
HoldPeakF<
Sum<
EffectPulseF<EFFECT_IGNITION>,
EffectPulseF<EFFECT_ALT_SOUND>
>,
Int<3000>,
Int<4000>
>,
Int<-2600>,
Int<-3600>
>,
Red,
Mix<Int<12000>,Black,Red>,
Pulsing<Red,Mix<Int<8000>,Black,Red>,1000>
>
>,
TransitionEffectL<
TrConcat<
TrDelayX<EffectDialF<750,250,EFFECT_USER7,EFFECT_USER8>>,
RgbArg<IGNITION_COLOR_ARG,White>,
TrFade<150>
>,
EFFECT_IGNITION
>,
AlphaL<
ColorSelect<
AltF,
TrInstant,
RgbArg<BASE_COLOR_ARG,Blue>,
RgbArg<ALT_COLOR_ARG,Cyan>,
RgbArg<ALT_COLOR2_ARG,Green>,
RgbArg<ALT_COLOR3_ARG,Rgb<80,50,210>>,
Magenta,
Mix<Int<16000>,Black,DarkOrange>,
Rgb<115,15,240>,
Rgb<100,100,150>,
Rgb<180,130,0>,
Red
>,
SwingSpeed<1000>
>,
InOutTrL<
TrConcat<
TrDelayX<EffectDialF<750,250,EFFECT_USER7,EFFECT_USER8>>,
TrDoEffect<
TrWipeX<
BendTimePowInvX<
IntArg<IGNITION_TIME_ARG,50>,
Mult<IntArg<IGNITION_OPTION2_ARG,10992>,Int<98304>>
>
>,
EFFECT_TRANSITION_SOUND,
1
>
>,
TrWipeInX<
BendTimePowX<
Percentage<RetractionTime<>,20>,
Mult<IntArg<RETRACTION_OPTION2_ARG,10992>,Int<98304>>
>
>
>,
TransitionEffectL<
TrDoEffectAlways<
TrConcat<TrWipe<100>,Rgb16<46419,65535,7>,TrWipe<100>>,
EFFECT_TRANSITION_SOUND,
1
>,
EFFECT_USER7
>,
TransitionEffectL<
TrDoEffectAlways<
TrConcat<TrWipeIn<100>,Rgb16<65535,882,7>,TrWipeIn<100>>,
EFFECT_TRANSITION_SOUND,
2
>,
EFFECT_USER8
>,
EffectSequence<
EFFECT_POWERSAVE,
AlphaL<Black,Int<8192>>,
AlphaL<Black,Int<16384>>,
AlphaL<Black,Int<24576>>,
AlphaL<Black,Int<0>>
>
>
>()
Not the most optimized, but I’m not very great at code in general ![]()
It’s a highly modified Fett style
Here’s a video of the behavior
My understanding is that crazy was asking for something that would modify one of the options that can be changed from edit mode.
This class changes an internal (and not saved) value. That’s fine, if that’s what OP wants…
This works for my purpose, I asked about args since it seemed like a logical way to do things, but this works just fine as well. We’re just a little confused as to why it ignores repeated inputs until it’s ignited again