diff --git a/OLEDDisplay.cpp b/OLEDDisplay.cpp index 5ebb433200b5aa565c20f9e0dc9ed224de7e61b5..01844466b37d3726fb8a57e2851b4fcdb44fb5e3 100644 --- a/OLEDDisplay.cpp +++ b/OLEDDisplay.cpp @@ -215,14 +215,18 @@ void OLEDDisplay::drawHorizontalLine(int16_t x, int16_t y, int16_t length) { } void OLEDDisplay::drawVerticalLine(int16_t x, int16_t y, int16_t length) { - if (y < 0 || y > DISPLAY_HEIGHT) return; + if (x < 0 || x > DISPLAY_WIDTH) return; - if (x < 0) { - length += x; - x = 0; + if (y < 0) { + length += y; + y = 0; + } + + if ( (y + length) > DISPLAY_HEIGHT) { + length = (DISPLAY_HEIGHT - y); } - if (length < 0) return; + if (length <= 0) return; uint8_t yOffset = y & 7;