Reset config, fix screen calibration

This commit is contained in:
suchmememanyskill
2024-02-10 12:09:43 +01:00
parent 64266b1ff8
commit d3e7eec47a
2 changed files with 6 additions and 6 deletions

View File

@@ -3,12 +3,12 @@
#include "lvgl.h" #include "lvgl.h"
#define CONFIG_VERSION 3 #define CONFIG_VERSION 4
typedef struct _GLOBAL_CONFIG { typedef struct _GLOBAL_CONFIG {
unsigned char version; unsigned char version;
union { union {
unsigned char raw; unsigned int raw;
struct { struct {
// Internal // Internal
bool screenCalibrated : 1; bool screenCalibrated : 1;

View File

@@ -77,14 +77,14 @@ void touchscreen_calibrate(bool force)
tft.drawFastHLine(300, 230, 20, ILI9341_BLACK); tft.drawFastHLine(300, 230, 20, ILI9341_BLACK);
tft.drawFastVLine(310, 220, 20, ILI9341_BLACK); tft.drawFastVLine(310, 220, 20, ILI9341_BLACK);
int16_t xDist = 320 - 40; int16_t xDist = 320 - 20;
int16_t yDist = 240 - 40; int16_t yDist = 240 - 20;
global_config.screenCalXMult = (float)xDist / (float)(x2 - x1); global_config.screenCalXMult = (float)xDist / (float)(x2 - x1);
global_config.screenCalXOffset = 20.0 - ((float)x1 * global_config.screenCalXMult); global_config.screenCalXOffset = 10.0 - ((float)x1 * global_config.screenCalXMult);
global_config.screenCalYMult = (float)yDist / (float)(y2 - y1); global_config.screenCalYMult = (float)yDist / (float)(y2 - y1);
global_config.screenCalYOffset = 20.0 - ((float)y1 * global_config.screenCalYMult); global_config.screenCalYOffset = 10.0 - ((float)y1 * global_config.screenCalYMult);
global_config.screenCalibrated = true; global_config.screenCalibrated = true;
WriteGlobalConfig(); WriteGlobalConfig();