SSD1306 OLED display driver  1.8.2
This library is developed to control SSD1306/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
sprite_pool.h
Go to the documentation of this file.
1 /*
2  MIT License
3 
4  Copyright (c) 2017-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 _SPRITE_POOL_H_
30 #define _SPRITE_POOL_H_
31 
32 #include "nano_gfx.h"
33 
43 {
44 public:
46  static const uint8_t SP_ERR_NO_SPACE = 0xFF;
47 
48 #if defined(ESP32) || defined(ESP8266)
49  static const uint8_t MAX_SPRITES = 32;
51 #else
52  static const uint8_t MAX_SPRITES = 10;
54 #endif
55 
61  SpritePool( );
62 
68  void drawSprites();
69 
73  void refreshScreen();
74 
80  uint8_t add( SPRITE &sprite );
81 
85  void clear();
86 
90  void remove( SPRITE &sprite );
91 
96  void setRect(SSD1306_RECT rect) { m_rect = rect; };
97 
98 protected:
101 
104 
114  virtual void drawBlock(uint8_t blockColumn, uint8_t blockRow);
115 
116 private:
117 
119  uint8_t m_canvasBuf[8*8/8];
120 
122  SPRITE *m_sprites[MAX_SPRITES];
123 
125  uint8_t m_count;
126 
127  void updateRegion(SSD1306_RECT ur);
128 };
129 
130 #endif
131 
static const uint8_t SP_ERR_NO_SPACE
No free space for new sprite error.
Definition: sprite_pool.h:46
void refreshScreen()
NanoCanvas m_canvas
Canvas used to draw sprites to avoid flickering.
Definition: sprite_pool.h:96
virtual void drawBlock(uint8_t blockColumn, uint8_t blockRow)
static const uint8_t MAX_SPRITES
Defines max sprites number supported by SpritePool.
Definition: sprite_pool.h:53
void drawSprites()
uint8_t add(SPRITE &sprite)
void setRect(SSD1306_RECT rect)
Definition: sprite_pool.h:96
SSD1306_RECT m_rect
Rectangle, which specifies part of the display, used by the sprites.
Definition: sprite_pool.h:103
void clear()