FastLED 3.10.6
Loading...
Searching...
No Matches

◆ printf() [1/2]

void fl::printf ( const char * format)
Examples
Chromancer.ino, MoodRing.ino, and hydropack.ino.

Definition at line 241 of file stdio.cpp.hpp.

241 {
242 char output[64];
243 fl::size used = 0;
244 const auto flush_buffer = [&]() {
245 if (used == 0) {
246 return;
247 }
248 output[used] = '\0';
249 fl::print(output);
250 // `append` resumes writing only after this shared cursor is reset.
251 used = 0;
252 };
253 const auto append = [&](const char* text) {
254 while (*text) {
255 if (used == sizeof(output) - 1) {
256 flush_buffer();
257 }
258 output[used++] = *text++;
259 }
260 };
261
262 while (*format) {
263 if (*format == '%') {
266 append(spec.type == '%' ? "%" : "<missing_arg>");
267 continue;
268 }
269 if (format[0] == '{' && format[1] == '{') {
270 append("{");
271 format += 2;
272 continue;
273 }
274 if (format[0] == '}' && format[1] == '}') {
275 append("}");
276 format += 2;
277 continue;
278 }
279 if (format[0] == '{' && format[1] == '}') {
280 append("<missing_arg>");
281 format += 2;
282 continue;
283 }
284 if (used == sizeof(output) - 1) {
285 flush_buffer();
286 }
287 output[used++] = *format++;
288 }
289 flush_buffer();
290}
FormatSpec parse_format_spec(const char *&format) FL_NO_EXCEPT
Definition stdio.h:130
void print(const char *str)
fl::string format(const char *fmt)
Format with no arguments.
Definition format.h:439

References FL_NO_EXCEPT, format(), fl::printf_detail::parse_format_spec(), print(), and fl::printf_detail::FormatSpec::type.

Referenced by fl::test::DefaultReporter::assertResult(), fl::test::TestContext::checkTimeout(), fl::test::fail(), handleClientResponse(), handleResponse(), fl::test::TestContext::listTests(), fl::detail::log_emit_f(), loop(), fl::test::outputCapture(), fl::test::outputMessage(), fl::test::SerialReporter::print(), printSense(), sendAsyncRequest(), sendAsyncStreamRequest(), sendSyncRequest(), setup(), fl::test::skipTest(), fl::test::DefaultReporter::subcaseStart(), fl::test::DefaultReporter::testCaseEnd(), fl::test::DefaultReporter::testCaseStart(), fl::test::DefaultReporter::testRunEnd(), and fl::test::DefaultReporter::testRunStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: