⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hwtp_manage_fs.c

📁 嵌入式系统展讯mmi kernel 的c源代码, 仅供学习, 如果商用, 后果自负.
💻 C
📖 第 1 页 / 共 3 页
字号:
				cur_point.y);
		}	
		break;
		
	case SIG_HWTP_MOVE:
		if(g_tp_manage.is_pen_down)
		{	
			FilterCurPoint(TP_GetBackPoint1(), TP_GetBackPoint2(), &cur_point);

			if (bPenDown)
			{
				bPenDown = FALSE;
				TP_DrawPenPoint(cur_point, TP_GetBackPoint2(), TRUE);
			}
			else
			{
				TP_DrawPenPoint(cur_point, TP_GetBackPoint2(), FALSE);
			}
			TP_SavePoint1(TP_GetBackPoint2());
			TP_SavePoint2(cur_point);
			TP_StrokeBufferAddPt(
				&g_tp_manage,
				cur_point.x, 
				cur_point.y
				);
		}
		break;
		
	case SIG_HWTP_UP:
		//即时up到inputbox外也由HW处理,不做位置判断
		if(g_tp_manage.is_pen_down)		
		{
			g_tp_manage.is_pen_down = FALSE;
			TP_DrawPenPoint(cur_point, TP_GetBackPoint2(), TRUE);
			TP_StrokeBufferAddPt(
				&g_tp_manage,
				cur_point.x, 
				cur_point.y);
			TP_StrokeBufferAddPt(
				&g_tp_manage,
				HW_STROKE_END_FLAG1,
				HW_STROKE_END_FLAG2);
			HW_ManageHandleMsg(
				&g_hw_manage,
				HWMSG_PEN_UP, 
				(void*)g_tp_manage.tp_buf,
				&g_tp_manage.pos_offset);
		}
		break;
		
	default:	
		break;
	}

	SCI_PutMutex(g_HWTP_Mutex_ptr);
	return;
}


/*****************************************************************************/
//  Description:   initialize tp manage
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void TP_manage_init(
							TP_MANAGE_T	*tp_manage_ptr,
							void				*hw_manage_ptr
							)
{
	SCI_ASSERT(NULL != tp_manage_ptr);
	SCI_ASSERT(NULL != hw_manage_ptr);

	tp_manage_ptr->pos_offset = 0;

	tp_manage_ptr->is_pen_down = FALSE;
	tp_manage_ptr->is_task_startup = FALSE;

	tp_manage_ptr->hw_manage_ptr = hw_manage_ptr;
}

/*****************************************************************************/
//  Description:   get tp task state, work or stop?
//  Author:         hb
//	Note:           
/*****************************************************************************/
PUBLIC BOOLEAN HWTP_GetTaskWorkState(void)
{
	return g_tp_manage.is_task_startup;
}

/*****************************************************************************/
//  Description:   add pen point data to tp_buffer
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL BOOLEAN TP_StrokeBufferAddPt(
									TP_MANAGE_T *tp_manage_ptr,
									uint16 x, 
									uint16 y
									)
{
	uint16 size = TP_SIZE << 1;
#if WIN32
	uint8 *tp_buf_ptr = NULL;
#else
	uint16 *tp_buf_ptr = NULL;
#endif

	tp_buf_ptr = tp_manage_ptr->tp_buf;
	
	if ((tp_manage_ptr->pos_offset + 2) >= size)
	{
		tp_buf_ptr[size-2] = HW_CHAR_END_FLAG1;
		tp_buf_ptr[size-1] = HW_CHAR_END_FLAG2;
		return FALSE;
	}
	else
	{
		if (s_touchpanel_lcd_width > 255 && x != HW_CHAR_END_FLAG1)
		{
			tp_buf_ptr[tp_manage_ptr->pos_offset++] = (x * 255) / (s_touchpanel_lcd_width + 1);
		}
		else
		{
			tp_buf_ptr[tp_manage_ptr->pos_offset++] = x;
		}
		if (s_touchpanel_lcd_height > 255 && y != HW_CHAR_END_FLAG2)
		{
			tp_buf_ptr[tp_manage_ptr->pos_offset++] = (y * 255) / (s_touchpanel_lcd_height + 1);
		}
		else
		{
			tp_buf_ptr[tp_manage_ptr->pos_offset++] = y;
		}
		return TRUE;
	}
}

//===========================================================
//		HW manage: the operation for HW recognise task
//===========================================================

/*****************************************************************************/
//  Description:    initialize hw manage
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_manage_init(HW_MANAGE_T	*hw_manage_ptr, 
							void*	tp_manage_ptr)
{
	SCI_ASSERT(NULL != hw_manage_ptr);

	hw_manage_ptr->is_recoging = FALSE;
	hw_manage_ptr->charend_timer_data = 0;
	hw_manage_ptr->tp_manage_ptr = tp_manage_ptr;
}

/*****************************************************************************/
//  Description:   hw manage msg process
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL BOOLEAN HW_ManageHandleMsg(
							void*	hw_manage_ptr,
							HWMSG_ID_E	msg_id,
							void*	param1,
							void*	param2 
							)
{
	BOOLEAN		ret_val = TRUE;
	HW_MANAGE_T *hw_manage_p = (HW_MANAGE_T*)hw_manage_ptr; 
	uint32 *timer_data_ptr;
	
	SCI_ASSERT(NULL != hw_manage_ptr);

	switch(msg_id)
	{
		case HWMSG_PEN_DOWN:
			//关定时器
			HW_StopCharEndTimer(hw_manage_p);
			if(HW_IsRecoging(hw_manage_p))
			{
				ret_val = FALSE;
				break;
			}
			hw_manage_p->tp_buf_ptr = (uint16*)param2;		
			break;

		case HWMSG_PEN_UP:		
			HW_StartCharEndTimer(hw_manage_p);
			break;

		case HWMSG_TIMEOUT:
			timer_data_ptr  = (uint32 *)param1;
			SCI_ASSERT(*timer_data_ptr == hw_manage_p->charend_timer_data);		
			HW_AddCharEndFlag(hw_manage_p);
			HW_StartTPRecog(hw_manage_p);		
			g_bDeleteTimer = TRUE;
			break;
			
		default:
			ret_val = FALSE;
			break;

	}
	return	ret_val;
}

/*****************************************************************************/
//  Description:   START timer when pen up
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_StartCharEndTimer(HW_MANAGE_T *hw_manage_ptr)
{
	if (0 == hw_manage_ptr->charend_timer_data)
	{
		
		hw_manage_ptr->charend_timer_data = (uint32)SCI_CreateTimer(
														PNULL,
														HW_TimerCallBack,
														(uint32)(&hw_manage_ptr->charend_timer_data),
														g_recog_timeout,
														(uint32)TRUE);
		SCI_ASSERT(0 != hw_manage_ptr->charend_timer_data);
	}
	else
	{
		HW_StopCharEndTimer(hw_manage_ptr);
		
		hw_manage_ptr->charend_timer_data = (uint32)SCI_CreateTimer(
														PNULL,
														HW_TimerCallBack,
														(uint32)(&hw_manage_ptr->charend_timer_data),
														g_recog_timeout,
														(uint32)TRUE);
		SCI_ASSERT(0 != hw_manage_ptr->charend_timer_data);
	}
}

/*****************************************************************************/
//  Description:   Stop timer when pen down
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_StopCharEndTimer(HW_MANAGE_T *hw_manage_ptr)
{
	if (0 != hw_manage_ptr->charend_timer_data)
	{	
		SCI_DeleteTimer((SCI_TIMER_PTR)hw_manage_ptr->charend_timer_data);
		hw_manage_ptr->charend_timer_data = 0;
	}
}

/*****************************************************************************/
//  Description:   HW timer CALLBACK
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL  void HW_TimerCallBack(uint32 input)
{
	uint32        *timer ;
    
	SCI_ASSERT( PNULL != input );

	timer = (uint32 *)input;
	HW_ManageHandleMsg(
					(void*)(&g_hw_manage),
					HWMSG_TIMEOUT, 
					(void *)timer, 
					NULL);
}


/*****************************************************************************/
//  Description:   ADD char end flag to tp_buffer, and user has writen a char
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_AddCharEndFlag(HW_MANAGE_T *hw_manage_ptr)
{
	SCI_ASSERT(NULL != hw_manage_ptr);

	TP_StrokeBufferAddPt(
						hw_manage_ptr->tp_manage_ptr,
						HW_CHAR_END_FLAG1,
						HW_CHAR_END_FLAG2
						);
			
	((TP_MANAGE_T*)hw_manage_ptr->tp_manage_ptr)->pos_offset = 0;
}

/*****************************************************************************/
//  Description:   是否正在识别
//  Author:         hb
//	Note:         
/*****************************************************************************/
LOCAL BOOLEAN HW_IsRecoging(HW_MANAGE_T *hw_manage_ptr)
{
	SCI_ASSERT(NULL != hw_manage_ptr);

	return hw_manage_ptr->is_recoging;
}

/*****************************************************************************/
//  Description:  复位识别的状态
//  Author:         hb
//	Note:       true: is recoging;	false: finish recognise    
/*****************************************************************************/
LOCAL void HW_ResetRecogState(HW_MANAGE_T *hw_manage_ptr)
{
	SCI_ASSERT(NULL != hw_manage_ptr);
	
	hw_manage_ptr->is_recoging = FALSE;
}

/*****************************************************************************/
//  Description:   Stop timer when pen down
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_StartTPRecog(HW_MANAGE_T *hw_manage_ptr)
{
	HWRECOG_SIGNAL_T	*recog_sig;
	uint32 	result = 0;
	
	SCI_ASSERT(NULL != hw_manage_ptr);
	SCI_ASSERT(NULL !=  hw_manage_ptr->tp_buf_ptr);
	SCI_ASSERT(FALSE == hw_manage_ptr->is_recoging);
	
	hw_manage_ptr->is_recoging = TRUE;

	MMI_CREATE_SIGNAL(
					recog_sig,
					0,
					sizeof(HWRECOG_SIGNAL_T),
					HW_TP_MANAGE);

	recog_sig->recog_type = IMM_GetCurHWType(hw_manage_ptr->imm_ptr);
	recog_sig->tp_buffer_ptr = hw_manage_ptr->tp_buf_ptr;
	hw_manage_ptr->tp_buf_ptr = NULL;
	recog_sig->max_candi_num = HW_CANDI_MAX_NUM;

	result = SCI_SendSignal((xSignalHeader)recog_sig, HW_RECOG);
	
	if(SCI_SUCCESS != result)
	{
		HWTP_TRACE("HWDOC_CharEnd: result = %d", result);
		SCI_ASSERT(0);
		SCI_FREE(recog_sig);
	}
}

#ifdef WIN32
#include "windows.h"
LOCAL BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
	TCHAR title[256];
	LPCTSTR lpName = TEXT("MS Simulator");	
	GetWindowText(hwnd, title, sizeof(title));
	if (_tcscmp(lpName, title) == 0)
	{
		*(HWND*)lParam = hwnd;
		return FALSE;
	}
	return TRUE;
}

PUBLIC HWND MMI_FindEmulatorWin(void)
{
	HWND hWnd = NULL;
	EnumWindows(EnumWindowsProc, &hWnd);
	return hWnd;
}

PUBLIC void MMI_UpdataEmulatorWin(void)
{	
	static HWND	hwnd = NULL;
	if (NULL == hwnd)
		hwnd = MMI_FindEmulatorWin();
	
	if (NULL != hwnd)
	{
		RECT	rect;
		GetClientRect(hwnd,  &rect);
		InvalidateRect(hwnd, &rect, TRUE);
	}
}

#endif

LOCAL void	FilterCurPoint(GUI_POINT_T point1, GUI_POINT_T point2, GUI_POINT_T *cur_point)
{
	cur_point->x = (cur_point->x + point2.x) / 2;
	cur_point->y = (cur_point->y + point2.y) / 2;
}
/*****************************************************************************/
//  Description:   draw ponit in hw input box
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void TP_DrawPenPoint(GUI_POINT_T cur_point, GUI_POINT_T back_point, BOOLEAN bImmediate)
{
	static uint32 pre_tick_count = 0;
	uint32 cur_tick_count = 0;
	int16 left = 0, right = 0, top = 0, bottom = 0;	

	HWTP_OPEN_LCD(TOUCHPANEL_LCD_ID)
	if((cur_point.x == back_point.x) && (cur_point.y == back_point.y))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -