aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormrfaptastic <12006953+mrfaptastic@users.noreply.github.com>2023-03-22 13:20:46 +0000
committerGitHub <noreply@github.com>2023-03-22 13:20:46 +0000
commit58610563ee7a7084db1a58fd715faea35904cf17 (patch)
treebfeb4bfdde2302203f05f37e13df9a334aa1510d /src
parente36b9d8a87df6d33a6173d82a94f5b181ebf2651 (diff)
parente668d59cc44d4143002b54b569e0a84d697d97ff (diff)
Merge pull request #427 from drvkmr/master
setRotation implementation changed
Diffstat (limited to 'src')
-rw-r--r--src/ESP32-VirtualMatrixPanel-I2S-DMA.h45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h
index 0520c70..93d54ca 100644
--- a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h
+++ b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h
@@ -131,7 +131,7 @@ public:
void flipDMABuffer() { display->flipDMABuffer(); }
void drawDisplayTest();
- void setRotate(bool rotate);
+ void setRotation(int rotate);
void setPhysicalPanelScanRate(PANEL_SCAN_RATE rate);
@@ -155,7 +155,7 @@ private:
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
@@ -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
@@ -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)