Allow calibration to work in newmouse even if there is no text / font support.
parent
5b806ef66b
commit
105e50dcd4
|
@ -443,14 +443,18 @@ static void MousePoll(void *param) {
|
||||||
coord_t w, h;
|
coord_t w, h;
|
||||||
point cross[4]; // The locations of the test points on the display
|
point cross[4]; // The locations of the test points on the display
|
||||||
point points[4]; // The x, y readings obtained from the mouse for each test point
|
point points[4]; // The x, y readings obtained from the mouse for each test point
|
||||||
font_t font1, font2;
|
|
||||||
uint32_t err;
|
uint32_t err;
|
||||||
|
#if GDISP_NEED_TEXT
|
||||||
|
font_t font1, font2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if GDISP_NEED_TEXT
|
||||||
|
font1 = gdispOpenFont(CALIBRATION_FONT);
|
||||||
|
if (!font1) font1 = gdispOpenFont("*");
|
||||||
|
font2 = gdispOpenFont(CALIBRATION_FONT2);
|
||||||
|
if (!font2) font2 = gdispOpenFont("*");
|
||||||
|
#endif
|
||||||
err = 0;
|
err = 0;
|
||||||
font1 = gdispOpenFont(CALIBRATION_FONT);
|
|
||||||
if (!font1) font1 = gdispOpenFont("*");
|
|
||||||
font2 = gdispOpenFont(CALIBRATION_FONT2);
|
|
||||||
if (!font2) font2 = gdispOpenFont("*");
|
|
||||||
w = gdispGGetWidth(m->display);
|
w = gdispGGetWidth(m->display);
|
||||||
h = gdispGGetHeight(m->display);
|
h = gdispGGetHeight(m->display);
|
||||||
#if GDISP_NEED_CLIP
|
#if GDISP_NEED_CLIP
|
||||||
|
@ -475,10 +479,12 @@ static void MousePoll(void *param) {
|
||||||
|
|
||||||
// Set up the calibration display
|
// Set up the calibration display
|
||||||
gdispGClear(m->display, Blue);
|
gdispGClear(m->display, Blue);
|
||||||
gdispGFillStringBox(m->display,
|
#if GDISP_NEED_TEXT
|
||||||
0, CALIBRATION_TITLE_Y, w, CALIBRATION_TITLE_HEIGHT,
|
gdispGFillStringBox(m->display,
|
||||||
CALIBRATION_TITLE, font1, CALIBRATION_TITLE_COLOR, CALIBRATION_TITLE_BACKGROUND,
|
0, CALIBRATION_TITLE_Y, w, CALIBRATION_TITLE_HEIGHT,
|
||||||
justifyCenter);
|
CALIBRATION_TITLE, font1, CALIBRATION_TITLE_COLOR, CALIBRATION_TITLE_BACKGROUND,
|
||||||
|
justifyCenter);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Calculate the calibration
|
// Calculate the calibration
|
||||||
{
|
{
|
||||||
|
@ -570,19 +576,23 @@ static void MousePoll(void *param) {
|
||||||
// Is this accurate enough?
|
// Is this accurate enough?
|
||||||
err = (points[3].x - cross[3].x) * (points[3].x - cross[3].x) + (points[3].y - cross[3].y) * (points[3].y - cross[3].y);
|
err = (points[3].x - cross[3].x) * (points[3].x - cross[3].x) + (points[3].y - cross[3].y) * (points[3].y - cross[3].y);
|
||||||
if (err > (uint32_t)pj->calibrate * (uint32_t)pj->calibrate) {
|
if (err > (uint32_t)pj->calibrate * (uint32_t)pj->calibrate) {
|
||||||
// No - Display error and return
|
#if GDISP_NEED_TEXT
|
||||||
gdispGFillStringBox(m->display,
|
// No - Display error and return
|
||||||
0, CALIBRATION_ERROR_Y, w, CALIBRATION_ERROR_HEIGHT,
|
gdispGFillStringBox(m->display,
|
||||||
CALIBRATION_ERROR_TEXT, font2, CALIBRATION_ERROR_COLOR, CALIBRATION_ERROR_BACKGROUND,
|
0, CALIBRATION_ERROR_Y, w, CALIBRATION_ERROR_HEIGHT,
|
||||||
justifyCenter);
|
CALIBRATION_ERROR_TEXT, font2, CALIBRATION_ERROR_COLOR, CALIBRATION_ERROR_BACKGROUND,
|
||||||
gfxSleepMilliseconds(CALIBRATION_ERROR_DELAY);
|
justifyCenter);
|
||||||
|
gfxSleepMilliseconds(CALIBRATION_ERROR_DELAY);
|
||||||
|
#endif
|
||||||
} else
|
} else
|
||||||
err = 0;
|
err = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are done calibrating
|
// We are done calibrating
|
||||||
gdispCloseFont(font1);
|
#if GDISP_NEED_TEXT
|
||||||
gdispCloseFont(font2);
|
gdispCloseFont(font1);
|
||||||
|
gdispCloseFont(font2);
|
||||||
|
#endif
|
||||||
m->flags &= ~GMOUSE_FLG_IN_CAL;
|
m->flags &= ~GMOUSE_FLG_IN_CAL;
|
||||||
m->flags |= GMOUSE_FLG_CLIP;
|
m->flags |= GMOUSE_FLG_CLIP;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue