2022-01-30 14:44:36 +00:00
|
|
|
|
|
|
|
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
|
2022-11-10 19:03:13 +00:00
|
|
|
setTimeZone();
|
|
|
|
//setNTP();
|
|
|
|
settimeofday_cb(timeRefreshCallback); //internal callback for timesetting
|
|
|
|
ntpReachableCheck.enable();
|
2022-01-30 14:44:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
runner.execute();
|
|
|
|
yield();
|
|
|
|
#ifdef ESP8266
|
|
|
|
ESP.wdtFeed();
|
|
|
|
#endif
|
2022-11-10 19:03:13 +00:00
|
|
|
|
2022-01-30 14:44:36 +00:00
|
|
|
}
|