Case RGB Linkage Mode Flicker Fix (#1318)

* Modified animation effects so they return a bool if animation was successful.

This is important to our linkage frame as we use the "pre-button press" frame to copy to our case linkage RGBs.

Minor clean-ups to code

* Adding our missing button configs to our Javascript in WWW
This commit is contained in:
Luke A
2025-03-23 22:35:21 -04:00
committed by GitHub
parent 5dd048b2c9
commit b749e95cc4
20 changed files with 316 additions and 65 deletions

View File

@@ -270,6 +270,8 @@ private:
uint8_t multipleOfButtonLedsCount;
uint8_t remainderOfButtonLedsCount;
uint8_t alLinkageStartIndex;
};
#endif

View File

@@ -118,7 +118,7 @@ public:
static LEDFormat format;
bool notInFilter(Pixel pixel);
virtual void Animate(RGB (&frame)[100]) = 0;
virtual bool Animate(RGB (&frame)[100]) = 0;
void UpdateTime();
void UpdatePresses(RGB (&frame)[100]);
void DecrementFadeCounter(int32_t index);

View File

@@ -13,7 +13,7 @@ public:
Chase(PixelMatrix &matrix);
~Chase() {};
void Animate(RGB (&frame)[100]);
bool Animate(RGB (&frame)[100]);
void ParameterUp();
void ParameterDown();

View File

@@ -11,7 +11,7 @@ public:
~CustomTheme() { };
bool HasTheme();
void Animate(RGB (&frame)[100]);
bool Animate(RGB (&frame)[100]);
void ParameterUp();
void ParameterDown();
protected:

View File

@@ -12,7 +12,7 @@ public:
CustomThemePressed(PixelMatrix &matrix, std::vector<Pixel> &pixels);
~CustomThemePressed() { pixels = nullptr; };
bool HasTheme();
void Animate(RGB (&frame)[100]);
bool Animate(RGB (&frame)[100]);
void ParameterUp() { }
void ParameterDown() { }
protected:

View File

@@ -13,7 +13,7 @@ public:
Rainbow(PixelMatrix &matrix);
~Rainbow() {};
void Animate(RGB (&frame)[100]);
bool Animate(RGB (&frame)[100]);
void ParameterUp();
void ParameterDown();

View File

@@ -13,7 +13,7 @@ public:
StaticColor(PixelMatrix &matrix, std::vector<Pixel> &pixels);
~StaticColor() { };
void Animate(RGB (&frame)[100]);
bool Animate(RGB (&frame)[100]);
void SaveIndexOptions(uint8_t colorIndex);
uint8_t GetColor();
void ParameterUp();

View File

@@ -17,7 +17,7 @@ public:
void AddTheme(const std::map<uint32_t, RGB>& theme) { themes.push_back(theme); }
void ClearThemes() { themes.clear(); }
void Animate(RGB (&frame)[100]);
bool Animate(RGB (&frame)[100]);
void ParameterUp();
void ParameterDown();
protected:

View File

@@ -43,14 +43,13 @@ void NeoPico::Setup(int ledPin, int inNumPixels, LEDFormat inFormat, PIO inPio){
bool rgbw = (format == LED_FORMAT_GRBW) || (format == LED_FORMAT_RGBW);
ws2812_program_init(pio, sm, offset, ledPin, 800000, rgbw);
this->Clear();
//sleep_ms(10);
}
void NeoPico::Clear() {
memset(frame, 0, sizeof(frame));
}
void NeoPico::SetFrame(uint32_t newFrame[100]) {
void NeoPico::SetFrame(uint32_t * newFrame) {
memcpy(frame, newFrame, sizeof(frame));
}
@@ -58,15 +57,6 @@ void NeoPico::Show() {
for (int i = 0; i < this->numPixels; ++i) {
this->PutPixel(this->frame[i]);
}
// Ambient lights
/*
for(int j = this->numPixels; j < 100; ++j) {
// this->PutPixel(this->frame[j]);
pio_sm_put_blocking(pio, 0, (this->frame[j]) << 8u);
}
*/
//sleep_ms(10);
}
void NeoPico::Off() {
@@ -74,5 +64,4 @@ void NeoPico::Off() {
for (int i = 0; i < this->numPixels; ++i) {
this->PutPixel(this->frame[i]);
}
//sleep_ms(10);
}

View File

@@ -21,8 +21,7 @@ public:
void Clear();
void Off();
LEDFormat GetFormat();
// void SetPixel(int pixel, uint32_t color);
void SetFrame(uint32_t newFrame[100]);
void SetFrame(uint32_t * newFrame);
private:
void PutPixel(uint32_t pixel_grb);
LEDFormat format;

View File

@@ -287,6 +287,8 @@ void NeoPicoLEDAddon::setup() {
multipleOfButtonLedsCount = (ledOptions.caseRGBCount) / (buttonLedCount);
remainderOfButtonLedsCount = (ledOptions.caseRGBCount) % (buttonLedCount);
alLinkageStartIndex = ledOptions.caseRGBIndex;
}
void NeoPicoLEDAddon::ambientLightCustom() {
@@ -458,8 +460,6 @@ void NeoPicoLEDAddon::ambientLightCustom() {
}
void NeoPicoLEDAddon::ambientLightLinkage() {
const LEDOptions & ledOptions = Storage::getInstance().getLedOptions();
uint8_t alLinkageStartIndex = ledOptions.caseRGBIndex;
float preLinkageBrightnessX = as.GetLinkageModeOfBrightnessX();
for(int i = 0; i < multipleOfButtonLedsCount; i++){ // Repeat buttons
for(int j = 0; j < buttonLedCount; j++){
@@ -579,10 +579,8 @@ void NeoPicoLEDAddon::process() {
}
}
neopico.SetFrame(frame); // this might have been a thing before?
neopico.SetFrame(frame);
neopico.Show();
//Storage::getInstance().save(false);
//AnimationStore.save();
this->nextRunTime = make_timeout_time_ms(intervalMS);
}

View File

@@ -139,10 +139,13 @@ void AnimationStation::Animate() {
return;
}
baseAnimation->Animate(this->frame);
// Copy frame to linkage frame before button press
memcpy(linkageFrame, frame, sizeof(RGB)*100);
// Only copy our frame to linkage frame if the animation effect updated our frame[]
if ( baseAnimation->Animate(this->frame) == true ) {
// Copy frame to linkage frame before button press
for(int i = 0; i < 100; i++){
linkageFrame[i] = this->frame[i];
}
}
buttonAnimation->Animate(this->frame);
}

View File

@@ -8,9 +8,9 @@
Chase::Chase(PixelMatrix &matrix) : Animation(matrix) {
}
void Chase::Animate(RGB (&frame)[100]) {
bool Chase::Animate(RGB (&frame)[100]) {
if (!time_reached(this->nextRunTime)) {
return;
return false;
}
UpdateTime();
@@ -66,6 +66,8 @@ void Chase::Animate(RGB (&frame)[100]) {
}
this->nextRunTime = make_timeout_time_ms(animationOptions.chaseCycleTime);
return true;
}
bool Chase::IsChasePixel(int i) {

View File

@@ -26,7 +26,7 @@ CustomTheme::CustomTheme(PixelMatrix &matrix) : Animation(matrix) {
}
}
void CustomTheme::Animate(RGB (&frame)[100]) {
bool CustomTheme::Animate(RGB (&frame)[100]) {
UpdateTime();
UpdatePresses(frame);
@@ -51,6 +51,8 @@ void CustomTheme::Animate(RGB (&frame)[100]) {
}
}
}
return true;
}
bool CustomTheme::HasTheme() {

View File

@@ -33,7 +33,7 @@ CustomThemePressed::CustomThemePressed(PixelMatrix &matrix, std::vector<Pixel> &
this->filtered = true;
}
void CustomThemePressed::Animate(RGB (&frame)[100]) {
bool CustomThemePressed::Animate(RGB (&frame)[100]) {
for (size_t r = 0; r != matrix->pixels.size(); r++) {
for (size_t c = 0; c != matrix->pixels[r].size(); c++) {
if (matrix->pixels[r][c].index == NO_PIXEL.index || this->notInFilter(matrix->pixels[r][c]))
@@ -48,6 +48,7 @@ void CustomThemePressed::Animate(RGB (&frame)[100]) {
frame[matrix->pixels[r][c].positions[p]] = defaultColor;
}
}
return true;
}
bool CustomThemePressed::HasTheme() {

View File

@@ -4,9 +4,9 @@
Rainbow::Rainbow(PixelMatrix &matrix) : Animation(matrix) {
}
void Rainbow::Animate(RGB (&frame)[100]) {
bool Rainbow::Animate(RGB (&frame)[100]) {
if (!time_reached(this->nextRunTime)) {
return;
return false;
}
UpdateTime();
@@ -44,6 +44,8 @@ void Rainbow::Animate(RGB (&frame)[100]) {
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
this->nextRunTime = make_timeout_time_ms(animationOptions.rainbowCycleTime);
return true;
}
// clamp rainbowCycleTime to [1 ... INT16_MAX]

View File

@@ -9,7 +9,7 @@ StaticColor::StaticColor(PixelMatrix &matrix, std::vector<Pixel> &inpixels) : An
pixels = inpixels;
}
void StaticColor::Animate(RGB (&frame)[100]) {
bool StaticColor::Animate(RGB (&frame)[100]) {
UpdateTime();
UpdatePresses(frame);
@@ -31,6 +31,7 @@ void StaticColor::Animate(RGB (&frame)[100]) {
}
}
}
return true;
}
uint8_t StaticColor::GetColor() {

View File

@@ -303,7 +303,7 @@ StaticTheme::StaticTheme(PixelMatrix &matrix) : Animation(matrix) {
AddTheme(themeFightboard);
}
void StaticTheme::Animate(RGB (&frame)[100]) {
bool StaticTheme::Animate(RGB (&frame)[100]) {
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
if (themes.size() > 0) {
UpdateTime();
@@ -333,6 +333,7 @@ void StaticTheme::Animate(RGB (&frame)[100]) {
}
}
}
return true;
}
void StaticTheme::ParameterUp() {

View File

@@ -446,45 +446,301 @@ export const BUTTON_LAYOUTS = [
mainButtons: MAIN_BUTTONS,
},
{
label: 'Stickless 13',
label: 'Buttons Angled',
value: 2,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Buttons Basic',
value: 3,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Keyboard Angled',
value: 4,
stickLayout: 'keyboard',
matrix: KEYBOARD_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Keyboard',
value: 5,
stickLayout: 'keyboard',
matrix: KEYBOARD_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Dancepad',
value: 6,
stickLayout: 'keyboard',
matrix: STICKLESS_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Twin Stick',
value: 7,
stickLayout: 'standard',
matrix: STICKLESS_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Blank',
value: 8,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Vewlix',
value: 9,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Fightboard Stick',
value: 10,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Fightboard Mirrored',
value: 11,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Custom',
value: 12,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'OpenCore0 WASD',
value: 13,
stickLayout: 'keyboard',
matrix: KEYBOARD_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Stickless 13',
value: 14,
stickLayout: 'stickless-13',
matrix: STICKLESS_13_LAYOUT,
auxButtons: AUX_BUTTONS_STICKLESS_13,
mainButtons: MAIN_BUTTONS_STICKLESS_13,
},
{
label: 'Stickless 14',
value: 3,
stickLayout: 'stickless-14',
matrix: STICKLESS_14_LAYOUT,
auxButtons: AUX_BUTTONS_STICKLESS_14,
mainButtons: MAIN_BUTTONS_STICKLESS_14,
},
{
label: 'Stickless 16',
value: 4,
value: 15,
stickLayout: 'stickless-16',
matrix: STICKLESS_16_LAYOUT,
auxButtons: AUX_BUTTONS_STICKLESS_16,
mainButtons: MAIN_BUTTONS_STICKLESS_16,
},
{
label: 'Stickless 16 A',
value: 5,
stickLayout: 'stickless-16-a',
matrix: STICKLESS_16_A_LAYOUT,
auxButtons: AUX_BUTTONS_STICKLESS_16_A,
mainButtons: MAIN_BUTTONS_STICKLESS_16_A,
label: 'Stickless 14',
value: 16,
stickLayout: 'stickless-14',
matrix: STICKLESS_14_LAYOUT,
auxButtons: AUX_BUTTONS_STICKLESS_14,
mainButtons: MAIN_BUTTONS_STICKLESS_14,
},
{
label: 'WASD',
value: 6,
stickLayout: 'keyboard',
matrix: KEYBOARD_LAYOUT,
label: 'Dancepad DDR Left',
value: 17,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Dancepad DDR SOLO',
value: 18,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Dancepad DDR Right',
value: 19,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Pop\'n Music',
value: 20,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Taiko',
value: 21,
stickLayout: 'taiko',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'BeatMania Turntable',
value: 22,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'BeatMania 5-Key',
value: 23,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'BeatMania 7-Key',
value: 24,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Gitadora Fret',
value: 25,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Gitadora Strum',
value: 26,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Board-Defined',
value: 27,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Band Hero Fret',
value: 28,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Band Hero Strum',
value: 29,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: '6Gawd',
value: 30,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: '6Gawd All-Button',
value: 31,
stickLayout: 'stickless-13',
matrix: STICKLESS_13_LAYOUT,
auxButtons: AUX_BUTTONS_STICKLESS_14,
mainButtons: MAIN_BUTTONS_STICKLESS_14,
},
{
label: '6Gawd All-Button Plus',
value: 32,
stickLayout: 'stickless-14',
matrix: STICKLESS_14_LAYOUT,
auxButtons: AUX_BUTTONS_STICKLESS_14,
mainButtons: MAIN_BUTTONS_STICKLESS_14,
},
{
label: 'Stickless R16',
value: 33,
stickLayout: 'stickless-16',
matrix: STICKLESS_16_LAYOUT,
auxButtons: AUX_BUTTONS_STICKLESS_16,
mainButtons: MAIN_BUTTONS_STICKLESS_16,
},
{
label: 'Board Defined Alt0',
value: 34,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Board Defined Alt1',
value: 35,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Board Defined Alt2',
value: 36,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Board Defined Alt3',
value: 37,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
},
{
label: 'Board Defined Alt4',
value: 38,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
}
];
export const BUTTON_MASKS = [

View File

@@ -20,6 +20,7 @@ import { getButtonLabels } from '../Data/Buttons';
import LEDColors from '../Data/LEDColors';
import { hexToInt } from '../Services/Utilities';
import WebApi from '../Services/WebApi';
import { BUTTON_LAYOUTS } from '../Data/Buttons';
const LED_FORMATS = [
{ label: 'GRB', value: 0 },
@@ -28,12 +29,6 @@ const LED_FORMATS = [
{ label: 'RGBW', value: 3 },
];
const BUTTON_LAYOUTS = [
{ label: '8-Button Layout', value: 0 },
{ label: 'Stickless Layout', value: 1 },
{ label: 'WASD Layout', value: 2 },
];
const PLED_LABELS = [
{ 0: 'PLED #1 Pin', 1: 'PLED #1 Index' },
{ 0: 'PLED #2 Pin', 1: 'PLED #2 Index' },
@@ -102,7 +97,7 @@ const schema = yup.object().shape({
.positive()
.integer()
.min(0)
.max(2)
.max(38)
.label('LED Layout'),
ledsPerButton: yup
.number()