Adafruit_GFX.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef _ADAFRUIT_GFX_H
  2. #define _ADAFRUIT_GFX_H
  3. #if ARDUINO >= 100
  4. #include "Arduino.h"
  5. #include "Print.h"
  6. #else
  7. #include "WProgram.h"
  8. #endif
  9. #define swap(a, b) { int16_t t = a; a = b; b = t; }
  10. class Adafruit_GFX : public Print{
  11. public:
  12. // this must be defined by the subclass
  13. virtual void drawPixel(uint8_t x, uint8_t y, uint8_t color);
  14. // these are 'generic' drawing functions, so we can share them!
  15. void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
  16. uint8_t color);
  17. virtual void drawFastVLine(uint8_t x, uint8_t y, uint8_t h, uint8_t color);
  18. void drawRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
  19. uint8_t color);
  20. void fillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
  21. uint8_t color);
  22. void drawCircle(uint8_t x0, uint8_t y0, uint8_t r,
  23. uint8_t color);
  24. void fillCircle(uint8_t x0, uint8_t y0, uint8_t r,
  25. uint8_t color);
  26. void drawBitmap(uint8_t x, uint8_t y,
  27. const uint8_t *bitmap, uint8_t w, uint8_t h,
  28. uint8_t color);
  29. void drawChar(uint8_t x, uint8_t y, char c,
  30. uint16_t color, uint16_t bg, uint8_t size);
  31. #if ARDUINO >= 100
  32. virtual size_t write(uint8_t);
  33. #else
  34. virtual void write(uint8_t);
  35. #endif
  36. void setCursor(uint16_t x, uint16_t y);
  37. void setTextColor(uint16_t c);
  38. void setTextColor(uint16_t c, uint16_t bg);
  39. void setTextSize(uint8_t s);
  40. // return the size of the display
  41. uint16_t width() { return WIDTH; }
  42. uint16_t height() { return HEIGHT; }
  43. protected:
  44. uint16_t WIDTH, HEIGHT;
  45. uint16_t cursor_x, cursor_y, textcolor, textbgcolor;
  46. uint8_t textsize;
  47. };
  48. #endif