#include "stdbool.h"
Go to the source code of this file.
Functions | |
bool | rtouch_calibrate (void) |
Start new calibration process, return false if finished. |
bool rtouch_calibrate | ( | void | ) |
Start new calibration process, return false if finished.
Definition at line 81 of file rtouch_calibrate.c.
References calibratehandler(), rtouch_calibration_point_struct::panelX, rtouch_calibration_point_struct::panelY, rtouch_calibration_points_struct::point1, rtouch_calibration_points_struct::point2, rtouch_calibration_points_struct::point3, rtouch_calibration_point_struct::rawX, rtouch_calibration_point_struct::rawY, RTOUCH_COLOR, rtouch_compute_calibration_matrix(), rtouch_get_event(), rtouch_get_event_handler(), rtouch_is_touched(), rtouch_set_calibration_matrix(), rtouch_set_event_handler(), tft_draw_filled_circle, tft_print_string, and TFT_WHOLE.
Referenced by main().
00082 { 00083 //int * state = (int *) data; 00084 rtouch_event_t event; 00085 bool in_progress = true; 00086 static int state = 0; 00087 static rtouch_event_handler_t oldHandler; 00088 00089 switch (state) { 00090 00091 case 0: 00092 //TFT_SetClipping( 0, 0, TFT_GetWidth(), TFT_GetHeight() ); 00093 //TFT_color_t MEM_RAMTYPE * pixmap; 00094 //pixmap = MEM_ALLOC_ARRAY( TFT_color_t, (240UL * 320UL) ); 00095 00096 tft_print_string( 10, 10, "Touch screen calibration...", 00097 RTOUCH_COLOR); 00098 00099 points.point1.panelX = 30; 00100 points.point1.panelY = 30; 00101 points.point2.panelX = 170; 00102 points.point2.panelY = 220; 00103 points.point3.panelX = 300; 00104 points.point3.panelY = 120; 00105 tft_draw_filled_circle( points.point1.panelX, 00106 points.point1.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); 00107 state = 1; 00108 00109 oldHandler = rtouch_get_event_handler(); 00110 rtouch_set_event_handler( calibratehandler ); 00111 00112 break; 00113 00114 case 1: 00115 if (rtouch_is_touched() == false) { break; } 00116 tft_draw_filled_circle( points.point1.panelX, 00117 points.point1.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); 00118 rtouch_get_event(&event); 00119 points.point1.rawX = event.rawX; 00120 points.point1.rawY = event.rawY; 00121 state = 2; 00122 00123 break; 00124 00125 case 2: 00126 if (rtouch_is_touched() == true) { break; } 00127 tft_draw_filled_circle( points.point2.panelX, 00128 points.point2.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); 00129 state = 3; 00130 break; 00131 00132 case 3: 00133 if (rtouch_is_touched() == false) { break; } 00134 tft_draw_filled_circle( points.point2.panelX, 00135 points.point2.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); 00136 rtouch_get_event(&event); 00137 points.point2.rawX = event.rawX; 00138 points.point2.rawY = event.rawY; 00139 state = 4; 00140 break; 00141 00142 case 4: 00143 if (rtouch_is_touched() == true) { break; } 00144 tft_draw_filled_circle( points.point3.panelX, 00145 points.point3.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); 00146 state = 5; 00147 break; 00148 00149 case 5: 00150 if (rtouch_is_touched() == false) { break; } 00151 tft_draw_filled_circle( points.point3.panelX, 00152 points.point3.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); 00153 rtouch_get_event(&event); 00154 points.point3.rawX = event.rawX; 00155 points.point3.rawY = event.rawY; 00156 state = 6; 00157 break; 00158 00159 case 6: 00160 if (rtouch_is_touched() == true) { break; } 00161 rtouch_compute_calibration_matrix(&points, &matrix); 00162 rtouch_set_calibration_matrix(&matrix); 00163 state = 7; 00164 00165 rtouch_set_event_handler(oldHandler); 00166 in_progress = false; 00167 state = 0; 00168 // TODO redraw the background if needed 00169 break; 00170 00171 default: 00172 break; 00173 } 00174 return in_progress; 00175 }