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

📄 hwtp_manage_fs.c

📁 嵌入式系统展讯mmi kernel 的c源代码, 仅供学习, 如果商用, 后果自负.
💻 C
📖 第 1 页 / 共 3 页
字号:
/**
 * 文 件 名: HWRecog_Public.c
 * 版权所有: Radio-Tel
 * 作    者: yujianzhang
 * 功能描述: 
 * TO    DO: 
 * TO   FIX: 
 * 修改历史: 
 *==========================================================================
 * 2005-10-21  yujianzhang created
 * 
 */

#include "os_api.h"
#include "mmi_signal.h"
#include "HW_recog_FS.h"
#include "HWTP_manage_FS.h"
#include "mmidisplay_data.h"
#include "user_tasks_id.h"
#include "guilcd.h"
#include "mmi_theme.h"
#include "dal_lcd.h"
#include "mmiset_interface.h"

#ifdef _SMMI_UNIT_TEST_
#define LOCAL
#else
#define LOCAL   static
#endif
 

/**--------------------------------------------------------------------------*
 **                         MACRO DEFINITION                                 *
 **--------------------------------------------------------------------------*/

#define 	HWTP_TRACE	SCI_TRACE_LOW 

#define		HWTP_UPDATE_SCREEN_TIME	50

#define		HWTP_STROKE_DISPLACEMENT	10
#define		HWTP_TOUCH_TIME	200
#define		HWTP_ABS(value)	((value) >= 0 ? (value) : 0 - (value))
/**--------------------------------------------------------------------------*
 **                         STATIC DEFINITION                                *
 **--------------------------------------------------------------------------*/

LOCAL SCI_MUTEX_PTR g_HWTP_Mutex_ptr = SCI_NULL;
LOCAL BOOLEAN	g_bDeleteTimer = FALSE;

LOCAL BOOLEAN	g_bDiscard = FALSE;
LOCAL BOOLEAN	g_bBelongToMMI = FALSE;
LOCAL BOOLEAN	g_bHalt = FALSE;
LOCAL BOOLEAN	g_write_char = FALSE;
LOCAL	TP_MANAGE_T	g_tp_manage = {0};
LOCAL	HW_MANAGE_T	g_hw_manage = {0};

LOCAL GUI_POINT_T g_back_point1 = {0};
LOCAL GUI_POINT_T g_back_point2 = {0};

#define MAX_COORDINATE	0x7FFF
#define MIN_COORDINATE	0

LOCAL GUI_RECT_T g_update_rect = {MAX_COORDINATE, MAX_COORDINATE, MIN_COORDINATE, MIN_COORDINATE};
LOCAL GUI_COLOR_T *s_touchpanel_lcd_buf_ptr = PNULL;
LOCAL uint16 s_touchpanel_lcd_width = 0;
LOCAL uint16 s_touchpanel_lcd_height = 0;

LOCAL GUI_COLOR_T	g_char_color = 0;
LOCAL uint32	g_recog_timeout = 500;
LOCAL uint16	g_color_index = 0;
LOCAL const GUI_COLOR_T g_color[] =
{
	0x707f,
	0xb07f,
	0xfc5f,
	0xe9e0,
	0xfb80,
	0xfc60,
	0xfe40,
	0xff80,
	0xc700,
	0x7680,
	0x06df,
	0x05fd,
	0x03bd,
	0x003d
};

static BOOLEAN g_bTpOpen = FALSE;

#define HWTP_OPEN_LCD(lcd_id) if (!g_bTpOpen){g_bTpOpen = TRUE; LCD_Open(lcd_id);}
#define HWTP_CLOSE_LCD(lcd_id) if (g_bTpOpen){g_bTpOpen = FALSE;  LCD_Close(lcd_id);}
#define HWTP_LCD_INVALIDATE_RECT(lcd_id, left, top, right, bottom)	LCD_InvalidateRect((lcd_id), (left), (top), (right), (bottom))

/*---------------------------------------------------------------------------*/
/*                         TYPE AND CONSTANT                                 */
/*---------------------------------------------------------------------------*/

/**--------------------------------------------------------------------------*
 **                         EXTERNAL DEFINITION                              *
 **--------------------------------------------------------------------------*/
extern BOOLEAN MMIDEFAULT_GetBackLightState(void);
extern BOOLEAN MMI_SendPoint(int16 x, int16 y, uint32 TPMsg);
/**--------------------------------------------------------------------------*
 **                         GLOBAL DEFINITION                                *
 **--------------------------------------------------------------------------*/


/*---------------------------------------------------------------------------*/
/*                          LOCAL FUNCTION DECLARE                           */
/*---------------------------------------------------------------------------*/
/*****************************************************************************/
//  Description:    Main entry of HWTP_task task.
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HWTP_task_entry(uint32 argc, void *argv);



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

/*****************************************************************************/
//  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
									);

/*****************************************************************************/
//  Description:    initialize hw manage
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_manage_init(HW_MANAGE_T	*hw_manage_ptr, 
							void*	tp_manage_ptr);
/*****************************************************************************/
//  Description:   set HW RECOGNISE TYPE
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL BOOLEAN HW_ManageHandleMsg(
							void*	hw_manage_ptr,
							HWMSG_ID_E	msg_id,
							void*	param1,
							void*	param2 
							);

/*****************************************************************************/
//  Description:   START timer when pen up
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_StartCharEndTimer(HW_MANAGE_T *hw_manage_ptr);

/*****************************************************************************/
//  Description:   Stop timer when pen down
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_StopCharEndTimer(HW_MANAGE_T *hw_manage_ptr);

/*****************************************************************************/
//  Description:   HW timer CALLBACK
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL  void HW_TimerCallBack(uint32 input);

/*****************************************************************************/
//  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);

/*****************************************************************************/
//  Description:   Stop timer when pen down
//  Author:         hb
//	Note:           
/*****************************************************************************/
LOCAL void HW_StartTPRecog(HW_MANAGE_T *hw_manage_ptr);

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

/*****************************************************************************/
//  Description:  复位识别的状态
//  Author:         hb
//	Note:       true: is recoging;	false: finish recognise    
/*****************************************************************************/
LOCAL void HW_ResetRecogState(HW_MANAGE_T *hw_manage_ptr);

LOCAL void TP_DrawPenPoint(GUI_POINT_T cur_point, GUI_POINT_T back_point, BOOLEAN bImmediate);
LOCAL GUI_POINT_T TP_GetBackPoint1(void);
LOCAL GUI_POINT_T TP_GetBackPoint2(void);
LOCAL void TP_SavePoint1(GUI_POINT_T point);
LOCAL void TP_SavePoint2(GUI_POINT_T point);
LOCAL void	FilterCurPoint(GUI_POINT_T point1, GUI_POINT_T point2, GUI_POINT_T *cur_point);
LOCAL void HWTP_DrawLine(int16 x1, int16 y1, int16 x2, int16 y2, GUI_COLOR_T color);
LOCAL void HWTP_ClearScreen(void);

LOCAL void HWTP_VariableInit(void)
{
	int i = 0;

	g_bHalt = FALSE;
	g_bBelongToMMI = FALSE;
	g_write_char = FALSE;
}

/*****************************************************************************/
//  Description:    This function initializes HWTP TASK.
//  Author:         Jing.Li
//	Note:           
/*****************************************************************************/
 uint32 HWTP_task_init(void)  // If succeed, return SCI_SUCCESS,
                                                    			// else return SCI_ERROR
{
	LCD_INFO_T lcd_info;

	if (ERR_LCD_NONE != LCD_GetInfo(TOUCHPANEL_LCD_ID, &lcd_info))
	{
		SCI_ASSERT( 0 );
	}
	else
	{
		s_touchpanel_lcd_buf_ptr	= (GUI_COLOR_T *)(lcd_info.lcdbuff_ptr);
		s_touchpanel_lcd_height	= lcd_info.lcd_height;
		s_touchpanel_lcd_width	= lcd_info.lcd_width;
		SCI_ASSERT(s_touchpanel_lcd_buf_ptr != PNULL);
	}
	HWTP_ClearScreen();

	g_bDeleteTimer = FALSE;
    HW_manage_init(&g_hw_manage, &g_tp_manage);
	TP_manage_init(&g_tp_manage, &g_hw_manage); 
	g_HWTP_Mutex_ptr = SCI_CreateMutex("hwtp_mutex", SCI_INHERIT);
	SCI_ASSERT(SCI_NULL != g_HWTP_Mutex_ptr);
	if (SCI_NULL == g_HWTP_Mutex_ptr)
	{
		return SCI_ERROR;
	}
	else
	{
		return SCI_SUCCESS;
	}                         
}

 /*****************************************************************************/
//  Description:   Process start
//  Author:         
//	Note:           
/*****************************************************************************/
PUBLIC void HWTP_ProcessStart(void)
{
	if (SCI_SUCCESS != SCI_GetMutex(g_HWTP_Mutex_ptr, SCI_WAIT_FOREVER))
    {
        HWTP_TRACE("HWTP_ProcessStart get mutex error\n");
        return;
    }
	HWTP_TRACE("Enter HWTP_ProcessStart");
	if (TRUE == g_bDeleteTimer)
	{
		HW_StopCharEndTimer(&g_hw_manage);
		g_bDeleteTimer = FALSE;
	}

	g_char_color = MMISET_GetHandWritePenColor();
	g_recog_timeout = MMISET_GetHandWriteTimeOut();
	HW_manage_init(&g_hw_manage, &g_tp_manage);
	TP_manage_init(&g_tp_manage, &g_hw_manage);
	g_tp_manage.is_task_startup = TRUE;
	HWTP_VariableInit();
	HWTP_ClearScreen();

	SCI_PutMutex(g_HWTP_Mutex_ptr);
}

void HWTP_SetImmPtr(const void* imm_ptr)
{
	g_hw_manage.imm_ptr = (void*)imm_ptr;
}
/*****************************************************************************/
//  Description:  Process stop 
//  Author:         
//	Note:           
/*****************************************************************************/
PUBLIC void HWTP_ProcessStop(void)
{
	if (SCI_SUCCESS != SCI_GetMutex(g_HWTP_Mutex_ptr, SCI_WAIT_FOREVER))
    {
        HWTP_TRACE("HWTP_ProcessStop get mutex error\n");
        return;
    }
	HWTP_TRACE("Enter HWTP_ProcessStop ");
	if (TRUE == g_bDeleteTimer)
	{
		HW_StopCharEndTimer(&g_hw_manage);
		g_bDeleteTimer = FALSE;
	}

	g_tp_manage.is_task_startup = FALSE;
	g_tp_manage.is_pen_down = FALSE;
	HW_ResetRecogState(&g_hw_manage);
	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);
}

/*****************************************************************************/
//  Description:   Finish recognition
//  Author:         
//	Note:           
/*****************************************************************************/
PUBLIC void HWTP_FinishRecognition(void)
{
	if (SCI_SUCCESS != SCI_GetMutex(g_HWTP_Mutex_ptr, SCI_WAIT_FOREVER))
    {
        HWTP_TRACE("HWTP_FinishRecognition get mutex error\n");
        return;
    }
	HWTP_TRACE("Enter HWTP_FinishRecognition");
	if (TRUE == g_bDeleteTimer)
	{
		HW_StopCharEndTimer(&g_hw_manage);
		g_bDeleteTimer = FALSE;
	}

	SCI_ASSERT(TRUE == HWTP_GetTaskWorkState());
	g_write_char = FALSE;
	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)
	HW_ResetRecogState(&g_hw_manage);

	SCI_PutMutex(g_HWTP_Mutex_ptr);
}
/*****************************************************************************/
//  Description:   process the touch point of hw
//  Author:         
//	Note:           
/*****************************************************************************/
PUBLIC void HWTP_PointProcess(SIG_HWTP_ID_E sig_id, int16 x, int16 y)
{
	BOOLEAN		result = TRUE;
	GUI_POINT_T cur_point;
	static BOOLEAN bPenDown = FALSE;

	if (SCI_SUCCESS != SCI_GetMutex(g_HWTP_Mutex_ptr, SCI_WAIT_FOREVER))
    {
        HWTP_TRACE("TP_PointSignalProc get mutex error\n");
        return;
    }
	if (TRUE == g_bDeleteTimer)
	{
		HW_StopCharEndTimer(&g_hw_manage);
		g_bDeleteTimer = FALSE;
	}
	
	if(HW_IsRecoging(&g_hw_manage))
	{
		SCI_PutMutex(g_HWTP_Mutex_ptr);
		return;
	}
	
	cur_point.x = x;
	cur_point.y = y;
	
	switch(sig_id)
	{
	case SIG_HWTP_INQUIRE:
		break;
		
	case SIG_HWTP_DOWN:
		TP_SavePoint1(cur_point);
		TP_SavePoint2(cur_point);
		result = HW_ManageHandleMsg(
				&g_hw_manage,
				HWMSG_PEN_DOWN, 
				NULL, 
				(void*)g_tp_manage.tp_buf);
		
		if(result)
		{
			g_tp_manage.is_pen_down = TRUE;
			bPenDown = TRUE;
			TP_StrokeBufferAddPt(
				&g_tp_manage,
				cur_point.x,

⌨️ 快捷键说明

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