Add ESP32 WiFi interface (#11209)

This commit is contained in:
Hadrien Jouet
2019-03-12 22:48:08 -07:00
committed by Scott Lahteine
parent c03df89921
commit 0278ad0a6d
93 changed files with 915 additions and 22 deletions

37
data/www/index.html Normal file
View File

@ -0,0 +1,37 @@
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Marlin</title>
<link rel="stylesheet" type="text/css" href="marlin.css" />
<script type="text/javascript" src="marlin.js"></script>
</head>
<body>
<div class="tabs">
<div id="logo"></div>
<input class="input" name="tabs" type="radio" id="tab-1" checked="checked"/>
<label class="label" for="tab-1">console</label>
<div class="panel">
<div class="panel-content">
<ul id="serial-output"></ul>
<form id="serial-command-form" autocomplete="off">
<div class="form-wrapper">
<input type="text" id="serial-command">
<input type="submit" value="Send">
</div>
</form>
</div>
</div>
<input class="input" name="tabs" type="radio" id="tab-2"/>
<label class="label" for="tab-2">controls</label>
<div class="panel">
<div class="panel-content">
#controls
</div>
</div>
</div>
</body>
</html>

BIN
data/www/marlin-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

166
data/www/marlin.css Normal file
View File

@ -0,0 +1,166 @@
/* CSS reset */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
font-family: Impact, Charcoal, sans-serif;
}
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body { line-height: 1; }
ol, ul { list-style: none; }
blockquote, q { quotes: none; }
blockquote:before, blockquote:after,
q:before, q:after { content: ''; content: none; }
table {
border-collapse: collapse;
border-spacing: 0;
}
/* Custom */
/* Tabs */
* { box-sizing: border-box; }
body {
display: flex;
justify-content: center;
padding: 0px;
background: #1e1e1e;
color: #efefef;
}
h1 {
margin: 0;
font-size: 2em;
}
.tabs {
display: flex;
width: 100%;
flex-wrap: wrap;
background: #e5e5e5;
}
.input {
position: absolute;
opacity: 0;
}
.label {
width: 100%;
padding: 18px 28px;
background: #e5e5e5;
cursor: pointer;
font-weight: bold;
font-size: 18px;
color: #7f7f7f;
transition: background 0.1s, color 0.1s;
border-style: solid;
border-width: 0 0 4px 0;
border-color: #acacac;
}
.label:hover {
background: #d8d8d8;
}
.label:active {
background: #ccc;
}
.input:focus + .label {
z-index: 1;
}
.input:checked + .label {
background: #1e1e1e;
color: #efefef;
border-width: 4px 0 0 0;
border-color: #65a57d;
}
.panel {
display: none;
width: 100%;
padding: 20px 30px 30px;
background: #1e1e1e;
color: #e5e5e5;
}
.panel .panel-content {
width: 100%;
max-width: 800px;
}
@media (min-width: 600px) {
.label { width: auto; }
.panel { order: 99; }
}
.input:checked + .label + .panel { display: block; }
#logo {
width: 130px;
height: 58px;
margin-right: 20px;
background: url(marlin-logo.png) no-repeat center center;
}
input[type="text"], textarea {
background-color: #2c2c2c;
border: solid 2px #314b3b;
color: #e5e5e5;
outline: none;
}
input[type="text"]:focus, textarea:focus {
border-color: #4d7a5e;
}
ul#serial-output {
width: 100%;
height: 300px;
overflow-y: scroll;
background-color: #2c2c2c;
border: solid 2px #314b3b;
}
ul#serial-output li {
padding: 4px;
font-family: "Lucida Console", Monaco, monospace;
font-size: 0.8em;
}
ul#serial-output li:nth-child(odd) {
background-color: #3c3c3c;
}
div.form-wrapper {
display: flex;
width: 100%;
margin: 6px 0;
}
div.form-wrapper input {
font-size: 1.2em;
padding: 4px 6px;
}
div.form-wrapper input[type="text"] {
flex: 1 1 auto;
}
div.form-wrapper input[type="submit"],
div.form-wrapper button {
border: solid 2px #314b3b;
background-color: #4d7a5e;
color: #e5e5e5;
}

24
data/www/marlin.js Normal file
View File

@ -0,0 +1,24 @@
document.addEventListener('DOMContentLoaded', () => {
const ws = new WebSocket(`ws://${location.host}/ws`);
ws.onmessage = (e) => {
if (typeof e.data === 'string') {
let node = document.createElement('li');
let text = document.createTextNode(e.data);
node.appendChild(text);
document.getElementById('serial-output').appendChild(node);
}
};
document.getElementById('serial-command-form').addEventListener('submit', (e) => {
e.preventDefault();
let value = document.getElementById('serial-command').value.trim();
if (!value) return;
ws.send(`${value}\n`);
document.getElementById('serial-command').value = '';
});
});