rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
link_drawing.h File Reference

Reading a board drawing (LINK_ART_DRAWING): the layout link_pages.h gives under LINK_DRAW_*. More...

#include <stdbool.h>
#include <stdint.h>
#include "link_pages.h"

Go to the source code of this file.

Data Structures

 One pad record. More...
 One shape record; see link_pages.h for what a to d mean per kind. More...
 A drawing that passed link_drawing_parse(). More...

Functions

bool link_drawing_parse (link_drawing_t *out, const uint8_t *data, uint32_t bytes, const char **why)
 Check bytes of data whole and describe them in out.
bool link_drawing_pad_at (const link_drawing_t *d, uint8_t i, link_draw_pad_t *out)
 Pad record i, 0 to pads - 1, in the order the drawing lists them.
bool link_drawing_find_pad (const link_drawing_t *d, uint8_t pad, link_draw_pad_t *out)
 The record of pad number pad.
bool link_drawing_shape_at (const link_drawing_t *d, uint16_t i, link_draw_shape_t *out)
 Shape record i, 0 to shapes - 1, in drawing order.

Detailed Description

Reading a board drawing (LINK_ART_DRAWING): the layout link_pages.h gives under LINK_DRAW_*.

A drawing arrives over the link or out of the panel's flash, and either way it is bytes somebody else wrote. It is checked whole before any of it is used: every count against the length, every pad and every shape inside the outline, pads in ascending order, and only the kinds the format names. A drawing with one record out of place is refused, not drawn without it – a board that is drawn is a board an operator wires by.

Nothing is copied. A parsed drawing points into the bytes it was parsed from, which must outlive it.

SPDX-License-Identifier: MIT

Function Documentation

◆ link_drawing_find_pad()

bool link_drawing_find_pad ( const link_drawing_t * d,
uint8_t pad,
link_draw_pad_t * out )

The record of pad number pad.

False when the drawing has none.

Parameters
dThe parsed drawing.
padThe pad number, 1 to 63.
outReceives the record; may be NULL.
Returns
true when the drawing has the pad, else false.

◆ link_drawing_pad_at()

bool link_drawing_pad_at ( const link_drawing_t * d,
uint8_t i,
link_draw_pad_t * out )

Pad record i, 0 to pads - 1, in the order the drawing lists them.

Parameters
dThe parsed drawing.
iIndex of the record, 0 to pads - 1.
outReceives the record.
Returns
true when i is in range, else false.

◆ link_drawing_parse()

bool link_drawing_parse ( link_drawing_t * out,
const uint8_t * data,
uint32_t bytes,
const char ** why )

Check bytes of data whole and describe them in out.

False, with out zeroed, when anything is out of place; why (may be NULL) then names the first thing found, for a log line, and is never left pointing at nothing.

Parameters
outReceives the description; zeroed on failure.
dataThe drawing bytes.
bytesLength of data in bytes.
whyReceives the reason text on failure; may be NULL.
Returns
true when the drawing is whole and in order, else false.

◆ link_drawing_shape_at()

bool link_drawing_shape_at ( const link_drawing_t * d,
uint16_t i,
link_draw_shape_t * out )

Shape record i, 0 to shapes - 1, in drawing order.

Parameters
dThe parsed drawing.
iIndex of the record, 0 to shapes - 1.
outReceives the record.
Returns
true when i is in range, else false.