Skip to content

Commit b15d86a

Browse files
author
Owen L - SFE
committed
create swpixel implementation
1 parent 4918f7e commit b15d86a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/HyperDisplay_ILI9163C.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,23 @@ void ILI9163C::hwpixel(hd_hw_extent_t x0, hd_hw_extent_t y0, color_t data, hd_c
121121
writeToRAM( (uint8_t*)value, len );
122122
}
123123

124+
void ILI9163C::swpixel( hd_extent_t x0, hd_extent_t y0, color_t data, hd_colors_t colorCycleLength, hd_colors_t startColorOffset)
125+
{
126+
if(data == NULL){ return; }
127+
if(colorCycleLength == 0){ return; }
128+
129+
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
130+
color_t value = getOffsetColor(data, startColorOffset);
131+
132+
hd_hw_extent_t x0w = (hd_hw_extent_t)x0; // Cast to hw extent type to be sure of integer values
133+
hd_hw_extent_t y0w = (hd_hw_extent_t)y0;
134+
135+
hd_pixels_t pixOffst = wToPix(pCurrentWindow, x0, y0); // It was already ensured that this will be in range
136+
color_t dest = getOffsetColor(pCurrentWindow->data, pixOffst); // Rely on the user's definition of a pixel's width in memory
137+
uint32_t len = (uint32_t)getOffsetColor(0x00, 1); // Getting the offset from zero for one pixel tells us how many bytes to copy
138+
139+
memcpy((void*)dest, (void*)value, (size_t)len); // Copy data into the window's buffer
140+
}
124141

125142

126143
// Basic Control Functions

src/HyperDisplay_ILI9163C.h

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class ILI9163C : virtual public hyperdisplay{
166166
// 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);
167167
// virtual void hwfillFromArray(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t numPixels, color_t data);
168168

169+
void swpixel( hd_extent_t x0, hd_extent_t y0, color_t data = NULL, hd_colors_t colorCycleLength = 1, hd_colors_t startColorOffset = 0);
169170

170171
public:
171172

0 commit comments

Comments
 (0)