discoverpixy
Functions | Variables
screen_calibrate.c File Reference
#include "screen_calibrate.h"
#include "tft.h"
#include "touch.h"
Include dependency graph for screen_calibrate.c:

Go to the source code of this file.

Functions

static void enter (void *screen)
 
static void leave (void *screen)
 
static void update (void *screen)
 
SCREEN_STRUCTget_screen_calibrate ()
 

Variables

volatile bool calibration
 
static SCREEN_STRUCT screen
 

Function Documentation

static void enter ( void *  screen)
static

Definition at line 23 of file screen_calibrate.c.

24 {
26 }
void tft_clear(uint16_t color)
Definition: tft.c:45
#define BLACK
Definition: tft.h:54

Here is the call graph for this function:

static void leave ( void *  screen)
static

Definition at line 28 of file screen_calibrate.c.

29 {
30 
31 }
static void update ( void *  screen)
static

Definition at line 33 of file screen_calibrate.c.

34 {
35  int x1, y1, x2, y2, dx, dy;
36 
37 
38  tft_print_line(50, 50, WHITE, BLACK, 1, "Calibration:");
39  tft_print_line(50, 120, WHITE, BLACK, 0, "Hit the markers exactly!");
40  //-----------------First Point--------------------
41  tft_draw_line(CCENTER, CBEGIN, CCENTER, CEND, WHITE); //Draw Cross
42  tft_draw_line(CBEGIN, CCENTER, CEND, CCENTER, WHITE); //Draw Cross
43  calibration = 1; //TouchX + TouchY Values will not be converted to Pixels
44 
45  while (calibration); //Wait on PenUp
46 
48  x1 = p1.x;
49  y1 = p1.y;
50  tft_fill_rectangle(CBEGIN, CBEGIN, CEND, CEND, BLACK); //Clear Cross
51 
52  //-----------------Second Point-------------------
55  calibration = 1;
56 
57  while (calibration);
58 
60  x2 = p2.x;
61  y2 = p2.y;
63 
64  //-----------------Third Point--------------------
67  calibration = 1;
68 
69  while (calibration);
70 
72  x1 += p3.x; //Add(!) values. We'll build the average later
73  y2 += p3.y;
75 
76  //------------------4. Point---------------------
79  calibration = 1;
80 
81  while (calibration);
82 
84  x2 += p4.x;
85  y1 += p4.y;
87  //-------------------Calculation---------------------
88  x1++; //Add 1 and divide by 2 later = +0.5 (for correct rounding)
89  y1++;
90  x2++;
91  y2++;
92  x1 >>= 1; //Divide by 2
93  y1 >>= 1;
94  x2 >>= 1;
95  y2 >>= 1;
96  dx = (x2 - x1); //Build the Difference
97  dy = (y2 - y1);
98 
99  touch_set_calibration_values(x1, dx, y1, dy);
100  tft_print_line(50, 120, WHITE, BLACK, 0, "Calibration Done. Press anywhere");
101 
102  calibration = 1;
103 
104  while (calibration);
105 
106  gui_screen_back();
107 
108 }
#define CCENTER
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
void tft_print_line(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *text)
Definition: tft.c:98
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
#define DHEIGHT
#define CBEGIN
#define WHITE
Definition: tft.h:53
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
#define DWIDTH
#define CEND
bool gui_screen_back()
Definition: screen.c:85
void touch_set_calibration_values(int xs, int dx, int ys, int dy)
Definition: touch.c:51
#define BLACK
Definition: tft.h:54
volatile bool calibration
Definition: touch.c:40

Here is the call graph for this function:

Variable Documentation

volatile bool calibration

Definition at line 40 of file touch.c.

SCREEN_STRUCT screen
static
Initial value:
= {
}
static void enter(void *screen)
static void update(void *screen)
static void leave(void *screen)

Definition at line 111 of file screen_calibrate.c.