Skip to content

Commit 63dde9f

Browse files
author
bitluni
committed
changes from development
1 parent 8afdcc8 commit 63dde9f

File tree

121 files changed

+10976
-1793
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+10976
-1793
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Patreon https://patreon.com/bitluni
88
Paypal https://paypal.me/bitluni
99

1010
# Acknowledgements
11+
Great thanks to Martin Laclaustra for Version 0.4.0 that was refactored by in the development branch
12+
unifing even more features for this library.
1113
Thanks to Ivan Grokhotkov & Jeroen Domburg (aka Sprite_tm) for their great work on I2S revealing some nitty-gritty details and quirks of the ESP32.
1214
Special thanks to Fabrizio Di Vittorio for the inpiration to look deeper into 8Bit modes enabling higher resolutions. He developed the FabGL library simultaneously.
1315

examples/1BitMode/1BitMode.ino

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//This example shows a simple "Hello world!" on a VGA screen.
2+
//You need to connect a VGA screen cable to the pins specified below.
3+
//cc by-sa 4.0 license
4+
//bitluni
5+
6+
#include <ESP32Lib.h>
7+
#include <Ressources/Font6x8.h>
8+
9+
//pin configuration
10+
const int redPin = 14;
11+
const int greenPin = 19;
12+
const int bluePin = 27;
13+
const int hsyncPin = 32;
14+
const int vsyncPin = 33;
15+
16+
//VGA Device
17+
VGA1BitI videodisplay;
18+
19+
const uint8_t frontColors[] = {0x2,0x0,0x1,0x4,0x1,0x7,0x3};
20+
const uint8_t backColors[] = {0x0,0x7,0x0,0x6,0x7,0x0,0x4};
21+
22+
void setup()
23+
{
24+
//initializing vga at the specified pins
25+
videodisplay.init(VGAMode::MODE320x240, redPin, greenPin, bluePin, hsyncPin, vsyncPin);
26+
//selecting the font
27+
videodisplay.setFont(Font6x8);
28+
videodisplay.setCursor(120,115);
29+
//displaying the text
30+
//default coloring
31+
videodisplay.println("Hello World!");
32+
delay(10000);
33+
//custom coloring
34+
for(int i = 0; i < 10; i++)
35+
{
36+
videodisplay.setFrontGlobalColor(0,0,255);
37+
videodisplay.setBackGlobalColor(0,0,0);
38+
delay(500);
39+
videodisplay.setFrontGlobalColor(255,255,0);
40+
videodisplay.setBackGlobalColor(0,0,255);
41+
delay(500);
42+
}
43+
delay(2000);
44+
videodisplay.clear();
45+
}
46+
47+
void loop()
48+
{
49+
for(int i = 0; i < 10; i++)
50+
{
51+
videodisplay.setCursor(random(1,300),random(1,220));
52+
videodisplay.println("Hello World!");
53+
delay(250);
54+
}
55+
delay(1500);
56+
videodisplay.clear();
57+
static int currentpalette = 0;
58+
videodisplay.frontGlobalColor = frontColors[currentpalette];
59+
videodisplay.backGlobalColor = backColors[currentpalette];
60+
currentpalette = (currentpalette + 1)%sizeof(frontColors);
61+
}

examples/6BitMode/6BitMode.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <Ressources/Font6x8.h>
88

99
//VGA Device
10-
VGA6Bit vga;
10+
VGA6Bit videodisplay;
1111
//Pin presets are avaialable for: VGAv01, VGABlackEdition, VGAWhiteEdition, PicoVGA
1212
const PinConfig &pinConfig = VGA6Bit::PicoVGA;
1313

@@ -55,8 +55,8 @@ void renderTask(void *param)
5555
for(int x = data[1]; x < data[2]; x++)
5656
{
5757
int c = colors[julia(x, y, -0.74543f, v)];
58-
vga.dotFast(x, y, c);
59-
vga.dotFast(319 - x, 199 - y, c);
58+
videodisplay.dotFast(x, y, c);
59+
videodisplay.dotFast(319 - x, 199 - y, c);
6060
}
6161
data[0] = 0;
6262
}
@@ -66,7 +66,7 @@ void renderTask(void *param)
6666
void setup()
6767
{
6868
//initializing i2s vga (with only one framebuffer)
69-
vga.init(vga.MODE320x200, pinConfig);
69+
videodisplay.init(VGAMode::MODE320x200, pinConfig);
7070
TaskHandle_t xHandle = NULL;
7171
xTaskCreatePinnedToCore(renderTask, "Render1", 2000, taskData[0], ( 2 | portPRIVILEGE_BIT ), &xHandle, 0);
7272
xTaskCreatePinnedToCore(renderTask, "Render2", 2000, taskData[1], ( 2 | portPRIVILEGE_BIT ), &xHandle, 1);

examples/8BitDACMode/8BitDACMode.ino

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//You need to connect a VGA screen cable to the pins specified below.
2+
//cc by-sa 4.0 license
3+
//Martin-Laclaustra
4+
/*
5+
CONNECTION
6+
7+
A) voltageDivider = false; B) voltageDivider = true (last init parameter)
8+
9+
55 shades 255 shades
10+
11+
ESP32 VGA ESP32 VGA
12+
-----+ -----+ ____ 100 ohm
13+
G|- +---- R G|---|____|+ +---- R
14+
pin25|----+---- G pin25|---|____|+---------+---- G
15+
pin26|- +---- B pin26|- 220 ohm +---- B
16+
pin X|--------- HSYNC pin X|------------------------ HSYNC
17+
pin Y|--------- VSYNC pin Y|------------------------ VSYNC
18+
-----+ -----+
19+
20+
Connect pin 25 or 26
21+
Connect the 3 channels in parallel or whatever combination of them
22+
depending on the monochrome color of choice
23+
*/
24+
25+
#include <ESP32Lib.h>
26+
#include <Ressources/Font6x8.h>
27+
28+
//pin configuration
29+
const int outputPin = 25;
30+
const int hsyncPin = 16;
31+
const int vsyncPin = 4;
32+
33+
VGA8BitDAC videodisplay;
34+
35+
void setup()
36+
{
37+
//initializing vga at the specified pins
38+
//output pin and boolean for voltage divider can be omitted
39+
videodisplay.init(VGAMode::MODE320x240, hsyncPin, vsyncPin, outputPin, false);
40+
//selecting the font
41+
videodisplay.setFont(Font6x8);
42+
//displaying the test pattern
43+
videodisplay.rect(30, 88, 255+5, 40+4, 127);
44+
for(int x = 0; x < 256; x++)
45+
{
46+
videodisplay.fillRect(x + 32, 90, 1, 40, x);
47+
if(x % 16 == 0)
48+
{
49+
videodisplay.fillRect(x + 32, 85, 1, 4, 255);
50+
videodisplay.setCursor(x + 32 - 3, 78);
51+
videodisplay.print(x,HEX);
52+
}
53+
}
54+
}
55+
56+
void loop()
57+
{
58+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
//You need to connect a composite TV input cable to the pins specified below.
2+
//cc by-sa 4.0 license
3+
//Martin-Laclaustra
4+
/*
5+
CONNECTION
6+
7+
A) voltageDivider = false; B) voltageDivider = true
8+
9+
55 shades 179 shades
10+
11+
ESP32 TV ESP32 TV
12+
-----+ -----+ ____ 100 ohm
13+
G|- G|---|____|+
14+
pin25|--------- Comp pin25|---|____|+--------- Comp
15+
pin26|- pin26|- 150 ohm
16+
| |
17+
| |
18+
-----+ -----+
19+
20+
Connect pin 25 or 26
21+
22+
C) R-2R resistor ladder; D) unequal rungs ladder
23+
24+
55 shades up to 254 shades?
25+
26+
ESP32 TV ESP32 TV
27+
-----+ -----+ ____
28+
G|-+_____ G|---|____|
29+
pinA0|-| R2R |- Comp pinA0|---|____|+--------- Comp
30+
pinA1|-| | pinA1|---|____|
31+
pinA2|-| | ...|
32+
...|-|_____| |
33+
-----+ -----+
34+
35+
Connect pins of your choice (A0...A8=any pins).
36+
Custom ladders can be used by tweaking colorMinValue and colorMaxValue
37+
*/
38+
39+
#include <ESP32Lib.h>
40+
#include <Ressources/CodePage437_8x8.h>
41+
42+
//pin configuration for DAC
43+
const int outputPin = 25;
44+
45+
CompositeColorDAC videodisplay;
46+
//CompositeColorLadder videodisplay;
47+
48+
void setup()
49+
{
50+
//initializing composite at the specified pins
51+
//output pin and boolean for voltage divider can be omitted
52+
//see Composite/CompMode.h for other modes
53+
videodisplay.init(CompMode::MODENTSCColor240P, 25, false);
54+
//videodisplay.init(CompMode::MODEPALColor288P, 25, false);
55+
//use these for the ladder hardware configuration
56+
//videodisplay.init(CompMode::MODENTSCColor240P, videodisplay.XPlayer);
57+
//This PAL mode did not work with the ladder
58+
//videodisplay.init(CompMode::MODEPALColor288P, videodisplay.XPlayer);
59+
//But this PAL mode works
60+
//videodisplay.init(ModeComposite(10, 30, 48, 312, 1, 6, 5, 5, 15, 288, 0, 0, 0, 0, 1, 6244533,5,16,4433619,true), videodisplay.XPlayer);
61+
//NOTE: PAL color only works for CRT TVs, not LDC TVs
62+
63+
64+
videodisplay.fillCircle(25 + 55, 50, 1 + 50 / 4, videodisplay.RGB(96, 0, 0));
65+
videodisplay.fillCircle(25 + 55+30, 50, 1 + 50 / 4, videodisplay.RGB(0, 96, 0));
66+
videodisplay.fillCircle(25 + 55+60, 50, 1 + 50 / 4, videodisplay.RGB(0, 0, 96));
67+
68+
videodisplay.fillCircle(100 + 25 + 55, 50, 1 + 50 / 4, videodisplay.RGB(255, 0, 0));
69+
videodisplay.fillCircle(100 + 25 + 55+30, 50, 1 + 50 / 4, videodisplay.RGB(0, 255, 0));
70+
videodisplay.fillCircle(100 + 25 + 55+60, 50, 1 + 50 / 4, videodisplay.RGB(0, 0, 255));
71+
72+
videodisplay.fillCircle(200 + 25 + 55, 50, 1 + 50 / 4, videodisplay.RGB(96, 96, 0));
73+
videodisplay.fillCircle(200 + 25 + 55+30, 50, 1 + 50 / 4, videodisplay.RGB(0, 96, 96));
74+
videodisplay.fillCircle(200 + 25 + 55+60, 50, 1 + 50 / 4, videodisplay.RGB(96, 0, 96));
75+
76+
videodisplay.fillCircle(300 + 25 + 55, 50, 1 + 50 / 4, videodisplay.RGB(255, 255, 0));
77+
videodisplay.fillCircle(300 + 25 + 55+30, 50, 1 + 50 / 4, videodisplay.RGB(0, 255, 255));
78+
videodisplay.fillCircle(300 + 25 + 55+60, 50, 1 + 50 / 4, videodisplay.RGB(255, 0, 255));
79+
80+
81+
82+
//selecting the font
83+
videodisplay.setFont(CodePage437_8x8);
84+
//displaying the test pattern
85+
videodisplay.fillRect(8+30-4, 88-2, (2*255)+5+8, 40+4+4, videodisplay.RGB(127,127,127));
86+
videodisplay.fillRect(8+30, 88, (2*255)+5, 40+4, videodisplay.RGB(0,0,0));
87+
videodisplay.setTextColor(videodisplay.RGB(192,192,192));
88+
for(int x = 0; x < 256*2; x+=2)
89+
{
90+
videodisplay.fillRect(8+x + 32, 90, 2, 40, videodisplay.RGB(x/2,x/2,x/2));
91+
if(x % 32 == 0)
92+
{
93+
videodisplay.fillRect(8+x + 32, 85, 4, 4, videodisplay.RGB(255,255,255));
94+
videodisplay.setCursor(8+x + 32 - 4, 78 - 4);
95+
videodisplay.print(x/2,HEX);
96+
}
97+
}
98+
}
99+
100+
void loop()
101+
{
102+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//You need to connect a composite TV input cable to the pins specified below.
2+
//cc by-sa 4.0 license
3+
//Martin-Laclaustra
4+
/*
5+
CONNECTION
6+
7+
A) voltageDivider = false; B) voltageDivider = true
8+
9+
55 shades 179 shades
10+
11+
ESP32 TV ESP32 TV
12+
-----+ -----+ ____ 100 ohm
13+
G|- G|---|____|+
14+
pin25|--------- Comp pin25|---|____|+--------- Comp
15+
pin26|- pin26|- 220 ohm
16+
| |
17+
| |
18+
-----+ -----+
19+
20+
Connect pin 25 or 26
21+
22+
C) R–2R resistor ladder; D) unequal rungs ladder
23+
24+
55 shades up to 254 shades?
25+
26+
ESP32 TV ESP32 TV
27+
-----+ -----+ ____
28+
G|-+_____ G|---|____|
29+
pinA0|-| R2R |- Comp pinA0|---|____|+--------- Comp
30+
pinA1|-| | pinA1|---|____|
31+
pinA2|-| | ...|
32+
...|-|_____| |
33+
-----+ -----+
34+
35+
Connect pins of your choice (A0...A8=any pins).
36+
Custom ladders can be used by tweaking colorMinValue and colorMaxValue
37+
*/
38+
39+
#include <ESP32Lib.h>
40+
#include <Ressources/Font6x8.h>
41+
42+
//pin configuration for DAC
43+
const int outputPin = 25;
44+
45+
CompositeGrayDAC videodisplay;
46+
//CompositeGrayLadder videodisplay;
47+
48+
void setup()
49+
{
50+
//initializing composite at the specified pins
51+
//output pin and boolean for voltage divider can be omitted
52+
//see Composite/CompMode.h for other modes
53+
videodisplay.init(CompMode::MODEPAL288P, 25, false);
54+
//videodisplay.init(CompMode::MODEPAL288P, videodisplay.XPlayer);
55+
56+
//selecting the font
57+
videodisplay.setFont(Font6x8);
58+
//displaying the test pattern
59+
videodisplay.rect(30, 88, 255+5, 40+4, 127);
60+
for(int x = 0; x < 256; x++)
61+
{
62+
videodisplay.fillRect(x + 32, 90, 1, 40, x);
63+
if(x % 16 == 0)
64+
{
65+
videodisplay.fillRect(x + 32, 85, 1, 4, 255);
66+
videodisplay.setCursor(x + 32 - 3, 78);
67+
videodisplay.print(x,HEX);
68+
}
69+
}
70+
}
71+
72+
void loop()
73+
{
74+
}

examples/GFXWrapper/GFXWrapper.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
#include <Fonts/FreeSerif9pt7b.h>
1010

1111
//VGA Device
12-
VGA6Bit vga;
13-
GfxWrapper<VGA6Bit> gfx(vga, 640, 400);
12+
VGA6Bit videodisplay;
13+
GfxWrapper<VGA6Bit> gfx(videodisplay, 640, 400);
1414

1515
//initial setup
1616
void setup()
1717
{
1818
//initializing i2s vga (with only one framebuffer)
1919
//Pin presets are avaialable for: VGAv01, VGABlackEdition, VGAWhiteEdition, PicoVGA
2020
//But you can also use custom pins. Check the other examples
21-
vga.init(vga.MODE640x400, vga.VGABlackEdition);
21+
videodisplay.init(VGAMode::MODE640x400, videodisplay.VGABlackEdition);
2222
//using adafruit gfx
2323
gfx.setFont(&FreeMonoBoldOblique24pt7b);
2424
gfx.setCursor(100, 100);

examples/Raytracer/Raytracer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ class Sphere : public Raytracable
3434
float r2;
3535
Vector p;
3636
Sphere(Vector pos, float radius)
37-
:p(pos),
37+
:
3838
r(radius),
39-
r2(radius * radius)
39+
r2(radius * radius),
40+
p(pos)
4041
{
4142
}
4243

0 commit comments

Comments
 (0)