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-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 // must be a power of 2
53 #define VGA2_LinesCount 4
54 
55 
56 
57 
58 namespace fabgl {
59 
60 
61 
81 
82 public:
83 
85  ~VGA2Controller();
86 
87  // unwanted methods
88  VGA2Controller(VGA2Controller const&) = delete;
89  void operator=(VGA2Controller const&) = delete;
90 
91 
97  static VGA2Controller * instance() { return s_instance; }
98 
99  void readScreen(Rect const & rect, RGB888 * destBuf);
100 
112  void setPaletteItem(int index, RGB888 const & color);
113 
114 
115 protected:
116 
117  void setupDefaultPalette();
118 
119 
120 private:
121 
122  // abstract method of BitmappedDisplayController
123  void setPixelAt(PixelDesc const & pixelDesc, Rect & updateRect);
124 
125  // abstract method of BitmappedDisplayController
126  void drawEllipse(Size const & size, Rect & updateRect);
127 
128  // abstract method of BitmappedDisplayController
129  void clear(Rect & updateRect);
130 
131  // abstract method of BitmappedDisplayController
132  void VScroll(int scroll, Rect & updateRect);
133 
134  // abstract method of BitmappedDisplayController
135  void HScroll(int scroll, Rect & updateRect);
136 
137  // abstract method of BitmappedDisplayController
138  void drawGlyph(Glyph const & glyph, GlyphOptions glyphOptions, RGB888 penColor, RGB888 brushColor, Rect & updateRect);
139 
140  // abstract method of BitmappedDisplayController
141  void invertRect(Rect const & rect, Rect & updateRect);
142 
143  // abstract method of BitmappedDisplayController
144  void copyRect(Rect const & source, Rect & updateRect);
145 
146  // abstract method of BitmappedDisplayController
147  void swapFGBG(Rect const & rect, Rect & updateRect);
148 
149  // abstract method of BitmappedDisplayController
150  void rawDrawBitmap_Native(int destX, int destY, Bitmap const * bitmap, int X1, int Y1, int XCount, int YCount);
151 
152  // abstract method of BitmappedDisplayController
153  void rawDrawBitmap_Mask(int destX, int destY, Bitmap const * bitmap, void * saveBackground, int X1, int Y1, int XCount, int YCount);
154 
155  // abstract method of BitmappedDisplayController
156  void rawDrawBitmap_RGBA2222(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_RGBA8888(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 rawFillRow(int y, int x1, int x2, RGB888 color);
163  void rawFillRow(int y, int x1, int x2, uint8_t colorIndex);
164 
165  void rawInvertRow(int y, int x1, int x2);
166 
167  void rawCopyRow(int x1, int x2, int srcY, int dstY);
168 
169  void swapRows(int yA, int yB, int x1, int x2);
170 
171  // abstract method of BitmappedDisplayController
172  void absDrawLine(int X1, int Y1, int X2, int Y2, RGB888 color);
173 
174  // abstract method of BitmappedDisplayController
175  int getBitmapSavePixelSize() { return 1; }
176 
177  static void ISRHandler(void * arg);
178 
179 
180 
181  static VGA2Controller * s_instance;
182 
183  volatile uint64_t * m_packedPaletteIndexOctet_to_signals;
184 
185 };
186 
187 
188 
189 } // end of namespace
190 
191 
192 
193 
194 
195 
196 
int16_t X2
Definition: fabutils.h:150
Represents a 24 bit RGB color.
Represents the VGA 2 colors bitmapped controller.
int16_t Y2
Definition: fabutils.h:151
int16_t Y1
Definition: fabutils.h:149
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:148
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:31
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..