|
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
|
Stores the touch calibration matrix in the MB85RS64V FRAM and checks it when loading. More...
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. | |
Variables | |
| constexpr uint16_t | TOUCH_CAL_ADDRESS = 0x0100 |
| FRAM address of the calibration matrix block written by the RA8875 library. | |
| constexpr uint16_t | TOUCH_CAL_HEADER_ADDRESS = 0x0120 |
| FRAM address of the 12-byte validity header. | |
Stores the touch calibration matrix in the MB85RS64V FRAM and checks it when loading.
The matrix itself is written and read by the RA8875 library (Adafruit_RA8875::writeCalibration()/readCalibration()), which calls back into this module to reach the FRAM. On top of that this module keeps a small header with a magic number, a version, the block length and a CRC-32 of the stored matrix bytes. The header is written last, after the matrix, so a power failure part-way through a save leaves a header that does not match the data and the next start simply calibrates again. A blank FRAM (all 00 or all FF), a damaged matrix, a different format version and a zero divider are all treated as "no valid calibration".
FRAM layout (all addresses inside the MB85RS64V's 8192 bytes):
Created on: Oct 5, 2026 Author: johng
Definition in file touchCalibrationStorage.hpp.
| void touchCalibrationAttachStorage | ( | Adafruit_RA8875 * | display, |
| MB85RS64V * | fram ) |
Registers the FRAM read and write callbacks with the display library.
| display | The RA8875 display object. |
| fram | The 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().
| bool touchCalibrationLoad | ( | Adafruit_RA8875 * | display, |
| MB85RS64V * | fram, | ||
| tsMatrix_t * | matrix ) |
Loads the calibration matrix from the FRAM if a valid one is stored.
| display | The RA8875 display object, with the storage attached. |
| fram | The started MB85RS64V driver. |
| matrix | Receives the matrix when the function returns true. |
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().
| bool touchCalibrationSave | ( | Adafruit_RA8875 * | display, |
| MB85RS64V * | fram, | ||
| tsMatrix_t * | matrix ) |
Saves the calibration matrix to the FRAM and checks it by reading it back.
| display | The RA8875 display object, with the storage attached. |
| fram | The started MB85RS64V driver. |
| matrix | The matrix to store. |
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().
|
constexpr |
FRAM address of the calibration matrix block written by the RA8875 library.
Definition at line 39 of file touchCalibrationStorage.hpp.
Referenced by touchCalibrationLoad(), and touchCalibrationSave().
|
constexpr |
FRAM address of the 12-byte validity header.
Definition at line 42 of file touchCalibrationStorage.hpp.
Referenced by touchCalibrationLoad(), and touchCalibrationSave().