Compare commits
121
Commits
36fb748f6d
...
FSM2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22f141e2cd | ||
|
|
f5d6e376c6 | ||
|
|
eeac10c66f | ||
|
|
e9d16a80d4 | ||
|
|
dcae074b55 | ||
|
|
472eba7977 | ||
|
|
6a398d9ba0 | ||
|
|
f28aa2df8b | ||
|
|
754da9f931 | ||
|
|
df2a8fa1e3 | ||
|
|
dc159a35d0 | ||
|
|
2378ca80b9 | ||
|
|
79ff1f0d33 | ||
|
|
6a36971406 | ||
|
|
714fcb4b18 | ||
|
|
712acf3541 | ||
|
|
df89c9716c | ||
|
|
66e8ddb2d9 | ||
|
|
5b197288bc | ||
|
|
a9f098097c | ||
|
|
a0f6a5aec3 | ||
|
|
633b99f818 | ||
|
|
5d32392844 | ||
|
|
50e714e5f8 | ||
|
|
e0bc75826f | ||
|
|
3d13e761f4 | ||
|
|
3c824bfc92 | ||
|
|
9ea541a1b4 | ||
|
|
b89604edc3 | ||
|
|
4e6445fea8 | ||
|
|
10b57ca516 | ||
|
|
e8329f2587 | ||
|
|
014aa028d7 | ||
|
|
b47f778fc1 | ||
|
|
c7eaffda00 | ||
|
|
69e1e869a5 | ||
|
|
1a284080e8 | ||
|
|
3490e7ba44 | ||
|
|
d059c3d72d | ||
|
|
33499beb32 | ||
|
|
38c81ae182 | ||
|
|
a8ceb258b8 | ||
|
|
7e5a6fac9f | ||
|
|
b7ba521c59 | ||
|
|
55ebd21975 | ||
|
|
2b2a135bd5 | ||
|
|
a400b0464d | ||
|
|
2d9be85b09 | ||
|
|
33b9f0150e | ||
|
|
48d0dc50f7 | ||
|
|
cdb34a3cbf | ||
|
|
1b34714d27 | ||
|
|
90a9213a3c | ||
|
|
7976f5258f | ||
|
|
bb3a735d37 | ||
|
|
3c186771fe | ||
|
|
c40e7f80e5 | ||
|
|
9d1105cb80 | ||
|
|
4130b64370 | ||
|
|
bff8cdbeb7 | ||
|
|
d8343ea91f | ||
|
|
78f09b3a3b | ||
|
|
bd0e364d22 | ||
|
|
32266b5f37 | ||
|
|
b62f4f9f95 | ||
|
|
a8af7543ba | ||
|
|
85f8da3476 | ||
|
|
f323bd4cf9 | ||
|
|
708bb2cda4 | ||
|
|
a4196bb579 | ||
|
|
908c4298be | ||
|
|
6e885673b8 | ||
|
|
93cc958800 | ||
|
|
9d30423ca3 | ||
|
|
b3b11d0818 | ||
|
|
51bdd6210e | ||
|
|
d51bb4c95c | ||
|
|
2659e366ec | ||
|
|
4951ca46c1 | ||
|
|
97a6076864 | ||
|
|
ff6b82867c | ||
|
|
a3dc7a5fba | ||
|
|
c13b0adc82 | ||
|
|
da20f74db8 | ||
|
|
d5b9827543 | ||
|
|
3c6889854e | ||
|
|
8d8ffe4173 | ||
|
|
006404fccf | ||
|
|
d17091651f | ||
|
|
4b608c42ca | ||
|
|
278f746b33 | ||
|
|
642ee7d0a6 | ||
|
|
6596346d3d | ||
|
|
b696703d45 | ||
|
|
baecaf02da | ||
|
|
1d7f2f368b | ||
|
|
c8938f4b36 | ||
|
|
cd80b9b7ba | ||
|
|
657f77e73d | ||
|
|
b51cce709a | ||
|
|
09aff91b31 | ||
|
|
36fd363d67 | ||
|
|
ee72092a3a | ||
|
|
a66ab2b1d0 | ||
|
|
6a7f2e6a4e | ||
|
|
49f9c9c217 | ||
|
|
61d6cde899 | ||
|
|
65e922b090 | ||
|
|
461c887ddf | ||
|
|
e7cf45c45e | ||
|
|
055a6193df | ||
|
|
c6e288280e | ||
|
|
d0b824963b | ||
|
|
407581451b | ||
|
|
5443800b40 | ||
|
|
769e132baa | ||
|
|
b5a5257a37 | ||
|
|
f317600d03 | ||
|
|
306d9721c4 | ||
|
|
71e5c47852 | ||
|
|
29e130b837 |
No files matched your search
+5
-4
@@ -1,8 +1,9 @@
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
.vscode
|
||||
.vscode/*
|
||||
.vscode/**
|
||||
compress
|
||||
data_gz
|
||||
platformio.ini
|
||||
include/wifi_credentials.h
|
||||
include/*.gz.h
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "lib/PCA9685-Arduino"]
|
||||
path = lib/PCA9685-Arduino
|
||||
url = https://github.com/NachtRaveVL/PCA9685-Arduino
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"random": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,23 @@ https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html
|
||||
```
|
||||
|
||||
##### platformio.ini
|
||||
change IP of esp8266 accordingly
|
||||
IP gets printed on Serial Monitor after first Upload
|
||||
see templ_platformio_ini
|
||||
|
||||
```ini
|
||||
[env:<BOARD>]
|
||||
platform = espressif8266
|
||||
board = <BOARD>
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
|
||||
extra_scripts = pre:extra_script.py
|
||||
|
||||
; stuff for OTA
|
||||
; https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
|
||||
upload_protocol = espota
|
||||
upload_port = <IPADRESS>
|
||||
upload_flags =
|
||||
--port=8266
|
||||
--auth=admin
|
||||
```
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os, gzip
|
||||
# https://www.mischianti.org/2020/10/26/web-server-with-esp8266-and-esp32-byte-array-gzipped-pages-and-spiffs-2/
|
||||
@@ -27,8 +28,11 @@ def convert_to_gzip(src, out, f):
|
||||
f_out.write(top.encode(encoding='utf-8'))
|
||||
|
||||
|
||||
src='include/http/'
|
||||
out='include/'
|
||||
src='data/'
|
||||
out='compress/'
|
||||
|
||||
if not 'compress' in os.listdir():
|
||||
os.mkdir('compress')
|
||||
|
||||
for f in os.listdir(src):
|
||||
convert_to_gzip(src, out, f)
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os, gzip
|
||||
# https://stackoverflow.com/questions/8156707/gzip-a-file-in-python
|
||||
|
||||
src_dir='data'
|
||||
out_dir='data_gz'
|
||||
|
||||
if not 'data_gz' in os.listdir():
|
||||
os.mkdir('data_gz')
|
||||
|
||||
for f in os.listdir(src_dir):
|
||||
with open(f'{src_dir}/{f}', 'rb') as f_in:
|
||||
with gzip.open(f'{out_dir}/{f}.gz', 'wb') as f_out:
|
||||
f_out.writelines(f_in)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 209 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 531 B |
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>ESP8266 Treppenlicht</title>
|
||||
<!-- main style sheet -->
|
||||
<link href="/favicon.png" rel="icon" type="image/png" sizes="10x10">
|
||||
<link href="/style.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="kopfzeile" style="text-align: center;">
|
||||
<b>Treppenlicht</b>
|
||||
</div>
|
||||
|
||||
<div class="ueberschrift">
|
||||
Helligkeit
|
||||
<!--<label id="label_pwm">
|
||||
</label>-->
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="helligkeit" name="rangeInput" min="0" max="100" value="50"
|
||||
oninput="amount1.value=helligkeit.value">
|
||||
<br>
|
||||
<output name="amount1" id="amount1" for="helligkeit">50</output>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ueberschrift">
|
||||
Helligkeit bei Dunkelheit
|
||||
<!--<label id="label_pwm_dark">
|
||||
</label>-->
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="helligkeit_dunkel" name="rangeInput" min="0" max="100" value="50"
|
||||
oninput="amount2.value=helligkeit_dunkel.value">
|
||||
<br>
|
||||
<output name="amount2" id="amount2" for="helligkeit_dunkel">50</output>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ueberschrift">
|
||||
Laufgeschwindigkeit
|
||||
<!--<label id="label_geschwindigkeit">
|
||||
</label>-->
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="geschwindigkeit" name="rangeInput" min="0" max="100" value="50"
|
||||
oninput="amount3.value=geschwindigkeit.value">
|
||||
<br>
|
||||
<output name="amount3" id="amount3" for="geschwindigkeit">50</output>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ueberschrift">
|
||||
Licht-An-Zeit
|
||||
<!-- <label id="label_time">
|
||||
</label>-->
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="time" name="rangeInput" min="0" max="100" value="50"
|
||||
oninput="amount4.value=time.value">
|
||||
<br>
|
||||
<output name="amount4" id="amount4" for="time">50</output>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="terminal">
|
||||
<input type="button" id="clear_term" value="clear" onclick="clearTerminal();">
|
||||
<input type="checkbox" id="scroll" name="scroll" value="scroll" checked>
|
||||
<label for="scroll"> autoscroll </label>
|
||||
<textarea id="term">waiting for log messages ... </textarea>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<script src="/input.js"></script>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
// var slider = document.getElementById("helligkeit");
|
||||
// var output = document.getElementById("l_pwm");
|
||||
// output.innerHTML = slider.value; // Display the default slider value
|
||||
|
||||
// // Update the current slider value (each time you drag the slider handle)
|
||||
// slider.oninput = function() {
|
||||
// output.innerHTML = this.value;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.onreadystatechange = function(){
|
||||
if(xhr.readyState == 4) {
|
||||
if (xhr.status == 200){
|
||||
console.log(xhr.responseText);
|
||||
terminal = document.getElementById("term");
|
||||
autoscroll = document.getElementById("scroll");
|
||||
terminal.innerHTML += xhr.responseText;
|
||||
if(autoscroll.checked)
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
}
|
||||
else {
|
||||
console.log("status:", xhr.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reloadTerminal() {
|
||||
xhr.open("POST", "/app=terminal", true);
|
||||
xhr.send();
|
||||
setTimeout(reloadTerminal, 1000);
|
||||
};
|
||||
|
||||
reloadTerminal();
|
||||
|
||||
function clearTerminal() {
|
||||
document.getElementById("term").innerHTML = '';
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
html {
|
||||
font-size: 16px;
|
||||
font-family: sans-serif, Arial, Helvetica;
|
||||
background-color: #d4d4d4;
|
||||
height: 100%;
|
||||
/* background-image: url('Background.png'); */
|
||||
background-repeat: repeat;
|
||||
background-size: 150% 150%;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
margin: 0 auto;
|
||||
border: none;
|
||||
border-radius: 3;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
padding: 1em;
|
||||
background-color: #1f1f1f;
|
||||
color: white;
|
||||
font-size: x-large;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ueberschrift{
|
||||
color: #ffffff;
|
||||
font-size: 50px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.regler{
|
||||
|
||||
-webkit-appearance: none;
|
||||
height: 30px;
|
||||
width: 100%;
|
||||
border-radius: 20px;
|
||||
outline: black;
|
||||
background-color: rgb(176, 188, 228);
|
||||
}
|
||||
.regler::-webkit-slider-thumb{
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 5%;
|
||||
height: 20px;
|
||||
border-radius: 10px;
|
||||
background-color: rgb(107, 122, 192);
|
||||
cursor:pointer;
|
||||
}
|
||||
input[type=range]::-webkit-slider-thumb{
|
||||
-webkit-appearance: none;
|
||||
border:none;
|
||||
height: 30px;
|
||||
width: 4%;
|
||||
border-radius: 30px;
|
||||
}
|
||||
.slider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.kopfzeile{
|
||||
color: #1f1f1f;
|
||||
font-size: 50px;
|
||||
width: 100%;
|
||||
background-color: #8d8a8a;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------*/
|
||||
|
||||
|
||||
/*Switch:
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
Hide default HTML checkbox
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
*/
|
||||
/* The slider */
|
||||
|
||||
|
||||
/*input:checked + .slider {
|
||||
background-color: #04AA6D;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #04AA6D;
|
||||
}*/
|
||||
/*
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
}
|
||||
*/
|
||||
|
||||
.terminal {
|
||||
margin:5%;
|
||||
padding: 1%;
|
||||
width: 80%;
|
||||
border: 1px solid black;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#term {
|
||||
font-size: large;
|
||||
width: 100%;
|
||||
height: 20em;
|
||||
}
|
||||
|
||||
#clear_term {
|
||||
margin: 2px;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
Hardware Timer didnt work https://github.com/khoih-prog/ESP8266TimerInterrupt#why-using-isr-based-hardware-timer-interrupt-is-better
|
||||
|
||||
=> Software Timer https://ullisroboterseite.de/esp8266-timing.html#timer
|
||||
|
||||
|
||||
|
||||
|
||||
### __Zum aktivieren von GDBStub:__
|
||||
```c
|
||||
#include <GDBStub.h>
|
||||
|
||||
...
|
||||
|
||||
void setup() {
|
||||
Serial.begin(460800);
|
||||
gdbstub_init();
|
||||
```
|
||||
|
||||
### __Achtung !__
|
||||
GDB muss dafür compiled werden
|
||||
GDB-Version aus Arduino Toolchain hat Support
|
||||
|
||||
```sh
|
||||
$ ./start_xtensa_gdb_stub.sh
|
||||
```
|
||||
|
||||
### __Achtung !__
|
||||
Don`t forget __\r__
|
||||
|
||||
ESP-OTA wird von ufw oder Defender geblockt.
|
||||
- Windows -> Python needs to be granted with rights
|
||||
- Linux -> open udp port in ufw ->
|
||||
|
||||
```sh
|
||||
platform.ini
|
||||
upload_flags =
|
||||
--host-port <PORT>
|
||||
...
|
||||
$ sudo ufw allow tcp/<PORT>
|
||||
```
|
||||
|
||||
|
||||
```c++
|
||||
server.streamFile(f, mime::getContentType(SRH::_path), requestMethod);
|
||||
|
||||
=====>
|
||||
|
||||
const String& p = SRH::_path;
|
||||
if(p.endsWith(".gzip")) {
|
||||
server.sendHeader("Content-Encoding", "gzip");
|
||||
server.streamFile(f, mime::getContentType(p.substring(0, p.length()-5)), requestMethod);
|
||||
}
|
||||
else
|
||||
server.streamFile(f, mime::getContentType(SRH::_path), requestMethod);
|
||||
```
|
||||
|
||||
LED_sequence_v1:
|
||||
TODO:
|
||||
- disable led stripes after defined time (webserver paramter?)
|
||||
- define what to do if people enter stairs from different directions
|
||||
- CAUTION: Sensor-Deadtime at LEAST 8 seconds
|
||||
- --> switch off with person leaving stairs might not be possible
|
||||
|
||||
Webserver on v0.3.0 now working with LittleFS
|
||||
TODO:
|
||||
- check dir for files automatic
|
||||
- move handleNotFound to httpserver.h
|
||||
- maybe compress files ?
|
||||
|
||||
|
||||
### LED Flickering issue
|
||||
https://github.com/NachtRaveVL/PCA9685-Arduino/issues/15
|
||||
PlatformIO Library veraltet !!
|
||||
|
||||
|
||||
### TIMER in OTA unterbrechen !!!!!
|
||||
|
||||
|
||||
|
||||
### further improvments
|
||||
with streamFile gzip encoded Files can be sent
|
||||
this reduces space on fs !
|
||||
new easier script needed to just convert to .gz
|
||||
maybe measure timings on ESP
|
||||
|
||||
__=> use serveStatic because way simpler !__
|
||||
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 54 KiB |
@@ -1,23 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>My test page</title>
|
||||
<link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
|
||||
<link href="styles/style.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Mozilla is cool</h1>
|
||||
<p>At Mozilla, we’re a global community of</p>
|
||||
|
||||
<ul> <!-- changed to list in the tutorial -->
|
||||
<li>technologists</li>
|
||||
<li>thinkers</li>
|
||||
<li>builders</li>
|
||||
</ul>
|
||||
|
||||
<p>working together to keep the Internet alive and accessible, so people worldwide can be informed contributors and creators of the Web. We believe this act of human collaboration across an open platform is essential to individual growth and our collective future.</p>
|
||||
|
||||
<p>Read the <a href="https://www.mozilla.org/en-US/about/manifesto/">Mozilla Manifesto</a> to learn even more about the values and principles that guide the pursuit of our mission.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,41 +0,0 @@
|
||||
html {
|
||||
font-size: 10px;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
}
|
||||
|
||||
|
||||
h1 {
|
||||
font-size: 60px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
p, li {
|
||||
font-size: 16px;
|
||||
line-height: 2;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
|
||||
html {
|
||||
background-color: #00539F;
|
||||
}
|
||||
|
||||
body {
|
||||
width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #FF9500;
|
||||
padding: 0 20px 20px 20px;
|
||||
border: 5px solid black;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 20px 0;
|
||||
color: #00539F;
|
||||
text-shadow: 3px 3px 1px black;
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// filename: index.html.gz.h
|
||||
#define index_html_gz_len 573
|
||||
const char index_html_gz[] = {
|
||||
0x1F, 0x8B, 0x08, 0x00, 0xB4, 0x6E, 0xC7, 0x60, 0x02, 0xFF,
|
||||
0x8D, 0x53, 0xCB, 0x8E, 0xD4, 0x30, 0x10, 0xBC, 0x23, 0xF1,
|
||||
0x0F, 0xBD, 0xB9, 0xB2, 0x13, 0x6B, 0x6F, 0x08, 0x65, 0x82,
|
||||
0x10, 0x70, 0xE0, 0x30, 0x5A, 0xC4, 0x82, 0x10, 0x47, 0xC7,
|
||||
0xE9, 0x24, 0xD6, 0x38, 0x6E, 0xCB, 0x6E, 0x6F, 0x18, 0x4E,
|
||||
0xFC, 0x06, 0xBF, 0xC7, 0x97, 0xD0, 0xCE, 0x64, 0x16, 0x56,
|
||||
0x70, 0xE0, 0x92, 0x87, 0xAB, 0x1F, 0x55, 0xD5, 0xED, 0xE6,
|
||||
0xEA, 0xCD, 0xED, 0xEB, 0x8F, 0x5F, 0xDE, 0xBF, 0x85, 0x89,
|
||||
0x67, 0xD7, 0x3E, 0x7D, 0xD2, 0x6C, 0x6F, 0x80, 0x66, 0x42,
|
||||
0xDD, 0xAF, 0x5F, 0xF2, 0x3D, 0x23, 0x6B, 0x30, 0x93, 0x8E,
|
||||
0x09, 0x79, 0x5F, 0x65, 0x1E, 0x76, 0xCF, 0xAB, 0x0B, 0xC6,
|
||||
0x96, 0x1D, 0xB6, 0x87, 0x13, 0x30, 0x26, 0x86, 0xA0, 0x47,
|
||||
0x6C, 0xD4, 0xF9, 0x6C, 0x0B, 0x70, 0xD6, 0x1F, 0x61, 0x8A,
|
||||
0x38, 0xEC, 0xAB, 0x89, 0x39, 0xBC, 0x50, 0x6A, 0x20, 0xCF,
|
||||
0xA9, 0x1E, 0x89, 0x46, 0x87, 0x3A, 0xD8, 0x54, 0x1B, 0x9A,
|
||||
0x95, 0x49, 0xE9, 0xE5, 0xA0, 0x67, 0xEB, 0x4E, 0xFB, 0xDB,
|
||||
0x80, 0xFE, 0xD9, 0x9D, 0xF6, 0xA9, 0x82, 0x88, 0x6E, 0x5F,
|
||||
0x25, 0x3E, 0x39, 0x4C, 0x13, 0x22, 0x57, 0xC0, 0xA7, 0x80,
|
||||
0xFB, 0x8A, 0xF1, 0x2B, 0x97, 0x8C, 0xEA, 0x1F, 0x4D, 0xCE,
|
||||
0xD1, 0x6A, 0x7D, 0xD5, 0x25, 0xE6, 0xFF, 0x8A, 0x34, 0xEA,
|
||||
0x41, 0x71, 0xD3, 0x51, 0x7F, 0xBA, 0x54, 0x9E, 0x6E, 0xDA,
|
||||
0x03, 0x7D, 0xB3, 0xCE, 0x69, 0xB0, 0x09, 0x0C, 0x91, 0x93,
|
||||
0xC8, 0x9B, 0x0B, 0x1A, 0xDA, 0x57, 0x0C, 0x1B, 0x7E, 0x0D,
|
||||
0x0B, 0xFE, 0xFC, 0xFE, 0x23, 0x22, 0x68, 0x18, 0x1D, 0x75,
|
||||
0xDA, 0x49, 0xF8, 0x3C, 0x67, 0x6F, 0xF9, 0x04, 0x34, 0x34,
|
||||
0x2A, 0x48, 0xD6, 0x96, 0x97, 0x5D, 0x0B, 0xCD, 0xD5, 0x6E,
|
||||
0x57, 0x5C, 0xF5, 0x23, 0xF6, 0xC0, 0x04, 0xCE, 0x8A, 0x81,
|
||||
0xD6, 0x03, 0x4F, 0x08, 0x9C, 0x99, 0xA2, 0x95, 0x0A, 0xBB,
|
||||
0xDD, 0xD6, 0x6A, 0x15, 0xD9, 0x32, 0x9A, 0xC9, 0x93, 0xA3,
|
||||
0x51, 0x62, 0x53, 0xA3, 0xE4, 0xE4, 0x11, 0x3A, 0x89, 0x0D,
|
||||
0x18, 0xFF, 0x06, 0xBA, 0x6C, 0x5D, 0xFF, 0x18, 0x68, 0x54,
|
||||
0x76, 0xBF, 0xF9, 0x84, 0x76, 0xA1, 0x78, 0xB4, 0x7E, 0x14,
|
||||
0x22, 0x23, 0x0A, 0x83, 0x58, 0x18, 0x1D, 0x11, 0xC3, 0x4A,
|
||||
0xE7, 0x9D, 0x67, 0x8C, 0x1E, 0x19, 0xB4, 0xB3, 0xF7, 0xA2,
|
||||
0xCF, 0xF7, 0xA0, 0x8D, 0xC1, 0x94, 0x6C, 0xE7, 0xF0, 0x1A,
|
||||
0x12, 0x41, 0x40, 0x0A, 0x0E, 0x41, 0xAA, 0xB8, 0x7E, 0xB1,
|
||||
0x3D, 0x82, 0xD1, 0x1E, 0x3A, 0x14, 0x3D, 0x03, 0xC5, 0x59,
|
||||
0x04, 0x1A, 0x19, 0x7A, 0xB4, 0x5D, 0xD1, 0x95, 0xD6, 0x02,
|
||||
0x26, 0xA2, 0x5E, 0x7F, 0x68, 0x58, 0x7B, 0x7C, 0xC6, 0xAE,
|
||||
0x96, 0x87, 0x24, 0x39, 0x8B, 0xD2, 0x44, 0xC4, 0x48, 0xA0,
|
||||
0xE1, 0x82, 0x4F, 0x79, 0x96, 0x72, 0x86, 0xC4, 0xE5, 0x8E,
|
||||
0xA2, 0x66, 0x4B, 0x5E, 0xA0, 0x48, 0xA9, 0x94, 0x02, 0x92,
|
||||
0x7D, 0x81, 0xE0, 0x34, 0x97, 0x56, 0x65, 0x4A, 0x42, 0x0C,
|
||||
0x3D, 0x17, 0xFB, 0x44, 0x84, 0xF5, 0xBD, 0xBD, 0xB7, 0x7D,
|
||||
0x96, 0xBF, 0x31, 0xD2, 0xC2, 0xD3, 0xDA, 0x9D, 0x72, 0x5C,
|
||||
0xEB, 0xA1, 0xE1, 0xA2, 0x68, 0xC8, 0x9C, 0x23, 0xD6, 0x8F,
|
||||
0x66, 0x14, 0xDA, 0x0F, 0xB2, 0x11, 0x2B, 0xB7, 0x46, 0xFF,
|
||||
0xB1, 0xC1, 0x49, 0x56, 0x78, 0x59, 0x96, 0x7A, 0x3E, 0x8F,
|
||||
0xBD, 0xA6, 0x38, 0x2A, 0xF4, 0xBB, 0x4F, 0x77, 0x4A, 0xC8,
|
||||
0x65, 0x56, 0x42, 0xD5, 0x0E, 0x72, 0x19, 0x48, 0x55, 0x0F,
|
||||
0xAB, 0x73, 0xB8, 0x9C, 0x35, 0x4A, 0xB7, 0xEB, 0xB0, 0x51,
|
||||
0x47, 0x0F, 0xA2, 0xD3, 0xC3, 0x4C, 0x65, 0x65, 0x4A, 0xEA,
|
||||
0xDA, 0xEB, 0x5E, 0xBB, 0x8C, 0x67, 0x8B, 0x42, 0xB4, 0xDE,
|
||||
0x58, 0xF1, 0x35, 0x09, 0xA2, 0x19, 0xC6, 0x5C, 0x9C, 0x2D,
|
||||
0x41, 0x21, 0xC7, 0x94, 0xED, 0xEA, 0x4D, 0x51, 0x32, 0x5B,
|
||||
0x19, 0x05, 0xF9, 0x8D, 0x7F, 0x19, 0xEE, 0xB6, 0xC2, 0xB2,
|
||||
0xAB, 0xE7, 0x1B, 0xFD, 0x0B, 0xD0, 0xF5, 0x7E, 0xB7, 0xEB,
|
||||
0x03, 0x00, 0x00};
|
||||
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
|
||||
void ota_setup() {
|
||||
ArduinoOTA.setPort(8266);
|
||||
ArduinoOTA.setHostname("ESP_Treppenlicht");
|
||||
ArduinoOTA.setPassword("admin");
|
||||
// Password can be set with it's md5 value as well
|
||||
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
|
||||
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
|
||||
|
||||
ArduinoOTA.onStart([]() {
|
||||
String type;
|
||||
if (ArduinoOTA.getCommand() == U_FLASH) {
|
||||
type = "sketch";
|
||||
} else { // U_FS
|
||||
type = "filesystem";
|
||||
}
|
||||
|
||||
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
|
||||
Serial.println("Start updating " + type);
|
||||
});
|
||||
ArduinoOTA.onEnd([]() {
|
||||
Serial.println("\nEnd");
|
||||
});
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
|
||||
});
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
Serial.printf("Error[%u]: ", error);
|
||||
if (error == OTA_AUTH_ERROR) {
|
||||
Serial.println("Auth Failed");
|
||||
} else if (error == OTA_BEGIN_ERROR) {
|
||||
Serial.println("Begin Failed");
|
||||
} else if (error == OTA_CONNECT_ERROR) {
|
||||
Serial.println("Connect Failed");
|
||||
} else if (error == OTA_RECEIVE_ERROR) {
|
||||
Serial.println("Receive Failed");
|
||||
} else if (error == OTA_END_ERROR) {
|
||||
Serial.println("End Failed");
|
||||
}
|
||||
});
|
||||
ArduinoOTA.begin();
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
// filename: style.css.gz.h
|
||||
#define style_css_gz_len 283
|
||||
const char style_css_gz[] = {
|
||||
0x1F, 0x8B, 0x08, 0x00, 0xB4, 0x6E, 0xC7, 0x60, 0x02, 0xFF,
|
||||
0x75, 0x51, 0xC1, 0x8A, 0xC3, 0x20, 0x10, 0xBD, 0x17, 0xFA,
|
||||
0x0F, 0x03, 0x7B, 0xE8, 0xA5, 0x82, 0x6D, 0x49, 0xA1, 0xF6,
|
||||
0x9E, 0x6B, 0x0F, 0xFB, 0x05, 0x26, 0x1A, 0x33, 0xAC, 0xD1,
|
||||
0xA0, 0x96, 0xB6, 0xBB, 0xEC, 0xBF, 0xEF, 0x24, 0xA9, 0x59,
|
||||
0x4A, 0x76, 0x11, 0x15, 0x9E, 0xEF, 0xBD, 0x79, 0x33, 0xB6,
|
||||
0xA9, 0xB3, 0xF0, 0xB5, 0x5E, 0x01, 0x34, 0xDE, 0x25, 0x16,
|
||||
0xF1, 0x53, 0x0B, 0xD8, 0xF1, 0xFE, 0x7E, 0x9E, 0xB1, 0x46,
|
||||
0x76, 0x68, 0x1F, 0x02, 0x36, 0x97, 0x5E, 0x3B, 0x78, 0x97,
|
||||
0x2E, 0x6E, 0xB6, 0x10, 0xE9, 0x62, 0x51, 0x07, 0x6C, 0x88,
|
||||
0xF8, 0xBD, 0x5E, 0x0D, 0xAB, 0xDD, 0x2D, 0x9C, 0x8E, 0xD9,
|
||||
0x29, 0xE9, 0x7B, 0x62, 0xD2, 0xA2, 0x71, 0x02, 0x6A, 0xED,
|
||||
0x92, 0x0E, 0x59, 0xD7, 0x6F, 0xC1, 0xE2, 0x32, 0xC2, 0xF1,
|
||||
0x29, 0xB4, 0xE8, 0x34, 0x6B, 0x35, 0x9A, 0x36, 0x09, 0xD8,
|
||||
0x4F, 0x90, 0x4E, 0xA4, 0x67, 0xB1, 0x97, 0x35, 0x3A, 0x43,
|
||||
0xDC, 0x91, 0x9A, 0x43, 0xCC, 0x0D, 0x55, 0xB2, 0xFE, 0x30,
|
||||
0xC1, 0x5F, 0x9D, 0x62, 0xB5, 0xB7, 0x3E, 0x08, 0x78, 0xE3,
|
||||
0xBC, 0x38, 0x9C, 0xCA, 0x4C, 0xAE, 0xBC, 0x7A, 0x4C, 0xD4,
|
||||
0x1B, 0xAA, 0xD4, 0x0E, 0x69, 0x73, 0xDC, 0x4E, 0x06, 0x83,
|
||||
0x14, 0x95, 0x83, 0xBC, 0x26, 0x7F, 0xFE, 0xC7, 0xAE, 0x2C,
|
||||
0x4F, 0x05, 0xE7, 0xE3, 0x6B, 0x2F, 0x95, 0x1A, 0xC3, 0x70,
|
||||
0xD8, 0x93, 0xC9, 0xEF, 0x31, 0x69, 0x7D, 0x50, 0x9A, 0x14,
|
||||
0x05, 0x81, 0xD1, 0x5B, 0x54, 0x50, 0x59, 0xB2, 0xCB, 0x41,
|
||||
0xF2, 0xE0, 0xE6, 0xAA, 0xAF, 0x96, 0xA3, 0xD7, 0x84, 0x2D,
|
||||
0x1A, 0x79, 0x4E, 0x36, 0xB6, 0x52, 0xF9, 0x9B, 0x80, 0x03,
|
||||
0x31, 0x87, 0x4D, 0x23, 0x79, 0x2D, 0x81, 0x9D, 0x99, 0x6A,
|
||||
0x28, 0x8C, 0xBD, 0x95, 0xF4, 0x9D, 0x95, 0xF5, 0xE3, 0xF3,
|
||||
0x1F, 0xCD, 0x92, 0xE2, 0x07, 0x5A, 0x7D, 0xE2, 0xF6, 0x18,
|
||||
0x02, 0x00, 0x00};
|
||||
@@ -1,44 +0,0 @@
|
||||
|
||||
// filename: include/http/index.html.gz.h
|
||||
// uncompressed: index.html, gzip: 622
|
||||
#define index_html_gz 622
|
||||
const char index_html_gz[] = {
|
||||
0x1F, 0x8B, 0x08, 0x00, 0x22, 0x7E, 0xC2, 0x60, 0x02, 0xFF, 0x8D, 0x54, 0xCD, 0x6E, 0xD4, 0x30,
|
||||
0x10, 0xBE, 0xF3, 0x14, 0x43, 0xAE, 0x74, 0x63, 0xF5, 0x86, 0xAA, 0x6C, 0x10, 0x82, 0x22, 0x71,
|
||||
0xA8, 0x8A, 0x68, 0x11, 0xE2, 0xE8, 0x38, 0x93, 0xC4, 0xAA, 0xE3, 0xB1, 0xEC, 0x71, 0xB7, 0xCB,
|
||||
0x89, 0xD7, 0xE0, 0xF5, 0x78, 0x12, 0xC6, 0xCE, 0xB6, 0x2A, 0xEA, 0x85, 0x4B, 0x12, 0xCF, 0xDF,
|
||||
0xF7, 0x7D, 0x33, 0xE3, 0x74, 0xAF, 0x3F, 0x5E, 0x7F, 0xB8, 0xFD, 0xF1, 0xE5, 0x12, 0x16, 0x5E,
|
||||
0x5D, 0xFF, 0xAA, 0xDB, 0x5E, 0x00, 0xDD, 0x82, 0x7A, 0x2C, 0x1F, 0xF2, 0xB9, 0x22, 0x6B, 0x30,
|
||||
0x8B, 0x8E, 0x09, 0x79, 0xDF, 0x64, 0x9E, 0x76, 0x6F, 0x9B, 0x93, 0x8B, 0x2D, 0x3B, 0xEC, 0xAF,
|
||||
0x8E, 0xC0, 0x98, 0x18, 0x82, 0x9E, 0xB1, 0x53, 0x9B, 0x6D, 0xF3, 0x3B, 0xEB, 0xEF, 0x60, 0x89,
|
||||
0x38, 0xED, 0x9B, 0x85, 0x39, 0x5C, 0x28, 0x35, 0x91, 0xE7, 0xD4, 0xCE, 0x44, 0xB3, 0x43, 0x1D,
|
||||
0x6C, 0x6A, 0x0D, 0xAD, 0xCA, 0xA4, 0xF4, 0x6E, 0xD2, 0xAB, 0x75, 0xC7, 0xFD, 0x75, 0x40, 0xFF,
|
||||
0xE6, 0x46, 0xFB, 0xD4, 0x40, 0x44, 0xB7, 0x6F, 0x12, 0x1F, 0x1D, 0xA6, 0x05, 0x91, 0x1B, 0xE0,
|
||||
0x63, 0xC0, 0x7D, 0xC3, 0xF8, 0xC0, 0x25, 0xA3, 0x79, 0x89, 0xB1, 0x05, 0xAB, 0xFA, 0x6A, 0x4B,
|
||||
0xC8, 0x7F, 0xD5, 0xE8, 0xD4, 0xA3, 0xD8, 0x6E, 0xA0, 0xF1, 0x78, 0x2A, 0xBB, 0x9C, 0xF7, 0x57,
|
||||
0xF4, 0xD3, 0x3A, 0xA7, 0xC1, 0x26, 0x30, 0x44, 0x4E, 0xE2, 0xCE, 0x4F, 0x4E, 0xBB, 0xCE, 0x90,
|
||||
0xA2, 0xD9, 0x37, 0x76, 0x15, 0xCD, 0x49, 0x4D, 0x56, 0xF0, 0xE9, 0xA1, 0x0D, 0x7E, 0x6E, 0x40,
|
||||
0x3B, 0x69, 0xD3, 0xED, 0x82, 0xF0, 0x69, 0xB3, 0x82, 0xA3, 0x99, 0x2E, 0x40, 0xC3, 0xE4, 0x44,
|
||||
0xA3, 0x9F, 0xA1, 0xD8, 0x52, 0x8E, 0x91, 0xB2, 0x1F, 0xCB, 0x99, 0x25, 0xF6, 0x52, 0x47, 0x5E,
|
||||
0x5A, 0xE1, 0xB3, 0x01, 0x84, 0xFE, 0x3D, 0xC3, 0x09, 0xFF, 0x0C, 0x0E, 0xF8, 0xE7, 0xD7, 0xEF,
|
||||
0x88, 0x52, 0x62, 0x76, 0x34, 0x68, 0x27, 0x74, 0xD6, 0x35, 0x7B, 0xCB, 0x47, 0xA0, 0xA9, 0x53,
|
||||
0xE1, 0x31, 0x2B, 0xBB, 0x1E, 0xBA, 0xD7, 0xBB, 0x5D, 0x99, 0x96, 0x9F, 0x71, 0x04, 0x26, 0x70,
|
||||
0x56, 0x26, 0x63, 0x7D, 0x05, 0xE1, 0xCC, 0x14, 0xAD, 0xE4, 0xEF, 0x76, 0x9B, 0x90, 0xDA, 0xBE,
|
||||
0x9E, 0xD1, 0x2C, 0x9E, 0x84, 0xA5, 0x84, 0xA6, 0x4E, 0x89, 0xE5, 0xB9, 0x73, 0x91, 0xFE, 0x62,
|
||||
0x7C, 0x61, 0x1F, 0xB2, 0x75, 0xE3, 0x3F, 0xF6, 0x4E, 0x09, 0xFE, 0x13, 0xFF, 0x03, 0xC5, 0xBB,
|
||||
0x2A, 0x8E, 0x66, 0x14, 0xEC, 0x58, 0xB8, 0xDC, 0x21, 0x86, 0x4A, 0xE4, 0xB3, 0x67, 0x8C, 0x1E,
|
||||
0x59, 0x7A, 0x65, 0xEF, 0x45, 0x97, 0x1F, 0x41, 0x1B, 0x83, 0x29, 0xD9, 0xC1, 0xE1, 0x19, 0x24,
|
||||
0x82, 0x80, 0x14, 0x1C, 0x82, 0x54, 0x71, 0xE3, 0xC1, 0x8E, 0x08, 0x46, 0x7B, 0x18, 0x50, 0x94,
|
||||
0x4C, 0x14, 0x57, 0x91, 0x66, 0x64, 0x91, 0xA2, 0x1D, 0x8A, 0xA2, 0x54, 0x0B, 0x98, 0x88, 0xBA,
|
||||
0x1E, 0x68, 0xAA, 0x18, 0xDF, 0x71, 0x68, 0xE5, 0x21, 0x49, 0xCE, 0xA2, 0x80, 0x88, 0x10, 0x09,
|
||||
0x34, 0x5C, 0xFC, 0x4B, 0x5E, 0xA5, 0x9C, 0x21, 0xE9, 0xEE, 0x40, 0x51, 0xB3, 0x25, 0x2F, 0xAE,
|
||||
0x48, 0xA9, 0x94, 0x02, 0x92, 0x1D, 0x84, 0xE0, 0x34, 0x17, 0xA8, 0x32, 0x7D, 0x21, 0x86, 0x9E,
|
||||
0x4B, 0xE3, 0x44, 0x84, 0x95, 0xA1, 0xDD, 0xDB, 0x31, 0xCB, 0x69, 0x8E, 0x74, 0xE0, 0xA5, 0xA2,
|
||||
0x53, 0x8E, 0xB5, 0x1E, 0x1A, 0x2E, 0x8A, 0xA6, 0xCC, 0x39, 0x62, 0xFB, 0x6C, 0x36, 0xA1, 0xFF,
|
||||
0x2A, 0x5B, 0x56, 0x99, 0x75, 0xFA, 0xD9, 0x9D, 0x48, 0x72, 0x29, 0x0E, 0x87, 0x43, 0xBB, 0x6E,
|
||||
0xC3, 0x6E, 0x29, 0xCE, 0x0A, 0xFD, 0xEE, 0xDB, 0x8D, 0x12, 0x6A, 0x99, 0x95, 0x10, 0xB5, 0x93,
|
||||
0xDC, 0x2E, 0x52, 0xCD, 0xD3, 0x42, 0x5E, 0x3D, 0xDA, 0x3A, 0xA5, 0xFB, 0x3A, 0x64, 0xD4, 0xD1,
|
||||
0x83, 0xA8, 0xF4, 0xB0, 0x52, 0x59, 0x94, 0x92, 0x5A, 0xB1, 0xEE, 0xB5, 0xCB, 0xB8, 0x35, 0x28,
|
||||
0x44, 0xEB, 0x8D, 0x95, 0xAE, 0x26, 0xF1, 0x68, 0x86, 0x39, 0x97, 0xBE, 0x96, 0xA0, 0x90, 0x63,
|
||||
0xCA, 0xB6, 0x76, 0xA6, 0xE8, 0x58, 0xAD, 0x0C, 0x82, 0xFC, 0xC6, 0xBE, 0xCC, 0x75, 0xBB, 0x16,
|
||||
0xB2, 0xFF, 0xF5, 0xEF, 0xF0, 0x17, 0x2C, 0x3C, 0x3D, 0x28, 0x35, 0x04, 0x00, 0x00};
|
||||
Submodule
+1
Submodule lib/PCA9685-Arduino added at a70be39257.
-46
@@ -1,46 +0,0 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -0,0 +1,128 @@
|
||||
#include "filesys.h"
|
||||
|
||||
FSInfo fsinfo;
|
||||
|
||||
bool mount_fs() {
|
||||
if(!LittleFS.begin()) {
|
||||
Serial.println("[ERROR] LittleFS.info(), reset ...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!LittleFS.info(fsinfo)) {
|
||||
Serial.println("[ERROR] LittleFS.info(), reset ...");
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("Filesystem opened:\n\r");
|
||||
printf("\ttotalBytes:\t%d\n\r", fsinfo.totalBytes);
|
||||
printf("\tusedBytes:\t%d\n\r", fsinfo.usedBytes);
|
||||
printf("\tblockSize:\t%d\n\r", fsinfo.blockSize);
|
||||
printf("\tpageSize:\t%d\n\r", fsinfo.pageSize);
|
||||
printf("\tmaxOpenFiles:\t%d\n\r", fsinfo.maxOpenFiles);
|
||||
printf("\tmaxPathLength:\t%d\n\r", fsinfo.maxPathLength);
|
||||
printf("\n\r");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool format_fs() {
|
||||
printf("Formatting FS ! \n\r");
|
||||
return LittleFS.format();
|
||||
}
|
||||
|
||||
void ls(const char * dirname) {
|
||||
Serial.printf("ls -l %s\n\r", dirname);
|
||||
Dir root = LittleFS.openDir(dirname);
|
||||
|
||||
while (root.next()) {
|
||||
File file = root.openFile("r");
|
||||
|
||||
time_t lw = file.getLastWrite();
|
||||
struct tm * tmstruct = localtime(&lw);
|
||||
Serial.printf("%8d %02d %02d %02d:%02d %s\n\r",
|
||||
file.size(),
|
||||
tmstruct->tm_mon + 1,
|
||||
tmstruct->tm_mday,
|
||||
tmstruct->tm_hour,
|
||||
tmstruct->tm_min,
|
||||
root.fileName().c_str());
|
||||
file.close();
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
File open(const char * path) {
|
||||
return LittleFS.open(path, "r");
|
||||
}
|
||||
|
||||
|
||||
void printFile(const char * path) {
|
||||
Serial.printf("Reading file: %s\n\r", path);
|
||||
|
||||
File file = LittleFS.open(path, "r");
|
||||
if (!file) {
|
||||
Serial.println("Failed to open file for reading");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print("Read from file: ");
|
||||
while (file.available()) {
|
||||
Serial.write(file.read());
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
void writeFile(const char * path, const char * message) {
|
||||
Serial.printf("Writing file: %s\n\r", path);
|
||||
|
||||
File file = LittleFS.open(path, "w");
|
||||
if (!file) {
|
||||
Serial.println("Failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
if (file.print(message)) {
|
||||
Serial.println("File written");
|
||||
} else {
|
||||
Serial.println("Write failed");
|
||||
}
|
||||
delay(2000); // Make sure the CREATE and LASTWRITE times are different
|
||||
file.close();
|
||||
}
|
||||
|
||||
void appendFile(const char * path, const char * message) {
|
||||
Serial.printf("Appending to file: %s\n\r", path);
|
||||
|
||||
File file = LittleFS.open(path, "a");
|
||||
if (!file) {
|
||||
Serial.println("Failed to open file for appending");
|
||||
return;
|
||||
}
|
||||
if(file.print(message)) {
|
||||
Serial.println("Message appended");
|
||||
} else {
|
||||
Serial.println("Append failed");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
void renameFile(const char * path1, const char * path2) {
|
||||
Serial.printf("Renaming file %s to %s\n\r", path1, path2);
|
||||
if (LittleFS.rename(path1, path2)) {
|
||||
Serial.println("File renamed");
|
||||
} else {
|
||||
Serial.println("Rename failed");
|
||||
}
|
||||
}
|
||||
|
||||
void deleteFile(const char * path) {
|
||||
Serial.printf("Deleting file: %s\n\r", path);
|
||||
if (LittleFS.remove(path)) {
|
||||
Serial.println("File deleted");
|
||||
} else {
|
||||
Serial.println("Delete failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <LittleFS.h>
|
||||
|
||||
// some usefull wrappers for Filesystem
|
||||
|
||||
bool mount_fs();
|
||||
bool format_fs();
|
||||
|
||||
File open(const char * path);
|
||||
|
||||
void ls(const char * dirname);
|
||||
void printFile(const char * path);
|
||||
void writeFile(const char * path, const char * message);
|
||||
void appendFile(const char * path, const char * message);
|
||||
void renameFile(const char * path1, const char * path2);
|
||||
void deleteFile(const char * path);
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "httpserver.h"
|
||||
|
||||
|
||||
bool HTTPServer::start() {
|
||||
if(!mount_fs()) {
|
||||
logf("cant mount filesystem, EXIT !\n\r");
|
||||
return false;
|
||||
}
|
||||
logf("LittleFS mounted !\n\r");
|
||||
logf("root:\n\r");
|
||||
this->listRoot();
|
||||
logf("\n\r");
|
||||
|
||||
// default handler
|
||||
this->onNotFound([this]() {
|
||||
String message = "File Not Found\n\n";
|
||||
message += "URI: ";
|
||||
message += uri();
|
||||
message += "\nMethod: ";
|
||||
message += (method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += "\nArguments: ";
|
||||
message += args();
|
||||
message += "\n";
|
||||
|
||||
for (uint8_t i = 0; i < args(); i++) {
|
||||
message += " " + argName(i) + ": " + arg(i) + "\n";
|
||||
}
|
||||
send(404, "text/plain", message);
|
||||
});
|
||||
|
||||
// add static root file handler for http
|
||||
this->serveStatic("/", LittleFS, "/");
|
||||
this->begin();
|
||||
Serial.printf("Server active on Port 80 !\n\r");
|
||||
return true;
|
||||
}
|
||||
|
||||
void HTTPServer::logf(const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char temp[64];
|
||||
size_t len = vsnprintf(temp, sizeof(temp), format, args);
|
||||
Serial.print(log_prefix);
|
||||
Serial.write(temp, len);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void HTTPServer::logt(const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
// append logging string to local buffer
|
||||
if(tbuf_head < TBUF_LEN) {
|
||||
size_t len = vsnprintf(tbuf+tbuf_head, TBUF_LEN-tbuf_head, format, args);
|
||||
tbuf_head += len;
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void HTTPServer::start_apps() {
|
||||
// application handler
|
||||
this->on("/app=terminal", HTTP_POST, [this]() {
|
||||
if(tbuf_head) {
|
||||
send(200, "text/plain", tbuf);
|
||||
tbuf_head = 0;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Wrapper for ESP8266WebServer with Filesystem as HTTP source
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <stdarg.h>
|
||||
#include "filesys.h"
|
||||
|
||||
// debug log <ESP8266WebServer.h>
|
||||
// #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
||||
|
||||
#define TBUF_LEN 256
|
||||
|
||||
|
||||
class HTTPServer : public ESP8266WebServer {
|
||||
|
||||
private:
|
||||
const char* rootDir = "/";
|
||||
const char* log_prefix = "[HTTPServer] ";
|
||||
|
||||
size_t tbuf_head = 0;
|
||||
char tbuf[TBUF_LEN];
|
||||
|
||||
void listRoot() {
|
||||
ls(rootDir);
|
||||
}
|
||||
|
||||
public:
|
||||
HTTPServer(const int _port, const char* _rootDir) :
|
||||
ESP8266WebServer(_port), rootDir(_rootDir)
|
||||
{ }
|
||||
~HTTPServer()
|
||||
{
|
||||
Serial.printf("[HTTPServer] shut down ...\n\r");
|
||||
}
|
||||
|
||||
bool start();
|
||||
void start_apps();
|
||||
|
||||
void logf(const char *format, ...);
|
||||
void logt(const char *format, ...);
|
||||
};
|
||||
@@ -0,0 +1,237 @@
|
||||
//
|
||||
// Academic License - for use in teaching, academic research, and meeting
|
||||
// course requirements at degree granting institutions only. Not for
|
||||
// government, commercial, or other organizational use.
|
||||
//
|
||||
// File: FSMTreppe.cpp
|
||||
//
|
||||
// Code generated for Simulink model 'FSMTreppe'.
|
||||
//
|
||||
// Model version : 1.29
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Sat Jul 3 17:39:25 2021
|
||||
//
|
||||
// Target selection: ert.tlc
|
||||
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
|
||||
// Code generation objectives: Unspecified
|
||||
// Validation result: Not run
|
||||
//
|
||||
#include "FSMTreppe2.h"
|
||||
#include <stdint.h>
|
||||
|
||||
// Named constants for Chart: '<Root>/FSMTreppe'
|
||||
const uint8_t FSMTreppe_IN_abdimmen_hoch = 1U;
|
||||
const uint8_t FSMTreppe_IN_abdimmen_runter = 2U;
|
||||
const uint8_t FSMTreppe_IN_aufdimmen_hoch = 3U;
|
||||
const uint8_t FSMTreppe_IN_aufdimmen_runter = 4U;
|
||||
const uint8_t FSMTreppe_IN_inaktiv = 5U;
|
||||
const uint8_t FSMTreppe_IN_ruhezustand = 6U;
|
||||
const uint8_t FSMTreppe_IN_warten_hoch = 7U;
|
||||
const uint8_t FSMTreppe_IN_warten_runter = 8U;
|
||||
|
||||
// Model step function
|
||||
void FSMTreppeModelClass::step()
|
||||
{
|
||||
// Chart: '<Root>/FSMTreppe' incorporates:
|
||||
// Inport: '<Root>/anim_beendet'
|
||||
// Inport: '<Root>/ldr_schwelle'
|
||||
// Inport: '<Root>/sensor_oben'
|
||||
// Inport: '<Root>/sensor_unten'
|
||||
|
||||
if (FSMTreppe_DW.temporalCounter_i1 < 511U) {
|
||||
FSMTreppe_DW.temporalCounter_i1 = static_cast<uint16_t>
|
||||
(FSMTreppe_DW.temporalCounter_i1 + 1U);
|
||||
}
|
||||
|
||||
if (FSMTreppe_DW.is_active_c3_FSMTreppe == 0U) {
|
||||
FSMTreppe_DW.is_active_c3_FSMTreppe = 1U;
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_inaktiv;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
} else {
|
||||
switch (FSMTreppe_DW.is_c3_FSMTreppe) {
|
||||
case FSMTreppe_IN_abdimmen_hoch:
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 4U;
|
||||
if (FSMTreppe_U.anim_beendet || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
|
||||
{
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 1U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_abdimmen_runter:
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 7U;
|
||||
if (FSMTreppe_U.anim_beendet || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
|
||||
{
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 1U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_aufdimmen_hoch:
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 2U;
|
||||
if (FSMTreppe_U.anim_beendet || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
|
||||
{
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_aufdimmen_runter:
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 5U;
|
||||
if (FSMTreppe_U.anim_beendet || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
|
||||
{
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 6U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_inaktiv:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
if (FSMTreppe_U.ldr_schwelle == 1.0) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 1U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_ruhezustand:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 1U;
|
||||
if (FSMTreppe_U.sensor_unten) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 2U;
|
||||
} else if (FSMTreppe_U.sensor_oben) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 5U;
|
||||
} else if (FSMTreppe_U.ldr_schwelle == 0.0) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_inaktiv;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_warten_hoch:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
if (FSMTreppe_U.sensor_oben || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
|
||||
{
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 4U;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Outport: '<Root>/status'
|
||||
// case IN_warten_runter:
|
||||
FSMTreppe_Y.status = 6U;
|
||||
if (FSMTreppe_U.sensor_unten || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
|
||||
{
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 7U;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// End of Chart: '<Root>/FSMTreppe'
|
||||
}
|
||||
|
||||
// Model initialize function
|
||||
void FSMTreppeModelClass::initialize()
|
||||
{
|
||||
// (no initialization code required)
|
||||
}
|
||||
|
||||
// Model terminate function
|
||||
void FSMTreppeModelClass::terminate()
|
||||
{
|
||||
// (no terminate code required)
|
||||
}
|
||||
|
||||
// Constructor
|
||||
FSMTreppeModelClass::FSMTreppeModelClass() :
|
||||
FSMTreppe_DW(),
|
||||
FSMTreppe_U(),
|
||||
FSMTreppe_Y()
|
||||
{
|
||||
// Currently there is no constructor body generated.
|
||||
}
|
||||
|
||||
// Destructor
|
||||
FSMTreppeModelClass::~FSMTreppeModelClass()
|
||||
{
|
||||
// Currently there is no destructor body generated.
|
||||
}
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// Academic License - for use in teaching, academic research, and meeting
|
||||
// course requirements at degree granting institutions only. Not for
|
||||
// government, commercial, or other organizational use.
|
||||
//
|
||||
// File: FSMTreppe.h
|
||||
//
|
||||
// Code generated for Simulink model 'FSMTreppe'.
|
||||
//
|
||||
// Model version : 1.28
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Sat Jul 3 13:50:17 2021
|
||||
//
|
||||
// Target selection: ert.tlc
|
||||
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
|
||||
// Code generation objectives: Unspecified
|
||||
// Validation result: Not run
|
||||
//
|
||||
#ifndef RTW_HEADER_FSMTreppe_h_
|
||||
#define RTW_HEADER_FSMTreppe_h_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Class declaration for model FSMTreppe
|
||||
class FSMTreppeModelClass {
|
||||
// public data and function members
|
||||
public:
|
||||
// Block states (default storage) for system '<Root>'
|
||||
struct DW_FSMTreppe_T {
|
||||
uint16_t temporalCounter_i1; // '<Root>/FSMTreppe'
|
||||
uint8_t is_active_c3_FSMTreppe; // '<Root>/FSMTreppe'
|
||||
uint8_t is_c3_FSMTreppe; // '<Root>/FSMTreppe'
|
||||
};
|
||||
|
||||
// External inputs (root inport signals with default storage)
|
||||
struct ExtU_FSMTreppe_T {
|
||||
bool sensor_unten; // '<Root>/sensor_unten'
|
||||
bool sensor_oben; // '<Root>/sensor_oben'
|
||||
bool anim_beendet; // '<Root>/anim_beendet'
|
||||
double ldr_schwelle; // '<Root>/ldr_schwelle'
|
||||
};
|
||||
|
||||
// External outputs (root outports fed by signals with default storage)
|
||||
struct ExtY_FSMTreppe_T {
|
||||
uint8_t laufrichtung; // '<Root>/laufrichtung'
|
||||
uint8_t status; // '<Root>/status'
|
||||
uint8_t dimmrichtung; // '<Root>/dimmrichtung'
|
||||
};
|
||||
|
||||
// model initialize function
|
||||
void initialize();
|
||||
|
||||
// model step function
|
||||
void step();
|
||||
|
||||
// model terminate function
|
||||
void terminate();
|
||||
|
||||
// Constructor
|
||||
FSMTreppeModelClass();
|
||||
|
||||
// Destructor
|
||||
~FSMTreppeModelClass();
|
||||
|
||||
// Root-level structure-based inputs set method
|
||||
|
||||
// Root inports set method
|
||||
void setExternalInputs(const ExtU_FSMTreppe_T* pExtU_FSMTreppe_T)
|
||||
{
|
||||
FSMTreppe_U = *pExtU_FSMTreppe_T;
|
||||
}
|
||||
|
||||
// Root-level structure-based outputs get method
|
||||
|
||||
// Root outports get method
|
||||
const FSMTreppeModelClass::ExtY_FSMTreppe_T & getExternalOutputs() const
|
||||
{
|
||||
return FSMTreppe_Y;
|
||||
}
|
||||
|
||||
// private data and function members
|
||||
private:
|
||||
// Block states
|
||||
DW_FSMTreppe_T FSMTreppe_DW;
|
||||
|
||||
// External inputs
|
||||
ExtU_FSMTreppe_T FSMTreppe_U;
|
||||
|
||||
// External outputs
|
||||
ExtY_FSMTreppe_T FSMTreppe_Y;
|
||||
};
|
||||
|
||||
//-
|
||||
// The generated code includes comments that allow you to trace directly
|
||||
// back to the appropriate location in the model. The basic format
|
||||
// is <system>/block_name, where system is the system number (uniquely
|
||||
// assigned by Simulink) and block_name is the name of the block.
|
||||
//
|
||||
// Note that this particular code originates from a subsystem build,
|
||||
// and has its own system numbers different from the parent model.
|
||||
// Refer to the system hierarchy for this subsystem below, and use the
|
||||
// MATLAB hilite_system command to trace the generated code back
|
||||
// to the parent model. For example,
|
||||
//
|
||||
// hilite_system('FSM_Treppenlicht/FSMTreppe') - opens subsystem FSM_Treppenlicht/FSMTreppe
|
||||
// hilite_system('FSM_Treppenlicht/FSMTreppe/Kp') - opens and selects block Kp
|
||||
//
|
||||
// Here is the system hierarchy for this model
|
||||
//
|
||||
// '<Root>' : 'FSM_Treppenlicht'
|
||||
// '<S1>' : 'FSM_Treppenlicht/FSMTreppe'
|
||||
|
||||
#endif // RTW_HEADER_FSMTreppe_h_
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
@@ -0,0 +1,242 @@
|
||||
#include "treppe.h"
|
||||
|
||||
uint8_t Treppe::softstart_led(uint8_t led, uint16_t startval, uint16_t stopval){
|
||||
/*
|
||||
softstart task
|
||||
|
||||
- get's called at regular intervals (1ms at the moment)
|
||||
- dimms single led (0 - 15, PCA9685 outputs) with linear intervals vom startval to stopval
|
||||
- calculates pwm steps depending on startval, stopval and timeinterval
|
||||
- -> results in constanst speed
|
||||
- returns 1 if led dimming is running
|
||||
- returns 0 if led dimming is finished
|
||||
|
||||
*/
|
||||
|
||||
static uint8_t lastled = 255;
|
||||
static float current_pwm = 0;
|
||||
static float stepsize = 1.0;
|
||||
if(led != lastled){
|
||||
pwmController.setChannelPWM(led, (uint16_t)startval);
|
||||
lastled = led;
|
||||
current_pwm = startval;
|
||||
stepsize = INT_TIME*abs(stopval - startval)/(float)time_per_stair; // only valid at 1ms function call interval
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(startval > stopval){
|
||||
current_pwm -= stepsize;
|
||||
}
|
||||
else {
|
||||
current_pwm += stepsize;
|
||||
}
|
||||
// Serial.println((uint16_t)current_pwm);
|
||||
pwmController.setChannelPWM(led, (uint16_t)current_pwm);
|
||||
if(current_pwm > stopval - stepsize && current_pwm < stopval + stepsize){
|
||||
if(stopval == 0) pwmController.setChannelPWM(led, 0);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Treppe::ledsequence(){
|
||||
static int8_t led = 0;
|
||||
static uint16_t brightness = 0;
|
||||
static uint16_t lastbrightness = 0;
|
||||
static uint16_t status = 0;
|
||||
uint16_t status_build = 0;
|
||||
status_build |= direction << 8;
|
||||
status_build |= state;
|
||||
if(status_build != status){ // check if any parameter changed
|
||||
finish = 0; // set state unfinished -> start action
|
||||
if(direction) led = 0; // reset led counter depending of direction
|
||||
else led = stairs-1;
|
||||
if(state){
|
||||
brightness = active_brightness; // set brightness value depending of on/off
|
||||
lastbrightness = idle_brightness;
|
||||
}
|
||||
else{
|
||||
brightness = idle_brightness;
|
||||
lastbrightness = active_brightness;
|
||||
}
|
||||
status = status_build; // set parameter memory
|
||||
|
||||
Serial.printf("----Status Changed! onoff: %d, dir: %d\n", state, direction);
|
||||
}
|
||||
if(!finish){ // finish == 0 -> action pending
|
||||
if(!softstart_led(led,lastbrightness, brightness)){
|
||||
Serial.printf("one LED finished: led: %d, last: %d, curr %d\n",
|
||||
led, lastbrightness, brightness);
|
||||
|
||||
if(direction){
|
||||
led++;
|
||||
if(led >= stairs)
|
||||
finish = 1;
|
||||
}
|
||||
else{
|
||||
led--;
|
||||
if(led < 0)
|
||||
finish = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Treppe::rampe()
|
||||
{
|
||||
if(state) {
|
||||
finish = 0;
|
||||
state = 0;// set parameter memory
|
||||
}
|
||||
|
||||
if(!finish) {
|
||||
if(direction) { // aufwärts
|
||||
if(tick >= ticks_treppe-1) { // ziel erreicht
|
||||
Serial.println("[Treppe] oberster tick !");
|
||||
finish = 1;
|
||||
return;
|
||||
}
|
||||
tick++; // eins hoch
|
||||
}
|
||||
else { // abwärts
|
||||
if(tick <= 0) { // ziel erreicht
|
||||
Serial.println("[Treppe] unterster tick !");
|
||||
finish = 1;
|
||||
return;
|
||||
}
|
||||
tick--; // eins runter
|
||||
}
|
||||
|
||||
stufe = tick / ticks_pro_stufe;
|
||||
|
||||
float new_pwm = 0.0;
|
||||
if(an_aus) {
|
||||
new_pwm = differenz_pwm_pro_tick * (tick - ticks_pro_stufe*stufe);
|
||||
new_pwm += idle_brightness;
|
||||
if(direction) new_pwm += differenz_pwm_pro_tick;
|
||||
}
|
||||
else {
|
||||
new_pwm = active_brightness - differenz_pwm_pro_tick * (tick - ticks_pro_stufe*stufe);
|
||||
new_pwm += idle_brightness;
|
||||
if(direction) new_pwm -= differenz_pwm_pro_tick;
|
||||
}
|
||||
|
||||
pwmController.setChannelPWM(stufe, (uint16_t) new_pwm);
|
||||
Serial.printf("tick %04u, led %02d:%02u, pwm %4.1f\n",
|
||||
tick,
|
||||
stufe,
|
||||
(tick - ticks_pro_stufe*stufe),
|
||||
new_pwm
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Treppe::setup(){
|
||||
|
||||
pwmController.resetDevices();
|
||||
// Deactive PCA9685 Phase Balancer due to LED Flickering
|
||||
// https://github.com/NachtRaveVL/PCA9685-Arduino/issues/15
|
||||
// see also lib/PCA9685-Arduin/PCA9685.h:204
|
||||
pwmController.init(PCA9685_PhaseBalancer_None);
|
||||
//pwmController.init(PCA9685_PhaseBalancer_Linear);
|
||||
pwmController.setPWMFrequency(100);
|
||||
pwmController.setAllChannelsPWM(idle_brightness);
|
||||
|
||||
pinMode(A0, INPUT);
|
||||
pinMode(SENSOR_OBEN, INPUT);
|
||||
pinMode(SENSOR_UNTEN, INPUT);
|
||||
pinMode(OE, OUTPUT);
|
||||
digitalWrite(OE, 0);
|
||||
|
||||
Serial.printf("differenz_pwm_pro_tick %f\n", differenz_pwm_pro_tick);
|
||||
Serial.println("Hello from Treppe");
|
||||
Serial.print("Treppe: initial parameters: stairs=");
|
||||
Serial.println(stairs);
|
||||
}
|
||||
|
||||
void Treppe::print_state_on_change() {
|
||||
static FSMTreppeModelClass::ExtU_FSMTreppe_T last_in;
|
||||
static FSMTreppeModelClass::ExtY_FSMTreppe_T last_out;
|
||||
if(
|
||||
fsm_inputs.anim_beendet != last_in.anim_beendet ||
|
||||
fsm_inputs.sensor_oben != last_in.sensor_oben ||
|
||||
fsm_inputs.sensor_unten != last_in.sensor_unten ||
|
||||
fsm_outputs.dimmrichtung != last_out.dimmrichtung ||
|
||||
fsm_outputs.laufrichtung != last_out.laufrichtung ||
|
||||
fsm_outputs.status != last_out.status
|
||||
) {
|
||||
last_in.anim_beendet = fsm_inputs.anim_beendet;
|
||||
last_in.sensor_oben = fsm_inputs.sensor_oben;
|
||||
last_in.sensor_unten = fsm_inputs.sensor_unten;
|
||||
|
||||
Serial.printf("FSM IN: s_u: %d, s_o: %d, beendet: %d =>",
|
||||
fsm_inputs.sensor_oben, fsm_inputs.sensor_unten, fsm_inputs.anim_beendet);
|
||||
Serial.print(" step => ");
|
||||
Serial.printf("OUT: LR: %d DR: %d ST: %d\n",
|
||||
fsm_outputs.laufrichtung, fsm_outputs.dimmrichtung, fsm_outputs.status);
|
||||
}
|
||||
}
|
||||
|
||||
void Treppe::task(){
|
||||
//Serial.printf("LDR: %f\n", ((float)analogRead(A0))/1023.*3.68);
|
||||
|
||||
if(finish){
|
||||
direction = switch_direction;
|
||||
state = switch_state;
|
||||
}
|
||||
|
||||
fsm_inputs.ldr_schwelle = true;
|
||||
fsm_inputs.sensor_oben = read_sensor(SENSOR_OBEN);
|
||||
fsm_inputs.sensor_unten = read_sensor(SENSOR_UNTEN);
|
||||
fsm_inputs.anim_beendet = static_cast<bool>(finish);
|
||||
|
||||
FSMTreppe_Obj.setExternalInputs(&fsm_inputs);
|
||||
FSMTreppe_Obj.step();
|
||||
fsm_outputs = FSMTreppe_Obj.getExternalOutputs();
|
||||
print_state_on_change();
|
||||
|
||||
direction = fsm_outputs.laufrichtung;
|
||||
state = fsm_outputs.dimmrichtung;
|
||||
|
||||
// setTick(ticks_treppe);
|
||||
// setAnAus(1);
|
||||
// setDirection(0);
|
||||
// setState(0);
|
||||
|
||||
ledsequence();
|
||||
}
|
||||
|
||||
|
||||
uint16_t Treppe::setIdle(uint16_t _idle_brightness){
|
||||
idle_brightness = _idle_brightness;
|
||||
Serial.println("Treppe: idle brightness changed!");
|
||||
return idle_brightness;
|
||||
}
|
||||
uint16_t Treppe::setActive(uint16_t _active_brightness){
|
||||
active_brightness = _active_brightness;
|
||||
Serial.println("Treppe: active brightness changed!");
|
||||
return active_brightness;
|
||||
}
|
||||
uint16_t Treppe::setTime(uint16_t _time_per_stair){
|
||||
time_per_stair = _time_per_stair;
|
||||
Serial.println("Treppe: time changed!");
|
||||
return time_per_stair;
|
||||
}
|
||||
|
||||
void Treppe::setDirection(uint8_t _direction){
|
||||
switch_direction = _direction;
|
||||
Serial.printf("Treppe: switch_direction=%d!\n", switch_direction);
|
||||
if(finish) Serial.println("apply direction request immediately");
|
||||
else Serial.println("currently active, dir change afterwards");
|
||||
// to do: implement state command variable to determine dimm-state
|
||||
}
|
||||
|
||||
void Treppe::setState(uint8_t _state){
|
||||
if(state == _state) return;
|
||||
else {
|
||||
switch_state = _state;
|
||||
Serial.printf("Treppe: switch_state=%d!\n", switch_state);
|
||||
if(finish) Serial.println("apply state request immediately");
|
||||
else Serial.println("currently active, state changes after activity");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include "FSMTreppe/FSMTreppe2.h"
|
||||
#include "PCA9685.h"
|
||||
|
||||
#define SENSOR_OBEN 2
|
||||
#define SENSOR_UNTEN 12
|
||||
#define OE 14
|
||||
|
||||
#define INT_TIME 20 // interrupt intervall [ms]
|
||||
|
||||
class Treppe {
|
||||
private:
|
||||
|
||||
uint8_t stairs;
|
||||
uint16_t time_per_stair = 300; // dimmtime per stair [ms]
|
||||
uint16_t idle_brightness = 100;
|
||||
uint16_t active_brightness = 300;
|
||||
|
||||
uint8_t direction = 0;
|
||||
uint8_t switch_direction = 0;
|
||||
uint8_t state = 0;
|
||||
uint8_t switch_state = 0;
|
||||
bool finish = 1;
|
||||
|
||||
// alternative
|
||||
uint32_t tick = 0;
|
||||
uint32_t stufe = 0;
|
||||
uint8_t an_aus = 0;
|
||||
|
||||
uint32_t ticks_treppe = 0;
|
||||
uint32_t ticks_pro_stufe = 0;
|
||||
float differenz_pwm_pro_tick = 0.0;
|
||||
// alternative
|
||||
|
||||
// initialize with i2c-Address 0, use Wire Library
|
||||
PCA9685 pwmController;
|
||||
FSMTreppeModelClass FSMTreppe_Obj;
|
||||
FSMTreppeModelClass::ExtU_FSMTreppe_T fsm_inputs;
|
||||
FSMTreppeModelClass::ExtY_FSMTreppe_T fsm_outputs;
|
||||
void print_state_on_change();
|
||||
|
||||
const uint8_t FSMTreppe_IN_animation_down = 1U;
|
||||
const uint8_t FSMTreppe_IN_animation_up = 2U;
|
||||
const uint8_t FSMTreppe_IN_idle = 3U;
|
||||
|
||||
|
||||
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval);
|
||||
void ledsequence();
|
||||
void rampe();
|
||||
bool read_sensor(int sensor) {
|
||||
int pegel = digitalRead(sensor);
|
||||
return static_cast<bool>(pegel);
|
||||
}
|
||||
public:
|
||||
Treppe(uint8_t _stairs) : stairs(_stairs){
|
||||
FSMTreppe_Obj.initialize();
|
||||
|
||||
|
||||
|
||||
ticks_pro_stufe = time_per_stair / 20; // [ms]
|
||||
ticks_treppe = ticks_pro_stufe * stairs;
|
||||
|
||||
differenz_pwm_pro_tick = (float) (active_brightness - idle_brightness)
|
||||
/ (float) ticks_pro_stufe;
|
||||
}
|
||||
~Treppe() {
|
||||
FSMTreppe_Obj.terminate();
|
||||
}
|
||||
|
||||
void setup();
|
||||
void task(); // call periodically
|
||||
|
||||
// Parameter section
|
||||
uint16_t setIdle(uint16_t _idle_brightness);
|
||||
uint16_t setActive(uint16_t _active_brightness);
|
||||
uint16_t setTime(uint16_t _time_per_stair);
|
||||
|
||||
void setTick(uint32_t _tick) {
|
||||
tick = _tick;
|
||||
Serial.printf("Treppe: Tick: %u!\n", tick);
|
||||
}
|
||||
uint32_t getTicks() {
|
||||
return ticks_treppe;
|
||||
}
|
||||
|
||||
// Runtime Parameter section
|
||||
void setDirection(uint8_t _direction);
|
||||
void setState(uint8_t _state);
|
||||
void setAnAus(uint8_t _an_aus) {
|
||||
an_aus = _an_aus;
|
||||
}
|
||||
|
||||
uint8_t getState() { return state;};
|
||||
uint8_t getFinished() { return finish;};
|
||||
uint8_t getDirection() {return direction;};
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp01_1m]
|
||||
platform = espressif8266
|
||||
board = esp01_1m
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
|
||||
extra_scripts = pre:extra_script.py
|
||||
|
||||
; stuff for OTA
|
||||
; https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
|
||||
upload_protocol = espota
|
||||
upload_port = 192.168.10.94
|
||||
upload_flags =
|
||||
--port=8266
|
||||
--auth=admin
|
||||
|
||||
lib_deps =
|
||||
|
||||
# The exact version
|
||||
ottowinter/PCA9685 16-Channel PWM Driver Module Library @ 1.2.9
|
||||
@@ -0,0 +1,17 @@
|
||||
set remote hardware-breakpoint-limit 1
|
||||
set remote hardware-watchpoint-limit 1
|
||||
set remote interrupt-on-connect on
|
||||
set remote kill-packet off
|
||||
set remote symbol-lookup-packet off
|
||||
set remote verbose-resume-packet off
|
||||
mem 0x20000000 0x3fefffff ro cache
|
||||
mem 0x3ff00000 0x3fffffff rw
|
||||
mem 0x40000000 0x400fffff ro cache
|
||||
mem 0x40100000 0x4013ffff rw cache
|
||||
mem 0x40140000 0x5fffffff ro cache
|
||||
mem 0x60000000 0x60001fff rw
|
||||
set serial baud 460800
|
||||
|
||||
file .pio/build/debug/firmware.elf
|
||||
target remote /dev/ttyUSB0
|
||||
thb loop
|
||||
+87
-134
@@ -1,71 +1,75 @@
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#include "wifi_credentials.h"
|
||||
#ifdef WITH_DEBUGGING_ON
|
||||
#include <GDBStub.h> // debugging support via GDBStub over UART
|
||||
#endif
|
||||
|
||||
#include "PCA9685.h"
|
||||
|
||||
// Änderung
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
// OTA & WEB
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include "wifi_credentials.h"
|
||||
#include "ota.h"
|
||||
#include "httpserver.h"
|
||||
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <WiFiClient.h> // evtl weghauen ?
|
||||
// BOARD
|
||||
#define ESP12_LED 2
|
||||
#define NODEMCU_LED 16
|
||||
|
||||
#include "index.html.gz.h"
|
||||
#include "style.css.gz.h"
|
||||
// images are possible
|
||||
// maybe check out FS <- SPIFFS
|
||||
// PWM
|
||||
#include "treppe.h"
|
||||
os_timer_t timer1;
|
||||
uint8_t timer_flag = 0;
|
||||
Treppe stairs(16);
|
||||
|
||||
// WIFI
|
||||
const char* ssid = STASSID;
|
||||
const char* password = STAPSK;
|
||||
|
||||
const int led = 13;
|
||||
ESP8266WebServer server(80);
|
||||
// port 80, root directory of server '/'
|
||||
HTTPServer httpServer(80, "/");
|
||||
|
||||
void handleRootGz() {
|
||||
const char* dataType = "text/html";
|
||||
server.sendHeader(F("Content-Encoding"), F("gzip"));
|
||||
server.send(200, dataType, (const char*)index_html_gz, index_html_gz_len);
|
||||
uint32_t _t=0;
|
||||
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us")
|
||||
#define TIMEIF_US(_f, _l, _str) _t=micros(); _f; _t=micros()-_t; if(_t > _l) { SP_US(_str, _t); }
|
||||
|
||||
|
||||
void timerCallback(void *pArg)
|
||||
{
|
||||
*((int *) pArg) += 1;
|
||||
stairs.task();
|
||||
}
|
||||
|
||||
void handleCssGz() {
|
||||
const char* dataType = "text/css";
|
||||
server.sendHeader(F("Content-Encoding"), F("gzip"));
|
||||
server.send(200, dataType, (const char*)style_css_gz, style_css_gz_len);
|
||||
// ===============================================
|
||||
uint8_t inter = 0;
|
||||
ICACHE_RAM_ATTR void int_test(){
|
||||
inter = 1;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
#ifdef WITH_DEBUGGING_ON
|
||||
Serial.begin(460800);
|
||||
gdbstub_init();
|
||||
#else
|
||||
Serial.begin(76800);
|
||||
#endif
|
||||
|
||||
void handleNotFound() {
|
||||
digitalWrite(led, 1);
|
||||
String message = "File Not Found\n\n";
|
||||
message += "URI: ";
|
||||
message += server.uri();
|
||||
message += "\nMethod: ";
|
||||
message += (server.method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += "\nArguments: ";
|
||||
message += server.args();
|
||||
message += "\n";
|
||||
Serial.println(F("Booting ...."));
|
||||
|
||||
for (uint8_t i = 0; i < server.args(); i++) {
|
||||
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
|
||||
}
|
||||
//pinMode(NODEMCU_LED, OUTPUT);
|
||||
pinMode(ESP12_LED, OUTPUT);
|
||||
|
||||
server.send(404, "text/plain", message);
|
||||
digitalWrite(led, 0);
|
||||
}
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
void setup_webserver() {
|
||||
pinMode(led, OUTPUT);
|
||||
digitalWrite(led, 0);
|
||||
Serial.println("");
|
||||
|
||||
// Wait for connection
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||
Serial.println("Connection Failed! Rebooting...");
|
||||
delay(5000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
Serial.println("");
|
||||
@@ -74,97 +78,46 @@ void setup_webserver() {
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
//server.on("/", handleRoot);
|
||||
server.on("/", handleRootGz);
|
||||
server.on("/styles/style.css", handleCssGz);
|
||||
server.onNotFound(handleNotFound);
|
||||
ota_setup();
|
||||
|
||||
server.begin();
|
||||
Serial.println("HTTP server started");
|
||||
httpServer.start();
|
||||
httpServer.start_apps();
|
||||
|
||||
Serial.println("HTTP server started !");
|
||||
|
||||
stairs.setup();
|
||||
Serial.println("PCA9685 connected !");
|
||||
//attachInterrupt(digitalPinToInterrupt(2), int_test, RISING);
|
||||
//attachInterrupt(digitalPinToInterrupt(12), int_test, RISING);
|
||||
|
||||
os_timer_setfn(&timer1, timerCallback, &timer_flag);
|
||||
os_timer_arm(&timer1, 20, true);
|
||||
}
|
||||
|
||||
#include <random>
|
||||
|
||||
|
||||
PCA9685 pwmController;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Booting");
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
|
||||
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||
Serial.println("Connection Failed! Rebooting...");
|
||||
delay(5000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
// setup OTA
|
||||
ArduinoOTA.setPort(8266);
|
||||
ArduinoOTA.setHostname("ESP_Treppenlicht");
|
||||
ArduinoOTA.setPassword("admin");
|
||||
// Password can be set with it's md5 value as well
|
||||
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
|
||||
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
|
||||
|
||||
ArduinoOTA.onStart([]() {
|
||||
String type;
|
||||
if (ArduinoOTA.getCommand() == U_FLASH) {
|
||||
type = "sketch";
|
||||
} else { // U_FS
|
||||
type = "filesystem";
|
||||
}
|
||||
|
||||
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
|
||||
Serial.println("Start updating " + type);
|
||||
});
|
||||
ArduinoOTA.onEnd([]() {
|
||||
Serial.println("\nEnd");
|
||||
});
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
|
||||
});
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
Serial.printf("Error[%u]: ", error);
|
||||
if (error == OTA_AUTH_ERROR) {
|
||||
Serial.println("Auth Failed");
|
||||
} else if (error == OTA_BEGIN_ERROR) {
|
||||
Serial.println("Begin Failed");
|
||||
} else if (error == OTA_CONNECT_ERROR) {
|
||||
Serial.println("Connect Failed");
|
||||
} else if (error == OTA_RECEIVE_ERROR) {
|
||||
Serial.println("Receive Failed");
|
||||
} else if (error == OTA_END_ERROR) {
|
||||
Serial.println("End Failed");
|
||||
}
|
||||
});
|
||||
ArduinoOTA.begin();
|
||||
Serial.println("Ready");
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
setup_webserver();
|
||||
|
||||
pwmController.resetDevices(); // Software resets all PCA9685 devices on Wire line
|
||||
|
||||
pwmController.init(B000000); // Address pins A5-A0 set to B000000
|
||||
pwmController.setPWMFrequency(200); // Default is 200Hz, supports 24Hz to 1526Hz
|
||||
|
||||
pwmController.setChannelPWM(0, 128 << 4); // Set PWM to 128/255, but in 4096 land
|
||||
|
||||
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
|
||||
|
||||
}
|
||||
|
||||
uint32_t t;
|
||||
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("µs")
|
||||
#define TIMEIF_US(_str,_f, _l) t=micros(); _f; t=micros()-t; if(t > _l) { SP_US(_str, t); }
|
||||
uint32_t c = 0;
|
||||
|
||||
void loop() {
|
||||
TIMEIF_US("OTA", ArduinoOTA.handle(), 20000);
|
||||
// if(stairs.getState() == 0) {
|
||||
// delay(1000);
|
||||
|
||||
// // uint32_t t = rand() % stairs.getTicks();
|
||||
// // uint32_t d = rand() % 2;
|
||||
|
||||
// // stairs.setTick(t);
|
||||
// // stairs.setDirection(d);
|
||||
|
||||
// stairs.setDirection(!stairs.getDirection());
|
||||
// stairs.setState(1);
|
||||
// }
|
||||
if(inter){
|
||||
Serial.printf("interrupt\n");
|
||||
inter = 0;
|
||||
}
|
||||
if(c++%1000000 == 0)
|
||||
httpServer.logt("[%d] starting :)\n", c);
|
||||
|
||||
TIMEIF_US("HTTP", server.handleClient(), 20000);
|
||||
TIMEIF_US(ArduinoOTA.handle(), 10000, "OTA");
|
||||
TIMEIF_US(httpServer.handleClient(), 10000, "HTTP");
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
GDB_PATH=~/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.0-newlib4.0.0-gnu23-48f7b08/bin/xtensa-lx106-elf-gdb
|
||||
|
||||
cd ..
|
||||
echo "Starting gdb"
|
||||
$GDB_PATH -x scripts/gdboptions
|
||||
@@ -0,0 +1,84 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
description = ESP8266 Treppenlicht Steuerung
|
||||
default_envs = ota
|
||||
; test_dir = test
|
||||
data_dir = data_gz
|
||||
|
||||
[env:hardware]
|
||||
platform = espressif8266
|
||||
board = nodemcuv2
|
||||
framework = arduino
|
||||
|
||||
board_build.filesystem = littlefs
|
||||
board_build.ldscript = eagle.flash.4m1m.ld
|
||||
extra_scripts = pre:create_gz_files.py
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:serial]
|
||||
extends = env:hardware
|
||||
upload_protocol = esptool
|
||||
upload_speed = 921600
|
||||
|
||||
[env:ota]
|
||||
extends = env:hardware
|
||||
; OTA => https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
|
||||
upload_protocol = espota
|
||||
upload_port = <!! IP ADDRESS !!>
|
||||
upload_flags =
|
||||
--port=8266
|
||||
--host_port=<!! PORT !!>
|
||||
--auth=admin
|
||||
|
||||
|
||||
[env:debug]
|
||||
extends = env:hardware
|
||||
; look at doku.md
|
||||
build_flags = -DWITH_DEBUGGING_ON -Os -g3 -ggdb3
|
||||
upload_protocol = esptool
|
||||
upload_speed = 921600
|
||||
|
||||
|
||||
# This file is used compile and run tests located in the `unit` directory.
|
||||
# For more info, see:
|
||||
# https://docs.platformio.org/en/latest/plus/unit-testing.html
|
||||
# https://github.com/ThrowTheSwitch/Unity
|
||||
# https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityAssertionsReference.md
|
||||
|
||||
|
||||
|
||||
# To prepare coverage data for lcov, add ${coverage.build_flags} to env:test build flags
|
||||
# To actually generate coverage report:
|
||||
# $ `pio test` / run the test `program` manually
|
||||
# $ lcov --include (readlink -f ../espurna)'/*' --capture --directory .pio/build/test/ --output-file test.info
|
||||
# $ genhtml --ignore-errors source test.info --output-directory out
|
||||
|
||||
[coverage]
|
||||
build_flags = -lgcov -fprofile-arcs -ftest-coverage
|
||||
|
||||
[env:test]
|
||||
extends = env:hardware
|
||||
|
||||
|
||||
[env:native]
|
||||
platform = native
|
||||
test_build_project_src = true
|
||||
build_flags =
|
||||
-DMANUFACTURER="PLATFORMIO"
|
||||
-DDEVICE="TEST"
|
||||
-std=gnu++11
|
||||
-g
|
||||
-Os
|
||||
-I lib/treppe
|
||||
-I lib/PCA9685-Arduino
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// #include <Arduino.h>
|
||||
// #include <unity.h>
|
||||
|
||||
// String STR_TO_TEST;
|
||||
|
||||
// // void setUp(void) {
|
||||
// // // set stuff up here
|
||||
// // STR_TO_TEST = "Hello, world!";
|
||||
// // }
|
||||
|
||||
// // void tearDown(void) {
|
||||
// // // clean stuff up here
|
||||
// // STR_TO_TEST = "";
|
||||
// // }
|
||||
|
||||
// void test_led_builtin_pin_number(void) {
|
||||
// TEST_ASSERT_EQUAL(2, LED_BUILTIN);
|
||||
// }
|
||||
|
||||
// void test_string_concat(void) {
|
||||
// String hello = "Hello, ";
|
||||
// String world = "world!";
|
||||
// TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str());
|
||||
// }
|
||||
|
||||
|
||||
// void setup()
|
||||
// {
|
||||
// delay(2000); // service delay
|
||||
// UNITY_BEGIN();
|
||||
|
||||
// RUN_TEST(test_led_builtin_pin_number);
|
||||
// RUN_TEST(test_string_concat);
|
||||
|
||||
// UNITY_END(); // stop unit testing
|
||||
// }
|
||||
|
||||
// void loop()
|
||||
// {
|
||||
// }
|
||||
@@ -0,0 +1,47 @@
|
||||
// #include <Arduino.h>
|
||||
#include "treppe.h"
|
||||
#include <unity.h>
|
||||
|
||||
Treppe stairs(10);
|
||||
|
||||
void setUp(void) {
|
||||
// run before each test
|
||||
// set stuff up here
|
||||
stairs.setup();
|
||||
Serial.println("Treppe initialized !");
|
||||
Serial.println("PCA9685 connected !");
|
||||
}
|
||||
|
||||
void tearDown(void) {
|
||||
// clean stuff up here
|
||||
}
|
||||
|
||||
void test_set_state(void) {
|
||||
stairs.setState(1);
|
||||
TEST_ASSERT_EQUAL(1, stairs.getState());
|
||||
stairs.setState(0);
|
||||
TEST_ASSERT_EQUAL(0, stairs.getState());
|
||||
}
|
||||
|
||||
|
||||
void test_set_direction(void) {
|
||||
stairs.setDirection(1);
|
||||
TEST_ASSERT_EQUAL(1, stairs.getDirection());
|
||||
stairs.setDirection(0);
|
||||
TEST_ASSERT_EQUAL(0, stairs.getDirection());
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
delay(2000); // service delay
|
||||
UNITY_BEGIN();
|
||||
|
||||
RUN_TEST(test_set_state);
|
||||
RUN_TEST(test_set_direction);
|
||||
|
||||
UNITY_END(); // stop unit testing
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
CD .\data
|
||||
py.exe -m http.server
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
cd data
|
||||
python3 -m http.server
|
||||
Reference in new issue
Block a user