mirror of
https://github.com/s00500/ESPUI.git
synced 2024-12-22 19:30:50 +00:00
🌈 Files Added
This commit is contained in:
parent
8e07effe47
commit
10000fdf51
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Ayush Sharma (ayushsharma82)
|
||||
Authors: Ayush Sharma
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
7
keywords.txt
Normal file
7
keywords.txt
Normal file
@ -0,0 +1,7 @@
|
||||
EasyUI KEYWORD1
|
||||
|
||||
title KEYWORD2
|
||||
begin KEYWORD2
|
||||
label KEYWORD2
|
||||
toggleButton KEYWORD2
|
||||
loop KEYWORD2
|
15
library.json
Normal file
15
library.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "EasyUI",
|
||||
"keywords": "EasyUI, esp8266, ui, easyui, user, interface, gui, iot, arduino, Wifi, server",
|
||||
"description": "Easily Setup an User Interface on Your ESP8266 with EasyUI",
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/ayushsharma82/EasyDDNS.git"
|
||||
},
|
||||
"frameworks": "arduino",
|
||||
"platforms":
|
||||
[
|
||||
"espressif"
|
||||
]
|
||||
}
|
9
library.properties
Normal file
9
library.properties
Normal file
@ -0,0 +1,9 @@
|
||||
name=EasyUI
|
||||
version=0.5
|
||||
author=Ayush Sharma
|
||||
maintainer=Ayush Sharma <asrocks5@gmail.com>
|
||||
sentence=ESP8266 User Interface Library.
|
||||
paragraph=A Simple library that implements a Good Looking User Interface for ESP8266. It is Easy to Setup and Works side by side with your Sketch.
|
||||
category=Communication
|
||||
url=https://github.com/ayushsharma82/EasyUI
|
||||
architectures=*
|
250
src/CSS_NORMALIZE.h
Normal file
250
src/CSS_NORMALIZE.h
Normal file
@ -0,0 +1,250 @@
|
||||
const char CSS_NORMALIZE[] PROGMEM = R"=====(
|
||||
|
||||
html {
|
||||
font-family: sans-serif; /* 1 */
|
||||
-ms-text-size-adjust: 100%; /* 2 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* HTML5 display definitions
|
||||
========================================================================== */
|
||||
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
main,
|
||||
menu,
|
||||
nav,
|
||||
section,
|
||||
summary {
|
||||
display: block;
|
||||
}
|
||||
|
||||
audio,
|
||||
canvas,
|
||||
progress,
|
||||
video {
|
||||
display: inline-block; /* 1 */
|
||||
vertical-align: baseline; /* 2 */
|
||||
}
|
||||
|
||||
audio:not([controls]) {
|
||||
display: none;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
[hidden],
|
||||
template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Links
|
||||
========================================================================== */
|
||||
|
||||
a {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
a:active,
|
||||
a:hover {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
/* Text-level semantics
|
||||
========================================================================== */
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: 1px dotted;
|
||||
}
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
dfn {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
mark {
|
||||
background: #ff0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
/* Embedded content
|
||||
========================================================================== */
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
svg:not(:root) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Grouping content
|
||||
========================================================================== */
|
||||
|
||||
figure {
|
||||
margin: 1em 40px;
|
||||
}
|
||||
|
||||
hr {
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
code,
|
||||
kbd,
|
||||
pre,
|
||||
samp {
|
||||
font-family: monospace, monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
color: inherit; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
margin: 0; /* 3 */
|
||||
}
|
||||
|
||||
button {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
button,
|
||||
select {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
button,
|
||||
html input[type="button"], /* 1 */
|
||||
input[type="reset"],
|
||||
input[type="submit"] {
|
||||
-webkit-appearance: button; /* 2 */
|
||||
cursor: pointer; /* 3 */
|
||||
}
|
||||
|
||||
button[disabled],
|
||||
html input[disabled] {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
button::-moz-focus-inner,
|
||||
input::-moz-focus-inner {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
input {
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
box-sizing: border-box; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
input[type="number"]::-webkit-inner-spin-button,
|
||||
input[type="number"]::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
input[type="search"] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
-moz-box-sizing: content-box;
|
||||
-webkit-box-sizing: content-box; /* 2 */
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
input[type="search"]::-webkit-search-cancel-button,
|
||||
input[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
border: 1px solid #c0c0c0;
|
||||
margin: 0 2px;
|
||||
padding: 0.35em 0.625em 0.75em;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct `color` not being inherited in IE 8/9/10/11.
|
||||
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
|
||||
*/
|
||||
|
||||
legend {
|
||||
border: 0; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
textarea {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't inherit the `font-weight` (applied by a rule above).
|
||||
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
|
||||
*/
|
||||
|
||||
optgroup {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Tables
|
||||
========================================================================== */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
)=====";
|
402
src/CSS_STYLE.h
Normal file
402
src/CSS_STYLE.h
Normal file
@ -0,0 +1,402 @@
|
||||
const char CSS_STYLE[] PROGMEM = R"=====(
|
||||
body{
|
||||
background-color: #F4F3EF;
|
||||
}
|
||||
.container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
margin: 20px;
|
||||
box-sizing: border-box; }
|
||||
.column,
|
||||
.columns {
|
||||
width: 100%;
|
||||
float: left; }
|
||||
|
||||
.card{
|
||||
margin-top: 2%;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 2px 2px rgba(204, 197, 185, 0.5);
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
margin-bottom: 10px;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.label {
|
||||
box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
border-radius: 0.2em;
|
||||
padding: 0.12em 0.4em 0.14em;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
font-size: 0.75em;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
display: inline;
|
||||
white-space: nowrap;
|
||||
vertical-align: baseline;
|
||||
position: relative;
|
||||
top: -0.15em;
|
||||
background-color: #999999; }
|
||||
|
||||
.label { ... }
|
||||
|
||||
.label.color-blue { background-color: #6f9ad1; }
|
||||
.label.color-red { background-color: #d37c7c; }
|
||||
.label.color-green { background-color: #9bc268; }
|
||||
.label.color-orange { background-color: #dea154; }
|
||||
.label.color-yellow { background-color: #e9d641; }
|
||||
.label.color-purple { background-color: #9f83d1; }
|
||||
|
||||
/* For devices larger than 400px */
|
||||
@media (min-width: 400px) {
|
||||
.container {
|
||||
width: 85%;}
|
||||
|
||||
}
|
||||
|
||||
/* For devices larger than 550px */
|
||||
@media (min-width: 630px) {
|
||||
.container {
|
||||
width: 98%; }
|
||||
.column,
|
||||
.columns {
|
||||
margin-right: 2%; }
|
||||
.column:first-child,
|
||||
.columns:first-child {
|
||||
margin-left: 0; }
|
||||
|
||||
.one.column,
|
||||
.one.columns { width: 4.66666666667%; }
|
||||
.two.columns { width: 13.3333333333%; }
|
||||
.three.columns { width: 22%; }
|
||||
.four.columns { width: 30.6666666667%; }
|
||||
.five.columns { width: 39.3333333333%; }
|
||||
.six.columns { width: 48%; }
|
||||
.seven.columns { width: 56.6666666667%; }
|
||||
.eight.columns { width: 65.3333333333%; }
|
||||
.nine.columns { width: 74.0%; }
|
||||
.ten.columns { width: 82.6666666667%; }
|
||||
.eleven.columns { width: 91.3333333333%; }
|
||||
.twelve.columns { width: 100%; margin-left: 0; }
|
||||
|
||||
.one-third.column { width: 30.6666666667%; }
|
||||
.two-thirds.column { width: 65.3333333333%; }
|
||||
|
||||
.one-half.column { width: 48%; }
|
||||
|
||||
/* Offsets */
|
||||
.offset-by-one.column,
|
||||
.offset-by-one.columns { margin-left: 8.66666666667%; }
|
||||
.offset-by-two.column,
|
||||
.offset-by-two.columns { margin-left: 17.3333333333%; }
|
||||
.offset-by-three.column,
|
||||
.offset-by-three.columns { margin-left: 26%; }
|
||||
.offset-by-four.column,
|
||||
.offset-by-four.columns { margin-left: 34.6666666667%; }
|
||||
.offset-by-five.column,
|
||||
.offset-by-five.columns { margin-left: 43.3333333333%; }
|
||||
.offset-by-six.column,
|
||||
.offset-by-six.columns { margin-left: 52%; }
|
||||
.offset-by-seven.column,
|
||||
.offset-by-seven.columns { margin-left: 60.6666666667%; }
|
||||
.offset-by-eight.column,
|
||||
.offset-by-eight.columns { margin-left: 69.3333333333%; }
|
||||
.offset-by-nine.column,
|
||||
.offset-by-nine.columns { margin-left: 78.0%; }
|
||||
.offset-by-ten.column,
|
||||
.offset-by-ten.columns { margin-left: 86.6666666667%; }
|
||||
.offset-by-eleven.column,
|
||||
.offset-by-eleven.columns { margin-left: 95.3333333333%; }
|
||||
|
||||
.offset-by-one-third.column,
|
||||
.offset-by-one-third.columns { margin-left: 34.6666666667%; }
|
||||
.offset-by-two-thirds.column,
|
||||
.offset-by-two-thirds.columns { margin-left: 69.3333333333%; }
|
||||
|
||||
.offset-by-one-half.column,
|
||||
.offset-by-one-half.columns { margin-left: 52%; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Base Styles
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
/* NOTE
|
||||
html is set to 62.5% so that all the REM measurements throughout Skeleton
|
||||
are based on 10px sizing. So basically 1.5rem = 15px :) */
|
||||
html {
|
||||
font-size: 62.5%; }
|
||||
body {
|
||||
margin: 0;
|
||||
font-size: 1.5em; /* currently ems cause chrome bug misinterpreting rems on body element */
|
||||
line-height: 1.0;
|
||||
font-weight: 400;
|
||||
font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
color: #222; }
|
||||
|
||||
|
||||
/* Typography
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 300; }
|
||||
h1 { font-size: 4.0rem; line-height: 1.2; letter-spacing: -.1rem;}
|
||||
h2 { font-size: 3.6rem; line-height: 1.25; letter-spacing: -.1rem; }
|
||||
h3 { font-size: 3.0rem; line-height: 1.3; letter-spacing: -.1rem; }
|
||||
h4 { font-size: 2.4rem; line-height: 1.35; letter-spacing: -.08rem; }
|
||||
h5 { font-size: 1.8rem; line-height: 1.5; letter-spacing: -.05rem; }
|
||||
h6 { font-size: 1.5rem; line-height: 1.6; letter-spacing: 0; }
|
||||
|
||||
/* Larger than phablet */
|
||||
@media (min-width: 630px) {
|
||||
h1 { font-size: 5.0rem; }
|
||||
h2 { font-size: 4.2rem; }
|
||||
h3 { font-size: 3.6rem; }
|
||||
h4 { font-size: 3.0rem; }
|
||||
h5 { font-size: 2.4rem; }
|
||||
h6 { font-size: 1.5rem; }
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0; }
|
||||
|
||||
|
||||
/* Links
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
a {
|
||||
color: #1EAEDB; }
|
||||
a:hover {
|
||||
color: #0FA0CE; }
|
||||
|
||||
|
||||
/* Buttons
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
.button,
|
||||
button,
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="button"] {
|
||||
display: inline-block;
|
||||
height: 38px;
|
||||
padding: 0 30px;
|
||||
color: #555;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 38px;
|
||||
letter-spacing: .1rem;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
background-color: transparent;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #bbb;
|
||||
cursor: pointer;
|
||||
box-sizing: border-box; }
|
||||
.button:hover,
|
||||
button:hover,
|
||||
input[type="submit"]:hover,
|
||||
input[type="reset"]:hover,
|
||||
input[type="button"]:hover,
|
||||
.button:focus,
|
||||
button:focus,
|
||||
input[type="submit"]:focus,
|
||||
input[type="reset"]:focus,
|
||||
input[type="button"]:focus {
|
||||
color: #333;
|
||||
border-color: #888;
|
||||
outline: 0; }
|
||||
.button.button-primary,
|
||||
button.button-primary,
|
||||
input[type="submit"].button-primary,
|
||||
input[type="reset"].button-primary,
|
||||
input[type="button"].button-primary {
|
||||
color: #FFF;
|
||||
background-color: #33C3F0;
|
||||
border-color: #33C3F0; }
|
||||
.button.button-primary:hover,
|
||||
button.button-primary:hover,
|
||||
input[type="submit"].button-primary:hover,
|
||||
input[type="reset"].button-primary:hover,
|
||||
input[type="button"].button-primary:hover,
|
||||
.button.button-primary:focus,
|
||||
button.button-primary:focus,
|
||||
input[type="submit"].button-primary:focus,
|
||||
input[type="reset"].button-primary:focus,
|
||||
input[type="button"].button-primary:focus {
|
||||
color: #FFF;
|
||||
background-color: #1EAEDB;
|
||||
border-color: #1EAEDB; }
|
||||
|
||||
|
||||
/* Forms
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
input[type="email"],
|
||||
input[type="number"],
|
||||
input[type="search"],
|
||||
input[type="text"],
|
||||
input[type="tel"],
|
||||
input[type="url"],
|
||||
input[type="password"],
|
||||
textarea,
|
||||
select {
|
||||
height: 38px;
|
||||
padding: 6px 10px; /* The 6px vertically centers text on FF, ignored by Webkit */
|
||||
background-color: #fff;
|
||||
border: 1px solid #D1D1D1;
|
||||
border-radius: 4px;
|
||||
box-shadow: none;
|
||||
box-sizing: border-box; }
|
||||
/* Removes awkward default styles on some inputs for iOS */
|
||||
input[type="email"],
|
||||
input[type="number"],
|
||||
input[type="search"],
|
||||
input[type="text"],
|
||||
input[type="tel"],
|
||||
input[type="url"],
|
||||
input[type="password"],
|
||||
textarea {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none; }
|
||||
textarea {
|
||||
min-height: 65px;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px; }
|
||||
input[type="email"]:focus,
|
||||
input[type="number"]:focus,
|
||||
input[type="search"]:focus,
|
||||
input[type="text"]:focus,
|
||||
input[type="tel"]:focus,
|
||||
input[type="url"]:focus,
|
||||
input[type="password"]:focus,
|
||||
textarea:focus,
|
||||
select:focus {
|
||||
border: 1px solid #33C3F0;
|
||||
outline: 0; }
|
||||
label,
|
||||
legend {
|
||||
display: block;
|
||||
margin-bottom: .5rem;
|
||||
font-weight: 600; }
|
||||
fieldset {
|
||||
padding: 0;
|
||||
border-width: 0; }
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
display: inline; }
|
||||
label > .label-body {
|
||||
display: inline-block;
|
||||
margin-left: .5rem;
|
||||
font-weight: normal; }
|
||||
|
||||
|
||||
/* Lists
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
ul {
|
||||
list-style: circle inside; }
|
||||
ol {
|
||||
list-style: decimal inside; }
|
||||
ol, ul {
|
||||
padding-left: 0;
|
||||
margin-top: 0; }
|
||||
ul ul,
|
||||
ul ol,
|
||||
ol ol,
|
||||
ol ul {
|
||||
margin: 1.5rem 0 1.5rem 3rem;
|
||||
font-size: 90%; }
|
||||
li {
|
||||
margin-bottom: 1rem; }
|
||||
|
||||
|
||||
/* Code
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
code {
|
||||
padding: .2rem .5rem;
|
||||
margin: 0 .2rem;
|
||||
font-size: 90%;
|
||||
white-space: nowrap;
|
||||
background: #F1F1F1;
|
||||
border: 1px solid #E1E1E1;
|
||||
border-radius: 4px; }
|
||||
pre > code {
|
||||
display: block;
|
||||
padding: 1rem 1.5rem;
|
||||
white-space: pre; }
|
||||
|
||||
|
||||
/* Tables
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
th,
|
||||
td {
|
||||
padding: 12px 15px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #E1E1E1; }
|
||||
th:first-child,
|
||||
td:first-child {
|
||||
padding-left: 0; }
|
||||
th:last-child,
|
||||
td:last-child {
|
||||
padding-right: 0; }
|
||||
|
||||
|
||||
/* Spacing
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
button,
|
||||
.button {
|
||||
margin-bottom: 1rem; }
|
||||
input,
|
||||
textarea,
|
||||
select,
|
||||
fieldset {
|
||||
margin-bottom: 1.5rem; }
|
||||
pre,
|
||||
blockquote,
|
||||
dl,
|
||||
figure,
|
||||
table,
|
||||
p,
|
||||
ul,
|
||||
ol,
|
||||
form {
|
||||
margin-bottom: 2.5rem; }
|
||||
|
||||
|
||||
/* Utilities
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
.u-full-width {
|
||||
width: 100%;
|
||||
box-sizing: border-box; }
|
||||
.u-max-full-width {
|
||||
max-width: 100%;
|
||||
box-sizing: border-box; }
|
||||
.u-pull-right {
|
||||
float: right; }
|
||||
.u-pull-left {
|
||||
float: left; }
|
||||
|
||||
|
||||
/* Misc
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
hr {
|
||||
margin-top: 0.5rem;
|
||||
margin-bottom: 1.2rem;
|
||||
border-width: 0;
|
||||
border-top: 1px solid #E1E1E1; }
|
||||
|
||||
|
||||
/* Clearing
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
|
||||
/* Self Clearing Goodness */
|
||||
.container:after,
|
||||
.row:after,
|
||||
.u-cf {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both; }
|
||||
|
||||
)=====";
|
277
src/EasyUI.cpp
Normal file
277
src/EasyUI.cpp
Normal file
@ -0,0 +1,277 @@
|
||||
#include "EasyUI.h"
|
||||
|
||||
#include "HTML_PAGE.h" // Added HTML Index Page
|
||||
#include "CSS_STYLE.h" // Added Main CSS Style
|
||||
#include "CSS_NORMALIZE.h" // Added Normalize CSS
|
||||
#include "JS_JQUERY.h" // Added Jquery JS
|
||||
|
||||
#include <functional>
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
|
||||
|
||||
// Generate Websockets Script for Webpage
|
||||
void EasyUIClass::handleSockets(){
|
||||
String ip = WiFi.localIP().toString();
|
||||
String ws;
|
||||
ws = "var connection = new WebSocket(\"ws://"+ip+":81/\", ['easyui']);";
|
||||
ws += " var keys = {};";
|
||||
ws += " connection.onopen = function () {";
|
||||
ws += " $(\"#connection_status\").toggleClass(\"color-green\");";
|
||||
ws += " $(\"#connection_status\").text(\"Connected\");";
|
||||
ws += String(" connection.send(")+"\"{'mode': 'check_tb_status'}\");";
|
||||
for(int i=0; i<tb_index; i++){
|
||||
ws += String(" $(document).on('click',")+"'#tb"+i+"', function() {";
|
||||
ws += String(" if($('#tb")+i+"').hasClass(\"button\")){ console.log(\"Button Clicked!\"); connection.send("+"\"{'mode': 'tb_click', 'index': '"+i+"', 'status': 'on'}\""+"); }";
|
||||
ws += String(" else if($('#tb")+i+"').hasClass(\"button-primary\")){ connection.send("+"\"{'mode': 'tb_click', 'index': '"+i+"', 'status': 'off'}\""+"); } });";
|
||||
}
|
||||
ws += " };";
|
||||
ws += " connection.onerror = function (error) { $('#connection_status').toggleClass(\"color-red\"); $(\"#connection_status\").text(\"Error / No Connection\"); };";
|
||||
ws += " connection.onmessage = function (e) {";
|
||||
ws += " console.log(e.data); ";
|
||||
ws += " var obj = jQuery.parseJSON(e.data);";
|
||||
ws += " if(obj.mode === 'create_label'){ $('#row').append(\"<div class='two columns card'><h5>\"+obj.l_title+\"</h5><hr /><h3><span class='label'>\"+obj.l_value+\"</span></h3></div>\");}";
|
||||
ws += " else if(obj.mode === 'create_tbutton'){ $('#row').append(\"<div class='two columns card'><h5>\"+obj.tb_title+\"</h5><hr/><button id=\"+\"tb\"+obj.index+\"></button></div>\");}";
|
||||
ws += " else if(obj.mode === 't_button_startup'){ var tb_index = obj.index; for(i=0; i<tb_index; i++){ var tb_index2 = \"tb\"+i; var tb_status = obj[tb_index2]; var tb_index3 = \"#\"+tb_index2; console.log(tb_status); if(tb_status === \"1\"){$(tb_index3).toggleClass('button-primary'); $(tb_index3).text('Turn Off');} else if(tb_status === \"0\"){$(tb_index3).toggleClass('button'); $(tb_index3).text('Turn On');} } }";
|
||||
ws += " else if(obj.mode === 't_button_click'){ var tb_index = \"tb\"+obj.index; var tb_status = obj[tb_index]; var tb_index3 = \"#\"+tb_index; console.log(tb_status); if(tb_status == \"1\"){ console.log(\"Status Tuned ON\"); $(tb_index3).text('Turn Off'); $(tb_index3).removeClass( \"button\" ).addClass( \"button-primary\" );} else if(tb_status == \"0\"){console.log(\"Status Tuned OFF\"); $(tb_index3).text('Turn On'); $(tb_index3).removeClass( \"button-primary\" ).addClass( \"button\" ); } } };";
|
||||
server->send(200, "application/javascript", ws);
|
||||
}
|
||||
|
||||
// Handle Websockets Communication ( Out of Class)
|
||||
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) {
|
||||
switch(type) {
|
||||
case WStype_DISCONNECTED:
|
||||
Serial.printf("Disconnected!\n");
|
||||
break;
|
||||
case WStype_CONNECTED:
|
||||
{
|
||||
Serial.printf("[WSc] Connected to url: %s\n", payload);
|
||||
Serial.println("Connected");
|
||||
EasyUI.handleWebpage();
|
||||
Serial.println("JSON Data Sent to Client!");
|
||||
}
|
||||
break;
|
||||
case WStype_TEXT:
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.parseObject(payload);
|
||||
String mode = root["mode"];
|
||||
if(mode == "check_tb_status"){
|
||||
EasyUI.tbuttonStatus();
|
||||
}
|
||||
else if(mode == "tb_click"){
|
||||
String status = root["status"];
|
||||
String index = root["index"];
|
||||
EasyUI.tbClick(index, status);
|
||||
}
|
||||
// send message to server
|
||||
// webSocket.sendTXT("message here");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EasyUIClass::title(const char* _title){
|
||||
ui_title = _title;
|
||||
}
|
||||
|
||||
// Create Labels
|
||||
void EasyUIClass::label(const char* label_name,const char* label_val){
|
||||
label_value[l_index] = label_val;
|
||||
label_title[l_index] = label_name;
|
||||
l_index++;
|
||||
}
|
||||
|
||||
// Create Toggle Buttons
|
||||
void EasyUIClass::toggleButton(uint8_t pin, const char* tbutton_label, int start_state, bool swap_state){
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, start_state);
|
||||
tbutton_swap[tb_index] = swap_state;
|
||||
tbutton_pinout[tb_index] = pin;
|
||||
tbuttontitle[tb_index] = tbutton_label;
|
||||
tb_index++;
|
||||
}
|
||||
|
||||
// Check Toggle Buttons States and Transfer to Webpage
|
||||
void EasyUIClass::tbuttonStatus(){
|
||||
String json;
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
root["mode"] = "t_button_startup";
|
||||
root["index"] = tb_index;
|
||||
for(int i=0; i<tb_index; i++){
|
||||
String name = "tb"+String(i);
|
||||
int stat = digitalRead(tbutton_pinout[i]);
|
||||
if(tbutton_swap[i]){
|
||||
if(stat == HIGH)
|
||||
root[name] = "0";
|
||||
else if(stat == LOW)
|
||||
root[name] = "1";
|
||||
else
|
||||
root[name] = "unknown";
|
||||
}
|
||||
else{
|
||||
if(stat == HIGH)
|
||||
root[name] = "1";
|
||||
else if(stat == LOW)
|
||||
root[name] = "0";
|
||||
else
|
||||
root[name] = "unknown";
|
||||
}
|
||||
}
|
||||
root.printTo(json);
|
||||
webSocket->broadcastTXT(json);
|
||||
}
|
||||
|
||||
// Handle Index HTML
|
||||
void EasyUIClass::handleRoot(){
|
||||
server->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||
server->send(200,"text/html", "");
|
||||
server->sendContent(HTML_HEAD1);
|
||||
server->sendContent(String("<title>")+ui_title+"</title>");
|
||||
server->sendContent(HTML_HEAD2);
|
||||
server->sendContent(String("<h4>")+ui_title+" <span id=\"connection_status\" class=\"label\">Offline</span></h4></div><hr />");
|
||||
server->sendContent(HTML_BODY);
|
||||
server->client().stop();
|
||||
}
|
||||
|
||||
// Handle Main Style CSS
|
||||
void EasyUIClass::handleSCSS(){
|
||||
server->send(200, "text/css", CSS_STYLE);
|
||||
}
|
||||
|
||||
// Handle Normalize CSS
|
||||
void EasyUIClass::handleNCSS(){
|
||||
server->send(200, "text/css", CSS_NORMALIZE);
|
||||
}
|
||||
|
||||
// Handle Jquery
|
||||
void EasyUIClass::handleJS(){
|
||||
server->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||
server->send(200,"application/javascript", "");
|
||||
server->sendContent(JS_JQUERY1);
|
||||
server->sendContent(JS_JQUERY2);
|
||||
server->sendContent(JS_JQUERY3);
|
||||
server->sendContent(JS_JQUERY4);
|
||||
server->sendContent(JS_JQUERY5);
|
||||
server->sendContent(JS_JQUERY6);
|
||||
server->sendContent(JS_JQUERY7);
|
||||
server->sendContent(JS_JQUERY8);
|
||||
server->sendContent(JS_JQUERY9);
|
||||
server->sendContent(JS_JQUERY10);
|
||||
server->sendContent(JS_JQUERY11);
|
||||
|
||||
server->client().stop();
|
||||
}
|
||||
|
||||
// Handle Not found Page
|
||||
void EasyUIClass::handleNotFound() {
|
||||
String url = "";
|
||||
String type = "";
|
||||
url = server->uri();
|
||||
if (SPIFFS.exists(url)) {
|
||||
File file = SPIFFS.open(url, "r");
|
||||
|
||||
if (url.endsWith(".htm")) type = "text/html";
|
||||
else if (url.endsWith(".html")) type = "text/html";
|
||||
else if (url.endsWith(".css")) type = "text/css";
|
||||
else if (url.endsWith(".js")) type = "application/javascript";
|
||||
else if (url.endsWith(".png")) type = "image/png";
|
||||
else if (url.endsWith(".gif")) type = "image/gif";
|
||||
else if (url.endsWith(".jpg")) type = "image/jpeg";
|
||||
else if (url.endsWith(".ico")) type = "image/x-icon";
|
||||
else if (url.endsWith(".xml")) type = "text/xml";
|
||||
else if (url.endsWith(".pdf")) type = "application/x-pdf";
|
||||
else if (url.endsWith(".zip")) type = "application/x-zip";
|
||||
else if (url.endsWith(".gz")) type = "application/x-gzip";
|
||||
else type = "text/plain";
|
||||
|
||||
server->streamFile(file, type);
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
Serial.println("File not Found : " + url);
|
||||
server->send(200, "text/html", "<html><h1>404 - You are Lost</h1></html>");
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Toggle Button Click Response
|
||||
void EasyUIClass::tbClick(String _index, String _status){
|
||||
String json;
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
String name = "tb"+_index;
|
||||
root["mode"] = "t_button_click";
|
||||
root["index"] = _index;
|
||||
|
||||
if(_status == "on"){
|
||||
root[name] = "1";
|
||||
root.printTo(json);
|
||||
webSocket->broadcastTXT(json);
|
||||
if(tbutton_swap[_index.toInt()]){
|
||||
digitalWrite(tbutton_pinout[_index.toInt()], LOW);
|
||||
}else{
|
||||
digitalWrite(tbutton_pinout[_index.toInt()], HIGH);
|
||||
}
|
||||
}
|
||||
else if(_status == "off"){
|
||||
root[name] = "0";
|
||||
root.printTo(json);
|
||||
webSocket->broadcastTXT(json);
|
||||
if(tbutton_swap[_index.toInt()]){
|
||||
digitalWrite(tbutton_pinout[_index.toInt()], HIGH);
|
||||
}else{
|
||||
digitalWrite(tbutton_pinout[_index.toInt()], LOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert & Transfer Arduino elements to JSON elements
|
||||
void EasyUIClass::handleWebpage(){
|
||||
|
||||
for(int i=0; i<l_index; i++){
|
||||
String json;
|
||||
StaticJsonBuffer<200> jsonBuffer1;
|
||||
JsonObject& root1 = jsonBuffer1.createObject();
|
||||
root1["mode"] = "create_label";
|
||||
root1["l_title"] = String(label_title[i]);
|
||||
root1["l_value"] = String(label_value[i]);
|
||||
root1.printTo(json);
|
||||
webSocket->broadcastTXT(json);
|
||||
}
|
||||
|
||||
for(int i=0; i<tb_index; i++){
|
||||
String json;
|
||||
StaticJsonBuffer<200> jsonBuffer2;
|
||||
JsonObject& root2 = jsonBuffer2.createObject();
|
||||
root2["mode"] = "create_tbutton";
|
||||
root2["index"] = String(i);
|
||||
root2["tb_title"] = tbuttontitle[i];
|
||||
root2.printTo(json);
|
||||
webSocket->broadcastTXT(json);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void EasyUIClass::begin(){
|
||||
server.reset(new ESP8266WebServer(80));
|
||||
webSocket.reset(new WebSocketsServer(81,"","easyui"));
|
||||
SPIFFS.begin();
|
||||
server->on("/", std::bind(&EasyUIClass::handleRoot, this));
|
||||
server->on("/css/normalize.css", std::bind(&EasyUIClass::handleNCSS, this));
|
||||
server->on("/css/skeleton.css", std::bind(&EasyUIClass::handleSCSS, this));
|
||||
server->on("/js/jquery.js", std::bind(&EasyUIClass::handleJS, this));
|
||||
server->on("/js/sockets.js", std::bind(&EasyUIClass::handleSockets, this));
|
||||
server->onNotFound(std::bind(&EasyUIClass::handleNotFound, this));
|
||||
server->begin();
|
||||
webSocket->begin();
|
||||
webSocket->onEvent(webSocketEvent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EasyUIClass::loop(){
|
||||
webSocket->loop();
|
||||
server->handleClient();
|
||||
}
|
||||
|
||||
|
||||
EasyUIClass EasyUI;
|
65
src/EasyUI.h
Normal file
65
src/EasyUI.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef EasyUI_h
|
||||
#define EasyUI_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "stdlib_noniso.h"
|
||||
#include "FS.h"
|
||||
#include "ESP8266WiFi.h"
|
||||
#include "WiFiClient.h"
|
||||
#include "ESP8266WebServer.h"
|
||||
#include "ArduinoJson.h"
|
||||
#include "WebSocketsServer.h"
|
||||
#include "Hash.h"
|
||||
|
||||
|
||||
#define HARDWARE "esp8266"
|
||||
|
||||
class EasyUIClass{
|
||||
|
||||
public:
|
||||
void begin(); // Begin HTTP Server + WebSocketsServer & Initalize All Elements
|
||||
void title(const char* _title); // Define Webpage Header Name and title
|
||||
void toggleButton(uint8_t pin, const char* tbutton_label, int start_state = 0, bool swap_state = false); // Create Toggle Button
|
||||
void label(const char* label_name, const char* label_val); // Create Label
|
||||
void loop(); // Do All Loop Work
|
||||
|
||||
// Variables ---
|
||||
const char* ui_title = "EasyUI"; // Store UI Title and Header Name
|
||||
int tb_index; // Calculate How Many Toggle Buttons
|
||||
int l_index; // Calculate How Many Labels
|
||||
|
||||
bool tbutton_swap[10];
|
||||
uint8_t tbutton_pinout[10]; // Stores GPIO Values - MAX 10
|
||||
const char* label_value[10]; // Stores Label Values - MAX 10
|
||||
|
||||
const char* tbuttontitle[10]; // Stores Toggle Button Titles - MAX 10
|
||||
const char* label_title[10]; // Stores Label Titles - MAX 10
|
||||
|
||||
// const char* variable_type[10]; // un-used feature for now // Stores Label Types, Like 'C' , 'F' or '%' - MAX 10
|
||||
|
||||
String webpage; // Coverts Arduino elements to JSON elements
|
||||
String ws = ""; // Stores Websockets Script
|
||||
|
||||
// Don't Issue the Below functions in your Sketch! - These are Resposible for Webpage functioning.
|
||||
void tbClick(String _index, String _status);
|
||||
void tbuttonStatus();
|
||||
void handleWebpage();
|
||||
|
||||
|
||||
private:
|
||||
std::unique_ptr<ESP8266WebServer> server; // Create Unique Instance for Webserver
|
||||
std::unique_ptr<WebSocketsServer> webSocket; // Create Unique Instance for WebSocketsServer
|
||||
|
||||
|
||||
void handleRoot(); // Handle Index HTML
|
||||
void handleNCSS(); // Handle Normalize CSS
|
||||
void handleSCSS(); // Handle Main Style CSS
|
||||
void handleJS(); // Handle JQuery
|
||||
void handleNotFound(); // Handle Page Not-Found
|
||||
void handleSockets(); // Handle Sockets Script
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern EasyUIClass EasyUI;
|
||||
#endif
|
28
src/HTML_PAGE.h
Normal file
28
src/HTML_PAGE.h
Normal file
@ -0,0 +1,28 @@
|
||||
const char HTML_HEAD1[] PROGMEM = R"=====(
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
)=====";
|
||||
|
||||
const char HTML_HEAD2[] PROGMEM = R"=====(
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAPFBMVEUAAACA1VWR21qQ2liR3FqR3FqS3VuR3VqR3VuR3VqO21mS21uS3FqS3FqS21uJ2GKQ21qR3FuR3FoAAAB/3Gu7AAAAEnRSTlMABoA3kPBwz8i5Kzioxg4NVcU3uEJHAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAAN1wAADdcBQiibeAAAAAd0SU1FB+EFEhcEM+HpYwQAAABYSURBVBjThY/JDsAgCESt4lpX/v9jLQZJ6qF9t3khAyj1xXUKbQ4BVowDwqOYgExkkW4iY6lPaF06RqM8YItOuRbMaz6xjbsusDAW/drplBg47jP696cXE8bPA1eUDeK2AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE3LTA1LTE4VDIzOjA0OjUxKzAyOjAwxE59ewAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNy0wNS0xOFQyMzowNDo1MSswMjowMLUTxccAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC"/>
|
||||
|
||||
<link rel="stylesheet" href="/css/normalize.css">
|
||||
<link rel="stylesheet" href="/css/skeleton.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
)=====";
|
||||
|
||||
const char HTML_BODY[] PROGMEM = R"=====(
|
||||
<div class="container">
|
||||
<div id="row" class="row u-full-width">
|
||||
</div>
|
||||
</div>
|
||||
<script src="/js/jquery.js"></script>
|
||||
<script src="/js/sockets.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
)=====";
|
43
src/JS_JQUERY.h
Normal file
43
src/JS_JQUERY.h
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user