Compare commits
9
Commits
461c887ddf
...
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b51cce709a | ||
|
|
09aff91b31 | ||
|
|
36fd363d67 | ||
|
|
ee72092a3a | ||
|
|
a66ab2b1d0 | ||
|
|
6a7f2e6a4e | ||
|
|
49f9c9c217 | ||
|
|
61d6cde899 | ||
|
|
65e922b090 |
No files matched your search
Vendored
+7
-7
@@ -1,7 +1,7 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -23,9 +23,13 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="pwm">
|
||||
<label id="l_pwm"></label>
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
+70
-52
@@ -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>
|
||||
@@ -144,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
|
||||
|
||||
@@ -166,7 +198,11 @@ void setup() {
|
||||
delay(5000);
|
||||
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());
|
||||
@@ -205,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;
|
||||
@@ -221,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)){
|
||||
@@ -238,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;
|
||||
}
|
||||
}
|
||||
@@ -254,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;
|
||||
}
|
||||
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);
|
||||
=======
|
||||
TIMEIF_US("OTA", ArduinoOTA.handle(), 1000);
|
||||
|
||||
|
||||
if(millis() - dimmtimer > 2){
|
||||
//ledsequence(direction, onoff, 4);
|
||||
dimmtimer = millis();
|
||||
}
|
||||
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