adafruit / Adafruit-GFX-Library

Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from

Home Page:https://learn.adafruit.com/adafruit-gfx-graphics-library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setCursor function suggestion - setCursorX(x) and setCursorY(y)

PeakeElectronicInnovation opened this issue · comments

Just a quick suggestion, could we add setCursorX(uint16_t x) and setCursorY(uint16_t y) to Adafruit_GFX.h?

Often I find myself having to get the cursor X or Y position when populating a screen with text, which looks a bit like:

uint16_t RH_text_x_pos = 55;
tft.print("Some text");
tft.setCursor(RH_text_x_pos , tft.getCursorY());
tft.println("RH text at a consistant X co-ord");

if we had the following added to Adafruit_GFX.h then it would clean up the main code a bit... Just a suggestion of course :-)

Line 126

//
/
!
@brief Set text cursor location
@param x X coordinate in pixels
@param y Y coordinate in pixels
/
/
/
void setCursor(int16_t x, int16_t y) {
cursor_x = x;
cursor_y = y;
}

// Custom cursor functions...
void setCursorX(int16_t x) {
cursor_x = x;
}

void setCursorY(int16_t y) {
cursor_y = y;
}