Compare commits
11
Commits
055a6193df
...
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b51cce709a | ||
|
|
09aff91b31 | ||
|
|
36fd363d67 | ||
|
|
ee72092a3a | ||
|
|
a66ab2b1d0 | ||
|
|
6a7f2e6a4e | ||
|
|
49f9c9c217 | ||
|
|
61d6cde899 | ||
|
|
65e922b090 | ||
|
|
461c887ddf | ||
|
|
e7cf45c45e |
No files matched your search
@@ -0,0 +1,3 @@
|
||||
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
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 531 B |
+31
-14
@@ -1,23 +1,40 @@
|
||||
<!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="style.css" rel="stylesheet" type="text/css">
|
||||
<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>
|
||||
<h1>Mozilla is cool</h1>
|
||||
<p>At Mozilla, we’re a global community of</p>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<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;
|
||||
}
|
||||
+110
-19
@@ -1,14 +1,22 @@
|
||||
html {
|
||||
font-size: 10px;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-family: sans-serif, Arial, Helvetica;
|
||||
background-color: #b3b3b3;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
padding: 1em;
|
||||
background-color: #1f1f1f;
|
||||
|
||||
h1 {
|
||||
font-size: 60px;
|
||||
color: white;
|
||||
font-size: x-large;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.control {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
p, li {
|
||||
font-size: 16px;
|
||||
line-height: 2;
|
||||
@@ -16,26 +24,109 @@ p, li {
|
||||
}
|
||||
|
||||
|
||||
html {
|
||||
background-color: #00539F;
|
||||
}
|
||||
|
||||
body {
|
||||
width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #FF9500;
|
||||
padding: 0 20px 20px 20px;
|
||||
border: 5px solid black;
|
||||
border: 1px solid black;
|
||||
border-radius: 3;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 20px 0;
|
||||
color: #00539F;
|
||||
text-shadow: 3px 3px 1px black;
|
||||
|
||||
|
||||
/* The switch - the box around the slider */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
/* 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 */
|
||||
}
|
||||
+73
-48
@@ -2,8 +2,39 @@
|
||||
#include <Wire.h>
|
||||
|
||||
#include "PCA9685.h"
|
||||
#include <GDBStub.h>
|
||||
|
||||
#define ESP12_LED 2
|
||||
#define NODEMCU_LED 16
|
||||
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
// Änderung
|
||||
// OTA & WEB
|
||||
#include "wifi_credentials.h"
|
||||
#include <ESP8266WiFi.h>
|
||||
@@ -15,6 +46,7 @@
|
||||
|
||||
#include "index.html.gz.h"
|
||||
#include "style.css.gz.h"
|
||||
#include "favicon.png.gz.h"
|
||||
// images are possible
|
||||
// maybe check out FS <- SPIFFS
|
||||
|
||||
@@ -43,6 +75,11 @@ void handleCssGz() {
|
||||
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() {
|
||||
digitalWrite(led, 1);
|
||||
@@ -83,6 +120,7 @@ void setup_webserver() {
|
||||
|
||||
server.on("/", handleRootGz);
|
||||
server.on("/style.css", handleCssGz);
|
||||
server.on("/favicon.png", handleFaviconGz);
|
||||
server.onNotFound(handleNotFound);
|
||||
|
||||
server.begin();
|
||||
@@ -137,17 +175,18 @@ void setup_pwm_pca9685() {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.begin(460800);
|
||||
gdbstub_init();
|
||||
|
||||
Serial.println(F("Booting ...."));
|
||||
|
||||
pinMode(NODEMCU_LED, OUTPUT);
|
||||
pinMode(ESP12_LED, OUTPUT);
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
|
||||
@@ -160,6 +199,10 @@ void setup() {
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
os_timer_setfn(&Timer1, timerCallback, &c);
|
||||
os_timer_arm(&Timer1, 1, true);
|
||||
|
||||
|
||||
Serial.println("Ready");
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
@@ -198,7 +241,7 @@ uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define LEDCOUNT 13
|
||||
#define LEDCOUNT 16
|
||||
|
||||
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){
|
||||
static int8_t led = 0;
|
||||
@@ -214,10 +257,20 @@ void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){
|
||||
finish = 0; // set state unfinished -> start action
|
||||
if(direction) led = 0; // reset led counter depending of direction
|
||||
else led = LEDCOUNT-1;
|
||||
if(onoff) brightness = 127; // set brightness value depending of on/off
|
||||
else brightness = 0;
|
||||
if(onoff){
|
||||
brightness = 127; // set brightness value depending of on/off
|
||||
lastbrightness = 0;
|
||||
}
|
||||
else{
|
||||
brightness = 0;
|
||||
lastbrightness = 127;
|
||||
}
|
||||
status = status_build; // set parameter memory
|
||||
Serial.println("----Status Changed!");
|
||||
Serial.print("----Status Changed! onoff: ");
|
||||
Serial.print(onoff);
|
||||
Serial.print(" dir: ");
|
||||
Serial.println(direction);
|
||||
|
||||
}
|
||||
if(!finish){ // finish == 0 -> action pending
|
||||
if(!softstart_led(led,lastbrightness, brightness, factor)){
|
||||
@@ -231,13 +284,13 @@ void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){
|
||||
led++;
|
||||
if(led >= LEDCOUNT) {
|
||||
finish = 1;
|
||||
lastbrightness = brightness;
|
||||
//lastbrightness = brightness;
|
||||
}
|
||||
}
|
||||
else{
|
||||
led--;
|
||||
if(led < 0){
|
||||
lastbrightness = brightness;
|
||||
//lastbrightness = brightness;
|
||||
finish = 1;
|
||||
}
|
||||
}
|
||||
@@ -247,46 +300,18 @@ void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){
|
||||
|
||||
|
||||
void loop() {
|
||||
<<<<<<< HEAD
|
||||
static uint32_t dimmtimer = 0;
|
||||
/* static uint8_t led = 0;
|
||||
static uint16_t brightness = 127;
|
||||
static uint16_t lastbrightness = 0;
|
||||
|
||||
|
||||
|
||||
if(millis() - dimmtimer > 2){
|
||||
if(softstart_led(led, lastbrightness, brightness)){
|
||||
// do nothing
|
||||
}
|
||||
else{
|
||||
if(led < LEDCOUNT-1) led++;
|
||||
else {
|
||||
led = 0;
|
||||
uint16_t mem = lastbrightness;
|
||||
lastbrightness = brightness;
|
||||
brightness = mem;
|
||||
}
|
||||
softstart_led((led), lastbrightness, brightness);
|
||||
}
|
||||
if(led >= LEDCOUNT){
|
||||
//led = 0;
|
||||
//uint16_t mem = lastbrightness;
|
||||
//lastbrightness = brightness;
|
||||
// brightness = mem;
|
||||
}
|
||||
//ledsequence(direction, onoff, 4);
|
||||
dimmtimer = millis();
|
||||
}*/
|
||||
|
||||
static uint8_t direction = 1;
|
||||
static uint8_t onoff = 1;
|
||||
if(millis() - dimmtimer > 2){
|
||||
ledsequence(direction, onoff, 4);
|
||||
}
|
||||
if(millis() > 25000) onoff = 0;
|
||||
TIMEIF_US("OTA", ArduinoOTA.handle(), 20000);
|
||||
TIMEIF_US("HTTP", server.handleClient(), 20000);
|
||||
=======
|
||||
if(millis() > 25000 && onoff == 1 && direction == 1) onoff = 0;
|
||||
if(millis() > 35000 && direction == 1){
|
||||
onoff = 1;
|
||||
direction = 0;
|
||||
}
|
||||
TIMEIF_US("OTA", ArduinoOTA.handle(), 1000);
|
||||
|
||||
TIMEIF_US("HTTP", server.handleClient(), 1000);
|
||||
>>>>>>> d0b824963bd79fc436b4b312e49b48081860d8d4
|
||||
}
|
||||
Whitespace-only changes.
Reference in new issue
Block a user