-
-
Save sutaburosu/76d5d49ab6d5157a07d600b96c2ce010 to your computer and use it in GitHub Desktop.
A quick look at mangling SmartMatrix to support mirrored X-axis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Layer_BackgroundGfx_Impl.h b/src/Layer_BackgroundGfx_Impl.h | |
index 2120b1f..4723654 100644 | |
--- a/src/Layer_BackgroundGfx_Impl.h | |
+++ b/src/Layer_BackgroundGfx_Impl.h | |
@@ -236,7 +236,8 @@ void SMLayerBackgroundGFX<RGB, optionFlags>::drawPixel(int16_t x, int16_t y, con | |
hwy = y; | |
} else if (this->layerRotation == rotation180) { | |
hwx = (this->matrixWidth - 1) - x; | |
- hwy = (this->matrixHeight - 1) - y; | |
+ // hwy = (this->matrixHeight - 1) - y; | |
+ hwy = y; | |
} else if (this->layerRotation == rotation90) { | |
hwx = (this->matrixWidth - 1) - y; | |
hwy = x; | |
@@ -304,7 +305,8 @@ void SMLayerBackgroundGFX<RGB, optionFlags>::drawFastHLine(int16_t x0, int16_t x | |
if (this->layerRotation == rotation0) { | |
drawHardwareHLine(x0, x1, y, color); | |
} else if (this->layerRotation == rotation180) { | |
- drawHardwareHLine((this->matrixWidth - 1) - x1, (this->matrixWidth - 1) - x0, (this->matrixHeight - 1) - y, color); | |
+ // drawHardwareHLine((this->matrixWidth - 1) - x1, (this->matrixWidth - 1) - x0, (this->matrixHeight - 1) - y, color); | |
+ drawHardwareHLine((this->matrixWidth - 1) - x1, (this->matrixWidth - 1) - x0, y, color); | |
} else if (this->layerRotation == rotation90) { | |
drawHardwareVLine((this->matrixWidth - 1) - y, x0, x1, color); | |
} else { /* if (rotation == rotation270)*/ | |
@@ -333,7 +335,8 @@ void SMLayerBackgroundGFX<RGB, optionFlags>::drawFastVLine(int16_t x, int16_t y0 | |
if (this->layerRotation == rotation0) { | |
drawHardwareVLine(x, y0, y1, color); | |
} else if (this->layerRotation == rotation180) { | |
- drawHardwareVLine((this->matrixWidth - 1) - x, (this->matrixHeight - 1) - y1, (this->matrixHeight - 1) - y0, color); | |
+ // drawHardwareVLine((this->matrixWidth - 1) - x, (this->matrixHeight - 1) - y1, (this->matrixHeight - 1) - y0, color); | |
+ drawHardwareVLine((this->matrixWidth - 1) - x, y1, y0, color); | |
} else if (this->layerRotation == rotation90) { | |
drawHardwareHLine((this->matrixWidth - 1) - y1, (this->matrixWidth - 1) - y0, x, color); | |
} else { /* if (layerRotation == rotation270)*/ | |
@@ -387,7 +390,8 @@ const RGB SMLayerBackgroundGFX<RGB, optionFlags>::readPixel(int16_t x, int16_t y | |
hwy = y; | |
} else if (this->layerRotation == rotation180) { | |
hwx = (this->matrixWidth - 1) - x; | |
- hwy = (this->matrixHeight - 1) - y; | |
+ // hwy = (this->matrixHeight - 1) - y; | |
+ hwy = y; | |
} else if (this->layerRotation == rotation90) { | |
hwx = (this->matrixWidth - 1) - y; | |
hwy = x; | |
diff --git a/src/Layer_Background_Impl.h b/src/Layer_Background_Impl.h | |
index 68454f6..e96d3ea 100644 | |
--- a/src/Layer_Background_Impl.h | |
+++ b/src/Layer_Background_Impl.h | |
@@ -218,7 +218,8 @@ void SMLayerBackground<RGB, optionFlags>::drawPixel(int16_t x, int16_t y, const | |
hwy = y; | |
} else if (this->layerRotation == rotation180) { | |
hwx = (this->matrixWidth - 1) - x; | |
- hwy = (this->matrixHeight - 1) - y; | |
+ // hwy = (this->matrixHeight - 1) - y; | |
+ hwy = y; | |
} else if (this->layerRotation == rotation90) { | |
hwx = (this->matrixWidth - 1) - y; | |
hwy = x; | |
@@ -271,7 +272,8 @@ void SMLayerBackground<RGB, optionFlags>::drawFastHLine(int16_t x0, int16_t x1, | |
if (this->layerRotation == rotation0) { | |
drawHardwareHLine(x0, x1, y, color); | |
} else if (this->layerRotation == rotation180) { | |
- drawHardwareHLine((this->matrixWidth - 1) - x1, (this->matrixWidth - 1) - x0, (this->matrixHeight - 1) - y, color); | |
+ // drawHardwareHLine((this->matrixWidth - 1) - x1, (this->matrixWidth - 1) - x0, (this->matrixHeight - 1) - y, color); | |
+ drawHardwareHLine((this->matrixWidth - 1) - x1, (this->matrixWidth - 1) - x0, y, color); | |
} else if (this->layerRotation == rotation90) { | |
drawHardwareVLine((this->matrixWidth - 1) - y, x0, x1, color); | |
} else { /* if (rotation == rotation270)*/ | |
@@ -300,7 +302,8 @@ void SMLayerBackground<RGB, optionFlags>::drawFastVLine(int16_t x, int16_t y0, i | |
if (this->layerRotation == rotation0) { | |
drawHardwareVLine(x, y0, y1, color); | |
} else if (this->layerRotation == rotation180) { | |
- drawHardwareVLine((this->matrixWidth - 1) - x, (this->matrixHeight - 1) - y1, (this->matrixHeight - 1) - y0, color); | |
+ // drawHardwareVLine((this->matrixWidth - 1) - x, (this->matrixHeight - 1) - y1, (this->matrixHeight - 1) - y0, color); | |
+ drawHardwareVLine((this->matrixWidth - 1) - x, y0, y1, color); | |
} else if (this->layerRotation == rotation90) { | |
drawHardwareHLine((this->matrixWidth - 1) - y1, (this->matrixWidth - 1) - y0, x, color); | |
} else { /* if (layerRotation == rotation270)*/ | |
@@ -1029,7 +1032,8 @@ const RGB SMLayerBackground<RGB, optionFlags>::readPixel(int16_t x, int16_t y) { | |
hwy = y; | |
} else if (this->layerRotation == rotation180) { | |
hwx = (this->matrixWidth - 1) - x; | |
- hwy = (this->matrixHeight - 1) - y; | |
+ // hwy = (this->matrixHeight - 1) - y; | |
+ hwy = y; | |
} else if (this->layerRotation == rotation90) { | |
hwx = (this->matrixWidth - 1) - y; | |
hwy = x; | |
diff --git a/src/Layer_Gfx_Mono_Impl.h b/src/Layer_Gfx_Mono_Impl.h | |
index 99ad14d..b6af1e8 100644 | |
--- a/src/Layer_Gfx_Mono_Impl.h | |
+++ b/src/Layer_Gfx_Mono_Impl.h | |
@@ -255,7 +255,8 @@ void SMLayerGFXMono<RGB_API, RGB_STORAGE, optionFlags>::drawPixel(int16_t x, int | |
hwy = y; | |
} else if (this->layerRotation == rotation180) { | |
hwx = (this->layerWidth - 1) - x; | |
- hwy = (this->layerHeight - 1) - y; | |
+ // hwy = (this->layerHeight - 1) - y; | |
+ hwy = y; | |
} else if (this->layerRotation == rotation90) { | |
hwx = (this->layerWidth - 1) - y; | |
hwy = x; | |
@@ -499,7 +500,8 @@ void SMLayerGFXMono<RGB_API, RGB_STORAGE, optionFlags>::updateScrollingText(void | |
layerYOffset = fontTopOffset; | |
} else if(this->layerRotation == rotation180){ | |
layerXOffset = scrollPosition; | |
- layerYOffset = (matrixHeight - 1) - (fontTopOffset + layerHeight); | |
+ // layerYOffset = (matrixHeight - 1) - (fontTopOffset + layerHeight); | |
+ layerYOffset = fontTopOffset; | |
} else if(this->layerRotation == rotation90){ | |
layerXOffset = (matrixWidth - 1) - (fontTopOffset + layerWidth); | |
layerYOffset = scrollPosition; | |
diff --git a/src/Layer_Indexed_Impl.h b/src/Layer_Indexed_Impl.h | |
index 184af85..52c7948 100644 | |
--- a/src/Layer_Indexed_Impl.h | |
+++ b/src/Layer_Indexed_Impl.h | |
@@ -75,7 +75,8 @@ bool SMLayerIndexed<RGB, optionFlags>::getPixel(uint16_t hardwareX, uint16_t har | |
break; | |
case rotation180 : | |
localScreenX = (this->matrixWidth - 1) - hardwareX; | |
- localScreenY = (this->matrixHeight - 1) - hardwareY; | |
+ // localScreenY = (this->matrixHeight - 1) - hardwareY; | |
+ localScreenY = hardwareY; | |
break; | |
case rotation90 : | |
localScreenX = hardwareY; | |
diff --git a/src/Layer_Scrolling_Impl.h b/src/Layer_Scrolling_Impl.h | |
index db033e3..1b85f93 100644 | |
--- a/src/Layer_Scrolling_Impl.h | |
+++ b/src/Layer_Scrolling_Impl.h | |
@@ -70,7 +70,8 @@ bool SMLayerScrolling<RGB, optionFlags>::getPixel(uint16_t hardwareX, uint16_t h | |
break; | |
case rotation180 : | |
localScreenX = (this->matrixWidth - 1) - hardwareX; | |
- localScreenY = (this->matrixHeight - 1) - hardwareY; | |
+ // localScreenY = (this->matrixHeight - 1) - hardwareY; | |
+ localScreenY = hardwareY; | |
break; | |
case rotation90 : | |
localScreenX = hardwareY; | |
@@ -107,7 +108,8 @@ bool SMLayerScrolling<RGB, optionFlags>::getPixel(uint16_t hardwareX, uint16_t h | |
break; | |
case rotation180 : | |
localScreenX = (this->matrixWidth - 1) - hardwareX; | |
- localScreenY = (this->matrixHeight - 1) - hardwareY; | |
+ // localScreenY = (this->matrixHeight - 1) - hardwareY; | |
+ localScreenY = hardwareY; | |
break; | |
case rotation90 : | |
localScreenX = hardwareY; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment