FabGL
ESP32 Display Controller and Graphics Library
cvbsbasecontroller.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-2022 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.
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
41#include "freertos/FreeRTOS.h"
42#include "freertos/queue.h"
43
44#include "fabglconf.h"
45#include "fabutils.h"
46#include "devdrivers/cvbsgenerator.h"
47#include "displaycontroller.h"
48
49
50
51namespace fabgl {
52
53
54class CVBSBaseController : public GenericBitmappedDisplayController {
55
56public:
57
58 CVBSBaseController();
59
60 // unwanted methods
61 CVBSBaseController(CVBSBaseController const&) = delete;
62 void operator=(CVBSBaseController const&) = delete;
63
64 void begin(gpio_num_t videoGPIO);
65
66 void begin();
67
68 virtual void end();
69
70 // abstract method of BitmappedDisplayController
71 virtual void suspendBackgroundPrimitiveExecution();
72
73 // abstract method of BitmappedDisplayController
74 virtual void resumeBackgroundPrimitiveExecution();
75
76 void setResolution(char const * modeline, int viewPortWidth = -1, int viewPortHeight = -1, bool doubleBuffered = false);
77
78 void setHorizontalRate(int value) { m_horizontalRate = value; }
79 int horizontalRate() { return m_horizontalRate; }
80
81 virtual void setResolution(CVBSParams const * params, int viewPortWidth = -1, int viewPortHeight = -1, bool doubleBuffered = false);
82
83 // abstract method of BitmappedDisplayController
84 int getViewPortWidth() { return m_viewPortWidth; }
85
86 // abstract method of BitmappedDisplayController
87 int getViewPortHeight() { return m_viewPortHeight; }
88
89 uint8_t * getScanline(int y) { return (uint8_t*) m_viewPort[y]; }
90
91 CVBSParams const * params() { return m_CVBSGenerator.params(); }
92
93
94protected:
95
96 void setDrawScanlineCallback(CVBSDrawScanlineCallback drawScanlineCallback) { m_CVBSGenerator.setDrawScanlineCallback(drawScanlineCallback, this); }
97
98 virtual void freeViewPort();
99
100 virtual void init();
101
102 void allocateViewPort(uint32_t allocCaps, int rowlen);
103 virtual void allocateViewPort() = 0;
104 virtual void checkViewPortSize() { };
105
106 // abstract method of BitmappedDisplayController
107 virtual void swapBuffers();
108
109 void run();
110
111
112 // when double buffer is enabled the "drawing" view port is always m_viewPort, while the "visible" view port is always m_viewPortVisible
113 // when double buffer is not enabled then m_viewPort = m_viewPortVisible
114 volatile uint8_t * * m_viewPort;
115 volatile uint8_t * * m_viewPortVisible;
116
117 volatile int m_primitiveProcessingSuspended; // 0 = enabled, >0 suspended
118
119 volatile int16_t m_viewPortWidth;
120 volatile int16_t m_viewPortHeight;
121
122
123private:
124
125 CVBSGenerator m_CVBSGenerator;
126
127 int m_horizontalRate; // 1...
128
129 uint8_t * m_viewPortMemoryPool[FABGLIB_VIEWPORT_MEMORY_POOL_COUNT + 1]; // last allocated pool is nullptr
130};
131
132
133
134
135
136
137
138
139} // end of namespace
This file contains fabgl::BitmappedDisplayController definition.
#define FABGLIB_VIEWPORT_MEMORY_POOL_COUNT
Definition: fabglconf.h:126
This file contains FabGL library configuration settings, like number of supported colors,...
This file contains some utility classes and functions.