1
0
forked from me/IronOS

Reduced stack usage in showBootLogoIfavailable().

Introduced new function OLED::drawAreaSwapped() for drawing images where
the octets are reveresed endianess in 16-bit words.
This commit is contained in:
fatcookies
2020-01-16 21:58:02 +00:00
parent 1ca87a4241
commit 0591a01c5a
3 changed files with 52 additions and 22 deletions

View File

@@ -262,6 +262,44 @@ void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
}
}
}
// Draw an area, but y must be aligned on 0/8 offset
// For data which has octets swapped in a 16-bit word.
void OLED::drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height,
const uint8_t *ptr) {
// Splat this from x->x+wide in two strides
if (x <= -wide)
return; // cutoffleft
if (x > 96)
return; // cutoff right
uint8_t visibleStart = 0;
uint8_t visibleEnd = wide;
// trimming to draw partials
if (x < 0) {
visibleStart -= x; // subtract negative value == add absolute value
}
if (x + wide > 96) {
visibleEnd = 96 - x;
}
if (y == 0) {
// Splat first line of data
for (uint8_t xx = visibleStart; xx < visibleEnd; xx+=2) {
firstStripPtr[xx + x] = ptr[xx + 1];
firstStripPtr[xx + x + 1] = ptr[xx];
}
}
if (y == 8 || height == 16) {
// Splat the second line
for (uint8_t xx = visibleStart; xx < visibleEnd; xx+=2) {
secondStripPtr[x + xx] = ptr[xx + 1 + (height == 16 ? wide : 0)];
secondStripPtr[x + xx + 1] = ptr[xx + (height == 16 ? wide : 0)];
}
}
}
void OLED::fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
const uint8_t value) {
// Splat this from x->x+wide in two strides