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

finish = 0; // set state unfinished -> start action finish = 0; // set state unfinished -> start action
if(direction) led = 0; // reset led counter depending of direction if(direction) led = 0; // reset led counter depending of direction
else led = LEDCOUNT-1; 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 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(!finish){ // finish == 0 -> action pending
if(!softstart_led(led,lastbrightness, brightness, factor)){ if(!softstart_led(led,lastbrightness, brightness, factor)){
led++; led++;
if(led >= LEDCOUNT) { if(led >= LEDCOUNT) {
finish = 1; finish = 1;
lastbrightness = brightness;
//lastbrightness = brightness;
} }
} }
else{ else{
led--; led--;
if(led < 0){ if(led < 0){
lastbrightness = brightness;
//lastbrightness = brightness;
finish = 1; finish = 1;
} }
} }




void loop() { 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 direction = 1;
static uint8_t onoff = 1; static uint8_t onoff = 1;

if(millis() - dimmtimer > 2){ if(millis() - dimmtimer > 2){
ledsequence(direction, onoff, 4); 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("OTA", ArduinoOTA.handle(), 20000);
TIMEIF_US("HTTP", server.handleClient(), 20000); TIMEIF_US("HTTP", server.handleClient(), 20000);
=======

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

} }

Loading…
Cancel
Save