Переглянути джерело

Merge pull request #45 from Mokolea/getCursor

Get current cursor position
Paint Your Dragon 10 роки тому
батько
коміт
b03b3fcd90
2 змінених файлів з 12 додано та 0 видалено
  1. 8 0
      Adafruit_GFX.cpp
  2. 4 0
      Adafruit_GFX.h

+ 8 - 0
Adafruit_GFX.cpp

@@ -466,6 +466,14 @@ void Adafruit_GFX::setCursor(int16_t x, int16_t y) {
   cursor_y = y;
 }
 
+int16_t Adafruit_GFX::getCursorX(void) const {
+  return cursor_x;
+}
+
+int16_t Adafruit_GFX::getCursorY(void) const {
+  return cursor_y;
+}
+
 void Adafruit_GFX::setTextSize(uint8_t s) {
   textsize = (s > 0) ? s : 1;
 }

+ 4 - 0
Adafruit_GFX.h

@@ -72,6 +72,10 @@ class Adafruit_GFX : public Print {
 
   uint8_t getRotation(void) const;
 
+  // get current cursor position (get rotation safe maximum values, using: width() for x, height() for y)
+  int16_t getCursorX(void) const;
+  int16_t getCursorY(void) const;
+
  protected:
   const int16_t
     WIDTH, HEIGHT;   // This is the 'raw' display w/h - never changes