Microchip® Advanced Software Framework

applications/sam_toolkit_demo/rtouch_calibrate.c File Reference

Resistive touch calibration for SAM toolkit demo.

Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "rtouch.h"
#include "rtouch_calibrate.h"
#include <asf.h>
#include "demo_parameters.h"
#include "demo.h"

Macros

#define BGCOLOR   GFX_COLOR_WHITE
 
#define DOTCOLOR   GFX_COLOR_RED
 
#define NUM_TOUCH_POINTS   5
 Number of touch points for the calibration. More...
 
#define POINTS_SIZE   4
 Size in pixels of calibration points. More...
 
#define TXTCOLOR   GFX_COLOR_BLUE
 

Functions

static void clear_calibration_point (const rtouch_point_t *p_point)
 Clears a calibration point from the given buffer. More...
 
static void draw_calibration_point (const rtouch_point_t *p_point)
 Display a calibration point on the given buffer. More...
 
uint32_t rtouch_calibrate (void)
 Starts the calibration routines and displays user instructions on screen. More...
 

Variables

static rtouch_calibration_point_t gs_calibration_points []
 Calibration points. More...
 
const char string_calib_done [] ="Calibration done."
 
const char string_calib_failed [] = "Calibration failed!"
 
const char string_calib_instruction [] = "Touch the dots to\ncalibrate the screen"
 
const char string_calib_name [] = "LCD calibration"
 
const char string_calib_retry [] = "Please try again..."
 

#define BGCOLOR   GFX_COLOR_WHITE
#define DOTCOLOR   GFX_COLOR_RED

Referenced by draw_calibration_point().

#define NUM_TOUCH_POINTS   5

Number of touch points for the calibration.

Referenced by rtouch_calibrate().

#define POINTS_SIZE   4

Size in pixels of calibration points.

Referenced by clear_calibration_point(), and draw_calibration_point().

#define TXTCOLOR   GFX_COLOR_BLUE

Referenced by rtouch_calibrate().

static void clear_calibration_point ( const rtouch_point_t p_point)
static

Clears a calibration point from the given buffer.

Parameters
p_pointCalibration point to clear.

References BGCOLOR, gfx_draw_filled_rect, POINTS_SIZE, rtouch_point_struct::x, and rtouch_point_struct::y.

Referenced by rtouch_calibrate().

static void draw_calibration_point ( const rtouch_point_t p_point)
static

Display a calibration point on the given buffer.

Parameters
p_pointCalibration point to display.

References DOTCOLOR, gfx_draw_filled_rect, POINTS_SIZE, rtouch_point_struct::x, and rtouch_point_struct::y.

Referenced by rtouch_calibrate().

uint32_t rtouch_calibrate ( void  )

Starts the calibration routines and displays user instructions on screen.

Returns
0 if calibration is successful, else 1.

Referenced by main(), and task_win().

rtouch_calibration_point_t gs_calibration_points[]
static
Initial value:
= {
{
{LCD_WIDTH / 10, LCD_HEIGHT / 10},
{0,0}
},
{
{LCD_WIDTH - LCD_WIDTH / 10, LCD_HEIGHT / 10},
{0,0}
},
{
{LCD_WIDTH - LCD_WIDTH / 10, LCD_HEIGHT - LCD_HEIGHT / 10},
{0,0}
},
{
{LCD_WIDTH / 10, LCD_HEIGHT - LCD_HEIGHT / 10},
{0,0}
},
{
{LCD_WIDTH / 2, LCD_HEIGHT / 2},
{0,0}
}
}

Calibration points.

const char string_calib_done[] ="Calibration done."

Referenced by rtouch_calibrate().

const char string_calib_failed[] = "Calibration failed!"

Referenced by rtouch_calibrate().

const char string_calib_instruction[] = "Touch the dots to\ncalibrate the screen"

Referenced by rtouch_calibrate().

const char string_calib_name[] = "LCD calibration"

Referenced by rtouch_calibrate().

const char string_calib_retry[] = "Please try again..."

Referenced by rtouch_calibrate().