-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "lwprintf/lwprintf.h" | ||
|
||
/* Define application custom instance */ | ||
lwprintf_t custom_instance; | ||
|
||
/* Define custom output function for print */ | ||
int | ||
custom_out(int ch, lwprintf_t* p) { | ||
/* Do whatever with this character */ | ||
if (ch == '\0') { | ||
/* This is end of string in current formatting */ | ||
/* Maybe time to start DMA transfer? */ | ||
} else { | ||
/* Print or send character */ | ||
} | ||
|
||
/* Return character to proceed */ | ||
return ch; | ||
} | ||
|
||
/* Define output function for default instance */ | ||
int | ||
default_out(int ch, lwprintf_t* p) { | ||
/* Print function for default instance */ | ||
|
||
/* See custom_out function for implementation details */ | ||
} | ||
|
||
int | ||
main(void) { | ||
/* Initialize default lwprintf instance with output function */ | ||
lwprintf_init(default_out); | ||
/* Initialize custom lwprintf instance with output function */ | ||
lwprintf_init_ex(&custom_instance, custom_out); | ||
|
||
/* Print first text over default output */ | ||
lwprintf_printf("Text: %d", 10); | ||
/* Print text over custom instance */ | ||
lwprintf_printf_ex(&custom_instance, "Custom: %f", 3.2f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "lwprintf/lwprintf.h" | ||
|
||
/* Define application custom instance */ | ||
lwprintf_t custom_instance1; | ||
lwprintf_t custom_instance2; | ||
|
||
/* Define custom output function for print */ | ||
int | ||
my_out(int ch, lwprintf_t* p) { | ||
if (p == &custom_instance1) { | ||
/* This is custom instance 1 */ | ||
} else if (p == &custom_instance2) { | ||
/* This is custom instance 2 */ | ||
} else { | ||
/* This is default instance */ | ||
} | ||
return ch; | ||
} | ||
|
||
int | ||
main(void) { | ||
/* Initialize default lwprintf instance with output function */ | ||
lwprintf_init(my_out); | ||
lwprintf_init_ex(&custom_instance1, my_out); | ||
lwprintf_init_ex(&custom_instance2, my_out); | ||
|
||
/* Use print functions ... */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,7 @@ User manual | |
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
how-it-works | ||
format-specifier | ||
instances | ||
thread-safety |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters