SSD1306 OLED display driver  1.4.6
This library is developed to control SSD1306/SSD1331 RGB i2c/spi OLED displays and spi PCD8544 LED display
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 
39 {
40 public:
51  NanoCanvas(uint8_t w, uint8_t h, uint8_t *bytes)
52  {
53  m_w = w;
54  m_h = h;
55  m_p = 3;
56  m_invertByte = 0;
57  while (w >> (m_p+1)) { m_p++; };
58  m_bytes = bytes;
59  clear();
60  };
61 
67  inline void drawPixel(uint8_t x, uint8_t y) __attribute__ ((deprecated)) { putPixel(x,y); };
68 
74  void putPixel(uint8_t x, uint8_t y);
75 
83  void drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
84 
91  void drawHLine(uint8_t x1, uint8_t y1, uint8_t x2);
92 
99  void drawVLine(uint8_t x1, uint8_t y1, uint8_t y2);
100 
109  void fillRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t templ);
110 
114  void clear();
115 
123  inline void char_f6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL)
124  __attribute__ ((deprecated))
125  { charF6x8(x,y,ch,style); };
126 
134  void charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL);
135 
143  void charF12x16(uint8_t x, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL);
144 
153  void printFixed(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL);
154 
163  void printFixed2x(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL);
164 
169  void drawSpritePgm(uint8_t x, uint8_t y, const uint8_t sprite[]);
170 
175  void drawSprite(uint8_t x, uint8_t y, const uint8_t sprite[]);
176 
181  void drawSprite(SPRITE *sprite);
182 
186  inline uint8_t width() const { return m_w; };
187 
191  inline uint8_t height() const { return m_h; };
192 
196  inline uint8_t *buffer() const { return m_bytes; };
197 
202  void invert();
203 
207  void flipH();
208 
214  void blt(uint8_t x, uint8_t y);
215 
216 private:
217  uint8_t m_w;
218  uint8_t m_p;
219  uint8_t m_h;
220  uint8_t m_invertByte;
221  uint8_t *m_bytes;
222 };
223 
224 #endif
225 
void charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
Definition: nano_gfx.cpp:120
uint8_t * buffer() const
Definition: nano_gfx.h:196
void charF12x16(uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
Definition: nano_gfx.cpp:166
void fillRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t templ)
Definition: nano_gfx.cpp:76
void clear()
Definition: nano_gfx.cpp:111
void drawSpritePgm(uint8_t x, uint8_t y, const uint8_t sprite[])
Definition: nano_gfx.cpp:408
void drawSprite(uint8_t x, uint8_t y, const uint8_t sprite[])
Definition: nano_gfx.cpp:424
void invert()
Definition: nano_gfx.cpp:458
void printFixed(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
Definition: nano_gfx.cpp:245
void flipH()
Definition: nano_gfx.cpp:464
uint8_t width() const
Definition: nano_gfx.h:186
uint8_t height() const
Definition: nano_gfx.h:191
void drawVLine(uint8_t x1, uint8_t y1, uint8_t y2)
Definition: nano_gfx.cpp:57
void drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
Definition: nano_gfx.cpp:67
NanoCanvas(uint8_t w, uint8_t h, uint8_t *bytes)
Definition: nano_gfx.h:51
void blt(uint8_t x, uint8_t y)
Definition: nano_gfx.cpp:453
void char_f6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL) __attribute__((deprecated))
Definition: nano_gfx.h:123
void drawPixel(uint8_t x, uint8_t y) __attribute__((deprecated))
Definition: nano_gfx.h:67
void putPixel(uint8_t x, uint8_t y)
Definition: nano_gfx.cpp:34
EFontStyle
void drawHLine(uint8_t x1, uint8_t y1, uint8_t x2)
Definition: nano_gfx.cpp:47
void printFixed2x(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
Definition: nano_gfx.cpp:322