A pin's name and a set of pins as text: see ui_pinlist.h.
More...
#include "ui_pinlist.h"
#include <stdio.h>
#include <string.h>
|
| size_t | ui_pin_name (char *out, size_t size, unsigned gpio) |
| | Writes the name of pin gpio into out: the pin word, a space and the number, "GPIO 13".
|
| unsigned | ui_pinlist_count (uint64_t mask) |
| | The number of pins in mask.
|
| static unsigned | digits (unsigned v) |
| | The decimal digits of v.
|
| static unsigned | pin_width (unsigned gpio, unsigned index) |
| | The characters pin gpio's name takes in the list ("GPIO 13", ui_pin_name()), with the space before it unless it is the first.
|
| size_t | ui_pinlist (char *out, size_t size, uint64_t mask, unsigned cells) |
| | Writes the pins of mask, lowest first, as "GPIO 2 GPIO 4
GPIO 5", each as ui_pin_name() names it, into out.
|
A pin's name and a set of pins as text: see ui_pinlist.h.
SPDX-License-Identifier: MIT
◆ digits()
| unsigned digits |
( |
unsigned | v | ) |
|
|
static |
The decimal digits of v.
- Parameters
-
- Returns
- its digits, 1 for 0
◆ pin_width()
| unsigned pin_width |
( |
unsigned | gpio, |
|
|
unsigned | index ) |
|
static |
The characters pin gpio's name takes in the list ("GPIO 13", ui_pin_name()), with the space before it unless it is the first.
- Parameters
-
| gpio | the pin |
| index | its place in the list, 0 for the first |
- Returns
- the characters
◆ ui_pin_name()
| size_t ui_pin_name |
( |
char * | out, |
|
|
size_t | size, |
|
|
unsigned | gpio ) |
Writes the name of pin gpio into out: the pin word, a space and the number, "GPIO 13".
The text is cut to size - 1 characters, as snprintf() cuts it.
- Parameters
-
| out | Where the text goes; NULL writes nothing. |
| size | The bytes at out; 0 writes nothing. |
| gpio | The pin, 0 to UI_PINLIST_PINS - 1. A higher number (a screen's NO_PIN, 0xFF) is no pin and writes "". |
- Returns
- The length of the text written, not counting the terminator; 0 for no pin, a NULL
out or a size of 0.
◆ ui_pinlist()
| size_t ui_pinlist |
( |
char * | out, |
|
|
size_t | size, |
|
|
uint64_t | mask, |
|
|
unsigned | cells ) |
Writes the pins of mask, lowest first, as "GPIO 2 GPIO 4
GPIO 5", each as ui_pin_name() names it, into out.
The text is at most cells characters (one character is one cell of the monospaced face the caller draws it in: a TARGET row in 8 x 16 or 10 x 20, ui_target_row_cells()) and at most size - 1 characters. When all pins do not fit, the list shows as many leading pins as fit, then "+N" with N the pins left out: "GPIO 2 GPIO 4 +2". When not even one pin and the count fit, the text is "+N" alone. When "+N" itself is wider than cells, the text is cut to cells characters.
- Parameters
-
| out | Where the text goes; NULL writes nothing. |
| size | The bytes at out; 0 writes nothing. |
| mask | The pins, bit n for GPIO n; 0 writes "". |
| cells | The cells the text may take. |
- Returns
- The length of the text written, not counting the terminator; 0 for an empty mask, a NULL
out or a size of 0.
◆ ui_pinlist_count()
| unsigned ui_pinlist_count |
( |
uint64_t | mask | ) |
|
The number of pins in mask.
- Parameters
-
| mask | The pins, bit n for GPIO n. |
- Returns
- Its set bits.