SSD1306 OLED display driver  1.3.5
This library is developed to control SSD1306 i2c/spi OLED display
sprite_pool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 Alexey Dynda
3 
4  This file is part of SSD1306 library.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
24 #ifndef _SPRITE_POOL_H_
25 #define _SPRITE_POOL_H_
26 
27 #include "nano_gfx.h"
28 
36 {
37 public:
39  static const uint8_t SP_ERR_NO_SPACE = 0xFF;
40 
42  static const uint8_t MAX_SPRITES = 10;
43 
48  SpritePool( );
49 
55  void drawSprites();
56 
60  void refreshScreen();
61 
67  uint8_t add( SPRITE &sprite );
68 
72  void clear();
73 
77  void remove( SPRITE &sprite );
78 
83  void setRect(SSD1306_RECT rect) { m_rect = rect; };
84 
85 protected:
88 
91 
101  virtual void drawBlock(uint8_t blockColumn, uint8_t blockRow);
102 
103 private:
104 
106  uint8_t m_canvasBuf[8*8/8];
107 
109  SPRITE *m_sprites[MAX_SPRITES];
110 
112  uint8_t m_count;
113 
114  void updateRegion(SSD1306_RECT ur);
115 };
116 
117 #endif
118 
static const uint8_t SP_ERR_NO_SPACE
No free space for new sprite error.
Definition: sprite_pool.h:39
void refreshScreen()
Definition: sprite_pool.cpp:60
NanoCanvas m_canvas
Canvas used to draw sprites to avoid flickering.
Definition: sprite_pool.h:83
static const uint8_t MAX_SPRITES
Defines max sprites number supported by SpritePool.
Definition: sprite_pool.h:42
void drawSprites()
Definition: sprite_pool.cpp:41
uint8_t add(SPRITE &sprite)
Definition: sprite_pool.cpp:68
void setRect(SSD1306_RECT rect)
Definition: sprite_pool.h:83
SSD1306_RECT m_rect
Rectangle, which specifies part of the display, used by the sprites.
Definition: sprite_pool.h:90
void clear()
Definition: sprite_pool.cpp:80
virtual void drawBlock(uint8_t blockColumn, uint8_t blockRow)
Definition: sprite_pool.cpp:36