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 uint8_t * getScanline(int y) { return (uint8_t*) m_viewPort[y]; }
84
85 CVBSParams const * params() { return m_CVBSGenerator.params(); }
86
87
88protected:
89
90 void setDrawScanlineCallback(CVBSDrawScanlineCallback drawScanlineCallback) { m_CVBSGenerator.setDrawScanlineCallback(drawScanlineCallback, this); }
91
92 virtual void freeViewPort();
93
94 virtual void init();
95
96 void allocateViewPort(uint32_t allocCaps, int rowlen);
97 virtual void allocateViewPort() = 0;
98 virtual void checkViewPortSize() { };
99
100 // abstract method of BitmappedDisplayController
101 virtual void swapBuffers();
102
103 void run();
104
105
106 // when double buffer is enabled the "drawing" view port is always m_viewPort, while the "visible" view port is always m_viewPortVisible
107 // when double buffer is not enabled then m_viewPort = m_viewPortVisible
108 volatile uint8_t * * m_viewPort;
109 volatile uint8_t * * m_viewPortVisible;
110
111 volatile int m_primitiveProcessingSuspended; // 0 = enabled, >0 suspended
112
113
114private:
115
116 CVBSGenerator m_CVBSGenerator;
117
118 int m_horizontalRate; // 1...
119
120 uint8_t * * m_viewPortMemoryPool; // array ends with nullptr
121};
122
123
124
125
126
127
128
129
130} // end of namespace
This file contains fabgl::BitmappedDisplayController definition.
This file contains FabGL library configuration settings, like number of supported colors,...
This file contains some utility classes and functions.