Skip to content

Commit

Permalink
Fix buffer flip
Browse files Browse the repository at this point in the history
  • Loading branch information
davepl committed Jul 15, 2023
1 parent e842a8a commit 1242118
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ default_envs = mesmerizer
; Options that are used (or extended) in all device sections (and hence environments) are defined here

[base]
upload_port = /dev/cu.usbserial-8411101
monitor_port = /dev/cu.usbserial-8411101
upload_port = /dev/ttyUSB1
monitor_port = /dev/ttyUSB1
upload_speed = 1500000

build_flags = -std=gnu++17
Expand Down
9 changes: 4 additions & 5 deletions src/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void MatrixInit()
LEDMatrixGFX::backgroundLayer.enableColorCorrection(true);

// Starting the effect might need to draw, so we need to set the leds up before doing so
auto pMatrix = std::static_pointer_cast<LEDMatrixGFX>(g_ptrEffectManager->g());
auto pMatrix = std::static_pointer_cast<LEDMatrixGFX>(g_ptrSystem->EffectManager().g());
pMatrix->setLeds(LEDMatrixGFX::GetMatrixBackBuffer());
}

Expand Down Expand Up @@ -118,7 +118,7 @@ void MatrixPreDraw()
LEDMatrixGFX::matrix.setCalcRefreshRateDivider(MATRIX_CALC_DIVIDER);
LEDMatrixGFX::matrix.setRefreshRate(MATRIX_REFRESH_RATE);

auto pMatrix = std::static_pointer_cast<LEDMatrixGFX>(graphics);
auto pMatrix = std::static_pointer_cast<LEDMatrixGFX>(g_ptrSystem->EffectManager().GetBaseGraphics());
pMatrix->setLeds(LEDMatrixGFX::GetMatrixBackBuffer());

// We set ourselves to the lower of the fader value or the brightness value,
Expand Down Expand Up @@ -171,7 +171,7 @@ void MatrixPreDraw()

void MatrixPostDraw()
{
auto pMatrix = std::static_pointer_cast<LEDMatrixGFX>(g_ptrEffectManager->g());
auto pMatrix = std::static_pointer_cast<LEDMatrixGFX>( g_ptrSystem->EffectManager().g() );

constexpr auto kCaptionPower = 500; // A guess as the power the caption will consume
g_MatrixPowerMilliwatts = pMatrix->EstimatePowerDraw(); // What our drawn pixels will consume
Expand Down Expand Up @@ -201,7 +201,7 @@ void MatrixPostDraw()
debugV("MW: %d, Setting Scaled Brightness to: %d", g_MatrixPowerMilliwatts, targetBrightness);
pMatrix->SetBrightness(targetBrightness );

LEDMatrixGFX::MatrixSwapBuffers(g_ptrEffectManager->GetCurrentEffect()->RequiresDoubleBuffering(), pMatrix->GetCaptionTransparency() > 0);
LEDMatrixGFX::MatrixSwapBuffers(g_ptrSystem->EffectManager().GetCurrentEffect().RequiresDoubleBuffering(), pMatrix->GetCaptionTransparency() > 0);
}
#endif

Expand Down Expand Up @@ -486,7 +486,6 @@ void IRAM_ATTR DrawLoopTaskEntry(void *)
#if USE_MATRIX
if (wifiPixelsDrawn + localPixelsDrawn > 0)
{
LEDMatrixGFX::MatrixSwapBuffers(g_ptrSystem->EffectManager().GetCurrentEffect().RequiresDoubleBuffering(), pMatrix->GetCaptionTransparency() > 0);
FastLED.countFPS();
g_FPS = FastLED.getFPS();
}
Expand Down

0 comments on commit 1242118

Please sign in to comment.