Here are some of the tweaks I showcased in my Wejack thread
Wejack - A prototyping & development lightsaberblaster block setting tweak:
Config.h
166: #define BLASTER_FX_DURATION 300166: #define BLASTER_FX_DURATION 150181: #define BLASTERBLOCK_SUPRESS 400181: #define BLASTERBLOCK_SUPRESS 100There's a bit of overlap, but it works out fine.
Lockup on clash event deactivate on swing:
LightSaberOS.ino
673: ActionModeSubStates != AS_BLADELOCKUP673: (ActionModeSubStates != AS_BLADELOCKUP or lockuponclash)// end lockuponclash event on a swingThis only interrupts the lockuponclash event, not the mode, and does not interrupt a manual aux-pressed lockup activation. The mode is deactivated the same as in v1.4.
Shimmer on lockup:
Light.cpp Replace 755-763:
if (AState==AS_BLADELOCKUP) { //animate blade in lockup mode
// gives 25% chance to flick larger range for better randomization
int lockupFlick = random(0,39);
if (lockupFlick < 10) {
cRGB color;
color.b = brightness * currentColor.r / rgbFactor;
color.g = brightness * currentColor.g / rgbFactor;
color.r = brightness * currentColor.b / rgbFactor;
for (uint16_t i = 0; i <= NUMPIXELS; i++) {
pixels.set_crgb_at(i, color);
}
} else if (lockupFlick < 20) {
cRGB color;
color.r = brightness * currentColor.r / rgbFactor;
color.b = brightness * currentColor.g / rgbFactor;
color.g = brightness * currentColor.b / rgbFactor;
for (uint16_t i = 0; i <= NUMPIXELS; i++) {
pixels.set_crgb_at(i, color);
}
} else if (lockupFlick < 30) {
cRGB color;
color.b = brightness * currentColor.r / rgbFactor;
color.r = brightness * currentColor.g / rgbFactor;
color.g = brightness * currentColor.b / rgbFactor;
for (uint16_t i = 0; i <= NUMPIXELS; i++) {
pixels.set_crgb_at(i, color);
}
} else {
cRGB color;
color.r = brightness * currentColor.r / rgbFactor;
color.g = brightness * currentColor.g / rgbFactor;
color.b = brightness * currentColor.b / rgbFactor;
for (uint16_t i = 0; i <= NUMPIXELS; i++) {
pixels.set_crgb_at(i, color);
}
}
} else { //normal operation
cRGB color;
color.r = brightness * currentColor.r / rgbFactor;
color.g = brightness * currentColor.g / rgbFactor;
color.b = brightness * currentColor.b / rgbFactor;
for (uint16_t i = 0; i <= NUMPIXELS; i++) {
pixels.set_crgb_at(i, color);
}
}
Here's the full version of the ignition function I'm using, which also fades and flickers.
Light.cpp Replace RampNeoPixel() funciton lines 929-966:
void RampNeoPixel(uint16_t RampDuration, bool DirectionUpDown) {
unsigned long ignitionStart = millis();
cRGB value;
#ifdef FIREBLADE
for (unsigned int i=0; i<NUMPIXELS; (i=i+5)) { // turn on/off one LED at a time
FireBlade();
for(unsigned int j=0; j<NUMPIXELS; j++ ) { // fill up string with data
if ((DirectionUpDown and j<=i) or (!DirectionUpDown and j<=NUMPIXELS-1-i)){
}
else if ((DirectionUpDown and j>i) or (!DirectionUpDown and j>NUMPIXELS-1-i)){
value.r=0;
value.g=0;
value.b=0;
//heat[j]=0;
pixels.set_crgb_at(j, value); // Set value at LED found at index j
}
}
pixels.sync(); // Sends the data to the LEDs
}
#else
// turn on/off the number of LEDs required to keep up with the ignition timing
for (unsigned int i = 0; i < NUMPIXELS; i = NUMPIXELS*(millis()-ignitionStart)/RampDuration) {
//generate a flicker effect between 65% and 115% of MAX_BRIGHTNESS, with a 1 in 115 chance of flicking to 0
int flickFactor = random(0,115);
if (flickFactor < 65 && flickFactor > 0) { flickFactor = 100; }
for(uint8_t j=0; j<NUMPIXELS; j++ ) { // fill up string with data
if ((DirectionUpDown and j<=i)){
value.r = MAX_BRIGHTNESS * i / NUMPIXELS * currentColor.r / rgbFactor * flickFactor/100;
value.g = MAX_BRIGHTNESS * i / NUMPIXELS * currentColor.g / rgbFactor * flickFactor/100;
value.b = MAX_BRIGHTNESS * i / NUMPIXELS * currentColor.b / rgbFactor * flickFactor/100;
} else if (!DirectionUpDown and j<=NUMPIXELS-1-i){
value.r = MAX_BRIGHTNESS * (NUMPIXELS - i) / NUMPIXELS * currentColor.r / rgbFactor * flickFactor/100;
value.g = MAX_BRIGHTNESS * (NUMPIXELS - i) / NUMPIXELS * currentColor.g / rgbFactor * flickFactor/100;
value.b = MAX_BRIGHTNESS * (NUMPIXELS - i) / NUMPIXELS * currentColor.b / rgbFactor * flickFactor/100;
}
else if ((DirectionUpDown and j>i) or (!DirectionUpDown and j>NUMPIXELS-1-i)){
value.r=0;
value.g=0;
value.b=0;
}
pixels.set_crgb_at(j, value);
}
pixels.sync(); // Sends the data to the LEDs
// calculate the interval based on the RampDuration set in Soundfont.h and the number of pixels
delay(RampDuration/NUMPIXELS);
}
#endif
}
Based on what we saw in Rogue One, the fading and flickering are perhaps non-canonical. Either can be removed (which is how I originally shared it), but I think it really adds to the effect. This bright effect is hard to notice on a 120 pixel blade, but it is what makes the single pixel tri-cree blade possible.
i / NUMPIXELS ramps the brightness for the ignition
(NUMPIXELS - i) / NUMPIXELS ramps the brightness for extinguish
In order to make the blaster blocks work with the single pixel blade I also inserted the following code:
Light.cpp Insert at 712: pixels.set_crgb_at(0, currentColor);
This is only necessary because my single pixel blade is actually just plugging in place of the pixel strips. It slightly brightens the base of the strip blade, which I don't think is a bad thing really.
EDIT: the single pixel effects are also important if you want to use a pixel lighted blade plug without using a separate signal line!