F439_CPP_SPI_RA8875_TFT_LCD_04 1.0
STM32F439 SPI RA8875 7-inch TFT display with FRAM-backed touch calibration, built on the STM32_GFX, STM32_RA8875 and STM32_MB85RS64V libraries
Loading...
Searching...
No Matches
touchCalibrationStorage.cpp File Reference

FRAM storage and validation of the touch calibration matrix. See touchCalibrationStorage.hpp. More...

#include <stdio.h>
#include <string.h>
#include "main.h"
#include "touchCalibrationStorage.hpp"

Go to the source code of this file.

Functions

void touchCalibrationAttachStorage (Adafruit_RA8875 *display, MB85RS64V *fram)
 Registers the FRAM read and write callbacks with the display library.
 
bool touchCalibrationLoad (Adafruit_RA8875 *display, MB85RS64V *fram, tsMatrix_t *matrix)
 Loads the calibration matrix from the FRAM if a valid one is stored.
 
bool touchCalibrationSave (Adafruit_RA8875 *display, MB85RS64V *fram, tsMatrix_t *matrix)
 Saves the calibration matrix to the FRAM and checks it by reading it back.
 

Detailed Description

FRAM storage and validation of the touch calibration matrix. See touchCalibrationStorage.hpp.

Created on: Oct 5, 2026 Author: johng

Definition in file touchCalibrationStorage.cpp.

Function Documentation

◆ touchCalibrationAttachStorage()

void touchCalibrationAttachStorage ( Adafruit_RA8875 * display,
MB85RS64V * fram )

Registers the FRAM read and write callbacks with the display library.

Parameters
displayThe RA8875 display object.
framThe started MB85RS64V driver that holds the calibration.

Must be called once before touchCalibrationLoad() or touchCalibrationSave(). If either pointer is null it prints the reason and calls Error_Handler(), which does not return.

Definition at line 94 of file touchCalibrationStorage.cpp.

References Adafruit_RA8875::setCalibrationStorage(), and MB85RS64V::SIZE_BYTES.

Referenced by initTouchCalibration(), and testTouch().

◆ touchCalibrationLoad()

bool touchCalibrationLoad ( Adafruit_RA8875 * display,
MB85RS64V * fram,
tsMatrix_t * matrix )

Loads the calibration matrix from the FRAM if a valid one is stored.

Parameters
displayThe RA8875 display object, with the storage attached.
framThe started MB85RS64V driver.
matrixReceives the matrix when the function returns true.
Returns
true if a valid calibration was found (magic, version, length, CRC and the library's flag all agree and the divider is not zero); false if none is stored or it is damaged, in which case the reason is printed and the caller should calibrate again. A failed SPI transfer is not reported here: the FRAM driver calls Error_Handler().

Definition at line 114 of file touchCalibrationStorage.cpp.

References tsMatrix_t::Divider, MB85RS64V::read(), Adafruit_RA8875::readCalibration(), TOUCH_CAL_ADDRESS, and TOUCH_CAL_HEADER_ADDRESS.

Referenced by initTouchCalibration(), and touchCalibrationSave().

◆ touchCalibrationSave()

bool touchCalibrationSave ( Adafruit_RA8875 * display,
MB85RS64V * fram,
tsMatrix_t * matrix )

Saves the calibration matrix to the FRAM and checks it by reading it back.

Parameters
displayThe RA8875 display object, with the storage attached.
framThe started MB85RS64V driver.
matrixThe matrix to store.
Returns
true if the data and header were written and loading them back gave exactly the same matrix; false if the read-back did not match.

Definition at line 175 of file touchCalibrationStorage.cpp.

References MB85RS64V::read(), TOUCH_CAL_ADDRESS, TOUCH_CAL_HEADER_ADDRESS, touchCalibrationLoad(), MB85RS64V::write(), and Adafruit_RA8875::writeCalibration().

Referenced by testTouch().