Skip to content

Commit 2be68ac

Browse files
committed
Merge branch 'bugfix/optimize_touch_panel_display' into 'master'
touch_panel: revise calibration prompt See merge request rd/esp-iot-solution!537
2 parents 1770f42 + 68bfe79 commit 2be68ac

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

components/display/touch_panel/calibration/basic_painter/basic_painter.c

+15-10
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,33 @@ void painter_draw_char(int x, int y, char ascii_char, const font_t *font, uint16
9292
PAINTER_CHECK(ascii_char >= ' ', "ACSII code invalid");
9393
PAINTER_CHECK(NULL != font, "Font pointer invalid");
9494
int i, j;
95-
int x0 = x;
9695
uint16_t char_size = font->Height * (font->Width / 8 + (font->Width % 8 ? 1 : 0));
9796
unsigned int char_offset = (ascii_char - ' ') * char_size;
9897
const unsigned char *ptr = &font->table[char_offset];
98+
uint16_t buf[18 * 25];
99+
PAINTER_CHECK(font->Height * font->Width * sizeof(uint16_t) <= sizeof(buf), "Font size is too large");
100+
int ox = 0;
101+
int oy = 0;
99102

103+
for (i = 0; i < font->Width * font->Height; i++) {
104+
buf[i] = g_back_color;
105+
}
100106
for (j = 0; j < char_size; j++) {
101107
uint8_t temp = ptr[j];
102108
for (i = 0; i < 8; i++) {
103109
if (temp & 0x80) {
104-
g_lcd.draw_pixel(x, y, g_point_color);
105-
} else {
106-
g_lcd.draw_pixel(x, y, g_back_color);
110+
buf[ox + (font->Width * oy)] = g_point_color;
107111
}
108112
temp <<= 1;
109-
x++;
110-
if ((x - x0) == font->Width) {
111-
x = x0;
112-
y++;
113+
ox++;
114+
if (ox == font->Width) {
115+
ox = 0;
116+
oy++;
113117
break;
114118
}
115119
}
116120
}
121+
g_lcd.draw_bitmap(x, y, font->Width, font->Height, buf); // Draw NxN char
117122
}
118123

119124
void painter_draw_string(int x, int y, const char *text, const font_t *font, uint16_t color)
@@ -149,7 +154,7 @@ void painter_draw_num(int x, int y, uint32_t num, uint8_t len, const font_t *fon
149154
{
150155
PAINTER_CHECK(len < 10, "The length of the number is too long");
151156
PAINTER_CHECK(NULL != font, "Font pointer invalid");
152-
char buf[10]={0};
157+
char buf[10] = {0};
153158
int8_t num_len;
154159

155160
itoa(num, buf, 10);
@@ -196,7 +201,7 @@ void painter_draw_line(int x1, int y1, int x2, int y2, uint16_t color)
196201
uint16_t t;
197202
int xerr = 0, yerr = 0, delta_x, delta_y, distance;
198203
int incx, incy, uRow, uCol;
199-
delta_x = x2 - x1;
204+
delta_x = x2 - x1;
200205
delta_y = y2 - y1;
201206
uRow = x1;
202207
uCol = y1;

components/display/touch_panel/calibration/touch_calibration.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ esp_err_t touch_calibration_run(const scr_driver_t *screen,
286286
calibrate_error = 0;
287287
ESP_LOGI(TAG, "/ XL = (%f)X + (%f)Y + (%f)", g_caldata.ax, g_caldata.bx, g_caldata.cx);
288288
ESP_LOGI(TAG, "\\ YL = (%f)X + (%f)Y + (%f)", g_caldata.ay, g_caldata.by, g_caldata.cy);
289-
show_prompt_with_dir(30, h/2, "Successful", &Font16, COLOR_BLUE, old_dir);
289+
show_prompt_with_dir((w/2)-(Font16.Width*5), (h/2)+Font16.Height, "Successful", &Font16, COLOR_BLUE, old_dir);
290290
touch_save_calibration(&g_caldata, sizeof(Calibration_t));
291291
vTaskDelay(2000 / portTICK_PERIOD_MS);
292292
}

0 commit comments

Comments
 (0)