LED-Clock/main.ino
2022-11-10 20:03:13 +01:00

83 lines
1.8 KiB
C++

void setup() {
#ifdef LDR_PIN
pinMode(LDR_PIN, INPUT_PULLUP);
#endif
pinMode(DATA_PIN, OUTPUT);
Serial.begin(SERIAL_BAUD);
Serial.flush();
delay(100);
Serial.println();
Serial.print("\n\n\nCPU Frequency is: ");
#ifdef ESP8266
Serial.print(ESP.getCpuFreqMHz());
Serial.println(" Mhz");
Serial.print("Chip ID: ");
Serial.println(ESP.getFlashChipId());
#elif defined(ESP32)
setCpuFrequencyMhz(160);
Serial.print(getCpuFrequencyMhz()); //Get CPU clock
Serial.println(" Mhz");
uint32_t Freq = getXtalFrequencyMhz();
Serial.print("XTAL Freq = ");
Serial.print(Freq);
uint32_t chipId = 0;
for (int i = 0; i < 17; i = i + 8) {
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
Serial.printf("This chip has %d cores\n", ESP.getChipCores());
Serial.print("Chip ID: "); Serial.println(chipId);
#endif
Serial.print("MAC address: ");
Serial.println(WiFi.macAddress()); //Get CPU clock
#ifdef RGBW
Serial.println("RGBW");
#else
Serial.println("RGB");
#endif
strip.Begin();
strip.ClearTo(white);
strip.SetBrightness( MINIMAL_BRIGHTNESS );
strip.Show();
runner.init();
runner.addTask(ledRefresh);
runner.addTask(clockTick);
#ifdef LDR_PIN
runner.addTask(brightnessAdjustment);
runner.addTask(brightnessFading);
#endif
runner.addTask(bootAnim);
runner.addTask(iotwebconfLoop);
bootAnim.enable();
iotwebconfLoop.enable();
iotWebConf_Setup();
//Serial.end();
#ifdef ESP8266
ESP.wdtDisable();
ESP.wdtEnable(1000);
#endif
#if defined(ESP32)
#endif
setTimeZone();
//setNTP();
settimeofday_cb(timeRefreshCallback); //internal callback for timesetting
ntpReachableCheck.enable();
}
void loop()
{
runner.execute();
yield();
#ifdef ESP8266
ESP.wdtFeed();
#endif
}