Merge pull request from j-g00da/scan_rate_pixel_base

Settable pixel-base
This commit is contained in:
mrcodetastic 2025-02-08 15:10:51 +00:00 committed by GitHub
commit 9da34a7225
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -97,6 +97,7 @@ public:
panelResX = _panelResX;
panelResY = _panelResY;
panel_pixel_base = _panelResX;
vmodule_rows = _vmodule_rows;
vmodule_cols = _vmodule_cols;
@ -135,8 +136,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)
@ -150,12 +151,14 @@ public:
void drawDisplayTest();
void setPhysicalPanelScanRate(PANEL_SCAN_RATE rate);
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;
int16_t panelResX;
int16_t panelResY;
uint8_t panelResX;
uint8_t panelResY;
uint8_t panel_pixel_base;
private:
MatrixPanel_I2S_DMA *display;
@ -163,17 +166,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;
uint8_t vmodule_rows;
uint8_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;
@ -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, uint8_t pixel_base)
{
panel_scan_rate = rate;
panel_pixel_base = pixel_base;
}
inline void VirtualMatrixPanel::setZoomFactor(int scale)
{
if(scale < 5 && scale > 0)