diff --git a/src/espstrutils.cpp b/src/espstrutils.cpp index be19006..f185b80 100644 --- a/src/espstrutils.cpp +++ b/src/espstrutils.cpp @@ -26,4 +26,20 @@ std::string toString(sntp_sync_mode_t val) } } +std::string toString(esp_log_level_t val) +{ + switch (val) + { + case ESP_LOG_NONE: return "NONE"; + case ESP_LOG_ERROR: return "ERROR"; + case ESP_LOG_WARN: return "WARN"; + case ESP_LOG_INFO: return "INFO"; + case ESP_LOG_DEBUG: return "DEBUG"; + case ESP_LOG_VERBOSE: return "VERBOSE"; + default: + ESP_LOGW(TAG, "unknown esp_log_level_t(%i)", std::to_underlying(val)); + return fmt::format("Unknown esp_log_level_t({})", std::to_underlying(val)); + } +} + } // namespace espcpputils diff --git a/src/espstrutils.h b/src/espstrutils.h index 9c4ca5a..481d4f3 100644 --- a/src/espstrutils.h +++ b/src/espstrutils.h @@ -5,9 +5,11 @@ // esp-idf includes #include +#include namespace espcpputils { std::string toString(sntp_sync_mode_t val); +std::string toString(esp_log_level_t val); } // namespace espcpputils diff --git a/src/tickchrono.h b/src/tickchrono.h index f883ea4..8f7dbd7 100644 --- a/src/tickchrono.h +++ b/src/tickchrono.h @@ -16,5 +16,9 @@ static_assert(pdMS_TO_TICKS(1000) == ticks(std::chrono::seconds(1)).count()); static_assert(pdMS_TO_TICKS(100) == std::chrono::floor(std::chrono::milliseconds(100)).count()); static_assert(pdMS_TO_TICKS(10) == std::chrono::floor(std::chrono::milliseconds(10)).count()); +inline void delay(std::chrono::milliseconds ms) +{ + vTaskDelay(std::chrono::ceil(ms).count()); +} } // namespace espcpputils