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