FabGL
ESP32 Display Controller and Graphics Library
vga4controller.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 #define VGA4_LinesCount 4
56 
57 
58 
59 
60 namespace fabgl {
61 
62 
63 
81 
82 public:
83 
85  ~VGA4Controller();
86 
87  // unwanted methods
88  VGA4Controller(VGA4Controller const&) = delete;
89  void operator=(VGA4Controller const&) = delete;
90 
91 
97  static VGA4Controller * 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 VGA4Controller * s_instance;
182 
183  volatile uint32_t * m_packedPaletteIndexQuad_to_signals;
184 
185 };
186 
187 
188 
189 } // end of namespace
190 
191 
192 
193 
194 
195 
196 
int16_t X2
Definition: fabutils.h:179
Represents a 24 bit RGB color.
Represents the VGA 4 colors bitmapped controller.
int16_t Y2
Definition: fabutils.h:180
int16_t Y1
Definition: fabutils.h:178
This file contains fabgl::GPIOStream definition.
This file contains fabgl::BitmappedDisplayController definition.
void setPaletteItem(int index, RGB888 const &color)
Determines color of specified palette item.
int16_t X1
Definition: fabutils.h:177
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
static VGA4Controller * instance()
Returns the singleton instance of VGA4Controller class.
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..