Added toString() for log type and added delay()
This commit is contained in:
@ -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
|
} // namespace espcpputils
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
|
|
||||||
// esp-idf includes
|
// esp-idf includes
|
||||||
#include <esp_sntp.h>
|
#include <esp_sntp.h>
|
||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
namespace espcpputils {
|
namespace espcpputils {
|
||||||
|
|
||||||
std::string toString(sntp_sync_mode_t val);
|
std::string toString(sntp_sync_mode_t val);
|
||||||
|
std::string toString(esp_log_level_t val);
|
||||||
|
|
||||||
} // namespace espcpputils
|
} // namespace espcpputils
|
||||||
|
@ -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<ticks>(std::chrono::milliseconds(100)).count());
|
static_assert(pdMS_TO_TICKS(100) == std::chrono::floor<ticks>(std::chrono::milliseconds(100)).count());
|
||||||
static_assert(pdMS_TO_TICKS(10) == std::chrono::floor<ticks>(std::chrono::milliseconds(10)).count());
|
static_assert(pdMS_TO_TICKS(10) == std::chrono::floor<ticks>(std::chrono::milliseconds(10)).count());
|
||||||
|
|
||||||
|
inline void delay(std::chrono::milliseconds ms)
|
||||||
|
{
|
||||||
|
vTaskDelay(std::chrono::ceil<espcpputils::ticks>(ms).count());
|
||||||
|
}
|
||||||
} // namespace espcpputils
|
} // namespace espcpputils
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user