ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_touch_cal.c File Reference

Implementation of the touch-screen calibration utility. More...

#include "ra8_touch_cal.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "ra8_attributes.h"
#include "ra8_err.h"
Include dependency graph for ra8_touch_cal.c:

Go to the source code of this file.

Data Structures

struct  internal_lsq_sums_t
 Accumulated least-squares sums driving the calibration solve. More...

Enumerations

enum  mat3_idx_t : uint8_t {
  k_m3_00 = 0U ,
  k_m3_01 = 1U ,
  k_m3_02 = 2U ,
  k_m3_10 = 3U ,
  k_m3_11 = 4U ,
  k_m3_12 = 5U ,
  k_m3_20 = 6U ,
  k_m3_21 = 7U ,
  k_m3_22 = 8U ,
  k_m3_len = 9U
}
 Row-major flat indices of a 3x3 matrix (a[r*3+c]). More...
enum  affine_coeff_idx_t : uint8_t {
  k_coeff_a = 0U ,
  k_coeff_b = 1U ,
  k_coeff_c = 2U ,
  k_coeff_d = 3U ,
  k_coeff_e = 4U ,
  k_coeff_f = 5U
}
 Affine calibration coefficient indices (a..f). More...
enum  internal_const_t : uint32_t {
  k_internal_centre_div = 2U ,
  k_internal_byte_mask = 0xFFU ,
  k_internal_byte_shift_8 = 8U ,
  k_internal_byte_shift_16 = 16U ,
  k_internal_byte_shift_24 = 24U ,
  k_internal_crc32_init = 0xFFFFFFFFU ,
  k_internal_crc32_poly = 0xEDB88320U ,
  k_internal_bits_per_byte = 8U
}
 Module-private numeric constants (no magic numbers). More...

Functions

static void internal_pack_le32 (uint8_t *dst, uint32_t word)
 Pack a 32-bit little-endian word into a byte buffer.
static uint32_t internal_unpack_le32 (const uint8_t *src)
 Unpack a 32-bit little-endian word from a byte buffer.
static uint32_t internal_float_to_u32 (float f)
 Bitwise reinterpret a float as a uint32_t.
static float internal_u32_to_float (uint32_t w)
 Bitwise reinterpret a uint32_t as a float.
static uint32_t internal_crc32 (const uint8_t *data, size_t len)
 Compute the IEEE 802.3 CRC32 of a byte range.
static void internal_solve3 (const float a[k_m3_len], const float b[3], float x[3], bool *ok)
 Solve a 3x3 system A * x = b via Cramer's rule.
static int32_t internal_clip32 (int32_t v, int32_t lo, int32_t hi)
 Clip a value to [lo, hi].
static void internal_accumulate_sums (const ra8_touch_cal_point_t *raw, const ra8_touch_cal_point_t *screen, uint8_t n, internal_lsq_sums_t *s)
 Accumulate the 11 least-squares sums over n sample pairs.
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_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.
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_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_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.

Variables

static const float s_min_det = 1.0e-3F
 Floor for |det| below which the normal equations are treated as singular.
static const float s_round_bias = 0.5F
 Round-to-nearest bias for float->int conversion.

Detailed Description

Implementation of the touch-screen calibration utility.

Tag
[Ring 3 / HAL] {World: NS}

The math here implements the weighted least-squares affine fit from Fang & Chang, "Calibration of Touch Screens for Use with Embedded Systems" (Analog Dialogue 41-08, 2007). For N raw/screen sample pairs the screen-X coefficients (a, b, c) satisfy

[ Sxx Sxy Sx ] [ a ]   [ Sxu ]
[ Sxy Syy Sy ] [ b ] = [ Syu ]
[ Sx  Sy  N  ] [ c ]   [ Su  ]

where the sums run over the N samples. The same 3x3 system with the right-hand side replaced by (Sxv, Syv, Sv) solves for the screen-Y coefficients (d, e, f). The solver is Cramer's rule on the shared coefficient matrix, which keeps the implementation branch-light and avoids dynamic allocation.

Definition in file ra8_touch_cal.c.

Enumeration Type Documentation

◆ affine_coeff_idx_t

enum affine_coeff_idx_t : uint8_t

Affine calibration coefficient indices (a..f).

Enumerator
k_coeff_a 

Coeff a.

k_coeff_b 

Coeff b.

k_coeff_c 

Coeff c.

k_coeff_d 

Coeff d.

k_coeff_e 

Coeff e.

k_coeff_f 

Coeff f.

Definition at line 57 of file ra8_touch_cal.c.

◆ internal_const_t

enum internal_const_t : uint32_t

Module-private numeric constants (no magic numbers).

Enumerator
k_internal_centre_div 

Halve to get panel centre.

k_internal_byte_mask 

8-bit mask for byte extracts.

k_internal_byte_shift_8 

Shift to byte 1.

k_internal_byte_shift_16 

Shift to byte 2.

k_internal_byte_shift_24 

Shift to byte 3.

k_internal_crc32_init 

IEEE 802.3 CRC seed.

k_internal_crc32_poly 

IEEE 802.3 reversed polynomial.

k_internal_bits_per_byte 

Bits in one byte.

Definition at line 70 of file ra8_touch_cal.c.

◆ mat3_idx_t

enum mat3_idx_t : uint8_t

Row-major flat indices of a 3x3 matrix (a[r*3+c]).

Enumerator
k_m3_00 

M3 00.

k_m3_01 

M3 01.

k_m3_02 

M3 02.

k_m3_10 

M3 10.

k_m3_11 

M3 11.

k_m3_12 

M3 12.

k_m3_20 

M3 20.

k_m3_21 

M3 21.

k_m3_22 

M3 22.

k_m3_len 

M3 length.

Definition at line 43 of file ra8_touch_cal.c.

Function Documentation

◆ internal_accumulate_sums()

void internal_accumulate_sums ( const ra8_touch_cal_point_t * raw,
const ra8_touch_cal_point_t * screen,
uint8_t n,
internal_lsq_sums_t * s )
static

Accumulate the 11 least-squares sums over n sample pairs.

Pure-data helper extracted from ra8_touch_cal_compute to keep the top-level function within the NASA P10 Rule 4 cap. The arithmetic is bit-identical to the inlined original.

Parameters
[in]rawRaw touch samples (length n).
[in]screenScreen targets (length n).
[in]nSample count.
[out]sAccumulated sums (zero-initialized by the helper).
Precondition
All pointers are non-NULL and n >= 1.
Caller has already validated argument ranges.
Postcondition
s holds the 11 sums over [0, n).
No global state is mutated.
Note
Pure compute helper; safe from any context.
Since
0.1.0

Definition at line 360 of file ra8_touch_cal.c.

References internal_lsq_sums_t::Su, internal_lsq_sums_t::Sv, internal_lsq_sums_t::Sx, internal_lsq_sums_t::Sxu, internal_lsq_sums_t::Sxv, internal_lsq_sums_t::Sxx, internal_lsq_sums_t::Sxy, internal_lsq_sums_t::Sy, internal_lsq_sums_t::Syu, internal_lsq_sums_t::Syv, and internal_lsq_sums_t::Syy.

Referenced by ra8_touch_cal_compute().

◆ internal_clip32()

int32_t internal_clip32 ( int32_t v,
int32_t lo,
int32_t hi )
static

Clip a value to [lo, hi].

See implementation.

Parameters
[in]vSee implementation.
[in]loSee implementation.
[in]hiSee implementation.
Returns
Result code.
Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 298 of file ra8_touch_cal.c.

Referenced by ra8_touch_cal_apply().

◆ internal_crc32()

uint32_t internal_crc32 ( const uint8_t * data,
size_t len )
static

Compute the IEEE 802.3 CRC32 of a byte range.

Bit-banged so the function works without depending on ra8_crc.

Parameters
[in]dataInput bytes.
[in]lenNumber of bytes.
Returns
Final CRC32, post-XOR.
Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 217 of file ra8_touch_cal.c.

References k_internal_bits_per_byte, k_internal_crc32_init, and k_internal_crc32_poly.

Referenced by ra8_touch_cal_load(), and ra8_touch_cal_save().

◆ internal_float_to_u32()

uint32_t internal_float_to_u32 ( float f)
static

Bitwise reinterpret a float as a uint32_t.

Implemented via memcpy to avoid strict-aliasing UB.

Parameters
[in]fSource float.
Returns
Bit pattern of f.
Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 168 of file ra8_touch_cal.c.

References memcpy().

Referenced by ra8_touch_cal_save().

◆ internal_pack_le32()

void internal_pack_le32 ( uint8_t * dst,
uint32_t word )
static

Pack a 32-bit little-endian word into a byte buffer.

Parameters
[out]dstDestination (4 bytes available).
[in]wordValue to write.

See implementation.

Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 118 of file ra8_touch_cal.c.

References k_internal_byte_mask, k_internal_byte_shift_16, k_internal_byte_shift_24, and k_internal_byte_shift_8.

Referenced by ra8_touch_cal_save().

◆ internal_solve3()

void internal_solve3 ( const float a[k_m3_len],
const float b[3],
float x[3],
bool * ok )
static

Solve a 3x3 system A * x = b via Cramer's rule.

Pure float math. Degenerate (collinear) systems are flagged via the ok out-parameter rather than an error code so the call sites can fold the check into their existing return path.

Parameters
[in]aRow-major coefficient matrix (length 9).
[in]bRight-hand side (length 3).
[out]xSolution vector (length 3).
[out]okSet to true on success, false if |det| < s_min_det.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 251 of file ra8_touch_cal.c.

References k_m3_00, k_m3_01, k_m3_02, k_m3_10, k_m3_11, k_m3_12, k_m3_20, k_m3_21, k_m3_22, k_m3_len, and s_min_det.

Referenced by ra8_touch_cal_compute().

◆ internal_u32_to_float()

float internal_u32_to_float ( uint32_t w)
static

Bitwise reinterpret a uint32_t as a float.

Parameters
[in]wSource bit pattern.
Returns
Float with the supplied encoding.

See implementation.

Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 191 of file ra8_touch_cal.c.

References memcpy().

Referenced by ra8_touch_cal_load().

◆ internal_unpack_le32()

uint32_t internal_unpack_le32 ( const uint8_t * src)
static

Unpack a 32-bit little-endian word from a byte buffer.

Parameters
[in]srcSource (4 bytes available).
Returns
Unpacked word.

See implementation.

Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 142 of file ra8_touch_cal.c.

References k_internal_byte_shift_16, k_internal_byte_shift_24, and k_internal_byte_shift_8.

Referenced by ra8_touch_cal_load().

◆ ra8_touch_cal_apply()

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 )
nodiscard

Apply a calibration matrix to a single raw touch sample.

Computes (u, v) = M * (x, y) + t and clips to [0, screen_width-1] x [0, screen_height-1]. The clip is necessary because least-squares fits can map slightly off-panel raw samples to negative or beyond-panel pixel coordinates.

Parameters
[in]rawRaw controller sample.
[in]matrixPre-computed affine transform.
[in]screen_widthPanel width in pixels (>0).
[in]screen_heightPanel height in pixels (>0).
[out]out_screenDestination screen pixel.
Returns
ra8_err_t error code.
Return values
k_ra8_okSample mapped.
k_ra8_err_null_ptrmatrix or out_screen NULL.
k_ra8_err_invalid_argPanel size is zero.
Precondition
matrix, out_screen non-NULL.
Postcondition
out_screen->x in [0, screen_width-1].
out_screen->y in [0, screen_height-1].
Note
Pure function. Constant-time, branch-free except for the clip.
Since
0.1.0

Definition at line 506 of file ra8_touch_cal.c.

References ra8_touch_cal_matrix_t::a, ra8_touch_cal_matrix_t::b, ra8_touch_cal_matrix_t::c, ra8_touch_cal_matrix_t::d, ra8_touch_cal_matrix_t::e, ra8_touch_cal_matrix_t::f, internal_clip32(), k_ra8_err_invalid_arg, k_ra8_err_null_ptr, k_ra8_ok, s_round_bias, ra8_touch_cal_point_t::x, and ra8_touch_cal_point_t::y.

Referenced by internal_tc_apply_and_measure().

◆ ra8_touch_cal_compute()

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 )
nodiscard

Compute an affine transform from N target/sample pairs.

Pure-math entry point. Solves the 3x3 normal-equation system per axis using Cramer's rule. The function does not touch any hardware and is the workhorse exercised by the unit tests.

Algorithm (Fang & Chang, eqn. 4–7):

  1. Accumulate sums Sx, Sy, Sxx, Syy, Sxy, Sxu, Syu, Su, Sxv, Syv, Sv.
  2. Compute det of the 3x3 system. Reject as k_ra8_err_invalid_arg if |det| is below ::k_ra8_touch_cal_min_det (panel-collinear targets).
  3. Solve for (a, b, c) and (d, e, f) via Cramer's rule.
Parameters
[in]rawArray of n raw controller samples.
[in]screenArray of n corresponding screen targets.
[in]nNumber of pairs (3..5).
[out]out_mtxDestination matrix.
Returns
ra8_err_t error code.
Return values
k_ra8_okMatrix populated.
k_ra8_err_null_ptrAny pointer NULL.
k_ra8_err_invalid_argn out of range or system is singular.
Precondition
raw, screen, out_mtx non-NULL.
n in [k_ra8_touch_cal_min_targets, k_ra8_touch_cal_max_targets].
Postcondition
On success out_mtx holds the affine transform.
On error out_mtx is unmodified.
Note
Pure function – no hardware access, safe from any context.
Example:
ra8_touch_cal_point_t raw[5] = { ... };
ra8_touch_cal_point_t scr[5] = { ... };
if (ra8_touch_cal_compute(raw, scr, 5, &m) == k_ra8_ok) { ... }
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
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.
2-D affine transform screen = [a b; d e] * raw + [c; f].
One (x, y) integer coordinate pair.
See also
ra8_touch_cal_run
ra8_touch_cal_apply
Since
0.1.0

Definition at line 395 of file ra8_touch_cal.c.

References ra8_touch_cal_matrix_t::a, ra8_touch_cal_matrix_t::b, ra8_touch_cal_matrix_t::c, ra8_touch_cal_matrix_t::d, ra8_touch_cal_matrix_t::e, ra8_touch_cal_matrix_t::f, internal_accumulate_sums(), internal_solve3(), k_ra8_err_invalid_arg, k_ra8_err_null_ptr, k_ra8_ok, k_ra8_touch_cal_max_targets, k_ra8_touch_cal_min_targets, internal_lsq_sums_t::Su, internal_lsq_sums_t::Sv, internal_lsq_sums_t::Sx, internal_lsq_sums_t::Sxu, internal_lsq_sums_t::Sxv, internal_lsq_sums_t::Sxx, internal_lsq_sums_t::Sxy, internal_lsq_sums_t::Sy, internal_lsq_sums_t::Syu, internal_lsq_sums_t::Syv, and internal_lsq_sums_t::Syy.

Referenced by ra8_touch_cal_run().

◆ ra8_touch_cal_load()

ra8_err_t ra8_touch_cal_load ( const uint8_t * src,
size_t src_size,
ra8_touch_cal_matrix_t * out_matrix )
nodiscard

Deserialise a calibration matrix from a byte blob.

Parameters
[in]srcSource buffer (non-NULL, >= blob size).
[in]src_sizeBytes available in src.
[out]out_matrixDestination matrix.
Returns
ra8_err_t error code.
Return values
k_ra8_okBlob accepted, matrix populated.
k_ra8_err_null_ptrAny pointer NULL.
k_ra8_err_invalid_sizesrc_size is too small.
k_ra8_err_invalid_argMagic, version, or reserved bytes wrong.
k_ra8_err_crc_mismatchCRC trailer does not match payload.
Precondition
src, out_matrix non-NULL.
src_size >= k_ra8_touch_cal_blob_size.
Postcondition
On error out_matrix is unmodified.
Since
0.1.0

Definition at line 576 of file ra8_touch_cal.c.

References ra8_touch_cal_matrix_t::a, ra8_touch_cal_matrix_t::b, ra8_touch_cal_matrix_t::c, ra8_touch_cal_matrix_t::d, ra8_touch_cal_matrix_t::e, ra8_touch_cal_matrix_t::f, internal_crc32(), internal_u32_to_float(), internal_unpack_le32(), k_coeff_a, k_coeff_b, k_coeff_c, k_coeff_d, k_coeff_e, k_coeff_f, k_ra8_err_crc_mismatch, k_ra8_err_invalid_arg, k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, k_ra8_touch_cal_blob_size, k_ra8_touch_cal_magic_b0, k_ra8_touch_cal_magic_b1, k_ra8_touch_cal_magic_b2, k_ra8_touch_cal_magic_b3, k_ra8_touch_cal_off_coeffs, k_ra8_touch_cal_off_crc32, k_ra8_touch_cal_off_magic, k_ra8_touch_cal_off_reserved, k_ra8_touch_cal_off_version, and k_ra8_touch_cal_storage_version.

Referenced by internal_tc_blob_roundtrip().

◆ ra8_touch_cal_run()

ra8_err_t ra8_touch_cal_run ( const ra8_touch_cal_run_cfg_t * cfg,
ra8_touch_cal_matrix_t * out_matrix )
nodiscard

Drive the on-screen calibration sequence and produce a matrix.

For each of the five built-in targets (4 corners inset by cfg->inset_px plus the panel centre), this function:

  1. Calls cfg->draw_target to paint the cross-hair.
  2. Calls cfg->read_raw to capture the user's touch.
  3. Stores the sample.

Once all five samples are captured, it invokes ra8_touch_cal_compute and copies the result into out_matrix.

Parameters
[in]cfgConfiguration (non-NULL).
[out]out_matrixDestination matrix (non-NULL).
Returns
ra8_err_t error code.
Return values
k_ra8_okCalibration matrix produced.
k_ra8_err_null_ptrAny pointer or shim NULL.
k_ra8_err_invalid_argPanel size or inset implausible, or solve failed.
k_ra8_err_hw_errorA draw or read shim returned non-OK.
Precondition
cfg->draw_target, cfg->read_raw non-NULL.
cfg->inset_px * 2 < min(width, height).
Postcondition
On success *out_matrix is fully written.
Note
Blocks for the duration of all five touches. Caller must ensure any concurrent UI is paused.
See also
ra8_touch_cal_compute
Since
0.1.0

Definition at line 450 of file ra8_touch_cal.c.

References ra8_touch_cal_run_cfg_t::draw_ctx, ra8_touch_cal_run_cfg_t::draw_target, ra8_touch_cal_run_cfg_t::inset_px, k_internal_centre_div, k_ra8_err_hw_error, k_ra8_err_invalid_arg, k_ra8_err_null_ptr, k_ra8_ok, k_ra8_touch_cal_n_targets, ra8_touch_cal_compute(), ra8_touch_cal_run_cfg_t::read_ctx, ra8_touch_cal_run_cfg_t::read_raw, ra8_touch_cal_run_cfg_t::screen_height, and ra8_touch_cal_run_cfg_t::screen_width.

Referenced by internal_tc_run_calibration().

◆ ra8_touch_cal_save()

ra8_err_t ra8_touch_cal_save ( const ra8_touch_cal_matrix_t * matrix,
uint8_t * dst,
size_t dst_size )
nodiscard

Serialise a calibration matrix to a fixed-size byte blob.

Writes k_ra8_touch_cal_blob_size bytes laid out as documented in the file header. The byte order of the IEEE-754 float words is little-endian to match the Cortex-M85 native order. The blob is intended for ra8_flash page storage but the function does not touch flash itself – the caller is responsible for the actual write.

Parameters
[in]matrixMatrix to serialise (non-NULL).
[out]dstDestination buffer (non-NULL).
[in]dst_sizeCapacity of dst in bytes.
Returns
ra8_err_t error code.
Return values
k_ra8_okBlob written.
k_ra8_err_null_ptrAny pointer NULL.
k_ra8_err_invalid_sizedst_size < k_ra8_touch_cal_blob_size.
Precondition
dst_size >= k_ra8_touch_cal_blob_size.
Postcondition
On success the first k_ra8_touch_cal_blob_size bytes of dst form a valid blob.
Note
Round-trip stable with ra8_touch_cal_load on any platform that uses IEEE-754 binary32 floats (i.e. all Cortex-M85 builds and all glibc / musl hosts).
Since
0.1.0

Definition at line 538 of file ra8_touch_cal.c.

References ra8_touch_cal_matrix_t::a, ra8_touch_cal_matrix_t::b, ra8_touch_cal_matrix_t::c, ra8_touch_cal_matrix_t::d, ra8_touch_cal_matrix_t::e, ra8_touch_cal_matrix_t::f, internal_crc32(), internal_float_to_u32(), internal_pack_le32(), k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, k_ra8_touch_cal_blob_size, k_ra8_touch_cal_magic_b0, k_ra8_touch_cal_magic_b1, k_ra8_touch_cal_magic_b2, k_ra8_touch_cal_magic_b3, k_ra8_touch_cal_off_coeffs, k_ra8_touch_cal_off_crc32, k_ra8_touch_cal_off_magic, k_ra8_touch_cal_off_reserved, k_ra8_touch_cal_off_version, and k_ra8_touch_cal_storage_version.

Referenced by internal_tc_blob_roundtrip().

Variable Documentation

◆ s_min_det

const float s_min_det = 1.0e-3F
static

Floor for |det| below which the normal equations are treated as singular.

1e-3 is chosen empirically for a 1024x600 panel: real-world raw-sample spreads produce |det| in the 1e8 .. 1e10 range, so 1e-3 only trips on truly collinear inputs.

Note
File-scope static; not thread-shared because it is read-only.

Definition at line 93 of file ra8_touch_cal.c.

Referenced by internal_solve3().

◆ s_round_bias

const float s_round_bias = 0.5F
static

Round-to-nearest bias for float->int conversion.

Definition at line 96 of file ra8_touch_cal.c.

Referenced by ra8_touch_cal_apply().