Browse Source

ledsequence updated

tags/v0.1.0
Dominik Bartsch 3 years ago
parent
commit
65e922b090
1 changed files with 25 additions and 36 deletions
  1. 25
    36
      src/main.cpp

+ 25
- 36
src/main.cpp View File

@@ -214,10 +214,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 +241,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 +257,25 @@ 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 uint32_t dimmtimer = 0;
static uint8_t direction = 1;
static uint8_t onoff = 1;

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;
}
if(millis() > 25000) onoff = 0;
TIMEIF_US("OTA", ArduinoOTA.handle(), 20000);
TIMEIF_US("HTTP", server.handleClient(), 20000);
=======

TIMEIF_US("OTA", ArduinoOTA.handle(), 1000);
TIMEIF_US("HTTP", server.handleClient(), 1000);
>>>>>>> d0b824963bd79fc436b4b312e49b48081860d8d4

}

Loading…
Cancel
Save