Browse Source

led dimm via timer

tags/v0.1.0
Dominik Bartsch 3 years ago
parent
commit
6a7f2e6a4e
1 changed files with 16 additions and 8 deletions
  1. 16
    8
      src/main.cpp

+ 16
- 8
src/main.cpp View File

@@ -11,13 +11,23 @@ os_timer_t Timer1; // Verwaltungsstruktur des Timers
uint32_t c;

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;
Serial.print("hallo\n");
Serial.println(micros()-m);
m = micros();
//Serial.print("hallo\n");
//Serial.println(micros()-m);
//m = micros();
ledsequence(direction, onoff, 4);
}


@@ -184,7 +194,7 @@ void setup() {
}
os_timer_setfn(&Timer1, timerCallback, &c);
os_timer_arm(&Timer1, 1000, true);
os_timer_arm(&Timer1, 1, true);

Serial.println("Ready");
Serial.print("IP address: ");
@@ -284,12 +294,10 @@ void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){

void loop() {

static uint32_t dimmtimer = 0;
static uint8_t direction = 1;
static uint8_t onoff = 1;

if(millis() - dimmtimer > 2){
ledsequence(direction, onoff, 4);
//ledsequence(direction, onoff, 4);
dimmtimer = millis();
}
if(millis() > 25000 && onoff == 1 && direction == 1) onoff = 0;

Loading…
Cancel
Save