diff --git a/src/HyperDisplay_ILI9163C.cpp b/src/HyperDisplay_ILI9163C.cpp index 64e6468..1e55fb3 100644 --- a/src/HyperDisplay_ILI9163C.cpp +++ b/src/HyperDisplay_ILI9163C.cpp @@ -121,6 +121,23 @@ void ILI9163C::hwpixel(hd_hw_extent_t x0, hd_hw_extent_t y0, color_t data, hd_c writeToRAM( (uint8_t*)value, len ); } +void ILI9163C::swpixel( hd_extent_t x0, hd_extent_t y0, color_t data, hd_colors_t colorCycleLength, hd_colors_t startColorOffset) +{ + if(data == NULL){ return; } + if(colorCycleLength == 0){ return; } + + startColorOffset = getNewColorOffset(colorCycleLength, startColorOffset, 0); // This line is needed to condition the user's input start color offset because it could be greater than the cycle length + color_t value = getOffsetColor(data, startColorOffset); + + hd_hw_extent_t x0w = (hd_hw_extent_t)x0; // Cast to hw extent type to be sure of integer values + hd_hw_extent_t y0w = (hd_hw_extent_t)y0; + + hd_pixels_t pixOffst = wToPix(pCurrentWindow, x0, y0); // It was already ensured that this will be in range + color_t dest = getOffsetColor(pCurrentWindow->data, pixOffst); // Rely on the user's definition of a pixel's width in memory + uint32_t len = (uint32_t)getOffsetColor(0x00, 1); // Getting the offset from zero for one pixel tells us how many bytes to copy + + memcpy((void*)dest, (void*)value, (size_t)len); // Copy data into the window's buffer +} // Basic Control Functions diff --git a/src/HyperDisplay_ILI9163C.h b/src/HyperDisplay_ILI9163C.h index a922794..9bd82a3 100644 --- a/src/HyperDisplay_ILI9163C.h +++ b/src/HyperDisplay_ILI9163C.h @@ -166,6 +166,7 @@ class ILI9163C : virtual public hyperdisplay{ // virtual void hwrectangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, bool filled = false, color_t data = NULL, uint16_t colorCycleLength = 1, uint16_t startColorOffset = 0, bool reverseGradient = false, bool gradientVertical = false); // virtual void hwfillFromArray(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t numPixels, color_t data); + void swpixel( hd_extent_t x0, hd_extent_t y0, color_t data = NULL, hd_colors_t colorCycleLength = 1, hd_colors_t startColorOffset = 0); public: