diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 76742890..b0bd7d26 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -639,39 +639,33 @@ void OLED::drawSymbol(uint8_t symbolID) { } // Draw an area, but y must be aligned on 0/8 offset -void OLED::drawArea(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) { +void OLED::drawArea(int16_t x, int8_t y, uint8_t width, uint8_t height, const uint8_t *ptr) { + // Splat this from x->x+width in two strides + if (x <= -width) { return; // cutoffleft } - if (x > 96) { + if (x > OLED_WIDTH) { return; // cutoff right } uint8_t visibleStart = 0; - uint8_t visibleEnd = wide; + uint8_t visibleEnd = width; // trimming to draw partials if (x < 0) { visibleStart -= x; // subtract negative value == add absolute value } - if (x + wide > 96) { - visibleEnd = 96 - x; + if (x + width > OLED_WIDTH) { + visibleEnd = OLED_WIDTH - x; } - - if (y == 0) { - // Splat first line of data + uint8_t rowsDrawn = 0; + while (height > 0) { for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) { - stripPointers[0][xx + x] = ptr[xx]; + stripPointers[(y / 8) + rowsDrawn][x + xx] = ptr[xx + (rowsDrawn * width)]; } + height -= 8; + rowsDrawn++; } - if (y == 8 || height >= 16) { - // Splat the second line - for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) { - stripPointers[1][x + xx] = ptr[xx + (height == 16 ? wide : 0)]; - } - } - // TODO NEEDS HEIGHT HANDLERS for 24/32 } // Draw an area, but y must be aligned on 0/8 offset