SSD1306 OLED display driver  1.3.1
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 
45  SpritePool( );
46 
52  void drawSprites();
53 
57  void refreshScreen();
58 
64  uint8_t add( SPRITE &sprite );
65 
69  void clear();
70 
74  void remove( SPRITE &sprite );
75 
80  void setRect(SSD1306_RECT rect) { m_rect = rect; };
81 
82 protected:
85 
88 
98  virtual void drawBlock(uint8_t blockColumn, uint8_t blockRow);
99 
100 private:
102  static const uint8_t MAX_SPRITES = 8;
103 
105  uint8_t m_canvasBuf[8*8/8];
106 
108  SPRITE *m_sprites[MAX_SPRITES];
109 
111  uint8_t m_count;
112 
113  void updateRegion(SSD1306_RECT ur);
114 };
115 
116 #endif
117 
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:80
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:80
SSD1306_RECT m_rect
Rectangle, which specifies part of the display, used by the sprites.
Definition: sprite_pool.h:87
void clear()
Definition: sprite_pool.cpp:80
virtual void drawBlock(uint8_t blockColumn, uint8_t blockRow)
Definition: sprite_pool.cpp:36