Files
pti-ledy/index.h
T
2026-02-06 10:40:56 +01:00

210 lines
8.3 KiB
C

const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html>
<head>
<title>LED Panel Control</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font-family: Arial; text-align: center; margin:0px auto; padding-top: 30px;}
.button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
textarea {
width: 80%;
height: 200px;
margin-top: 20px;
}
.text-controls {
margin-top: 20px;
border: 1px solid #ccc;
padding: 10px;
margin-bottom: 10px;
}
.text-input-group {
margin-bottom: 10px;
}
.param-explanation {
font-size: 0.8em;
color: #666;
}
pre {
text-align: left;
background-color: #f0f0f0;
padding: 10px;
white-space: pre-wrap;
}
</style>
</head>
<body>
<h1>LED Panel Control</h1>
<button class="button" onclick="location.href='/upload-page'">Upload Image</button>
<br>
<div>
<label for="brightness">Brightness: </label>
<input type="range" id="brightness" min="0" max="100" value="100" onchange="updateBrightness()">
<span id="brightnessValue">100</span>
</div>
<br>
<div class="text-controls">
<h3>Add Text Node (Full Control)</h3>
<pre><code>void addNewTextNode(char text[TEXT_MAX_LENGTH + 1], uint32_t color, bool handle_pos_via_cursor = true, short pos_x = 0, short pos_y = 0, unsigned char scroll_slowness = 1, bool is_scrolling = true, bool is_small = true, short disappear_time = -1)</code></pre>
<div class="text-input-group">
<input type="text" id="textInput" placeholder="Enter text...">
<div class="param-explanation">The text to display.</div>
</div>
<div class="text-input-group">
<input type="color" id="textColorPicker" value="#ffffff">
<div class="param-explanation">Color of the text.</div>
</div>
<div class="text-input-group">
<input type="number" id="xInput" placeholder="X position">
<div class="param-explanation">X coordinate of the text.</div>
</div>
<div class="text-input-group">
<input type="number" id="yInput" placeholder="Y position">
<div class="param-explanation">Y coordinate of the text.</div>
</div>
<div class="text-input-group">
<select id="fontSizeInput">
<option value="small">Small</option>
<option value="medium">Medium</option>
</select>
<div class="param-explanation">Font size of the text.</div>
</div>
<div class="text-input-group">
<input type="number" id="slownessInput" placeholder="Slowness" value="2" min="0" max="255">
<div class="param-explanation">Animation slowness (0-255).</div>
</div>
<div class="text-input-group">
<input type="checkbox" id="isRepeatingInput">
<label for="isRepeatingInput">Repeating</label>
<div class="param-explanation">If checked, the text will wrap around the screen.</div>
</div>
<div class="text-buttons">
<button class="button" onclick="sendText()">Add Text</button>
<button class="button" onclick="sendText('top')">Send to Top</button>
<button class="button" onclick="sendText('bottom')">Send to Bottom</button>
</div>
</div>
<div class="text-controls">
<h3>Add Multicolor Text Node</h3>
<pre><code>void addNewMultiColor(char text[TEXT_MAX_LENGTH + 1], RGBWithIndex colors[4], unsigned char color_count, bool handle_pos_via_cursor = true, short pos_x = 0, short pos_y = 0, unsigned char scroll_slowness = 1, bool is_scrolling = true, bool is_small = true, short disappear_time = -1)</code></pre>
<div class="text-input-group">
<input type="text" id="multicolorTextInput" placeholder="Enter text...">
<div class="param-explanation">The text to display.</div>
</div>
<div class="text-input-group">
<input type="text" id="multicolorColorInput" placeholder="e.g., #ff0000,#00ff00,#0000ff">
<div class="param-explanation">Comma-separated list of hex colors (max 4).</div>
</div>
<div class="text-input-group">
<input type="number" id="multicolorXInput" placeholder="X position">
<div class="param-explanation">X coordinate of the text.</div>
</div>
<div class="text-input-group">
<input type="number" id="multicolorYInput" placeholder="Y position">
<div class="param-explanation">Y coordinate of the text.</div>
</div>
<div class="text-input-group">
<select id="multicolorFontSizeInput">
<option value="small">Small</option>
<option value="medium">Medium</option>
</select>
<div class="param-explanation">Font size of the text.</div>
</div>
<div class="text-input-group">
<input type="number" id="multicolorSlownessInput" placeholder="Slowness" value="2" min="0" max="255">
<div class="param-explanation">Animation slowness (0-255).</div>
</div>
<div class="text-input-group">
<input type="checkbox" id="multicolorIsRepeatingInput">
<label for="multicolorIsRepeatingInput">Repeating</label>
<div class="param-explanation">If checked, the text will wrap around the screen.</div>
</div>
<div class="text-buttons">
<button class="button" onclick="sendMulticolorText()">Add Multicolor Text</button>
</div>
</div>
<script>
function updateBrightness() {
var brightness = document.getElementById("brightness").value;
document.getElementById("brightnessValue").innerText = brightness;
var xhr = new XMLHttpRequest();
xhr.open("POST", "/brightness", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("value=" + brightness);
}
function sendText(position) {
const text = document.getElementById('textInput').value;
const color = document.getElementById('textColorPicker').value;
const slowness = document.getElementById('slownessInput').value;
const x = document.getElementById('xInput').value;
const y = document.getElementById('yInput').value;
const fontSize = document.getElementById('fontSizeInput').value;
const isRepeating = document.getElementById('isRepeatingInput').checked;
if (!text) {
alert('Please enter some text.');
return;
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "/text", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
let data = "text=" + encodeURIComponent(text) + "&color=" + encodeURIComponent(color) + "&slowness=" + slowness + "&is_repeating=" + isRepeating;
if(position) {
data += "&position=" + position;
} else {
if(x) data += "&x=" + x;
if(y) data += "&y=" + y;
}
if(fontSize) data += "&fontSize=" + fontSize;
xhr.send(data);
}
function sendMulticolorText() {
const text = document.getElementById('multicolorTextInput').value;
const colors = document.getElementById('multicolorColorInput').value;
const slowness = document.getElementById('multicolorSlownessInput').value;
const x = document.getElementById('multicolorXInput').value;
const y = document.getElementById('multicolorYInput').value;
const fontSize = document.getElementById('multicolorFontSizeInput').value;
const isRepeating = document.getElementById('multicolorIsRepeatingInput').checked;
if (!text) {
alert('Please enter some text.');
return;
}
if (!colors) {
alert('Please enter some colors.');
return;
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "/multicolor-text", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
let data = "text=" + encodeURIComponent(text) + "&colors=" + encodeURIComponent(colors) + "&slowness=" + slowness + "&is_repeating=" + isRepeating;
if(x) data += "&x=" + x;
if(y) data += "&y=" + y;
if(fontSize) data += "&fontSize=" + fontSize;
xhr.send(data);
}
</script>
</body>
</html>
)rawliteral";