SSD1306 OLED display driver  1.7.20
This library is developed to control SSD1306/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
CompositeOutput.h
1 /*
2  * Credits to https://github.com/bitluni/ESP32CompositeVideo
3  */
4 
5 #pragma once
6 
7 #include "ssd1306_hal/io.h"
8 
9 #if defined(CONFIG_VGA_AVAILABLE) && defined(CONFIG_VGA_ENABLE) && defined(__XTENSA__)
10 
11 #include <stdint.h>
12 #include "driver/i2s.h"
13 
14 typedef struct
15 {
16  float lineMicros;
17  float syncMicros;
18  float blankEndMicros;
19  float backMicros;
20  float shortVSyncMicros;
21  float overscanLeftMicros;
22  float overscanRightMicros;
23  float syncVolts;
24  float blankVolts;
25  float blackVolts;
26  float whiteVolts;
27  short lines;
28  short linesFirstTop;
29  short linesOverscanTop;
30  short linesOverscanBottom;
31  float imageAspect;
32 } TechProperties;
33 
34 class CompositeOutput
35 {
36 public:
37 
38  enum Mode
39  {
40  PAL,
41  NTSC
42  };
43 
44  CompositeOutput(Mode mode, double Vcc = 3.3);
45 
46  void init(int xres, int yres, int bpp);
47 
48  void fillValues(uint8_t value, int count);
49 
50  void sendFrameHalfResolution(const uint8_t *frame);
51 
52 private:
53  const TechProperties &properties;
54 
55  int m_samples_per_line = 0;
56  int samplesSync = 0;
57  int samplesBlank = 0;
58  int samplesBack = 0;
59  int samplesActive = 0;
60  int samplesBlackLeft = 0;
61  int samplesBlackRight = 0;
62 
63  int samplesVSyncShort = 0;
64  int samplesVSyncLong = 0;
65 
66  uint8_t levelSync = 0;
67  uint8_t levelBlank = 0;
68  uint8_t levelBlack = 0;
69  uint8_t levelWhite = 0;
70  uint8_t grayValues = 0;
71 
72  int targetXres = 0;
73  int targetYres = 0;
74  int targetYresEven = 0;
75  int targetYresOdd = 0;
76 
77  int linesEven = 0;
78  int linesOdd = 0;
79  int linesEvenActive = 0;
80  int linesOddActive = 0;
81  int linesEvenVisible = 0;
82  int linesOddVisible = 0;
83  int linesEvenBlankTop = 0;
84  int linesEvenBlankBottom = 0;
85  int linesOddBlankTop = 0;
86  int linesOddBlankBottom = 0;
87 
88  int m_buffer_width = 0;
89  int m_buffer_height = 0;
90  int m_bpp = 0;
91 
92 // float pixelAspect;
93 
94  uint16_t *line = nullptr;
95  uint16_t *m_end = nullptr;
96  uint16_t *m_ptr = nullptr;
97 
98  void init_hardware();
99  void check_buffer();
100  void generate_vsync();
101  void generate_long_sync();
102  void generate_short_sync();
103  void generate_long_short_sync();
104  void generate_short_long_sync();
105  void generate_short_blank_sync();
106  void generate_blank_short_sync();
107  void generate_blank_line();
108  const uint8_t * generate_line_from_buffer(const uint8_t * buffer);
109 };
110 
111 #endif
112