Skip to content

Commit a83b05a

Browse files
authored
Merge pull request #2166 from jedgarpark/smpte-test
added NTSC SMPTE composite video code
2 parents 301a35e + e04b8a4 commit a83b05a

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

SMPTE_Color_Bars_Composite/.qtpy_esp32.test.only

Whitespace-only changes.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// SPDX-FileCopyrightText: 2022 John Park for Adafruit
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
/*
5+
Adafruit NTSC SMPTE color bars (resolution is 256x224, colors are approximate at best)
6+
uses composite video generator library on ESP32 by Roger Cheng
7+
Connect GPIO25 (A0 on QT Py ESP32 Pico) to signal line, usually the center of composite video plug.
8+
Please disable PSRAM option before uploading to the board, otherwise there may be vertical jitter.
9+
*/
10+
11+
#include <ESP_8_BIT_GFX.h>
12+
13+
14+
// Create an instance of the graphics library
15+
ESP_8_BIT_GFX videoOut(true /* = NTSC */, 8 /* = RGB332 color */);
16+
17+
uint8_t WHITE = 0xFF ;
18+
uint8_t DIM_WHITE = 0xB6 ;
19+
uint8_t YELLOW = 0xF4 ;
20+
uint8_t TEAL = 0x1C ;
21+
uint8_t GREEN = 0x70 ;
22+
uint8_t MAGENTA = 0x83 ;
23+
uint8_t RED = 0x82 ;
24+
uint8_t BLUE = 0x0B ;
25+
uint8_t DARK_BLUE = 0x06 ;
26+
uint8_t PURPLE = 0x23 ;
27+
uint8_t BLACK = 0x00 ;
28+
uint8_t GRAY = 0x24 ;
29+
uint8_t LIGHT_GRAY = 0x29 ;
30+
31+
uint8_t height_tall = 149 ;
32+
uint8_t height_squat = 19 ;
33+
uint8_t height_med = 56 ;
34+
35+
uint8_t width_med = 36 ;
36+
uint8_t width_large = 46;
37+
uint8_t width_skinny = 12 ;
38+
39+
uint8_t row2_y = height_tall ;
40+
uint8_t row3_y = height_tall + height_squat ;
41+
42+
43+
void setup() {
44+
// Initial setup of graphics library
45+
videoOut.begin();
46+
}
47+
48+
void loop() {
49+
// Wait for the next frame to minimize chance of visible tearing
50+
videoOut.waitForFrame();
51+
52+
// Clear screen
53+
videoOut.fillScreen(0);
54+
55+
// Draw rectangles
56+
//row 1
57+
videoOut.fillRect(0, 0, width_med, height_tall, DIM_WHITE);
58+
videoOut.fillRect(width_med, 0, width_med, height_tall, YELLOW);
59+
videoOut.fillRect(width_med*2, 0, width_med, height_tall, TEAL);
60+
videoOut.fillRect(width_med*3, 0, width_med, height_tall, GREEN);
61+
videoOut.fillRect(width_med*4, 0, width_med, height_tall, MAGENTA);
62+
videoOut.fillRect(width_med*5, 0, width_med, height_tall, RED);
63+
videoOut.fillRect(width_med*6, 0, width_med, height_tall, BLUE);
64+
//row 2
65+
videoOut.fillRect(0, row2_y, width_med, height_squat, BLUE);
66+
videoOut.fillRect(width_med, row2_y, width_med, height_squat, GRAY);
67+
videoOut.fillRect(width_med*2, row2_y, width_med, height_squat, MAGENTA);
68+
videoOut.fillRect(width_med*3, row2_y, width_med, height_squat, GRAY);
69+
videoOut.fillRect(width_med*4, row2_y, width_med, height_squat, TEAL);
70+
videoOut.fillRect(width_med*5, row2_y, width_med, height_squat, GRAY);
71+
videoOut.fillRect(width_med*6, row2_y , width_med, height_squat, DIM_WHITE);
72+
//row 3
73+
videoOut.fillRect(0, row3_y, width_large, height_med, DARK_BLUE);
74+
videoOut.fillRect(width_large, row3_y, width_large, height_med, WHITE);
75+
videoOut.fillRect(width_large*2, row3_y, width_large, height_med, PURPLE);
76+
videoOut.fillRect(width_large*3, row3_y, width_large, height_med, GRAY);
77+
videoOut.fillRect(width_large*4, row3_y, width_skinny, height_med, BLACK);
78+
videoOut.fillRect(width_large*4+width_skinny, row3_y, width_skinny, height_med, GRAY);
79+
videoOut.fillRect(((width_large*4)+(width_skinny*2)), row3_y , width_skinny, height_med, LIGHT_GRAY);
80+
videoOut.fillRect(width_med*6, row3_y , width_med, height_med, GRAY);
81+
82+
83+
// Draw text
84+
videoOut.setCursor(144, 180);
85+
videoOut.setTextColor(0xFF);
86+
videoOut.print("Adafruit NTSC");
87+
videoOut.setCursor(144, 190);
88+
videoOut.setTextColor(0xFF);
89+
videoOut.print("composite video");
90+
91+
}

0 commit comments

Comments
 (0)