@@ -131,7 +131,7 @@ class VirtualMatrixPanel
131131
132132 void flipDMABuffer () { display->flipDMABuffer (); }
133133 void drawDisplayTest ();
134- void setRotate ( bool rotate);
134+ void setRotation ( int rotate);
135135
136136 void setPhysicalPanelScanRate (PANEL_SCAN_RATE rate);
137137
@@ -155,7 +155,7 @@ class VirtualMatrixPanel
155155
156156 int16_t dmaResX; // The width of the chain in pixels (as the DMA engine sees it)
157157
158- bool _rotate = false ;
158+ int _rotate = 0 ;
159159
160160}; // end Class header
161161
@@ -172,12 +172,34 @@ inline VirtualCoords VirtualMatrixPanel::getCoords(int16_t &virt_x, int16_t &vir
172172 return coords;
173173 }
174174
175+
175176 // Do we want to rotate?
176- if (_rotate)
177- {
177+ switch (_rotate) {
178+ case 0 : // no rotation, do nothing
179+ break ;
180+
181+ case (1 ): // 90 degree rotation
182+ {
178183 int16_t temp_x = virt_x;
179184 virt_x = virt_y;
180185 virt_y = virtualResY - 1 - temp_x;
186+ break ;
187+ }
188+
189+ case (2 ): // 180 rotation
190+ {
191+ virt_x = virtualResX - 1 - virt_x;
192+ virt_y = virtualResY - 1 - virt_y;
193+ break ;
194+ }
195+
196+ case (3 ): // 270 rotation
197+ {
198+ int16_t temp_x = virt_x;
199+ virt_x = virtualResX - 1 - virt_y;
200+ virt_y = temp_x;
201+ break ;
202+ }
181203 }
182204
183205 int row = (virt_y / panelResY); // 0 indexed
@@ -404,21 +426,10 @@ inline void VirtualMatrixPanel::fillScreen(CRGB color)
404426}
405427#endif
406428
407- inline void VirtualMatrixPanel::setRotate ( bool rotate)
429+ inline void VirtualMatrixPanel::setRotation ( int rotate)
408430{
431+ if (rotate < 4 && rotate >= 0 )
409432 _rotate = rotate;
410-
411- #ifndef NO_GFX
412- // We don't support rotation by degrees.
413- if (rotate)
414- {
415- setRotation (1 );
416- }
417- else
418- {
419- setRotation (0 );
420- }
421- #endif
422433}
423434
424435inline void VirtualMatrixPanel::setPhysicalPanelScanRate (PANEL_SCAN_RATE rate)
0 commit comments