diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d75e046 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2025 András Wiesner + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7dcc023 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# EmbFmt + +A lightweight formatted printer (`printf()`) implementation for embedded systems with CMake support. + +## Formatting codes + +The library supports the following type designators: + +| Designator | Type | Description | +| --------------- | -------------- | ------------------------------------------------------------ | +| `%c` | `char` | Character | +| `%s` | `char *` | Null-terminated string | +| `%d`, `%i` | `int` | Signed decimal integer | +| `%u` | `unsigned int` | Unsigned decimal integer | +| `%x`, `%p`/`%X` | `unsigned int` | Unsigned hexadecimal integer with lowercase/UPPERcase digits | +| `%f`/`%k` | `double` | Floating point with rounding/truncation | +| `%e` | `double` | Floating point using scientific notation | +| `%%` | - | '%' character | + +## Length modifier + +By default, 32-bit integers are assumed (e.g.: `%u` - `uint32_t`), the `l` modifier always extends integer fields to 64 bits (e.g. `%lu` - `uint64_t`). + +## Precision modifier + +The library supports the precision modifiers, e.g. `%.4f` - four digits in the fractional part. The least significant digit is either determined by rounding (`%.3f`: 1.2345 -> 1.235), or by truncation (`%.3k`: 1.2345 -> 1.234). + +## Leading digits + +The library provides support for specifying the number and the type of leading character for numerical fields. The filling characters can be either `0` or spaces. (e.g. `%05u`: 12 -> 00012, `% 5u`: 12 -> ␣␣␣12) + +The length of a field can be also passed as a parameter with the `*` modifier. + +# License + +The EmbFmt library has been released under the MIT License. Developer and main contributor: [Epagris](https://github.com/epagris)