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-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 VGA4_LinesCount 4
53 
54 
55 
56 
57 namespace fabgl {
58 
59 
60 
78 
79 public:
80 
82  ~VGA4Controller();
83 
84  // unwanted methods
85  VGA4Controller(VGA4Controller const&) = delete;
86  void operator=(VGA4Controller const&) = delete;
87 
88 
94  static VGA4Controller * instance() { return s_instance; }
95 
96  void readScreen(Rect const & rect, RGB888 * destBuf);
97 
109  void setPaletteItem(int index, RGB888 const & color);
110 
111 
112 protected:
113 
114  void setupDefaultPalette();
115 
116 
117 private:
118 
119  // abstract method of BitmappedDisplayController
120  void setPixelAt(PixelDesc const & pixelDesc, Rect & updateRect);
121 
122  // abstract method of BitmappedDisplayController
123  void drawEllipse(Size const & size, Rect & updateRect);
124 
125  // abstract method of BitmappedDisplayController
126  void clear(Rect & updateRect);
127 
128  // abstract method of BitmappedDisplayController
129  void VScroll(int scroll, Rect & updateRect);
130 
131  // abstract method of BitmappedDisplayController
132  void HScroll(int scroll, Rect & updateRect);
133 
134  // abstract method of BitmappedDisplayController
135  void drawGlyph(Glyph const & glyph, GlyphOptions glyphOptions, RGB888 penColor, RGB888 brushColor, Rect & updateRect);
136 
137  // abstract method of BitmappedDisplayController
138  void invertRect(Rect const & rect, Rect & updateRect);
139 
140  // abstract method of BitmappedDisplayController
141  void copyRect(Rect const & source, Rect & updateRect);
142 
143  // abstract method of BitmappedDisplayController
144  void swapFGBG(Rect const & rect, Rect & updateRect);
145 
146  // abstract method of BitmappedDisplayController
147  void rawDrawBitmap_Native(int destX, int destY, Bitmap const * bitmap, int X1, int Y1, int XCount, int YCount);
148 
149  // abstract method of BitmappedDisplayController
150  void rawDrawBitmap_Mask(int destX, int destY, Bitmap const * bitmap, void * saveBackground, int X1, int Y1, int XCount, int YCount);
151 
152  // abstract method of BitmappedDisplayController
153  void rawDrawBitmap_RGBA2222(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_RGBA8888(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 rawFillRow(int y, int x1, int x2, RGB888 color);
160  void rawFillRow(int y, int x1, int x2, uint8_t colorIndex);
161 
162  void rawInvertRow(int y, int x1, int x2);
163 
164  void rawCopyRow(int x1, int x2, int srcY, int dstY);
165 
166  void swapRows(int yA, int yB, int x1, int x2);
167 
168  // abstract method of BitmappedDisplayController
169  void absDrawLine(int X1, int Y1, int X2, int Y2, RGB888 color);
170 
171  // abstract method of BitmappedDisplayController
172  int getBitmapSavePixelSize() { return 1; }
173 
174  static void ISRHandler(void * arg);
175 
176 
177 
178  static VGA4Controller * s_instance;
179 
180  volatile uint32_t * m_packedPaletteIndexQuad_to_signals;
181 
182 };
183 
184 
185 
186 } // end of namespace
187 
188 
189 
190 
191 
192 
193 
int16_t X2
Definition: fabutils.h:150
Represents a 24 bit RGB color.
Represents the VGA 4 colors bitmapped controller.
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.
void setPaletteItem(int index, RGB888 const &color)
Determines color of specified palette item.
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
This file contains fabgl::VGAPalettedController definition.
Specifies various glyph painting options.
Represents a rectangle.
Definition: fabutils.h:191
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:176
Represents the base class for paletted bitmapped controllers like VGA16Controller, VGA8Controller, etc..