📄 hwtp_manage_fs.c
字号:
{
return;
}
if (0 == g_char_color)
{
HWTP_DrawLine(cur_point.x, cur_point.y, back_point.x, back_point.y, g_color[g_color_index]);
if (g_color_index >= sizeof(g_color) / sizeof(g_color[0]) - 1)
{
g_color_index = 0;
}
else
{
g_color_index++;
}
}
else
{
HWTP_DrawLine(cur_point.x, cur_point.y, back_point.x, back_point.y, g_char_color);
}
left = cur_point.x - 2 < 0 ? 0 : cur_point.x - 2;
if (g_update_rect.left > left)
{
g_update_rect.left = left;
}
right = cur_point.x + 2 >= s_touchpanel_lcd_width ? s_touchpanel_lcd_width - 1 : cur_point.x + 2;
if (g_update_rect.right < right)
{
g_update_rect.right = right;
}
top = cur_point.y - 2 < 0 ? 0 : cur_point.y - 2;
if (g_update_rect.top > top)
{
g_update_rect.top = top;
}
bottom = cur_point.y + 2 >= s_touchpanel_lcd_height ? s_touchpanel_lcd_height - 1 : cur_point.y + 2;
if (g_update_rect.bottom < bottom)
{
g_update_rect.bottom = bottom;
}
cur_tick_count = SCI_GetTickCount();
if (cur_tick_count - pre_tick_count >= HWTP_UPDATE_SCREEN_TIME || bImmediate)
{
pre_tick_count = cur_tick_count;
HWTP_LCD_INVALIDATE_RECT(TOUCHPANEL_LCD_ID, g_update_rect.left, g_update_rect.top, g_update_rect.right, g_update_rect.bottom);
g_update_rect.left = left;
g_update_rect.right = right;
g_update_rect.top = top;
g_update_rect.bottom = bottom;
}
}
LOCAL void TP_SavePoint1(GUI_POINT_T point)
{
g_back_point1 = point;
}
LOCAL void TP_SavePoint2(GUI_POINT_T point)
{
g_back_point2 = point;
}
LOCAL GUI_POINT_T TP_GetBackPoint1(void)
{
return g_back_point1;
}
LOCAL GUI_POINT_T TP_GetBackPoint2(void)
{
return g_back_point2;
}
#define WR_COLOR_IN_LCD(_x, _y, _color) \
{ \
if ( ((_x) >= 0) && ((_y) >= 0) && ((_x) < s_touchpanel_lcd_width) && ((_y) < s_touchpanel_lcd_height) ) \
{ \
*( s_touchpanel_lcd_buf_ptr + (_y)*(s_touchpanel_lcd_width) + (_x) ) = (_color); \
} \
}
LOCAL void HWTP_DrawLine(int16 x1, int16 y1, int16 x2, int16 y2, GUI_COLOR_T color)
{
int16 dx, dy, dx2, dy2, dif, de;
int16 dwidth = 1;
int16 temp;
if (x1 < 2)
{
x1 = 2;
}
else if (x1 > s_touchpanel_lcd_width-3)
{
x1 = s_touchpanel_lcd_width-3;
}
if (x2 < 2)
{
x2 = 2;
}
else if (x2 > s_touchpanel_lcd_width-3)
{
x2 = s_touchpanel_lcd_width-3;
}
if (y1 < 2)
{
y1 = 2;
}
else if (y1 > s_touchpanel_lcd_height-3)
{
y1 = s_touchpanel_lcd_height-3;
}
if (y2 < 2)
{
y2 = 2;
}
else if (y2 > s_touchpanel_lcd_height-3)
{
y2 = s_touchpanel_lcd_height-3;
}
dx = (x2) - (x1);
dy = (y2) - (y1);
dx2 = dx < 0 ? -dx : dx;
dy2 = dy < 0 ? -dy : dy;
if (dx2 >= dy2)
{
if(dx < 0)
{
temp = x1;
x1 = x2;
x2 = temp;
temp = y1;
y1 = y2;
y2 = temp;
}
dx = (x2) - (x1);
dy = (y2) - (y1);
if(dy < 0)
{
dy = -dy;
dwidth = -dwidth;
}
}
else {
if (dy < 0 )
{
temp = x1;
x1 = x2;
x2 = temp;
temp = y1;
y1 = y2;
y2 = temp;
}
dx = (x2) - (x1);
dy = (y2) - (y1);
if(dx < 0)
{
dx = -dx;
dwidth = -dwidth;
}
}
dx2 = dx << 1;
dy2 = dy << 1;
if ( dx >= dy )
{
GUI_COLOR_T *cur_2, *cur_1, *cur, *cur1, *cur2;
dif = dy2 - dx2;
de = dy2 - dx;
cur = s_touchpanel_lcd_buf_ptr + y1*s_touchpanel_lcd_width + x1;
cur_1 = cur - s_touchpanel_lcd_width;
cur_2 = cur_1 - s_touchpanel_lcd_width;
cur1 = cur + s_touchpanel_lcd_width;
cur2 = cur1 + s_touchpanel_lcd_width;
for (; dx >= 0; dx--)
{
*cur_2++ = color;
*cur_1++ = color;
*cur++ = color;
*cur1++ = color;
*cur2++ = color;
if(de > 0)
{
(y1) += dwidth;
cur += dwidth*s_touchpanel_lcd_width;
cur_1 = cur - s_touchpanel_lcd_width;
cur_2 = cur_1 - s_touchpanel_lcd_width;
cur1 = cur + s_touchpanel_lcd_width;
cur2 = cur1 + s_touchpanel_lcd_width;
de += dif;
}
else
{
de += dy2;
}
}
}
else
{
GUI_COLOR_T *cur;
dif = dx2 - dy2;
de = dx2 - dy;
cur = s_touchpanel_lcd_buf_ptr + y1*s_touchpanel_lcd_width + x1;
for (; dy >= 0; dy--, cur+=s_touchpanel_lcd_width)
{
cur[-2] = color;
cur[-1] = color;
cur[0] = color;
cur[1] = color;
cur[2] = color;
if (de > 0)
{
(x1) += dwidth;
cur += dwidth;
de += dif;
}
else
{
de += dx2;
}
}
}
}
LOCAL void HWTP_ClearScreen(void)
{
int i = 0;
g_update_rect.left = MAX_COORDINATE;
g_update_rect.right = MIN_COORDINATE;
g_update_rect.top = MAX_COORDINATE;
g_update_rect.bottom = MIN_COORDINATE;
for (i = 0; i < s_touchpanel_lcd_width * s_touchpanel_lcd_height; ++i)
{
s_touchpanel_lcd_buf_ptr[i] = 0;
}
}
PUBLIC void HWTP_SetHaltFlag(BOOLEAN bHalt)
{
if (TRUE == g_tp_manage.is_task_startup)
{
g_bHalt = bHalt;
}
}
PUBLIC void HWTP_Clear(void)
{
if (SCI_SUCCESS != SCI_GetMutex(g_HWTP_Mutex_ptr, SCI_WAIT_FOREVER))
{
return;
}
if (TRUE == g_bDeleteTimer)
{
HW_StopCharEndTimer(&g_hw_manage);
g_bDeleteTimer = FALSE;
}
if (g_write_char && !g_hw_manage.is_recoging)
{
g_bDiscard = TRUE;
g_tp_manage.is_pen_down = FALSE;
g_tp_manage.pos_offset = 0;
g_write_char = FALSE;
HW_StopCharEndTimer(&g_hw_manage);
HWTP_ClearScreen();
// HWTP_LCD_INVALIDATE_RECT(TOUCHPANEL_LCD_ID, g_update_rect.left, g_update_rect.top, g_update_rect.right, g_update_rect.bottom);
HWTP_CLOSE_LCD(TOUCHPANEL_LCD_ID)
}
SCI_PutMutex(g_HWTP_Mutex_ptr);
}
//#endif
PUBLIC POINT_PROCESS_RESULT HWTP_SendPoint(int16 x, int16 y, uint32 TPMsg)
{
static int16 s_down_x = 0, s_down_y = 0;
static uint32 s_down_tick = 0;
uint32 cur_tick = 0;
POINT_PROCESS_RESULT result = POINT_MAX;
if (MSG_TP_DOWN == TPMsg)
{
s_down_x = x;
s_down_y = y;
}
if (FALSE == g_tp_manage.is_task_startup)
{
return POINT_UNPROCESSED;
}
if (g_bDiscard)
{
if (MSG_TP_UP == TPMsg)
{
g_bDiscard = FALSE;
}
result = POINT_DISCARD;
}
else
if (g_bHalt || !MMIDEFAULT_GetBackLightState())
{
if (MSG_TP_UP == TPMsg)
{
g_bBelongToMMI = FALSE;
}
else
{
g_bBelongToMMI = TRUE;
}
result = POINT_UNPROCESSED;
}
else if (g_bBelongToMMI)
{
if (MSG_TP_UP == TPMsg)
{
g_bBelongToMMI = FALSE;
}
result = POINT_UNPROCESSED;
}
else if (FALSE == g_write_char)
{
if ((y < 0 || y >= s_touchpanel_lcd_height) && MSG_TP_DOWN == TPMsg)
{
g_bBelongToMMI = TRUE;
result = POINT_UNPROCESSED;
}
else
{
if (MSG_TP_DOWN != TPMsg)
{
if (y < 0)
{
y = 0;
}
else if (y >= s_touchpanel_lcd_height)
{
y = s_touchpanel_lcd_height - 1;
}
}
switch (TPMsg)
{
case MSG_TP_DOWN:
s_down_x = x;
s_down_y = y;
s_down_tick = SCI_GetTickCount();
result = POINT_DELAY_PROCESS;
break;
case MSG_TP_MOVE:
cur_tick = SCI_GetTickCount();
if (HWTP_ABS(x - s_down_x) >= HWTP_STROKE_DISPLACEMENT
|| HWTP_ABS(y - s_down_y) >= HWTP_STROKE_DISPLACEMENT)
{
g_write_char = TRUE;
HWTP_PointProcess(SIG_HWTP_DOWN, s_down_x, s_down_y);
HWTP_PointProcess(SIG_HWTP_MOVE, x, y);
result = POINT_PROCESSED;
}
else if (cur_tick - s_down_tick >= HWTP_TOUCH_TIME)
{
g_bBelongToMMI = TRUE;
result = POINT_UNPROCESSED;
}
else
{
result = POINT_DELAY_PROCESS;
}
break;
case MSG_TP_UP:
result = POINT_UNPROCESSED;
break;
default:
SCI_TRACE_LOW(FALSE);
break;
}
}
}
else
{
if (y < 0)
{
y = 0;
}
else if (y >= s_touchpanel_lcd_height)
{
y = s_touchpanel_lcd_height - 1;
}
HWTP_PointProcess(TPMsg, x, y);
result = POINT_PROCESSED;
}
SCI_ASSERT(POINT_MAX > result);
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -