FabGL
ESP32 VGA Controller and Graphics Library
vgacontroller.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 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 
47 
48 
49 
50 namespace fabgl {
51 
52 
53 #define RED_BIT 0
54 #define GREEN_BIT 2
55 #define BLUE_BIT 4
56 #define HSYNC_BIT 6
57 #define VSYNC_BIT 7
58 
59 #define SYNC_MASK ((1 << HSYNC_BIT) | (1 << VSYNC_BIT))
60 
61 
62 // pixel 0 = byte 2, pixel 1 = byte 3, pixel 2 = byte 0, pixel 3 = byte 1 :
63 // pixel : 0 1 2 3 4 5 6 7 8 9 10 11 ...etc...
64 // byte : 2 3 0 1 6 7 4 5 10 11 8 9 ...etc...
65 // dword : 0 1 2 ...etc...
66 // Thanks to https://github.com/paulscottrobson for the new macro. Before was: (row[((X) & 0xFFFC) + ((2 + (X)) & 3)])
67 #define PIXELINROW(row, X) (row[(X) ^ 2])
68 
69 // requires variables: m_viewPort
70 #define PIXEL(X, Y) PIXELINROW(m_viewPort[(Y)], X)
71 
72 
73 
79  Sync,
82 };
83 
84 
86 struct Timings {
87  char label[22];
88  int frequency;
89  int16_t HVisibleArea;
90  int16_t HFrontPorch;
91  int16_t HSyncPulse;
92  int16_t HBackPorch;
93  int16_t VVisibleArea;
94  int16_t VFrontPorch;
95  int16_t VSyncPulse;
96  int16_t VBackPorch;
97  char HSyncLogic;
98  char VSyncLogic;
99  uint8_t scanCount;
100  uint8_t multiScanBlack;
102 };
103 
104 
105 
106 /*
107  Notes:
108  - all positions can have negative and outofbound coordinates. Shapes are always clipped correctly.
109 */
110 enum PrimitiveCmd {
111  // Set current pen color
112  // params: color
113  SetPenColor,
114 
115  // Set current brush color
116  // params: color
117  SetBrushColor,
118 
119  // Paint a pixel at specified coordinates, using current pen color
120  // params: color
121  SetPixel,
122 
123  // Paint a pixel at specified coordinates using the specified color
124  // params: pixelDesc
125  SetPixelAt,
126 
127  // Move current position to the specified one
128  // params: point
129  MoveTo,
130 
131  // Draw a line from current position to the specified one, using current pen color. Update current position.
132  // params: point
133  LineTo,
134 
135  // Fill a rectangle using current brush color
136  // params: rect
137  FillRect,
138 
139  // Draw a rectangle using current pen color
140  // params: rect
141  DrawRect,
142 
143  // Fill an ellipse, current position is the center, using current brush color
144  // params: size
145  FillEllipse,
146 
147  // Draw an ellipse, current position is the center, using current pen color
148  // params: size
149  DrawEllipse,
150 
151  // Fill viewport with brush color
152  // params: none
153  Clear,
154 
155  // Scroll vertically without copying buffers
156  // params: ivalue (scroll amount, can be negative)
157  VScroll,
158 
159  // Scroll horizontally (time consuming operation!)
160  // params: ivalue (scroll amount, can be negative)
161  HScroll,
162 
163  // Draw a glyph (BW image)
164  // params: glyph
165  DrawGlyph,
166 
167  // Set paint options
168  // params: glyphOptions
169  SetGlyphOptions,
170 
171  // Set gluph options
172  // params: paintOptions
173  SetPaintOptions,
174 
175  // Invert a rectangle
176  // params: rect
177  InvertRect,
178 
179  // Copy (overlapping) rectangle to current position
180  // params: rect (source rectangle)
181  CopyRect,
182 
183  // Set scrolling region
184  // params: rect
185  SetScrollingRegion,
186 
187  // Swap foreground (pen) and background (brush) colors of all pixels inside the specified rectangles. Other colors remain untaltered.
188  // params: rect
189  SwapFGBG,
190 
191  // Render glyphs buffer
192  // params: glyphsBufferRenderInfo
193  RenderGlyphsBuffer,
194 
195  // Draw a bitmap
196  // params: bitmapDrawingInfo
197  DrawBitmap,
198 
199  // Refresh sprites
200  // no params
201  RefreshSprites,
202 
203  // Swap buffers (m_doubleBuffered must be True)
204  SwapBuffers,
205 
206  // Fill a path, using current brush color
207  // params: path
208  FillPath,
209 
210  // Draw a path, using current pen color
211  // params: path
212  DrawPath,
213 
214  // Set axis origin
215  // params: point
216  SetOrigin,
217 
218  // Set clipping rectangle
219  // params: rect
220  SetClippingRect,
221 };
222 
223 
224 
230 enum Color {
232  Red,
247 };
248 
249 
250 
257 struct RGB {
258  uint8_t R : 2;
259  uint8_t G : 2;
260  uint8_t B : 2;
262  RGB() : R(0), G(0), B(0) { }
263  RGB(Color color);
264  RGB(uint8_t red, uint8_t green, uint8_t blue) : R(red), G(green), B(blue) { }
265 };
266 
267 
268 inline bool operator==(RGB const& lhs, RGB const& rhs)
269 {
270  return lhs.R == rhs.R && lhs.G == rhs.G && lhs.B == rhs.B;
271 }
272 
273 
274 inline bool operator!=(RGB const& lhs, RGB const& rhs)
275 {
276  return lhs.R != rhs.R || lhs.G != rhs.G || lhs.B == rhs.B;
277 }
278 
279 
280 
286 struct Glyph {
287  int16_t X;
288  int16_t Y;
289  int16_t width;
290  int16_t height;
291  uint8_t const * data;
293  Glyph() : X(0), Y(0), width(0), height(0), data(nullptr) { }
294  Glyph(int X_, int Y_, int width_, int height_, uint8_t const * data_) : X(X_), Y(Y_), width(width_), height(height_), data(data_) { }
295 };
296 
297 
298 
303  struct {
304  uint16_t fillBackground : 1;
305  uint16_t bold : 1;
306  uint16_t reduceLuminosity : 1;
307  uint16_t italic : 1;
308  uint16_t invert : 1;
309  uint16_t blank : 1;
310  uint16_t underline : 1;
311  uint16_t doubleWidth : 2;
312  uint16_t userOpt1 : 1;
313  uint16_t userOpt2 : 1;
314  };
315  uint16_t value;
316 
318  GlyphOptions & FillBackground(bool value) { fillBackground = value; return *this; }
319 
321  GlyphOptions & Bold(bool value) { bold = value; return *this; }
322 
324  GlyphOptions & Italic(bool value) { italic = value; return *this; }
325 
327  GlyphOptions & Underline(bool value) { underline = value; return *this; }
328 
330  GlyphOptions & DoubleWidth(uint8_t value) { doubleWidth = value; return *this; }
331 
333  GlyphOptions & Invert(uint8_t value) { invert = value; return *this; }
334 };
335 
336 
337 
338 // GlyphsBuffer.map support functions
339 // 0 .. 7 : index
340 // 8 .. 11 : BG color (Color)
341 // 12 .. 15 : FG color (Color)
342 // 16 .. 31 : options (GlyphOptions)
343 // note: volatile pointer to avoid optimizer to get less than 32 bit from 32 bit access only memory
344 #define GLYPHMAP_INDEX_BIT 0
345 #define GLYPHMAP_BGCOLOR_BIT 8
346 #define GLYPHMAP_FGCOLOR_BIT 12
347 #define GLYPHMAP_OPTIONS_BIT 16
348 #define GLYPHMAP_ITEM_MAKE(index, bgColor, fgColor, options) (((uint32_t)(index) << GLYPHMAP_INDEX_BIT) | ((uint32_t)(bgColor) << GLYPHMAP_BGCOLOR_BIT) | ((uint32_t)(fgColor) << GLYPHMAP_FGCOLOR_BIT) | ((uint32_t)((options).value) << GLYPHMAP_OPTIONS_BIT))
349 inline uint8_t glyphMapItem_getIndex(uint32_t const volatile * mapItem) { return *mapItem >> GLYPHMAP_INDEX_BIT & 0xFF; }
350 inline Color glyphMapItem_getBGColor(uint32_t const volatile * mapItem) { return (Color)(*mapItem >> GLYPHMAP_BGCOLOR_BIT & 0x0F); }
351 inline Color glyphMapItem_getFGColor(uint32_t const volatile * mapItem) { return (Color)(*mapItem >> GLYPHMAP_FGCOLOR_BIT & 0x0F); }
352 inline GlyphOptions glyphMapItem_getOptions(uint32_t const volatile * mapItem) { return (GlyphOptions){.value = (uint16_t)(*mapItem >> GLYPHMAP_OPTIONS_BIT & 0xFFFF)}; }
353 inline void glyphMapItem_setOptions(uint32_t volatile * mapItem, GlyphOptions const & options) { *mapItem = (*mapItem & ~((uint32_t)0xFFFF << GLYPHMAP_OPTIONS_BIT)) | ((uint32_t)(options.value) << GLYPHMAP_OPTIONS_BIT); }
354 
355 struct GlyphsBuffer {
356  int16_t glyphsWidth;
357  int16_t glyphsHeight;
358  uint8_t const * glyphsData;
359  int16_t columns;
360  int16_t rows;
361  uint32_t * map; // look at glyphMapItem_... inlined functions
362 };
363 
364 
365 struct GlyphsBufferRenderInfo {
366  int16_t itemX; // starts from 0
367  int16_t itemY; // starts from 0
368  GlyphsBuffer const * glyphsBuffer;
369 
370  GlyphsBufferRenderInfo(int itemX_, int itemY_, GlyphsBuffer const * glyphsBuffer_) : itemX(itemX_), itemY(itemY_), glyphsBuffer(glyphsBuffer_) { }
371 };
372 
373 
385 struct Bitmap {
386  int16_t width;
387  int16_t height;
388  uint8_t const * data;
391  Bitmap() : width(0), height(0), data(nullptr), dataAllocated(false) { }
392  Bitmap(int width_, int height_, void const * data_, bool copy = false);
393  Bitmap(int width_, int height_, void const * data_, int bitsPerPixel, RGB foregroundColor, bool copy = false);
394  ~Bitmap();
395 };
396 
397 
398 struct BitmapDrawingInfo {
399  int16_t X;
400  int16_t Y;
401  Bitmap const * bitmap;
402 
403  BitmapDrawingInfo(int X_, int Y_, Bitmap const * bitmap_) : X(X_), Y(Y_), bitmap(bitmap_) { }
404 };
405 
406 
410 enum CursorName : uint8_t {
430 };
431 
432 
436 struct Cursor {
437  int16_t hotspotX;
438  int16_t hotspotY;
440 };
441 
442 
443 struct QuadTreeObject;
444 
445 
454 struct Sprite {
455  volatile int16_t x;
456  volatile int16_t y;
457  Bitmap const * * frames; // array of pointer to Bitmap
458  int16_t framesCount;
459  int16_t currentFrame;
460  int16_t savedX;
461  int16_t savedY;
462  int16_t savedBackgroundWidth;
463  int16_t savedBackgroundHeight;
464  uint8_t * savedBackground;
465  QuadTreeObject * collisionDetectorObject;
466  struct {
467  uint8_t visible: 1;
468  // A static sprite should be positioned before dynamic sprites.
469  // It is never re-rendered unless allowDraw is 1. Static sprites always sets allowDraw=0 after drawings.
470  uint8_t isStatic: 1;
471  // This is always '1' for dynamic sprites and always '0' for static sprites.
472  uint8_t allowDraw: 1;
473  };
474 
475  Sprite();
476  ~Sprite();
477  Bitmap const * getFrame() { return frames ? frames[currentFrame] : nullptr; }
478  int getFrameIndex() { return currentFrame; }
479  void nextFrame() { ++currentFrame; if (currentFrame >= framesCount) currentFrame = 0; }
480  Sprite * setFrame(int frame) { currentFrame = frame; return this; }
481  Sprite * addBitmap(Bitmap const * bitmap);
482  Sprite * addBitmap(Bitmap const * bitmap[], int count);
483  void clearBitmaps();
484  int getWidth() { return frames[currentFrame]->width; }
485  int getHeight() { return frames[currentFrame]->height; }
486  void allocRequiredBackgroundBuffer();
487  Sprite * move(int offsetX, int offsetY, bool wrapAround = true);
488  Sprite * moveTo(int x, int y);
489 };
490 
491 
492 struct Path {
493  Point const * points;
494  int pointsCount;
495 };
496 
497 
501 struct PaintOptions {
502  uint8_t swapFGBG : 1;
503  uint8_t NOT : 1;
505  PaintOptions() : swapFGBG(false), NOT(false) { }
506 };
507 
508 
509 struct PixelDesc {
510  Point pos;
511  RGB color;
512 };
513 
514 
515 struct Primitive {
516  PrimitiveCmd cmd;
517  union {
518  int16_t ivalue;
519  RGB color;
520  Point position;
521  Size size;
522  Glyph glyph;
523  Rect rect;
524  GlyphOptions glyphOptions;
525  PaintOptions paintOptions;
526  GlyphsBufferRenderInfo glyphsBufferRenderInfo;
527  BitmapDrawingInfo bitmapDrawingInfo;
528  Path path;
529  PixelDesc pixelDesc;
530  };
531 
532  Primitive() { }
533 };
534 
535 
536 struct PaintState {
537  RGB penColor;
538  RGB brushColor;
539  Point position; // value already traslated to "origin"
540  GlyphOptions glyphOptions;
541  PaintOptions paintOptions;
542  Rect scrollingRegion;
543  Point origin;
544  Rect clippingRect; // relative clipping rectangle
545  Rect absClippingRect; // actual absolute clipping rectangle (calculated when setting "origin" or "clippingRect")
546 };
547 
548 
571 
572 public:
573 
590  void begin(gpio_num_t redGPIO, gpio_num_t greenGPIO, gpio_num_t blueGPIO, gpio_num_t HSyncGPIO, gpio_num_t VSyncGPIO);
591 
611  void begin(gpio_num_t red1GPIO, gpio_num_t red0GPIO, gpio_num_t green1GPIO, gpio_num_t green0GPIO, gpio_num_t blue1GPIO, gpio_num_t blue0GPIO, gpio_num_t HSyncGPIO, gpio_num_t VSyncGPIO);
612 
623  void begin();
624 
632  uint8_t getBitsPerChannel() { return m_bitsPerChannel; }
633 
661  void setResolution(char const * modeline, int viewPortWidth = -1, int viewPortHeight = -1, bool doubleBuffered = false);
662 
663  void setResolution(Timings const& timings, int viewPortWidth = -1, int viewPortHeight = -1, bool doubleBuffered = false);
664 
665  Timings * getResolutionTimings() { return &m_timings; }
666 
672  int getScreenWidth() { return m_timings.HVisibleArea; }
673 
679  int getScreenHeight() { return m_timings.VVisibleArea; }
680 
686  int getViewPortCol() { return m_viewPortCol; }
687 
693  int getViewPortRow() { return m_viewPortRow; }
694 
700  int getViewPortWidth() { return m_viewPortWidth; }
701 
707  int getViewPortHeight() { return m_viewPortHeight; }
708 
709  void addPrimitive(Primitive const & primitive);
710 
711  void primitivesExecutionWait();
712 
724  void enableBackgroundPrimitiveExecution(bool value);
725 
733  void enableBackgroundPrimitiveTimeout(bool value) { m_backgroundPrimitiveTimeoutEnabled = value; }
734 
735  bool backgroundPrimitiveTimeoutEnabled() { return m_backgroundPrimitiveTimeoutEnabled; }
736 
746 
753 
760  void processPrimitives();
761 
775  void moveScreen(int offsetX, int offsetY);
776 
791  void shrinkScreen(int shrinkX, int shrinkY);
792 
816  template <typename T>
817  void setSprites(T * sprites, int count) {
818  setSprites(sprites, count, sizeof(T));
819  }
820 
826  void removeSprites() { setSprites(nullptr, 0, 0); }
827 
836  void refreshSprites();
837 
843  bool isDoubleBuffered() { return m_doubleBuffered; }
844 
850  void setMouseCursor(Cursor const * cursor);
851 
861  void setMouseCursor(CursorName cursorName);
862 
869  void setMouseCursorPos(int X, int Y);
870 
897  void readScreen(Rect const & rect, RGB * destBuf);
898 
925  void writeScreen(Rect const & rect, RGB * srcBuf);
926 
939  uint8_t createRawPixel(RGB rgb) { return preparePixel(rgb); }
940 
955  void setRawPixel(int x, int y, uint8_t rgb) { PIXEL(x, y) = rgb; }
956 
970  uint8_t * getScanline(int y) { return (uint8_t*) m_viewPort[y]; }
971 
972 private:
973 
974  void init(gpio_num_t VSyncGPIO);
975 
976  uint8_t packHVSync(bool HSync = false, bool VSync = false);
977  uint8_t preparePixel(RGB rgb, bool HSync = false, bool VSync = false);
978 
979  void freeBuffers();
980  void fillHorizBuffers(int offsetX);
981  void fillVertBuffers(int offsetY);
982  int fill(uint8_t volatile * buffer, int startPos, int length, uint8_t red, uint8_t green, uint8_t blue, bool hsync, bool vsync);
983  void allocateViewPort();
984  void freeViewPort();
985  int calcRequiredDMABuffersCount(int viewPortHeight);
986 
987  void execPrimitive(Primitive const & prim);
988 
989  void execSetPixel(Point const & position);
990  void execSetPixelAt(PixelDesc const & pixelDesc);
991  void execLineTo(Point const & position);
992  void execFillRect(Rect const & rect);
993  void execDrawRect(Rect const & rect);
994  void execFillEllipse(Size const & size);
995  void execDrawEllipse(Size const & size);
996  void execClear();
997  void execVScroll(int scroll);
998  void execHScroll(int scroll);
999  void execDrawGlyph(Glyph const & glyph, GlyphOptions glyphOptions, RGB penColor, RGB brushColor);
1000  void execDrawGlyph_full(Glyph const & glyph, GlyphOptions glyphOptions, RGB penColor, RGB brushColor);
1001  void execDrawGlyph_light(Glyph const & glyph, GlyphOptions glyphOptions, RGB penColor, RGB brushColor);
1002  void execInvertRect(Rect const & rect);
1003  void execCopyRect(Rect const & source);
1004  void execSwapFGBG(Rect const & rect);
1005  void execRenderGlyphsBuffer(GlyphsBufferRenderInfo const & glyphsBufferRenderInfo);
1006  void execDrawBitmap(BitmapDrawingInfo const & bitmapDrawingInfo);
1007  void execSwapBuffers();
1008  void execDrawPath(Path const & path);
1009  void execFillPath(Path const & path);
1010 
1011  void updateAbsoluteClippingRect();
1012 
1013  void drawBitmap(int destX, int destY, Bitmap const * bitmap, uint8_t * saveBackground, bool ignoreClippingRect);
1014 
1015  void fillRow(int y, int x1, int x2, uint8_t pattern);
1016  void swapRows(int yA, int yB, int x1, int x2);
1017 
1018  void drawLine(int X1, int Y1, int X2, int Y2, uint8_t pattern);
1019 
1020  void hideSprites();
1021  void showSprites();
1022 
1023  void setSprites(Sprite * sprites, int count, int spriteSize);
1024 
1025  static void VSyncInterrupt();
1026 
1027  static void setupGPIO(gpio_num_t gpio, int bit, gpio_mode_t mode);
1028 
1029  // DMA related methods
1030  bool setDMABuffersCount(int buffersCount);
1031  void setDMABufferBlank(int index, void volatile * address, int length);
1032  void setDMABufferView(int index, int row, int scan, volatile uint8_t * * viewPort, bool onVisibleDMA);
1033  void setDMABufferView(int index, int row, int scan);
1034  void volatile * getDMABuffer(int index, int * length);
1035 
1036  int m_bitsPerChannel; // 1 = 8 colors, 2 = 64 colors, set by begin()
1037  Timings m_timings;
1038  int16_t m_linesCount;
1039  volatile int16_t m_maxVSyncISRTime; // Maximum us VSync interrupt routine can run
1040 
1041  // These buffers contains a full line, with FrontPorch, Sync, BackPorch and blank visible area, in the
1042  // order specified by timings.HStartingBlock
1043  volatile uint8_t * m_HBlankLine_withVSync;
1044  volatile uint8_t * m_HBlankLine;
1045  int16_t m_HLineSize;
1046 
1047  bool m_doubleBuffered;
1048 
1049  volatile int16_t m_viewPortCol;
1050  volatile int16_t m_viewPortRow;
1051  volatile int16_t m_viewPortWidth;
1052  volatile int16_t m_viewPortHeight;
1053 
1054  // when double buffer is enabled the "drawing" view port is always m_viewPort, while the "visible" view port is always m_viewPortVisible
1055  // when double buffer is not enabled then m_viewPort = m_viewPortVisible
1056  volatile uint8_t * * m_viewPort;
1057  volatile uint8_t * * m_viewPortVisible;
1058 
1059  uint8_t * m_viewPortMemoryPool[FABGLIB_VIEWPORT_MEMORY_POOL_COUNT + 1]; // last allocated pool is nullptr
1060 
1061  volatile QueueHandle_t m_execQueue;
1062  PaintState m_paintState;
1063 
1064  // when double buffer is enabled the running DMA buffer is always m_DMABuffersRunning
1065  // when double buffer is not enabled then m_DMABuffers = m_DMABuffersRunning
1066  lldesc_t volatile * m_DMABuffersHead;
1067  lldesc_t volatile * m_DMABuffers;
1068  lldesc_t volatile * m_DMABuffersVisible;
1069 
1070  int m_DMABuffersCount;
1071 
1072  gpio_num_t m_VSyncGPIO;
1073  int m_VSyncInterruptSuspended; // 0 = enabled, >0 suspended
1074  bool m_backgroundPrimitiveExecutionEnabled; // when False primitives are execute immediately
1075  volatile bool m_backgroundPrimitiveTimeoutEnabled; // when False VSyncInterrupt() has not timeout
1076 
1077  void * m_sprites; // pointer to array of sprite structures
1078  int m_spriteSize; // size of sprite structure
1079  int m_spritesCount; // number of sprites in m_sprites array
1080 
1081  bool m_spritesHidden; // true between hideSprites() and showSprites()
1082 
1083  // mouse cursor (mouse pointer) support
1084  Sprite m_mouseCursor;
1085  int16_t m_mouseHotspotX;
1086  int16_t m_mouseHotspotY;
1087 
1088 };
1089 
1090 
1091 
1092 } // end of namespace
1093 
1094 
1095 extern fabgl::VGAControllerClass VGAController;
1096 
1097 
1098 
1099 
Definition: vgacontroller.h:422
int16_t height
Definition: vgacontroller.h:387
uint16_t blank
Definition: vgacontroller.h:309
Definition: vgacontroller.h:411
Definition: vgacontroller.h:412
Defines a cursor.
Definition: vgacontroller.h:436
Represents an RGB color.
Definition: vgacontroller.h:257
Definition: vgacontroller.h:240
void enableBackgroundPrimitiveTimeout(bool value)
Enables or disables execution time limitation inside vertical retracing interrupt.
Definition: vgacontroller.h:733
uint8_t R
Definition: vgacontroller.h:258
Represents a sprite.
Definition: vgacontroller.h:454
Definition: vgacontroller.h:231
Definition: vgacontroller.h:243
int getViewPortWidth()
Determines horizontal size of the viewport.
Definition: vgacontroller.h:700
Definition: vgacontroller.h:237
Definition: vgacontroller.h:246
int getViewPortHeight()
Determines vertical size of the viewport.
Definition: vgacontroller.h:707
uint16_t italic
Definition: vgacontroller.h:307
Color
This enum defines named colors.
Definition: vgacontroller.h:230
Definition: vgacontroller.h:236
int getViewPortRow()
Determines vertical position of the viewport.
Definition: vgacontroller.h:693
void setMouseCursorPos(int X, int Y)
Sets mouse cursor position.
Definition: vgacontroller.cpp:2242
void processPrimitives()
Draws immediately all primitives in the queue.
Definition: vgacontroller.cpp:788
GlyphOptions & Bold(bool value)
Helper method to set or reset bold.
Definition: vgacontroller.h:321
void shrinkScreen(int shrinkX, int shrinkY)
Reduces or expands screen size by the specified horizontal and vertical offset.
Definition: vgacontroller.cpp:581
uint8_t createRawPixel(RGB rgb)
Creates a raw pixel to use with VGAControllerClass.setRawPixel.
Definition: vgacontroller.h:939
GlyphOptions & FillBackground(bool value)
Helper method to set or reset fillBackground.
Definition: vgacontroller.h:318
Definition: vgacontroller.h:234
int16_t width
Definition: vgacontroller.h:386
Definition: vgacontroller.h:235
int16_t HSyncPulse
Definition: vgacontroller.h:91
Definition: vgacontroller.h:81
uint8_t NOT
Definition: vgacontroller.h:503
uint16_t invert
Definition: vgacontroller.h:308
uint8_t const * data
Definition: vgacontroller.h:291
uint8_t const * data
Definition: vgacontroller.h:388
uint8_t * getScanline(int y)
Gets a raw scanline pointer.
Definition: vgacontroller.h:970
GlyphOptions & Invert(uint8_t value)
Helper method to set or reset foreground and background swapping.
Definition: vgacontroller.h:333
uint16_t doubleWidth
Definition: vgacontroller.h:311
int frequency
Definition: vgacontroller.h:88
int getViewPortCol()
Determines horizontal position of the viewport.
Definition: vgacontroller.h:686
void setMouseCursor(Cursor const *cursor)
Sets mouse cursor and make it visible.
Definition: vgacontroller.cpp:2213
Definition: vgacontroller.h:424
void moveScreen(int offsetX, int offsetY)
Moves screen by specified horizontal and vertical offset.
Definition: vgacontroller.cpp:572
Definition: vgacontroller.h:78
Definition: vgacontroller.h:79
void begin()
This is the 64 colors (8 GPIOs) initializer using default pinout.
Definition: vgacontroller.cpp:156
void enableBackgroundPrimitiveExecution(bool value)
Enables or disables drawings inside vertical retracing time.
Definition: vgacontroller.cpp:732
ScreenBlock
Represents one of the four blocks of horizontal or vertical line.
Definition: vgacontroller.h:77
Represents a glyph position, size and binary data.
Definition: vgacontroller.h:286
Definition: vgacontroller.h:427
GlyphOptions & Underline(bool value)
Helper method to set or reset underlined.
Definition: vgacontroller.h:327
Represents the coordinate of a point.
Definition: fabutils.h:125
Represents an image with 64 colors image and transparency.
Definition: vgacontroller.h:385
Definition: vgacontroller.h:242
Definition: vgacontroller.h:238
This file contains some utility classes and functions.
int16_t VSyncPulse
Definition: vgacontroller.h:95
Definition: canvas.cpp:47
CursorName
This enum defines a set of predefined mouse cursors.
Definition: vgacontroller.h:410
Definition: vgacontroller.h:233
uint16_t bold
Definition: vgacontroller.h:305
char VSyncLogic
Definition: vgacontroller.h:98
int16_t hotspotX
Definition: vgacontroller.h:437
void setResolution(char const *modeline, int viewPortWidth=-1, int viewPortHeight=-1, bool doubleBuffered=false)
Sets current resolution using linux-like modeline.
Definition: vgacontroller.cpp:267
int16_t HBackPorch
Definition: vgacontroller.h:92
Represents the VGA controller.
Definition: vgacontroller.h:570
Specifies various glyph painting options.
Definition: vgacontroller.h:302
Represents a rectangle.
Definition: fabutils.h:158
uint8_t getBitsPerChannel()
Gets number of bits allocated for each channel.
Definition: vgacontroller.h:632
ScreenBlock HStartingBlock
Definition: vgacontroller.h:101
GlyphOptions & Italic(bool value)
Helper method to set or reset italic.
Definition: vgacontroller.h:324
Definition: vgacontroller.h:239
Definition: vgacontroller.h:413
void refreshSprites()
Forces the sprites to be updated.
Definition: vgacontroller.cpp:2034
char HSyncLogic
Definition: vgacontroller.h:97
void setSprites(T *sprites, int count)
Sets the list of active sprites.
Definition: vgacontroller.h:817
int16_t X
Definition: vgacontroller.h:287
Definition: vgacontroller.h:414
Definition: vgacontroller.h:416
int16_t HFrontPorch
Definition: vgacontroller.h:90
int16_t VVisibleArea
Definition: vgacontroller.h:93
Definition: vgacontroller.h:429
void removeSprites()
Empties the list of active sprites.
Definition: vgacontroller.h:826
int16_t width
Definition: vgacontroller.h:289
This file contains FabGL library configuration settings, like number of supported colors...
uint8_t scanCount
Definition: vgacontroller.h:99
int16_t VFrontPorch
Definition: vgacontroller.h:94
int getScreenHeight()
Determines the screen height in pixels.
Definition: vgacontroller.h:679
Definition: vgacontroller.h:80
Represents a bidimensional size.
Definition: fabutils.h:143
Definition: vgacontroller.h:425
int getScreenWidth()
Determines the screen width in pixels.
Definition: vgacontroller.h:672
void setRawPixel(int x, int y, uint8_t rgb)
Sets a raw pixel prepared using VGAControllerClass.createRawPixel.
Definition: vgacontroller.h:955
void readScreen(Rect const &rect, RGB *destBuf)
Reads pixels inside the specified rectangle.
Definition: vgacontroller.cpp:1918
Definition: vgacontroller.h:232
GlyphOptions & DoubleWidth(uint8_t value)
Helper method to set or reset doubleWidth.
Definition: vgacontroller.h:330
int16_t Y
Definition: vgacontroller.h:288
Definition: vgacontroller.h:428
Specifies the VGA timings. This is a modeline decoded.
Definition: vgacontroller.h:86
Definition: vgacontroller.h:244
uint16_t fillBackground
Definition: vgacontroller.h:304
uint8_t multiScanBlack
Definition: vgacontroller.h:100
uint8_t B
Definition: vgacontroller.h:260
void suspendBackgroundPrimitiveExecution()
Suspends drawings.
Definition: vgacontroller.cpp:750
uint16_t reduceLuminosity
Definition: vgacontroller.h:306
Definition: vgacontroller.h:245
uint16_t userOpt2
Definition: vgacontroller.h:313
Definition: vgacontroller.h:415
uint8_t G
Definition: vgacontroller.h:259
Definition: vgacontroller.h:423
Definition: vgacontroller.h:241
Definition: vgacontroller.h:417
Definition: vgacontroller.h:426
uint16_t userOpt1
Definition: vgacontroller.h:312
#define FABGLIB_VIEWPORT_MEMORY_POOL_COUNT
Definition: fabglconf.h:111
Definition: vgacontroller.h:420
Definition: vgacontroller.h:421
void writeScreen(Rect const &rect, RGB *srcBuf)
Writes pixels inside the specified rectangle.
Definition: vgacontroller.cpp:1930
uint16_t underline
Definition: vgacontroller.h:310
int16_t VBackPorch
Definition: vgacontroller.h:96
Specifies general paint options.
Definition: vgacontroller.h:501
char label[22]
Definition: vgacontroller.h:87
int16_t HVisibleArea
Definition: vgacontroller.h:89
uint8_t swapFGBG
Definition: vgacontroller.h:502
void resumeBackgroundPrimitiveExecution()
Resumes drawings after suspendBackgroundPrimitiveExecution().
Definition: vgacontroller.cpp:760
Bitmap bitmap
Definition: vgacontroller.h:439
Definition: vgacontroller.h:419
int16_t height
Definition: vgacontroller.h:290
bool dataAllocated
Definition: vgacontroller.h:389
bool isDoubleBuffered()
Determines whether VGAControllerClass is on double buffered mode.
Definition: vgacontroller.h:843
Definition: vgacontroller.h:418
int16_t hotspotY
Definition: vgacontroller.h:438