![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
dd
Dependencies: Final HCSR04 TB6612FNG
oled/SSD1306-Library.h@97:b483e656bd14, 2019-06-16 (annotated)
- Committer:
- eunmango
- Date:
- Sun Jun 16 04:44:35 2019 +0000
- Revision:
- 97:b483e656bd14
t
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eunmango | 97:b483e656bd14 | 1 | /* |
eunmango | 97:b483e656bd14 | 2 | * SSD1306-Libary.h |
eunmango | 97:b483e656bd14 | 3 | * |
eunmango | 97:b483e656bd14 | 4 | * Created on: Jan 1, 2017 |
eunmango | 97:b483e656bd14 | 5 | * Author: johnsone |
eunmango | 97:b483e656bd14 | 6 | */ |
eunmango | 97:b483e656bd14 | 7 | |
eunmango | 97:b483e656bd14 | 8 | #ifndef SOURCE_SSD1306_LIBARY_H_ |
eunmango | 97:b483e656bd14 | 9 | #define SOURCE_SSD1306_LIBARY_H_ |
eunmango | 97:b483e656bd14 | 10 | |
eunmango | 97:b483e656bd14 | 11 | #include "Adafruit_GFX.h" |
eunmango | 97:b483e656bd14 | 12 | |
eunmango | 97:b483e656bd14 | 13 | #include <stdint.h> |
eunmango | 97:b483e656bd14 | 14 | |
eunmango | 97:b483e656bd14 | 15 | #define SSD1306_LCDWIDTH 128 |
eunmango | 97:b483e656bd14 | 16 | #define SSD1306_LCDHEIGHT 64 |
eunmango | 97:b483e656bd14 | 17 | |
eunmango | 97:b483e656bd14 | 18 | #define BLACK 0 |
eunmango | 97:b483e656bd14 | 19 | #define WHITE 1 |
eunmango | 97:b483e656bd14 | 20 | #define INVERSE 2 |
eunmango | 97:b483e656bd14 | 21 | |
eunmango | 97:b483e656bd14 | 22 | #define SSD1306_SETCONTRAST 0x81 |
eunmango | 97:b483e656bd14 | 23 | #define SSD1306_DISPLAYALLON_RESUME 0xA4 |
eunmango | 97:b483e656bd14 | 24 | #define SSD1306_DISPLAYALLON 0xA5 |
eunmango | 97:b483e656bd14 | 25 | #define SSD1306_NORMALDISPLAY 0xA6 |
eunmango | 97:b483e656bd14 | 26 | #define SSD1306_INVERTDISPLAY 0xA7 |
eunmango | 97:b483e656bd14 | 27 | #define SSD1306_DISPLAYOFF 0xAE |
eunmango | 97:b483e656bd14 | 28 | #define SSD1306_DISPLAYON 0xAF |
eunmango | 97:b483e656bd14 | 29 | |
eunmango | 97:b483e656bd14 | 30 | #define SSD1306_SETDISPLAYOFFSET 0xD3 |
eunmango | 97:b483e656bd14 | 31 | #define SSD1306_SETCOMPINS 0xDA |
eunmango | 97:b483e656bd14 | 32 | |
eunmango | 97:b483e656bd14 | 33 | #define SSD1306_SETVCOMDETECT 0xDB |
eunmango | 97:b483e656bd14 | 34 | |
eunmango | 97:b483e656bd14 | 35 | #define SSD1306_SETDISPLAYCLOCKDIV 0xD5 |
eunmango | 97:b483e656bd14 | 36 | #define SSD1306_SETPRECHARGE 0xD9 |
eunmango | 97:b483e656bd14 | 37 | |
eunmango | 97:b483e656bd14 | 38 | #define SSD1306_SETMULTIPLEX 0xA8 |
eunmango | 97:b483e656bd14 | 39 | |
eunmango | 97:b483e656bd14 | 40 | #define SSD1306_SETLOWCOLUMN 0x00 |
eunmango | 97:b483e656bd14 | 41 | #define SSD1306_SETHIGHCOLUMN 0x10 |
eunmango | 97:b483e656bd14 | 42 | |
eunmango | 97:b483e656bd14 | 43 | #define SSD1306_SETSTARTLINE 0x40 |
eunmango | 97:b483e656bd14 | 44 | |
eunmango | 97:b483e656bd14 | 45 | #define SSD1306_MEMORYMODE 0x20 |
eunmango | 97:b483e656bd14 | 46 | #define SSD1306_COLUMNADDR 0x21 |
eunmango | 97:b483e656bd14 | 47 | #define SSD1306_PAGEADDR 0x22 |
eunmango | 97:b483e656bd14 | 48 | |
eunmango | 97:b483e656bd14 | 49 | #define SSD1306_COMSCANINC 0xC0 |
eunmango | 97:b483e656bd14 | 50 | #define SSD1306_COMSCANDEC 0xC8 |
eunmango | 97:b483e656bd14 | 51 | |
eunmango | 97:b483e656bd14 | 52 | #define SSD1306_SEGREMAP 0xA0 |
eunmango | 97:b483e656bd14 | 53 | |
eunmango | 97:b483e656bd14 | 54 | #define SSD1306_CHARGEPUMP 0x8D |
eunmango | 97:b483e656bd14 | 55 | |
eunmango | 97:b483e656bd14 | 56 | // Scrolling #defines |
eunmango | 97:b483e656bd14 | 57 | #define SSD1306_ACTIVATE_SCROLL 0x2F |
eunmango | 97:b483e656bd14 | 58 | #define SSD1306_DEACTIVATE_SCROLL 0x2E |
eunmango | 97:b483e656bd14 | 59 | #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 |
eunmango | 97:b483e656bd14 | 60 | #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 |
eunmango | 97:b483e656bd14 | 61 | #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 |
eunmango | 97:b483e656bd14 | 62 | #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 |
eunmango | 97:b483e656bd14 | 63 | #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A |
eunmango | 97:b483e656bd14 | 64 | |
eunmango | 97:b483e656bd14 | 65 | |
eunmango | 97:b483e656bd14 | 66 | class SSD1306 : public Adafruit_GFX { |
eunmango | 97:b483e656bd14 | 67 | public: |
eunmango | 97:b483e656bd14 | 68 | SSD1306(int16_t w=SSD1306_LCDWIDTH, int16_t h=SSD1306_LCDHEIGHT); |
eunmango | 97:b483e656bd14 | 69 | |
eunmango | 97:b483e656bd14 | 70 | void drawPixel(int16_t x, int16_t y, uint16_t color); |
eunmango | 97:b483e656bd14 | 71 | |
eunmango | 97:b483e656bd14 | 72 | void hw_setup(); |
eunmango | 97:b483e656bd14 | 73 | |
eunmango | 97:b483e656bd14 | 74 | void begin(bool reset=true); |
eunmango | 97:b483e656bd14 | 75 | void display(void); |
eunmango | 97:b483e656bd14 | 76 | |
eunmango | 97:b483e656bd14 | 77 | void clearDisplay(void); |
eunmango | 97:b483e656bd14 | 78 | void invertDisplay(uint8_t i); |
eunmango | 97:b483e656bd14 | 79 | void startscrollleft(uint8_t start, uint8_t stop); |
eunmango | 97:b483e656bd14 | 80 | void startscrollright(uint8_t start, uint8_t stop); |
eunmango | 97:b483e656bd14 | 81 | void startscrolldiagright(uint8_t start, uint8_t stop); |
eunmango | 97:b483e656bd14 | 82 | void startscrolldiagleft(uint8_t start, uint8_t stop); |
eunmango | 97:b483e656bd14 | 83 | void stopscroll(void); |
eunmango | 97:b483e656bd14 | 84 | void dim(bool dim); |
eunmango | 97:b483e656bd14 | 85 | void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); |
eunmango | 97:b483e656bd14 | 86 | void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); |
eunmango | 97:b483e656bd14 | 87 | |
eunmango | 97:b483e656bd14 | 88 | |
eunmango | 97:b483e656bd14 | 89 | protected: |
eunmango | 97:b483e656bd14 | 90 | int16_t |
eunmango | 97:b483e656bd14 | 91 | _width, _height; // Display w/h as modified by current rotation |
eunmango | 97:b483e656bd14 | 92 | |
eunmango | 97:b483e656bd14 | 93 | uint8_t |
eunmango | 97:b483e656bd14 | 94 | textsize, |
eunmango | 97:b483e656bd14 | 95 | rotation; |
eunmango | 97:b483e656bd14 | 96 | |
eunmango | 97:b483e656bd14 | 97 | private: |
eunmango | 97:b483e656bd14 | 98 | void _sendData(const uint8_t *blk, uint32_t len, bool isData); |
eunmango | 97:b483e656bd14 | 99 | void sendCommands(const uint8_t *blk, uint32_t len); |
eunmango | 97:b483e656bd14 | 100 | void sendData(const uint8_t *blk, uint32_t len); |
eunmango | 97:b483e656bd14 | 101 | |
eunmango | 97:b483e656bd14 | 102 | //void ssd1306_command(uint8_t c); |
eunmango | 97:b483e656bd14 | 103 | |
eunmango | 97:b483e656bd14 | 104 | void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color); |
eunmango | 97:b483e656bd14 | 105 | void drawFastVLineInternal(int16_t x, int16_t __y, int16_t __h, uint16_t color); |
eunmango | 97:b483e656bd14 | 106 | |
eunmango | 97:b483e656bd14 | 107 | void _scroll(uint8_t mode, uint8_t start, uint8_t stop); |
eunmango | 97:b483e656bd14 | 108 | }; |
eunmango | 97:b483e656bd14 | 109 | |
eunmango | 97:b483e656bd14 | 110 | |
eunmango | 97:b483e656bd14 | 111 | |
eunmango | 97:b483e656bd14 | 112 | #endif /* SOURCE_SSD1306_LIBARY_H_ */ |