Added ESP32 as new target (still on SDK 1.0.6)

This commit is contained in:
Magnus Persson
2022-01-21 17:15:27 +01:00
parent 20771b3244
commit 767988a7c5
20 changed files with 2866 additions and 84 deletions

View File

@ -110,22 +110,39 @@ void setup() {
#if LOG_LEVEL == 6 && !defined(MAIN_DISABLE_LOGGING)
// Add a delay so that serial is started.
// delay(3000);
#if defined (ESP8266)
Log.verbose(F("Main: Reset reason %s." CR), ESP.getResetInfo().c_str());
#else // defined (ESP32)
#endif
#endif
// Main startup
#if defined (ESP8266)
Log.notice(F("Main: Started setup for %s." CR),
String(ESP.getChipId(), HEX).c_str());
#else // defined (ESP32)
char buf[20];
uint32_t chipId = 0;
for (int i = 0; i < 17; i = i+8) {
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
snprintf(&buf[0], sizeof(buf), "%6x", chipId);
Log.notice(F("Main: Started setup for %s." CR), &buf[0]);
#endif
printBuildOptions();
LOG_PERF_START("main-config-load");
myConfig.checkFileSystem();
myConfig.loadFile();
myWifi.init();
myHardwareConfig.loadFile();
LOG_PERF_STOP("main-config-load");
// Setup watchdog
#if defined (ESP8266)
ESP.wdtDisable();
ESP.wdtEnable(5000); // 5 seconds
#else // defined (ESP32)
#endif
// No stored config, move to portal
if (!myWifi.hasConfig()) {
@ -177,7 +194,7 @@ void setup() {
if (myWifi.checkFirmwareVersion()) myWifi.updateFirmware();
LOG_PERF_STOP("main-wifi-ota");
#endif
myWebServer
myWebServerHandler
.setupWebServer(); // Takes less than 4ms, so skip this measurement
}
@ -248,11 +265,7 @@ void loopGravityOnInterval() {
if (abs((int32_t)(millis() - loopMillis)) > interval) {
loopReadGravity();
loopMillis = millis();
#if LOG_LEVEL == 6 && !defined(MAIN_DISABLE_LOGGING)
Log.verbose(F("Main: Heap %d kb FreeSketch %d kb HeapFrag %d %%." CR),
ESP.getFreeHeap() / 1024, ESP.getFreeSketchSpace() / 1024,
ESP.getHeapFragmentation());
#endif
printHeap();
LOG_PERF_START("loop-gyro-read");
myGyro.read();
LOG_PERF_STOP("loop-gyro-read");
@ -286,7 +299,7 @@ void goToSleep(int sleepInterval) {
void loop() {
switch (runMode) {
case RunMode::configurationMode:
myWebServer.loop();
myWebServerHandler.loop();
myWifi.loop();
loopGravityOnInterval();
break;