Adafruit_GFX.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /***********************************
  2. This is a our graphics core library, for all our displays.
  3. We'll be adapting all the
  4. existing libaries to use this core to make updating, support
  5. and upgrading easier!
  6. Adafruit invests time and resources providing this open source code,
  7. please support Adafruit and open-source hardware by purchasing
  8. products from Adafruit!
  9. Written by Limor Fried/Ladyada for Adafruit Industries.
  10. BSD license, check license.txt for more information
  11. All text above must be included in any redistribution
  12. ****************************************/
  13. #ifndef _ADAFRUIT_GFX_H
  14. #define _ADAFRUIT_GFX_H
  15. #if ARDUINO >= 100
  16. #include "Arduino.h"
  17. #include "Print.h"
  18. #else
  19. #include "WProgram.h"
  20. #endif
  21. #define swap(a, b) { int16_t t = a; a = b; b = t; }
  22. class Adafruit_GFX : public Print{
  23. public:
  24. // this must be defined by the subclass
  25. virtual void drawPixel(uint8_t x, uint8_t y, uint8_t color);
  26. // these are 'generic' drawing functions, so we can share them!
  27. void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
  28. uint8_t color);
  29. virtual void drawFastVLine(uint8_t x, uint8_t y, uint8_t h, uint8_t color);
  30. void drawRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
  31. uint8_t color);
  32. void fillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
  33. uint8_t color);
  34. void drawCircle(uint8_t x0, uint8_t y0, uint8_t r,
  35. uint8_t color);
  36. void fillCircle(uint8_t x0, uint8_t y0, uint8_t r,
  37. uint8_t color);
  38. void drawBitmap(uint8_t x, uint8_t y,
  39. const uint8_t *bitmap, uint8_t w, uint8_t h,
  40. uint8_t color);
  41. void drawChar(uint8_t x, uint8_t y, char c,
  42. uint16_t color, uint16_t bg, uint8_t size);
  43. #if ARDUINO >= 100
  44. virtual size_t write(uint8_t);
  45. #else
  46. virtual void write(uint8_t);
  47. #endif
  48. void setCursor(uint16_t x, uint16_t y);
  49. void setTextColor(uint16_t c);
  50. void setTextColor(uint16_t c, uint16_t bg);
  51. void setTextSize(uint8_t s);
  52. // return the size of the display
  53. uint16_t width() { return WIDTH; }
  54. uint16_t height() { return HEIGHT; }
  55. protected:
  56. uint16_t WIDTH, HEIGHT;
  57. uint16_t cursor_x, cursor_y, textcolor, textbgcolor;
  58. uint8_t textsize;
  59. };
  60. #endif