Skip to content

Commit

Permalink
Merge pull request #427 from drvkmr/master
Browse files Browse the repository at this point in the history
setRotation implementation changed
  • Loading branch information
mrcodetastic authored Mar 22, 2023
2 parents e36b9d8 + e668d59 commit 5861056
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions src/ESP32-VirtualMatrixPanel-I2S-DMA.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class VirtualMatrixPanel

void flipDMABuffer() { display->flipDMABuffer(); }
void drawDisplayTest();
void setRotate(bool rotate);
void setRotation(int rotate);

void setPhysicalPanelScanRate(PANEL_SCAN_RATE rate);

Expand All @@ -155,7 +155,7 @@ class VirtualMatrixPanel

int16_t dmaResX; // The width of the chain in pixels (as the DMA engine sees it)

bool _rotate = false;
int _rotate = 0;

}; // end Class header

Expand All @@ -172,12 +172,34 @@ inline VirtualCoords VirtualMatrixPanel::getCoords(int16_t &virt_x, int16_t &vir
return coords;
}


// Do we want to rotate?
if (_rotate)
{
switch (_rotate) {
case 0: //no rotation, do nothing
break;

case (1): //90 degree rotation
{
int16_t temp_x = virt_x;
virt_x = virt_y;
virt_y = virtualResY - 1 - temp_x;
break;
}

case (2): //180 rotation
{
virt_x = virtualResX - 1 - virt_x;
virt_y = virtualResY - 1 - virt_y;
break;
}

case (3): //270 rotation
{
int16_t temp_x = virt_x;
virt_x = virtualResX - 1 - virt_y;
virt_y = temp_x;
break;
}
}

int row = (virt_y / panelResY); // 0 indexed
Expand Down Expand Up @@ -404,21 +426,10 @@ inline void VirtualMatrixPanel::fillScreen(CRGB color)
}
#endif

inline void VirtualMatrixPanel::setRotate(bool rotate)
inline void VirtualMatrixPanel::setRotation(int rotate)
{
if(rotate < 4 && rotate >= 0)
_rotate = rotate;

#ifndef NO_GFX
// We don't support rotation by degrees.
if (rotate)
{
setRotation(1);
}
else
{
setRotation(0);
}
#endif
}

inline void VirtualMatrixPanel::setPhysicalPanelScanRate(PANEL_SCAN_RATE rate)
Expand Down

0 comments on commit 5861056

Please sign in to comment.