Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added color calculation functions and a new 14bit example
- Loading branch information
Showing
10 changed files
with
265 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"board": "esp8266:esp8266:huzzah", | ||
"configuration": "xtal=80,vt=flash,exception=disabled,eesz=4M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200", | ||
"port": "COM8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Win32", | ||
"includePath": [ | ||
"C:\\Users\\luni\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**", | ||
"C:\\Users\\luni\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta3\\**" | ||
], | ||
"forcedInclude": [], | ||
"intelliSenseMode": "msvc-x64" | ||
} | ||
], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <ESP32Lib.h> | ||
#include <math.h> | ||
|
||
//pin configuration | ||
const int redPins[] = {2, 4, 12, 13, 14}; | ||
const int greenPins[] = {15, 16, 17, 18, 19}; | ||
const int bluePins[] = {21, 22, 23, 27}; | ||
const int hsyncPin = 0; | ||
const int vsyncPin = 5; | ||
|
||
//VGA Device | ||
VGA14Bit vga; | ||
|
||
void setup() | ||
{ | ||
//initializing i2s vga and frame buffers | ||
vga.init(vga.MODE200x150, redPins, greenPins, bluePins, hsyncPin, vsyncPin); | ||
} | ||
|
||
int heat(VGA14Bit::Color c) | ||
{ | ||
if (vga.B(c)) | ||
return vga.B(c) + 512; | ||
if (vga.G(c)) | ||
return vga.G(c) + 256; | ||
return vga.R(c); | ||
} | ||
|
||
VGA14Bit::Color color(int heat) | ||
{ | ||
if (heat >= 512) | ||
return vga.RGB(255, 255, heat - 512); | ||
if (heat >= 256) | ||
return vga.RGB(255, heat - 256, 0); | ||
return vga.RGB(heat, 0, 0); | ||
} | ||
|
||
void loop() | ||
{ | ||
float p = millis() * 0.001f; | ||
vga.fillCircle(vga.xres / 2 + sin(p) * vga.xres / 3, vga.yres / 2 + cos(p * 1.34f) * vga.yres / 3, (rand() & 1) + 3, vga.RGB(255, 255, 255)); | ||
for (int y = 0; y < vga.yres - 1; y++) | ||
for (int x = 1; x < vga.xres - 1; x++) | ||
{ | ||
int h = (heat(vga.get(x, y)) + (heat(vga.get(x - 1, y + 1)) + heat(vga.get(x + 1, y + 1))) / 2 + heat(vga.get(x, y + 1))) / 3; | ||
vga.dotFast(x, y, color(h)); | ||
} | ||
for (int x = 0; x < vga.xres; x++) | ||
vga.dotFast(x, vga.yres - 1, (rand() & 3 == 3) ? color(767) : 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,92 @@ | ||
R"( | ||
<html> | ||
|
||
<head> | ||
<title>bitluni's VGA text terminal</title> | ||
<script> | ||
function sendText() | ||
{ | ||
var e = document.getElementById("text"); | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open('POST', '/text'); | ||
xhr.send(e.value); | ||
e.value = ""; | ||
} | ||
<title>bitluni's VGA text terminal</title> | ||
<script> | ||
function load() { | ||
document.querySelector('#in').focus(); | ||
} | ||
|
||
</script> | ||
<style> | ||
.menu | ||
{ | ||
background-color: #eeeeee; | ||
padding: 1px; | ||
display: block; | ||
margin: 3px; | ||
padding: 5px; | ||
border-radius: 3px; | ||
} | ||
h2 | ||
{ | ||
color: white; | ||
background: #800000; | ||
padding: 10px; | ||
border-radius: 5px; | ||
margin-bottom: 5px; | ||
} | ||
</style> | ||
function send() { | ||
var e = document.querySelector('#in'); | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open('POST', '/text'); | ||
xhr.send(e.value); | ||
document.querySelector("#log").innerHTML = e.value + "\n" + document.querySelector("#log").innerHTML; | ||
e.value = ''; | ||
} | ||
</script> | ||
<style> | ||
h1 | ||
{ | ||
color: white; | ||
background: #800000; | ||
padding: 10px; | ||
border-radius: 5px; | ||
margin-bottom: 5px; | ||
} | ||
body | ||
{ | ||
font-family: monospace; | ||
padding: 0; | ||
} | ||
input, textarea, button | ||
{ | ||
border-style: solid; | ||
border-radius: 3px; | ||
} | ||
td | ||
{ | ||
width: auto; | ||
} | ||
td.min | ||
{ | ||
width: 1%; | ||
} | ||
#in{ | ||
margin-bottom: 10px; | ||
width: 100%; | ||
} | ||
#send{ | ||
margin-bottom: 10px; | ||
} | ||
#log | ||
{ | ||
resize: vertical; | ||
height: 200px; | ||
width: 100% | ||
} | ||
#area | ||
{ | ||
margin-top: 100px; | ||
height: 500px; | ||
} | ||
table | ||
{ | ||
width: 100%; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body style='font-family: arial'> | ||
<h2>bitluni's VGA text terminal</h2> | ||
<div> | ||
<div class='menu'> | ||
<input id='text' type='text' onchange='sendText()'> | ||
</div> | ||
</div> | ||
</body></html> | ||
)" | ||
|
||
<body onload='load()'> | ||
<h1>bitluni's VGA text terminal</h1> | ||
<table> | ||
<tr> | ||
<td><input id='in' type='text' tabindex=1 onchange='send()'></td> | ||
<td class='min'><button id='send' onclick='send()'>send</button></td> | ||
</tr> | ||
<tr> | ||
<td colspan=2> | ||
<textarea id='log' readonly> | ||
</textarea> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
</body> | ||
|
||
</html> | ||
|
||
)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.