Browse Source

added software timer

tags/v0.1.0
Simon Schmidt 3 years ago
parent
commit
49f9c9c217
1 changed files with 21 additions and 7 deletions
  1. 21
    7
      src/main.cpp

+ 21
- 7
src/main.cpp View File



#include "PCA9685.h" #include "PCA9685.h"


extern "C" {
#include "user_interface.h"
}
os_timer_t Timer1; // Verwaltungsstruktur des Timers

uint32_t c;

uint32_t m=0;
void timerCallback(void *pArg)
{
*((int *) pArg) += 1;
Serial.print("hallo\n");
Serial.println(micros()-m);
m = micros();
}


// Änderung // Änderung
// OTA & WEB // OTA & WEB
#include "wifi_credentials.h" #include "wifi_credentials.h"
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4 Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
} }




void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.println(F("Booting ....")); Serial.println(F("Booting ...."));
ESP.restart(); ESP.restart();
} }
os_timer_setfn(&Timer1, timerCallback, &c);
os_timer_arm(&Timer1, 1000, true);

Serial.println("Ready"); Serial.println("Ready");
Serial.print("IP address: "); Serial.print("IP address: ");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
onoff = 1; onoff = 1;
direction = 0; direction = 0;
} }
TIMEIF_US("OTA", ArduinoOTA.handle(), 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);

} }

Loading…
Cancel
Save