platform: fix crash, move some code from h to cpp

This commit is contained in:
Torrie Fischer 2023-02-19 18:44:26 +01:00
parent 0700dfaf92
commit 8223688d7b
2 changed files with 28 additions and 16 deletions

View File

@ -74,6 +74,9 @@ Platform::freeRam()
#ifdef BOARD_ESP8266 #ifdef BOARD_ESP8266
return ESP.getFreeHeap(); return ESP.getFreeHeap();
#endif #endif
#ifdef BOARD_ESP32
return ESP.getFreeHeap();
#endif
} }
void void
@ -206,6 +209,28 @@ Platform::deviceID()
return s_deviceID; return s_deviceID;
} }
void
Platform::addLEDs(CRGB* leds, unsigned int ledCount) {
FastLED.addLeds<WS2812B, RENDERBUG_LED_PIN, RENDERBUG_LED_PACKING>(leds, ledCount);
}
const String
Platform::model()
{
static String modelName = String("Renderbug " ) + Platform::name();
return modelName;
}
void
Platform::restart() {
#ifdef BOARD_ESP8266
ESP.wdtDisable();
ESP.restart();
#elif defined(BOARD_ESP32)
ESP.restart();
#endif
}
BootOptions BootOptions
Platform::bootopts; Platform::bootopts;

View File

@ -11,17 +11,11 @@ class Platform : public Task {
static BootOptions bootopts; static BootOptions bootopts;
static void setTimezone(int tz) { s_timezone = tz; } static void setTimezone(int tz) { s_timezone = tz; }
static int getTimezone() { return s_timezone; } static int getTimezone() { return s_timezone; }
static void addLEDs(CRGB* leds, unsigned int ledCount);
static void addLEDs(CRGB* leds, unsigned int ledCount) {
FastLED.addLeds<WS2812B, RENDERBUG_LED_PIN, RENDERBUG_LED_PACKING>(leds, ledCount);
}
static const char* name(); static const char* name();
static const char* version(); static const char* version();
static const String model() { static const String model();
static String modelName = String("Renderbug " ) + Platform::name();
return modelName;
}
static const String deviceName() { static const String deviceName() {
static String devName = model() + " " + Platform::deviceID(); static String devName = model() + " " + Platform::deviceID();
return devName; return devName;
@ -110,12 +104,5 @@ class Platform : public Task {
return task_iterator(NULL); return task_iterator(NULL);
} }
static void restart() { static void restart();
#ifdef BOARD_ESP8266
ESP.wdtDisable();
ESP.restart();
#elif defined(BOARD_ESP32)
ESP.restart();
#endif
}
}; };