1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-22 04:00:55 +00:00

#9 adjusting labels for wraping

renaming datafiles
going on for numbers
This commit is contained in:
Lukas Bachschwell 2018-05-27 11:47:53 +02:00
parent 7646d4e629
commit e771320e6a
15 changed files with 100 additions and 27 deletions

View File

@ -79,6 +79,12 @@
margin-bottom: 10px; margin-bottom: 10px;
} }
.label-wrap {
width: 90%;
white-space: pre-wrap;
word-wrap: break-word;
}
.label.color-blue { .label.color-blue {
background-color: #6f9ad1; background-color: #6f9ad1;
} }

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,31 @@
const UI_TITEL = 0; const UI_TITEL = 0;
const UI_LABEL = 1; const UI_LABEL = 1;
const UPDATE_LABEL = 6;
const UI_BUTTON = 2; const UI_BUTTON = 2;
const UI_SWITCHER = 3; const UI_SWITCHER = 3;
const UPDATE_SWITCHER = 7;
const UI_PAD = 4; const UI_PAD = 4;
const UI_CPAD = 5; const UI_CPAD = 5;
const UPDATE_LABEL = 6;
const UPDATE_SWITCHER = 7;
const UI_SLIDER = 8; const UI_SLIDER = 8;
const UPDATE_SLIDER = 9; const UPDATE_SLIDER = 9;
const UI_NUMBER = 10;
const UPDATE_NUMBER = 11;
const UI_TEXT_INPUT = 12;
const UPDATE_TEXT_INPUT = 13;
const UI_GRAPH = 14;
const CLEAR_GRAPH = 15;
const ADD_GRAPH_POINT = 16;
const FOR = 0; const FOR = 0;
const BACK = 1; const BACK = 1;
const LEFT = 2; const LEFT = 2;
@ -97,7 +114,7 @@ function start() {
$('#mainHeader').html(data.label); $('#mainHeader').html(data.label);
break; break;
case UI_LABEL: case UI_LABEL:
$('#row').append("<div class='two columns card tcenter " + colorClass(data.color) + "'><h5 id='" + data.id + "'>" + data.label + "</h5><hr /><span id='l" + data.id + "' class='label'>" + data.value + "</span></div>"); $('#row').append("<div class='two columns card tcenter " + colorClass(data.color) + "'><h5 id='" + data.id + "'>" + data.label + "</h5><hr /><span id='l" + data.id + "' class='label label-wrap'>" + data.value + "</span></div>");
break; break;
case UI_BUTTON: case UI_BUTTON:
$('#row').append("<div class='one columns card tcenter " + colorClass(data.color) + "'><h5>" + data.label + "</h5><hr/><button onmousedown='buttonclick(" + data.id + ", true)' onmouseup='buttonclick(" + data.id + ", false)' id='" + data.id + "'>" + data.value + "</button></div>"); $('#row').append("<div class='one columns card tcenter " + colorClass(data.color) + "'><h5>" + data.label + "</h5><hr/><button onmousedown='buttonclick(" + data.id + ", true)' onmouseup='buttonclick(" + data.id + ", false)' id='" + data.id + "'>" + data.value + "</button></div>");
@ -234,6 +251,33 @@ function start() {
case UPDATE_SLIDER: case UPDATE_SLIDER:
slider_move($('#sl' + data.id), data.value, '100', false); slider_move($('#sl' + data.id), data.value, '100', false);
break; break;
case UI_NUMBER:
$('#row').append(
"<div class='two columns card tcenter" + colorClass(data.color) + "'>" +
"<h5 id='" + data.id + "'>" + data.label + "</h5><hr />" +
"<input id='num" + data.id + "' type='number' value='" + data.value + "' onchange='numberchange(" + data.id + ")' />" +
"</div>"
);
break;
case UPDATE_NUMBER:
$('#num' + data.id).val(data.value);
break;
case UI_TEXT_INPUT:
$('#row').append(
"<div class='two columns card tcenter" + colorClass(data.color) + "'>" +
"<h5 id='" + data.id + "'>" + data.label + "</h5><hr />" +
"<input id='num" + data.id + "' type='number' value='" + data.value + "' onchange='numberchange(" + data.id + ")' />" +
"</div>"
);
break;
case UPDATE_TEXT_INPUT:
$('#num' + data.id).val(data.value);
break;
default: default:
console.error('Unknown type or event'); console.error('Unknown type or event');
break; break;
@ -241,6 +285,12 @@ function start() {
}; };
} }
function numberchange(number) {
var val = $('#num' + data.id).val();
websock.send("nchange:" + number + ":" + val);
console.log(val);
}
function buttonclick(number, isdown) { function buttonclick(number, isdown) {
if (isdown) websock.send("bdown:" + number); if (isdown) websock.send("bdown:" + number);

View File

@ -144,6 +144,10 @@ void setup(void) {
ESPUI.slider("Slider one", &slider, COLOR_ALIZARIN, "30"); ESPUI.slider("Slider one", &slider, COLOR_ALIZARIN, "30");
ESPUI.slider("Slider two", &slider, COLOR_NONE, "100"); ESPUI.slider("Slider two", &slider, COLOR_NONE, "100");
/*
.begin loads and serves all files from PROGMEM directly.
If you want to serve the files from SPIFFS use .beginSPIFFS (.prepareFileSystem has to be run in an empty sketch before)
*/
ESPUI.begin("ESPUI Control"); ESPUI.begin("ESPUI Control");
} }

View File

@ -20,8 +20,10 @@ pad KEYWORD2
slider KEYWORD2 slider KEYWORD2
begin KEYWORD2 begin KEYWORD2
beginSPIFFS KEYWORD2
print KEYWORD2 print KEYWORD2
updateSwitcher KEYWORD2 updateSwitcher KEYWORD2
updateSlider KEYWORD2
####################################### #######################################
# Instances (KEYWORD2) # Instances (KEYWORD2)

View File

@ -1,13 +1,13 @@
#include "ESPUI.h" #include "ESPUI.h"
#include "uploadDataIndex.h" #include "dataIndexHTML.h"
#include "uploadDataNormalize.h" #include "dataNormalizeCSS.h"
#include "uploadDataStyle.h" #include "dataStyleCSS.h"
#include "uploadDataControls.h" #include "dataControlsJS.h"
#include "uploadDataSlider.h" #include "dataSliderJS.h"
#include "uploadDataZepto.h" #include "dataZeptoJS.h"
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
#include <functional> #include <functional>
@ -586,7 +586,7 @@ void ESPUIClass::beginSPIFFS(const char *_title) {
// Heap for general Servertest // Heap for general Servertest
server->on("/heap", HTTP_GET, [](AsyncWebServerRequest *request) { server->on("/heap", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/plain", String(ESP.getFreeHeap()+ " In SPIFFSmode")); request->send(200, "text/plain", String(ESP.getFreeHeap()) + " In SPIFFSmode");
}); });
server->onNotFound( server->onNotFound(
@ -655,7 +655,7 @@ void ESPUIClass::begin(const char *_title) {
// Heap for general Servertest // Heap for general Servertest
server->on("/heap", HTTP_GET, [](AsyncWebServerRequest *request) { server->on("/heap", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/plain", String(ESP.getFreeHeap() + " In Memorymode")); request->send(200, "text/plain", String(ESP.getFreeHeap())+ " In Memorymode");
}); });
server->onNotFound( server->onNotFound(

View File

@ -41,20 +41,31 @@ typedef struct Control {
// Message Types (and control types) // Message Types (and control types)
#define UI_TITEL 0 #define UI_TITEL 0
#define UI_LABEL 1 #define UI_LABEL 1
#define UPDATE_LABEL 6
#define UI_BUTTON 2 #define UI_BUTTON 2
#define UI_SWITCHER 3 #define UI_SWITCHER 3
#define UPDATE_SWITCHER 7
#define UI_PAD 4 #define UI_PAD 4
#define UI_CPAD 5 #define UI_CPAD 5
#define UPDATE_LABEL 6
#define UPDATE_SWITCHER 7
#define UI_SLIDER 8 #define UI_SLIDER 8
#define UPDATE_SLIDER 9 #define UPDATE_SLIDER 9
#define UI_NUMBER 10 #define UI_NUMBER 10
#define UPDATE_NUMBER 11 #define UPDATE_NUMBER 11
#define UI_GRAPH 12
#define CLEAR_GRAPH 13 #define UI_TEXT_INPUT 12
#define ADD_GRAPH_POINT 14 #define UPDATE_TEXT_INPUT 13
#define UI_GRAPH 14
#define CLEAR_GRAPH 15
#define ADD_GRAPH_POINT 16
// Values // Values

5
src/dataControlsJS.h Normal file

File diff suppressed because one or more lines are too long

5
src/dataStyleCSS.h Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long