Compare commits
7
Commits
v0.2.0
..
d17091651f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d17091651f | ||
|
|
4b608c42ca | ||
|
|
278f746b33 | ||
|
|
642ee7d0a6 | ||
|
|
6596346d3d | ||
|
|
b696703d45 | ||
|
|
baecaf02da |
No files matched your search
Vendored
+3
-1
@@ -10,6 +10,8 @@
|
|||||||
"vector": "cpp",
|
"vector": "cpp",
|
||||||
"string_view": "cpp",
|
"string_view": "cpp",
|
||||||
"memory": "cpp",
|
"memory": "cpp",
|
||||||
"ranges": "cpp"
|
"ranges": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"utility": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 531 B |
@@ -0,0 +1,40 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>ESP8266 Treppenlicht</title>
|
||||||
|
<!-- main style sheet -->
|
||||||
|
<link href="/favicon.png" rel="icon" type="image/png" sizes="16x16">
|
||||||
|
<link href="/style.css" rel="stylesheet" type="text/css">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="topbar">
|
||||||
|
ESP8266 Treppenlicht Controller
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<div class="brightness">
|
||||||
|
</div>
|
||||||
|
<div class="onoff">
|
||||||
|
toggle all
|
||||||
|
<label id="l_onoff"></label>
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox">
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="pwm">
|
||||||
|
<label id="label_pwm"></label>
|
||||||
|
<input type="range" min="1" max="100" value="50" class="rangeslider" id="range1">
|
||||||
|
</div>
|
||||||
|
<div class="timer">
|
||||||
|
<label id="label_timer"></label>
|
||||||
|
<input type="range" min="1" max="100" value="50" class="rangeslider" id="timer_range">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script src="/input.js"></script>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
var slider = document.getElementById("range1");
|
||||||
|
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;
|
||||||
|
}
|
||||||
+132
@@ -0,0 +1,132 @@
|
|||||||
|
html {
|
||||||
|
font-size: 10px;
|
||||||
|
font-family: sans-serif, Arial, Helvetica;
|
||||||
|
background-color: #b3b3b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar {
|
||||||
|
padding: 1em;
|
||||||
|
background-color: #1f1f1f;
|
||||||
|
|
||||||
|
color: white;
|
||||||
|
font-size: x-large;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control {
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p, li {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 2;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0 auto;
|
||||||
|
border: 1px solid black;
|
||||||
|
border-radius: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The switch - the box around the slider */
|
||||||
|
.switch {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
width: 60px;
|
||||||
|
height: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide default HTML checkbox */
|
||||||
|
.switch input {
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The slider */
|
||||||
|
.slider {
|
||||||
|
position: absolute;
|
||||||
|
cursor: pointer;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: #ccc;
|
||||||
|
-webkit-transition: .4s;
|
||||||
|
transition: .4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider:before {
|
||||||
|
position: absolute;
|
||||||
|
content: "";
|
||||||
|
height: 26px;
|
||||||
|
width: 26px;
|
||||||
|
left: 4px;
|
||||||
|
bottom: 4px;
|
||||||
|
background-color: white;
|
||||||
|
-webkit-transition: .4s;
|
||||||
|
transition: .4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
/* Rounded sliders */
|
||||||
|
.slider.round {
|
||||||
|
border-radius: 34px;
|
||||||
|
}
|
||||||
|
.slider.round:before {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The slider itself */
|
||||||
|
.rangeslider {
|
||||||
|
-webkit-appearance: none; /* Override default CSS styles */
|
||||||
|
appearance: none;
|
||||||
|
width: 50%; /* Full-width */
|
||||||
|
height: 34px; /* Specified height */
|
||||||
|
border-radius: 34px; /* range round corners */
|
||||||
|
background: #d3d3d3; /* Grey background */
|
||||||
|
outline: none; /* Remove outline */
|
||||||
|
opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */
|
||||||
|
-webkit-transition: .2s; /* 0.2 seconds transition on hover */
|
||||||
|
transition: opacity .2s;
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Mouse-over effects */
|
||||||
|
.rangeslider:hover {
|
||||||
|
opacity: 1; /* Fully shown on mouse-over */
|
||||||
|
}
|
||||||
|
/* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
|
||||||
|
.rangeslider::-webkit-slider-thumb {
|
||||||
|
-webkit-appearance: none; /* Override default look */
|
||||||
|
appearance: none;
|
||||||
|
width: 26px; /* Set a specific slider handle width */
|
||||||
|
height: 26px; /* Slider handle height */
|
||||||
|
border-radius: 50%; /* Round Element */
|
||||||
|
background: #04AA6D; /* Green background */
|
||||||
|
cursor: pointer; /* Cursor on hover */
|
||||||
|
}
|
||||||
|
.rangeslider::-moz-range-thumb {
|
||||||
|
width: 26px; /* Set a specific slider handle width */
|
||||||
|
height: 26px; /* Slider handle height */
|
||||||
|
background: #04AA6D; /* Green background */
|
||||||
|
cursor: pointer; /* Cursor on hover */
|
||||||
|
}
|
||||||
@@ -23,3 +23,33 @@ GDB-Version aus Arduino Toolchain hat Support
|
|||||||
```sh
|
```sh
|
||||||
$ ./start_xtensa_gdb_stub.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);
|
||||||
|
```
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef __FILESYS_H
|
||||||
|
#define __FILESYS_H
|
||||||
|
|
||||||
|
#include <LittleFS.h>
|
||||||
|
|
||||||
|
bool mount_fs();
|
||||||
|
bool format_fs();
|
||||||
|
|
||||||
|
void ls(const char * dirname);
|
||||||
|
void readFile(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);
|
||||||
|
#endif // __FILESYS_H
|
||||||
+133
@@ -0,0 +1,133 @@
|
|||||||
|
#include "filesys.h"
|
||||||
|
|
||||||
|
// listDir("/");
|
||||||
|
// deleteFile("/hello.txt");
|
||||||
|
// writeFile("/hello.txt", "Hello ");
|
||||||
|
// appendFile("/hello.txt", "World!\n\r");
|
||||||
|
// readFile("/hello.txt");
|
||||||
|
// listDir("/");
|
||||||
|
|
||||||
|
FSInfo fsinfo;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void readFile(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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+61
-81
@@ -13,38 +13,13 @@ extern "C" {
|
|||||||
#define ESP12_LED 2
|
#define ESP12_LED 2
|
||||||
#define NODEMCU_LED 16
|
#define NODEMCU_LED 16
|
||||||
|
|
||||||
|
|
||||||
os_timer_t Timer1; // Verwaltungsstruktur des Timers
|
|
||||||
|
|
||||||
int c;
|
|
||||||
bool toggle = false;
|
|
||||||
uint32_t m=0;
|
|
||||||
|
|
||||||
uint32_t dimmtimer = 0;
|
|
||||||
uint8_t direction = 1;
|
|
||||||
uint8_t onoff = 1;
|
|
||||||
|
|
||||||
|
|
||||||
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor);
|
|
||||||
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor);
|
|
||||||
|
|
||||||
void timerCallback(void *pArg)
|
|
||||||
{
|
|
||||||
*((int *) pArg) += 1;
|
|
||||||
|
|
||||||
ledsequence(direction, onoff, 4);
|
|
||||||
// Serial.print("[");
|
|
||||||
// Serial.print(micros()-m);
|
|
||||||
// Serial.print("] timerCallback\n");
|
|
||||||
// m = micros();
|
|
||||||
}
|
|
||||||
|
|
||||||
// OTA & WEB
|
// OTA & WEB
|
||||||
#include "wifi_credentials.h"
|
#include "wifi_credentials.h"
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
|
#include "filesys.h"
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
|
|
||||||
@@ -52,41 +27,23 @@ void timerCallback(void *pArg)
|
|||||||
#include "style.css.gz.h"
|
#include "style.css.gz.h"
|
||||||
#include "favicon.png.gz.h"
|
#include "favicon.png.gz.h"
|
||||||
// images are possible
|
// images are possible
|
||||||
// maybe check out FS <- SPIFFS
|
|
||||||
|
|
||||||
const char* ssid = STASSID;
|
const char* ssid = STASSID;
|
||||||
const char* password = STAPSK;
|
const char* password = STAPSK;
|
||||||
|
|
||||||
|
os_timer_t timer1;
|
||||||
|
int timer_arg;
|
||||||
|
|
||||||
void setup_webserver();
|
void setup_webserver();
|
||||||
void setup_ota();
|
void setup_ota();
|
||||||
void setup_pwm_pca9685();
|
void setup_pwm_pca9685();
|
||||||
void handleRootGz();
|
|
||||||
void handleCssGz();
|
|
||||||
void handleNotFound();
|
void handleNotFound();
|
||||||
|
|
||||||
const int led = 13;
|
const int led = 13;
|
||||||
ESP8266WebServer server(80);
|
ESP8266WebServer server(80);
|
||||||
PCA9685 pwmController;
|
PCA9685 pwmController;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
void handleFaviconGz() {
|
|
||||||
const char* dataType = "image/png";
|
|
||||||
server.sendHeader(F("Content-Encoding"), F("gzip"));
|
|
||||||
server.send(200, dataType, (const char*)favicon_png_gz, favicon_png_gz_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleNotFound() {
|
void handleNotFound() {
|
||||||
digitalWrite(led, 1);
|
|
||||||
String message = "File Not Found\n\n";
|
String message = "File Not Found\n\n";
|
||||||
message += "URI: ";
|
message += "URI: ";
|
||||||
message += server.uri();
|
message += server.uri();
|
||||||
@@ -99,36 +56,23 @@ void handleNotFound() {
|
|||||||
for (uint8_t i = 0; i < server.args(); i++) {
|
for (uint8_t i = 0; i < server.args(); i++) {
|
||||||
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
|
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
server.send(404, "text/plain", message);
|
server.send(404, "text/plain", message);
|
||||||
digitalWrite(led, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setup_webserver() {
|
void setup_webserver() {
|
||||||
pinMode(led, OUTPUT);
|
// //experimental, see doku.md
|
||||||
digitalWrite(led, 0);
|
// server.serveStatic("/compressed", LittleFS, "/compressed.html.gzip");
|
||||||
Serial.println("");
|
|
||||||
|
|
||||||
// Wait for connection
|
server.serveStatic("", LittleFS, "/index.html");
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
server.serveStatic("/", LittleFS, "/index.html");
|
||||||
delay(500);
|
server.serveStatic("/#", LittleFS, "/index.html");
|
||||||
Serial.print(".");
|
server.serveStatic("/style.css", LittleFS, "/style.css");
|
||||||
}
|
server.serveStatic("/index.js", LittleFS, "/index.js");
|
||||||
|
server.serveStatic("/favicon.png", LittleFS, "/favicon.png");
|
||||||
Serial.println("");
|
|
||||||
Serial.print("Connected to ");
|
|
||||||
Serial.println(ssid);
|
|
||||||
Serial.print("IP address: ");
|
|
||||||
Serial.println(WiFi.localIP());
|
|
||||||
|
|
||||||
server.on("/", handleRootGz);
|
|
||||||
server.on("/style.css", handleCssGz);
|
|
||||||
server.on("/favicon.png", handleFaviconGz);
|
|
||||||
server.onNotFound(handleNotFound);
|
server.onNotFound(handleNotFound);
|
||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
Serial.println("HTTP server started");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_ota() {
|
void setup_ota() {
|
||||||
@@ -182,6 +126,23 @@ void setup_pwm_pca9685() {
|
|||||||
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
|
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t dimmtimer = 0;
|
||||||
|
uint8_t direction = 1;
|
||||||
|
uint8_t onoff = 1;
|
||||||
|
|
||||||
|
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor);
|
||||||
|
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor);
|
||||||
|
|
||||||
|
uint8_t flag = 0;
|
||||||
|
void timer_callback(void *pArg)
|
||||||
|
{
|
||||||
|
*((int *) pArg) += 1;
|
||||||
|
|
||||||
|
flag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
#ifdef WITH_DEBUGGING_ON
|
#ifdef WITH_DEBUGGING_ON
|
||||||
Serial.begin(460800);
|
Serial.begin(460800);
|
||||||
@@ -192,6 +153,12 @@ void setup() {
|
|||||||
|
|
||||||
Serial.println(F("Booting ...."));
|
Serial.println(F("Booting ...."));
|
||||||
|
|
||||||
|
mount_fs();
|
||||||
|
//format_fs();
|
||||||
|
ls("/");
|
||||||
|
ls("http/");
|
||||||
|
// readFile("/test.txt");
|
||||||
|
|
||||||
pinMode(NODEMCU_LED, OUTPUT);
|
pinMode(NODEMCU_LED, OUTPUT);
|
||||||
pinMode(ESP12_LED, OUTPUT);
|
pinMode(ESP12_LED, OUTPUT);
|
||||||
|
|
||||||
@@ -207,22 +174,29 @@ void setup() {
|
|||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
os_timer_setfn(&Timer1, timerCallback, &c);
|
pinMode(led, OUTPUT);
|
||||||
os_timer_arm(&Timer1, 1, true);
|
digitalWrite(led, 0);
|
||||||
|
Serial.println("");
|
||||||
|
Serial.print("Connected to ");
|
||||||
|
Serial.println(ssid);
|
||||||
|
Serial.print("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
|
os_timer_setfn(&timer1, timer_callback, &timer_arg);
|
||||||
|
os_timer_arm(&timer1, 1000, true);
|
||||||
|
|
||||||
Serial.println("Ready");
|
Serial.println("Ready");
|
||||||
Serial.print("IP address: ");
|
Serial.print("IP address: ");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
setup_ota();
|
setup_ota();
|
||||||
setup_webserver();
|
|
||||||
setup_pwm_pca9685();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t t;
|
setup_webserver();
|
||||||
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("µs")
|
Serial.println("HTTP server started !");
|
||||||
#define TIMEIF_US(_str,_f, _l) t=micros(); _f; t=micros()-t; if(t > _l) { SP_US(_str, t); }
|
|
||||||
|
setup_pwm_pca9685();
|
||||||
|
Serial.println("PCA9685 connected !");
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor){
|
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor){
|
||||||
static uint8_t lastled = 255;
|
static uint8_t lastled = 255;
|
||||||
@@ -306,11 +280,11 @@ void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 loop() {
|
void loop() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(millis() - dimmtimer > 2){
|
if(millis() - dimmtimer > 2){
|
||||||
//ledsequence(direction, onoff, 4);
|
//ledsequence(direction, onoff, 4);
|
||||||
dimmtimer = millis();
|
dimmtimer = millis();
|
||||||
@@ -320,6 +294,12 @@ void loop() {
|
|||||||
onoff = 1;
|
onoff = 1;
|
||||||
direction = 0;
|
direction = 0;
|
||||||
}
|
}
|
||||||
TIMEIF_US("OTA", ArduinoOTA.handle(), 1000);
|
TIMEIF_US(ArduinoOTA.handle(), 1000, "OTA");
|
||||||
TIMEIF_US("HTTP", server.handleClient(), 1000);
|
TIMEIF_US(server.handleClient(), 1000, "HTTP");
|
||||||
|
|
||||||
|
if(flag) {
|
||||||
|
flag = 0;
|
||||||
|
ledsequence(direction, onoff, 4);
|
||||||
|
Serial.printf("[%lu] interrupt\n\r", millis());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,23 +12,29 @@
|
|||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
board = nodemcuv2
|
board = nodemcuv2
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
|
; for http files
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
board_build.ldscript = eagle.flash.4m1m.ld
|
||||||
|
extra_scripts = pre:create_gz_files.py
|
||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
extra_scripts = pre:extra_script.py
|
|
||||||
|
|
||||||
[env:serial]
|
[env:serial]
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
|
|
||||||
[env:ota]
|
[env:ota]
|
||||||
; stuff for OTA
|
; OTA => https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
|
||||||
; https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
|
|
||||||
upload_protocol = espota
|
upload_protocol = espota
|
||||||
upload_port = <!! IP ADDRESS !!>
|
upload_port = <!! IP ADDRESS !!>
|
||||||
upload_flags =
|
upload_flags =
|
||||||
--port=8266
|
--port=8266
|
||||||
|
--host_port=<!! PORT !!>
|
||||||
--auth=admin
|
--auth=admin
|
||||||
|
|
||||||
[env:debug]
|
[env:debug]
|
||||||
|
; look at doku.md
|
||||||
build_flags = -DWITH_DEBUGGING_ON -Os -g3 -ggdb3
|
build_flags = -DWITH_DEBUGGING_ON -Os -g3 -ggdb3
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
|
|||||||
Reference in new issue
Block a user