repeating texts
This commit is contained in:
@@ -23,10 +23,23 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
}
|
||||
.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>
|
||||
@@ -39,19 +52,89 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
<span id="brightnessValue">100</span>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<div class="text-controls">
|
||||
<h3>Send Text</h3>
|
||||
<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>
|
||||
<br>
|
||||
|
||||
<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;
|
||||
@@ -66,6 +149,10 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
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.');
|
||||
@@ -75,7 +162,47 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/text", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send("text=" + encodeURIComponent(text) + "&color=" + encodeURIComponent(color) + "&position=" + position + "&slowness=" + slowness);
|
||||
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user