From 79ab7e76f82978b4afca19916e9116a416a8b066 Mon Sep 17 00:00:00 2001 From: Jagoda Estera Ślązak Date: Sat, 8 Feb 2025 12:15:53 +0100 Subject: Add ability to set pixel_base without overriding VirtualMatrixPanel --- src/ESP32-VirtualMatrixPanel-I2S-DMA.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h index f6df7ab..ac4c1f9 100644 --- a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h +++ b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h @@ -97,6 +97,7 @@ public: panelResX = _panelResX; panelResY = _panelResY; + panel_pixel_base = _panelResX; vmodule_rows = _vmodule_rows; vmodule_cols = _vmodule_cols; @@ -150,12 +151,14 @@ public: void drawDisplayTest(); void setPhysicalPanelScanRate(PANEL_SCAN_RATE rate); + void setPhysicalPanelScanRate(PANEL_SCAN_RATE rate, int16_t pixel_base); void setZoomFactor(int scale); virtual VirtualCoords getCoords(int16_t x, int16_t y); VirtualCoords coords; int16_t panelResX; int16_t panelResY; + int16_t panel_pixel_base; private: MatrixPanel_I2S_DMA *display; @@ -395,10 +398,10 @@ inline VirtualCoords VirtualMatrixPanel::getCoords(int16_t virt_x, int16_t virt_ if ((coords.y & 8) == 0) // 1st, 3rd 'block' of 8 rows of pixels, offset by panel width in DMA buffer - coords.x += ((coords.x / panelResX) + 1) * panelResX; + coords.x += ((coords.x / panel_pixel_base) + 1) * panel_pixel_base; else // 2nd, 4th 'block' of 8 rows of pixels, offset by panel width in DMA buffer - coords.x += (coords.x / panelResX) * panelResX; + coords.x += (coords.x / panel_pixel_base) * panel_pixel_base; // http://cpp.sh/4ak5u // Real number of DMA y rows is half reality @@ -408,17 +411,17 @@ inline VirtualCoords VirtualMatrixPanel::getCoords(int16_t virt_x, int16_t virt_ case FOUR_SCAN_16PX_HIGH: if ((coords.y & 4) == 0) // 1st, 3rd 'block' of 8 rows of pixels, offset by panel width in DMA buffer - coords.x += ((coords.x / panelResX) + 1) * panelResX; + coords.x += ((coords.x / panel_pixel_base) + 1) * panel_pixel_base; else // 2nd, 4th 'block' of 8 rows of pixels, offset by panel width in DMA buffer - coords.x += (coords.x / panelResX) * panelResX; + coords.x += (coords.x / panel_pixel_base) * panel_pixel_base; coords.y = (coords.y >> 3) * 4 + (coords.y & 0b00000011); break; case FOUR_SCAN_40PX_HIGH: if ((coords.y / 10) % 2 == 0) - coords.x += ((coords.x / panelResX) + 1) * panelResX; + coords.x += ((coords.x / panel_pixel_base) + 1) * panel_pixel_base; else - coords.x += (coords.x / panelResX) * panelResX; + coords.x += (coords.x / panel_pixel_base) * panel_pixel_base; coords.y = (coords.y / 20) * 10 + (coords.y % 10); break; default: @@ -524,6 +527,12 @@ inline void VirtualMatrixPanel::setPhysicalPanelScanRate(PANEL_SCAN_RATE rate) panel_scan_rate = rate; } +inline void VirtualMatrixPanel::setPhysicalPanelScanRate(PANEL_SCAN_RATE rate, int16_t pixel_base) +{ + panel_scan_rate = rate; + panel_pixel_base = pixel_base; +} + inline void VirtualMatrixPanel::setZoomFactor(int scale) { if(scale < 5 && scale > 0) -- cgit v1.3.1 From 4695ed3a0f8a4f1668cdb0717bc4cfb8da3b6589 Mon Sep 17 00:00:00 2001 From: Jagoda Estera Ślązak Date: Sat, 8 Feb 2025 14:37:12 +0100 Subject: Use unsigned integers where negative values doesn't make sense --- src/ESP32-VirtualMatrixPanel-I2S-DMA.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h index 50706a4..8270188 100644 --- a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h +++ b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h @@ -134,8 +134,8 @@ public: #endif #ifdef NO_GFX - inline int16_t width() const { return _virtualResX; } - inline int16_t height() const { return _virtualResY; } + inline uint16_t width() const { return _virtualResX; } + inline uint16_t height() const { return _virtualResY; } #endif uint16_t color444(uint8_t r, uint8_t g, uint8_t b) @@ -153,8 +153,8 @@ public: virtual VirtualCoords getCoords(int16_t x, int16_t y); VirtualCoords coords; - int16_t panelResX; - int16_t panelResY; + uint16_t panelResX; + uint16_t panelResY; private: MatrixPanel_I2S_DMA *display; @@ -162,17 +162,17 @@ private: PANEL_CHAIN_TYPE panel_chain_type; PANEL_SCAN_RATE panel_scan_rate = NORMAL_TWO_SCAN; - int16_t virtualResX; ///< Display width as combination of panels - int16_t virtualResY; ///< Display height as combination of panels + uint16_t virtualResX; ///< Display width as combination of panels + uint16_t virtualResY; ///< Display height as combination of panels - int16_t _virtualResX; ///< Display width as modified by current rotation - int16_t _virtualResY; ///< Display height as modified by current rotation + uint16_t _virtualResX; ///< Display width as modified by current rotation + uint16_t _virtualResY; ///< Display height as modified by current rotation - int16_t vmodule_rows; - int16_t vmodule_cols; + uint16_t vmodule_rows; + uint16_t vmodule_cols; - int16_t dmaResX; // The width of the chain in pixels (as the DMA engine sees it) + uint16_t dmaResX; // The width of the chain in pixels (as the DMA engine sees it) int _rotate = 0; -- cgit v1.3.1 From 7d2ed7936ddcc9202341351e97b45d0e8edced2c Mon Sep 17 00:00:00 2001 From: Jagoda Estera Ślązak Date: Sat, 8 Feb 2025 14:42:47 +0100 Subject: Use 8-bit integers, where larger don't make sense --- src/ESP32-VirtualMatrixPanel-I2S-DMA.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h index 8270188..0fe44e3 100644 --- a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h +++ b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h @@ -153,8 +153,8 @@ public: virtual VirtualCoords getCoords(int16_t x, int16_t y); VirtualCoords coords; - uint16_t panelResX; - uint16_t panelResY; + uint8_t panelResX; + uint8_t panelResY; private: MatrixPanel_I2S_DMA *display; @@ -169,8 +169,8 @@ private: uint16_t _virtualResX; ///< Display width as modified by current rotation uint16_t _virtualResY; ///< Display height as modified by current rotation - uint16_t vmodule_rows; - uint16_t vmodule_cols; + uint8_t vmodule_rows; + uint8_t vmodule_cols; uint16_t dmaResX; // The width of the chain in pixels (as the DMA engine sees it) -- cgit v1.3.1 From 0e5c84da78d041863c90d21f8c18db3139fa1e3f Mon Sep 17 00:00:00 2001 From: Jagoda Estera Ślązak Date: Sat, 8 Feb 2025 14:49:35 +0100 Subject: Use uint8_t for panel_pixel_base --- src/ESP32-VirtualMatrixPanel-I2S-DMA.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h index a38f0e9..0ad453b 100644 --- a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h +++ b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h @@ -151,14 +151,14 @@ public: void drawDisplayTest(); void setPhysicalPanelScanRate(PANEL_SCAN_RATE rate); - void setPhysicalPanelScanRate(PANEL_SCAN_RATE rate, int16_t pixel_base); + void setPhysicalPanelScanRate(PANEL_SCAN_RATE rate, uint8_t pixel_base); void setZoomFactor(int scale); virtual VirtualCoords getCoords(int16_t x, int16_t y); VirtualCoords coords; uint8_t panelResX; uint8_t panelResY; - int16_t panel_pixel_base; + uint8_t panel_pixel_base; private: MatrixPanel_I2S_DMA *display; @@ -527,7 +527,7 @@ inline void VirtualMatrixPanel::setPhysicalPanelScanRate(PANEL_SCAN_RATE rate) panel_scan_rate = rate; } -inline void VirtualMatrixPanel::setPhysicalPanelScanRate(PANEL_SCAN_RATE rate, int16_t pixel_base) +inline void VirtualMatrixPanel::setPhysicalPanelScanRate(PANEL_SCAN_RATE rate, uint8_t pixel_base) { panel_scan_rate = rate; panel_pixel_base = pixel_base; -- cgit v1.3.1