C
实施日志支持
打印日志
// 80 characters + \r + \n for a typical terminal config static const uint8_t logBufferLength = 80 + 1 + 1; static char logBuffer[logBufferLength]; static uint8_t logBufferCharCount = 0;
void ExamplePlatform::consoleWrite(char character) { logBuffer[logBufferCharCount] = character; logBufferCharCount++; if (logBufferCharCount == logBufferLength) { // Buffer full, flush data logFlush(); logBufferCharCount = 0; } }
static void logFlush() { if (logBufferCharCount > 0) { // HW_UART_Write(..., // logBuffer, // logBufferCharCount); // HW_UART_Wait_Write_To_Complete(); logBufferCharCount = 0; } }
void ExamplePlatform::exec() { while (true) { logFlush(); // Flush partially filled log buffer const uint64_t timestamp = this->update(); if (timestamp > Platform::getPlatformInstance()->currentTimestamp()) { // The device may yield or go into sleep mode } } }
PlatformInterface::log("Qt for MCUs!\r\n");
qul_printf("Ultimate performance. Tiny footprint.\r\n");
在特定 Qt 许可下提供。
了解更多。