SSD1306 OLED display driver  1.8.2
This library is developed to control SSD1306/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
nano_gfx.h
Go to the documentation of this file.
1 /*
2  MIT License
3 
4  Copyright (c) 2016-2018, Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
29 #ifndef _NANO_GFX_H_
30 #define _NANO_GFX_H_
31 
32 #include "nano_gfx_types.h"
33 #include "font6x8.h"
34 
40 {
41 public:
52  NanoCanvas(uint8_t w, uint8_t h, uint8_t *bytes)
53  {
54  m_w = w;
55  m_h = h;
56  m_p = 3;
57  m_invertByte = 0;
58  while (w >> (m_p+1)) { m_p++; };
59  m_bytes = bytes;
60  clear();
61  };
62 
69  inline void drawPixel(uint8_t x, uint8_t y) __attribute__ ((deprecated)) { putPixel(x,y); };
70 
76  void putPixel(uint8_t x, uint8_t y);
77 
85  void drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
86 
93  void drawHLine(uint8_t x1, uint8_t y1, uint8_t x2);
94 
101  void drawVLine(uint8_t x1, uint8_t y1, uint8_t y2);
102 
111  void fillRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t templ);
112 
116  void clear();
117 
126  inline void char_f6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL)
127  __attribute__ ((deprecated))
128  { charF6x8(x,y,ch,style); };
129 
138  void charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL);
139 
147  void charF12x16(uint8_t x, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL);
148 
157  void printFixed(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL);
158 
167  void printFixed2x(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL);
168 
173  void drawSpritePgm(uint8_t x, uint8_t y, const uint8_t sprite[]);
174 
183  void drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf);
184 
189  void drawSprite(uint8_t x, uint8_t y, const uint8_t sprite[]);
190 
195  void drawSprite(SPRITE *sprite);
196 
200  inline uint8_t width() const { return m_w; };
201 
205  inline uint8_t height() const { return m_h; };
206 
210  inline uint8_t *buffer() const { return m_bytes; };
211 
216  void invert();
217 
221  void flipH();
222 
228  void blt(uint8_t x, uint8_t y);
229 
230 private:
231  uint8_t m_w;
232  uint8_t m_p;
233  uint8_t m_h;
234  uint8_t m_invertByte;
235  uint8_t *m_bytes;
236 };
237 
238 #endif
239 
void charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
uint8_t * buffer() const
Definition: nano_gfx.h:210
void charF12x16(uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
void fillRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t templ)
void clear()
void drawSpritePgm(uint8_t x, uint8_t y, const uint8_t sprite[])
void drawSprite(uint8_t x, uint8_t y, const uint8_t sprite[])
void invert()
void printFixed(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
void flipH()
uint8_t width() const
Definition: nano_gfx.h:200
uint8_t height() const
Definition: nano_gfx.h:205
void drawVLine(uint8_t x1, uint8_t y1, uint8_t y2)
void drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
NanoCanvas(uint8_t w, uint8_t h, uint8_t *bytes)
Definition: nano_gfx.h:52
void blt(uint8_t x, uint8_t y)
void char_f6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL) __attribute__((deprecated))
Definition: nano_gfx.h:126
void drawPixel(uint8_t x, uint8_t y) __attribute__((deprecated))
Definition: nano_gfx.h:69
void putPixel(uint8_t x, uint8_t y)
void drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
EFontStyle
void drawHLine(uint8_t x1, uint8_t y1, uint8_t x2)
void printFixed2x(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)