FabGL
ESP32 Display Controller and Graphics Library
vga8controller.h
Go to the documentation of this file.
1 /*
2  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3  Copyright (c) 2019-2020 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6  This file is part of FabGL Library.
7 
8  FabGL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  FabGL is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #pragma once
24 
25 
26 
34 #include <stdint.h>
35 #include <stddef.h>
36 #include <atomic>
37 
38 #include "rom/lldesc.h"
39 #include "driver/gpio.h"
40 
41 #include "freertos/FreeRTOS.h"
42 #include "freertos/queue.h"
43 
44 #include "fabglconf.h"
45 #include "fabutils.h"
46 #include "devdrivers/swgenerator.h"
47 #include "displaycontroller.h"
49 
50 
51 
52 #define VGA8_LinesCount 4
53 
54 
55 
56 
57 namespace fabgl {
58 
59 
60 
80 
81 public:
82 
84  ~VGA8Controller();
85 
86  // unwanted methods
87  VGA8Controller(VGA8Controller const&) = delete;
88  void operator=(VGA8Controller const&) = delete;
89 
90 
96  static VGA8Controller * instance() { return s_instance; }
97 
98  void readScreen(Rect const & rect, RGB888 * destBuf);
99 
111  void setPaletteItem(int index, RGB888 const & color);
112 
113 
114 protected:
115 
116  void setupDefaultPalette();
117 
118 
119 private:
120 
121  // abstract method of BitmappedDisplayController
122  void setPixelAt(PixelDesc const & pixelDesc, Rect & updateRect);
123 
124  // abstract method of BitmappedDisplayController
125  void drawEllipse(Size const & size, Rect & updateRect);
126 
127  // abstract method of BitmappedDisplayController
128  void clear(Rect & updateRect);
129 
130  // abstract method of BitmappedDisplayController
131  void VScroll(int scroll, Rect & updateRect);
132 
133  // abstract method of BitmappedDisplayController
134  void HScroll(int scroll, Rect & updateRect);
135 
136  // abstract method of BitmappedDisplayController
137  void drawGlyph(Glyph const & glyph, GlyphOptions glyphOptions, RGB888 penColor, RGB888 brushColor, Rect & updateRect);
138 
139  // abstract method of BitmappedDisplayController
140  void invertRect(Rect const & rect, Rect & updateRect);
141 
142  // abstract method of BitmappedDisplayController
143  void copyRect(Rect const & source, Rect & updateRect);
144 
145  // abstract method of BitmappedDisplayController
146  void swapFGBG(Rect const & rect, Rect & updateRect);
147 
148  // abstract method of BitmappedDisplayController
149  void rawDrawBitmap_Native(int destX, int destY, Bitmap const * bitmap, int X1, int Y1, int XCount, int YCount);
150 
151  // abstract method of BitmappedDisplayController
152  void rawDrawBitmap_Mask(int destX, int destY, Bitmap const * bitmap, void * saveBackground, int X1, int Y1, int XCount, int YCount);
153 
154  // abstract method of BitmappedDisplayController
155  void rawDrawBitmap_RGBA2222(int destX, int destY, Bitmap const * bitmap, void * saveBackground, int X1, int Y1, int XCount, int YCount);
156 
157  // abstract method of BitmappedDisplayController
158  void rawDrawBitmap_RGBA8888(int destX, int destY, Bitmap const * bitmap, void * saveBackground, int X1, int Y1, int XCount, int YCount);
159 
160  // abstract method of BitmappedDisplayController
161  void rawFillRow(int y, int x1, int x2, RGB888 color);
162  void rawFillRow(int y, int x1, int x2, uint8_t colorIndex);
163 
164  void rawInvertRow(int y, int x1, int x2);
165 
166  void rawCopyRow(int x1, int x2, int srcY, int dstY);
167 
168  void swapRows(int yA, int yB, int x1, int x2);
169 
170  // abstract method of BitmappedDisplayController
171  void absDrawLine(int X1, int Y1, int X2, int Y2, RGB888 color);
172 
173  // abstract method of BitmappedDisplayController
174  int getBitmapSavePixelSize() { return 1; }
175 
176  static void ISRHandler(void * arg);
177 
178 
179  static VGA8Controller * s_instance;
180 
181  volatile uint16_t * m_packedPaletteIndexPair_to_signals;
182 
183 };
184 
185 
186 
187 } // end of namespace
188 
189 
190 
191 
192 
193 
194 
int16_t X2
Definition: fabutils.h:150
Represents a 24 bit RGB color.
int16_t Y2
Definition: fabutils.h:151
int16_t Y1
Definition: fabutils.h:149
This file contains fabgl::GPIOStream definition.
This file contains fabgl::BitmappedDisplayController definition.
int16_t X1
Definition: fabutils.h:148
Represents a glyph position, size and binary data.
Represents an image.
This file contains some utility classes and functions.
Definition: canvas.cpp:31
static VGA8Controller * instance()
Returns the singleton instance of VGA8Controller class.
void setPaletteItem(int index, RGB888 const &color)
Determines color of specified palette item.
This file contains fabgl::VGAPalettedController definition.
Specifies various glyph painting options.
Represents a rectangle.
Definition: fabutils.h:191
This file contains FabGL library configuration settings, like number of supported colors...
Represents a bidimensional size.
Definition: fabutils.h:176
Represents the base class for paletted bitmapped controllers like VGA16Controller, VGA8Controller, etc..
Represents the VGA 8 colors bitmapped controller.