SSD1327.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef SSD1327_H
  2. #define SSD1327_H
  3. #include <stdint.h>
  4. // Scroll rate constants. See datasheet page 40.
  5. #define SSD1327_SCROLL_2 0b111
  6. #define SSD1327_SCROLL_3 0b100
  7. #define SSD1327_SCROLL_4 0b101
  8. #define SSD1327_SCROLL_5 0b110
  9. #define SSD1327_SCROLL_6 0b000
  10. #define SSD1327_SCROLL_32 0b001
  11. #define SSD1327_SCROLL_64 0b010
  12. #define SSD1327_SCROLL_256 0b011
  13. class SSD1327 {
  14. public:
  15. SSD1327(int cs, int dc, int rst);
  16. void writeCmd(uint8_t reg);
  17. void writeData(uint8_t data);
  18. void setWriteZone(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
  19. uint16_t coordsToAddress(uint8_t x, uint8_t y);
  20. void setPixelChanged(uint8_t x, uint8_t y, bool changed);
  21. void drawPixel(uint8_t x, uint8_t y, uint8_t color, bool display);
  22. void drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color, bool display = false);
  23. void drawHLine(int x, int y, int length, uint8_t color, bool display = false);
  24. void drawVLine(int x, int y, int length, uint8_t color, bool display = false);
  25. void drawLine(int x1, int y1, int x2, int y2, uint8_t color, bool display = false);
  26. void drawByteAsRow(uint8_t x, uint8_t y, uint8_t byte, uint8_t color);
  27. void drawChar(uint8_t x, uint8_t y, char thisChar, uint8_t color);
  28. void drawChar16(uint8_t x, uint8_t y, char thisChar, uint8_t color);
  29. void drawChar32(uint8_t x, uint8_t y, char thisChar, uint8_t color);
  30. void drawCharArray(uint8_t x, uint8_t y, char text[], uint8_t color, int size=8);
  31. void drawString(uint8_t x, uint8_t y, char *textString, uint8_t color, int size=8);
  32. #if 1
  33. void setupScrolling(uint8_t startRow, uint8_t endRow, uint8_t startCol, uint8_t endCol, uint8_t scrollSpeed, bool right);
  34. void startScrolling();
  35. void stopScrolling();
  36. void scrollStep(uint8_t startRow, uint8_t endRow, uint8_t startCol, uint8_t endCol, bool right);
  37. void fillStripes(uint8_t offset);
  38. #endif
  39. void clearBuffer();
  40. void writeFullBuffer();
  41. #if 0
  42. void writeUpdates();
  43. void setContrast(uint8_t contrast);
  44. void initRegs();
  45. void init();
  46. #endif
  47. private:
  48. uint8_t *frameBuffer;
  49. uint8_t changedPixels[1024]; // Each bit of this array represets whether a given byte of frameBuffer (e.g. a pair of pixels) is not up to date.
  50. #if 0
  51. uint8_t frameBuffer[8192]; // Should mirror the display's own frameBuffer.
  52. #endif
  53. };
  54. extern SSD1327 ssd1327;
  55. #endif