ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_touch_cal.h
Go to the documentation of this file.
1
78
79#pragma once
80
81#ifdef __cplusplus
82extern "C" {
83#endif
84
85#include <stddef.h>
86#include <stdint.h>
87
88#include "ra8_err.h"
89
90/* ===========================================================================
91 * Compile-time limits
92 * ===========================================================================
93 */
94
106
118
129
130/* ===========================================================================
131 * Public types
132 * ===========================================================================
133 */
134
150typedef struct {
151 int32_t x;
152 int32_t y;
154
175typedef struct {
176 float a;
177 float b;
178 float c;
179 float d;
180 float e;
181 float f;
183
195
207
228
229/* ===========================================================================
230 * Public API
231 * ===========================================================================
232 */
233
282 const ra8_touch_cal_point_t* screen,
283 uint8_t n,
284 ra8_touch_cal_matrix_t* out_mtx);
285
321 ra8_touch_cal_matrix_t* out_matrix);
322
352 const ra8_touch_cal_matrix_t* matrix,
353 uint16_t screen_width,
354 uint16_t screen_height,
355 ra8_touch_cal_point_t* out_screen);
356
387[[nodiscard]] ra8_err_t
388ra8_touch_cal_save(const ra8_touch_cal_matrix_t* matrix, uint8_t* dst, size_t dst_size);
389
410[[nodiscard]] ra8_err_t
411ra8_touch_cal_load(const uint8_t* src, size_t src_size, ra8_touch_cal_matrix_t* out_matrix);
412
413#ifdef __cplusplus
414}
415#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_err_t ra8_touch_cal_compute(const ra8_touch_cal_point_t *raw, const ra8_touch_cal_point_t *screen, uint8_t n, ra8_touch_cal_matrix_t *out_mtx)
Compute an affine transform from N target/sample pairs.
ra8_err_t ra8_touch_cal_save(const ra8_touch_cal_matrix_t *matrix, uint8_t *dst, size_t dst_size)
Serialise a calibration matrix to a fixed-size byte blob.
ra8_touch_cal_limits_t
Static-allocation caps and protocol constants.
@ k_ra8_touch_cal_blob_size
Bytes in ra8_touch_cal_save.
@ k_ra8_touch_cal_min_targets
Floor for a unique solve.
@ k_ra8_touch_cal_n_targets
4 corners + centre.
@ k_ra8_touch_cal_max_targets
Ceiling for the fit.
@ k_ra8_touch_cal_storage_version
On-disk format version.
ra8_err_t ra8_touch_cal_load(const uint8_t *src, size_t src_size, ra8_touch_cal_matrix_t *out_matrix)
Deserialise a calibration matrix from a byte blob.
ra8_err_t(* ra8_touch_cal_draw_target_fn_t)(void *ctx, ra8_touch_cal_point_t target)
LCD shim: paint a cross-hair at the given pixel.
ra8_err_t(* ra8_touch_cal_read_raw_fn_t)(void *ctx, ra8_touch_cal_point_t *out_raw)
Touch shim: block until one raw touch sample is captured.
ra8_touch_cal_magic_t
Bytes of the storage magic 'TCAL'.
@ k_ra8_touch_cal_magic_b3
'L'
@ k_ra8_touch_cal_magic_b0
'T'
@ k_ra8_touch_cal_magic_b2
'A'
@ k_ra8_touch_cal_magic_b1
'C'
ra8_touch_cal_layout_t
Byte-offsets inside the serialised storage blob.
@ k_ra8_touch_cal_off_reserved
Offset of 3 reserved zero bytes.
@ k_ra8_touch_cal_off_magic
Offset of 'TCAL' magic.
@ k_ra8_touch_cal_off_version
Offset of version byte.
@ k_ra8_touch_cal_off_crc32
Offset of the CRC32 trailer.
@ k_ra8_touch_cal_off_coeffs
Offset of the 6-float coeff array.
ra8_err_t ra8_touch_cal_apply(ra8_touch_cal_point_t raw, const ra8_touch_cal_matrix_t *matrix, uint16_t screen_width, uint16_t screen_height, ra8_touch_cal_point_t *out_screen)
Apply a calibration matrix to a single raw touch sample.
ra8_err_t ra8_touch_cal_run(const ra8_touch_cal_run_cfg_t *cfg, ra8_touch_cal_matrix_t *out_matrix)
Drive the on-screen calibration sequence and produce a matrix.
2-D affine transform screen = [a b; d e] * raw + [c; f].
float e
Row 1, column 1: raw-Y gain on screen-Y.
float b
Row 0, column 1: raw-Y gain on screen-X.
float d
Row 1, column 0: raw-X gain on screen-Y.
float f
Row 1 offset: screen-Y bias.
float a
Row 0, column 0: raw-X gain on screen-X.
float c
Row 0 offset: screen-X bias.
One (x, y) integer coordinate pair.
int32_t y
Vertical coordinate.
int32_t x
Horizontal coordinate.
Configuration for ra8_touch_cal_run.
ra8_touch_cal_read_raw_fn_t read_raw
Raw sample reader.
ra8_touch_cal_draw_target_fn_t draw_target
Cross-hair painter.
void * draw_ctx
Forwarded to painter.
uint16_t inset_px
Margin from panel edge to corner targets.
uint16_t screen_height
Panel height, pixels.
void * read_ctx
Forwarded to reader.
uint16_t screen_width
Panel width, pixels.