I have not used the library for quite a while, so I had to look stuff up.
In the Adafruit GFX library is this function:
/**************************************************************************/
/*!
@brief Draw a line
@param x0 Start point x coordinate
@param y0 Start point y coordinate
@param x1 End point x coordinate
@param y1 End point y coordinate
@param color 16-bit 5-6-5 Color to draw with
*/
/**************************************************************************/
void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
uint16_t color) {
// Update in subclasses if desired!
if (x0 == x1) {
if (y0 > y1)
_swap_int16_t(y0, y1);
drawFastVLine(x0, y0, y1 - y0 + 1, color);
} else if (y0 == y1) {
if (x0 > x1)
_swap_int16_t(x0, x1);
drawFastHLine(x0, y0, x1 - x0 + 1, color);
} else {
startWrite();
writeLine(x0, y0, x1, y1, color);
endWrite();
}
}
Hopefully that helps.
Adafruit-GFX-Library/Adafruit_GFX.cpp at master · adafruit/Adafruit-GFX-Library (github.com)