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

📄 lcd2.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 4 页
字号:
        Lcd_Draw_Circle_Fill(Round->x, Round->y, Round->radius, Round->color);
}


/*---------------------------------------------------------------------------*
    将需要显示的字符串送到显示缓冲区
    此函数主要只是对待显示字符串的一个修正, 当显示长度超过允许长度时, 
    修正为最大允许长度. 并在字符串尾处添加字符串结束符
    真正的显示字符串的函数是
        Lcd_Send_Text_Buff_Str();
        
	text_id: the text buffer id.
	posi: the buffer start position. (1~MAX_LCD_TEXT)
	src: the source string.
	len: the source length.
	align: ALIGN_LEFT, ALIGH_MID, ALIGH_RIGHT

	Note: when select ALIGN_MID, the posi will be no effect
	此函数还需要一些修正, 从而达到需要的效果
*---------------------------------------------------------------------------*/
void Lcd_Send_Text_Buff_Mem(byte text_id, byte posi, char *src, byte len, byte align)
{
	byte tmp[MAX_LCD2_LEN+1];

	if (len > MAX_LCD2_LEN)
		len = MAX_LCD2_LEN;
	memcpy(tmp, src, len);
	tmp[len] = '\0';
	Lcd_Send_Text_Buff_Str(text_id, posi, tmp, align);
}

void Lcd_Send_Text_Buff_Str_Sub(byte text_ID, byte posi1,char *str,byte posi2, long num, byte dots,byte Align)
{
	byte tmp[MAX_LENGTH_15];
	byte sto_dot = 0;
	byte sto_aster = 0;
	byte adj = 0;
    byte len1;
    byte len2;
    
    if(text_ID == BUF_ID_TL_SUB)
    {
        Tl_Sub.align = Align;
        Tl_Sub.posi[0] = 1;
        Tl_Sub.posi_max = 1;
        len1 = strlen(str);
        memset(Tl_Sub.text, 0x20, MAX_TEXT);
        memcpy(Tl_Sub.text+posi1-1, str, len1);
        
        Get_Sto_Flag(&sto_dot, &adj, &sto_aster);
        
        len2 = LongAndDot2Str(num, dots, tmp, sto_dot, adj, sto_aster, 0);
        
        /* Store the data in the lcd dispaly buffer */
        memmove(tmp, tmp+MAX_LENGTH_15-len2, len2);
        tmp[len2] = '\0';
        memcpy(Tl_Sub.text+posi2-1, tmp, len2);
        
        Tl_Sub.len[0] = posi2 + len2;
        Tl_Sub.text[Tl_Sub.len[0]] = '\0';
    }
    else 
    {
    }
}


/*---------------------------------------------------------------------------*
	Send the string to the display buffer
	text_id: the text buffer id.
	posi: the buffer start position. (1~MAX_LCD_TEXT)
	src: the source string.
	align: ALIGN_LEFT, ALIGH_MID, ALIGH_RIGHT

	Note: when select ALIGN_MID, the posi will be no effect
*---------------------------------------------------------------------------*/
void Lcd_Send_Text_Buff_Str(byte text_id, byte posi, char *src, byte align)
{
	LCD_LINE_TEXT_DEF *line_text;
	byte color;
	byte max_posi;
	byte src_len;
	byte tmp;

	if (align != ALIGN_LEFT && align != ALIGN_RIGHT && align != ALIGN_MID)
		return;
	if (align == ALIGN_RIGHT)		/* The right align, return */
		return;

	if (text_id == BUF_ID_LCD_TEXT) //文本文档显示区域
    {
		if (Lcd_Text.cur_line == Lcd_Text.max_line) 
        {	/* Indicate the new line */
			if (Lcd_Text.max_line >= MAX_LCD_TEXT_LINE)	/* The buffer is full */
				return;
			Lcd_Text.cur_line = Lcd_Text.max_line + 1;
			Lcd_Text.dsp_line_new = Lcd_Text.cur_line - 1;

			// Initialize the new line text.
			tmp = Lcd_Text.dsp_line_new;
			Lcd_Text.line[tmp].align = DFT_ALING_LCD_TEXT;
			Lcd_Text.line[tmp].text_color = LCD_TEXT_COLOR;
			Lcd_Text.line[tmp].posi_max = 0;
			memset(Lcd_Text.line[tmp].posi, 0, MAX_LINE_POSI);
			memset(Lcd_Text.line[tmp].len, 0, MAX_LINE_POSI);
			memset(Lcd_Text.line[tmp].text, ' ', MAX_TEXT);
		}
		line_text = &Lcd_Text.line[Lcd_Text.dsp_line_new];
		color = LCD_TEXT_COLOR;
		max_posi = MAX_LCD_TEXT;
	}
	else if (text_id == BUF_ID_POP_TEXT) //弹出框显示区域
    {
		if (Pop_Text.cur_line == Pop_Text.max_line) {	/* Indicate the new line */
			if (Pop_Text.max_line == MAX_POP_TEXT_LINE)	/* The buffer is full */
				return;
			Pop_Text.cur_line = Pop_Text.max_line + 1;
			Pop_Text.dsp_line_new = Pop_Text.cur_line - 1;

			// Initialize the new line text.
			tmp = Pop_Text.dsp_line_new;
			Pop_Text.line[tmp].align = DFT_ALIGN_POP_TEXT;
			Pop_Text.line[tmp].text_color = POP_TEXT_COLOR;
			Pop_Text.line[tmp].posi_max = 0;
			memset(Pop_Text.line[tmp].posi, 0, MAX_LINE_POSI);
			memset(Pop_Text.line[tmp].len, 0, MAX_LINE_POSI);
			memset(Pop_Text.line[tmp].text, ' ', MAX_TEXT);
		}
		line_text = &Pop_Text.line[Pop_Text.dsp_line_new];
		color = POP_TEXT_COLOR;
		if (Lcd_Mode == LCD_10_INCH)
			max_posi = MAX_POP_TEXT;
		else
			max_posi = MAX_POP_TEXT7;
	}
	else if (text_id == BUF_ID_TL_TITLE) 
    {
		line_text = &Tl_Title;
		color = STAT_TEXT_COLOR;
		if (Lcd_Mode == LCD_10_INCH)
			max_posi = MAX_STAT_TEXT;
		else
			max_posi = MAX_STAT_TEXT7;
	}
	else if (text_id == BUF_ID_TL_INPUT) 
    {
		line_text = &Tl_Input;
		color = INPUT_TEXT_COLOR;
		if (Lcd_Mode == LCD_10_INCH)
			max_posi = MAX_INPUT_TEXT;
		else
			max_posi = MAX_INPUT_TEXT7;
	}
	else if (text_id == BUF_ID_TL_SUB) 
    {
		line_text = &Tl_Sub;
		color = SUB_TEXT_COLOR;
		if (Lcd_Mode == LCD_10_INCH)
			max_posi = MAX_SUB_TEXT;
		else
			max_posi = MAX_SUB_TEXT7;
	}
	else 
    {
		return;
	}

	if (posi > max_posi || posi < 1)
		return;
    
	if (!Tl_TiTl_Sto_Flag && text_id == BUF_ID_TL_TITLE) 
    {
		Tl_TiTl_Sto_Flag = 1;
		Rst_Tl_Titl();
	}
	else if (!Tl_Input_Sto_Flag && text_id == BUF_ID_TL_INPUT) 
    {
		Tl_Input_Sto_Flag = 1;
		Rst_Tl_Input();
	}
	else if (!Tl_Sub_Sto_Flag && text_id == BUF_ID_TL_SUB) 
    {
		Tl_Sub_Sto_Flag = 1;
		Rst_Tl_Sub();
	}

	src_len = strlen(src);
	if (src_len > max_posi - posi + 1)
		src_len = max_posi - posi + 1;
	if (align == ALIGN_MID) {		/* Center align */
		line_text->align = ALIGN_MID;
		line_text->posi_max = 1;
		line_text->text_color = color;
		memset(line_text->posi, 0, MAX_LINE_POSI);
		line_text->posi[0] = 1;
		line_text->len[0] = src_len;
        posi = posi +(max_posi-posi-src_len)/2;
		memcpy(line_text->text+posi, src, src_len);
	}
	else { // align == ALIGN_LEFT
		line_text->align = align;	// ALIGN_LEFT
		if (line_text->posi_max < MAX_LINE_POSI)
			line_text->posi_max++;
		line_text->text_color = color;
		line_text->posi[line_text->posi_max - 1] = posi;
		line_text->len[line_text->posi_max - 1] = src_len;
		memcpy(line_text->text + (posi-1), src, src_len);
	}
}

/*---------------------------------------------------------------------------*
    将 LCD text buffer 按需要显示在不同的区域
    根据不同的 text_id 显示在不同的位置
	text_id: The text buffer id.
*---------------------------------------------------------------------------*/
void Lcd_Disp_Text_Buff(byte text_id)
{
    Lcd_Disp_Text_Line(text_id);
}
/*---------------------------------------------------------------------------*
    在 BUF_ID_TL_SUB 和 BUF_ID_TL_INPUT 中 显示较长的字符串
*---------------------------------------------------------------------------*/
void Lcd_Disp_Str_Btn(byte Btn_ID, char *str)
{
    byte len;
    
    if((Btn_ID != BUF_ID_TL_SUB)&&(Btn_ID != BUF_ID_TL_INPUT))
    {//只限于在 BUF_ID_TL_SUB 和 BUF_ID_TL_INPUT 这两个框内显示
        return;
    }
    
    len = strlen(str);
    
    Lcd_Disp_Text_btn(Btn_ID, str, len, MAX_LCD_TEXT, DEFAULT_FONT, ALIGN_LEFT);
}

/*
	Send the descriptor to the display buffer
	text_id: the text buffer id.
	posi: the buffer start position. (1~MAX_LCD_TEXT)
	src: the source string.
	mode: The descriptor mode.
	align: ALIGN_LEFT, AILGN_MID, ALIGN_RIGHT.

	Note: when select ALIGN_MID, the posi will be no effect
*/
void Lcd_Send_Text_Buff_Desc(byte text_id, byte posi, char *desc, byte mode, byte align)
{
	byte tmp[MAX_PRN_LEN+1];
	byte len;
    byte i;
    byte j;

	if (mode == NO) 
    {
		len = Get_Desc_Len(desc, MAX_DESC_LEN_EX);
		memcpy(tmp, desc, len);
	}
	else 
    { // mode == YES, the string with control byte(about DBH, DBW, DBHW,and so on)
	    len =0;
        for(i = 0; i< MAX_PRN_LEN*2; i++)
        {
           if((*desc >= 0x20)&&(*desc <= 0x80))
              tmp[len++] = *desc;
           else if(*desc == 0)
              break;
           *desc++;
        }
	}
   
    while((len >0)&&(tmp[len-1] == 0x20))len--;//去掉空字符
    
    tmp[len] = '\0';
       
      if(len > MAX_TEXT)
      {
         char tmp_str[MAX_TEXT+1];
         for(j = MAX_TEXT-1; j>0 ; j--)
         {
            if(tmp[j] == 0x20)
               break;
         }
         if(j == 0)
            j = MAX_TEXT-1;
         memset(tmp_str, 0, MAX_TEXT+1);
         memcpy(tmp_str, tmp, j);
         Lcd_Send_Text_Buff_Str(text_id, posi, tmp_str, align);
         Lcd_Disp_Text_Buff(text_id);
         memmove(tmp, tmp+j, len - j);
         tmp[len-j] = '\0';
      }
	Lcd_Send_Text_Buff_Str(text_id, posi, tmp, align);
}

/*
	Send the long data and dots to the dispaly buffer
	text_id: the text buffer id.
	posi: the buffer start position. (1~MAX_LCD_TEXT)
	data: the print data
	dots: byte dots of data
	align: ALIGN_LEFT, AILGN_MID, ALIGN_RIGHT.

	Note: when select ALIGN_MID, the posi will be no effect
*/
void LongLcdFmt_Text_Buff(byte text_id, byte posi, long data, byte dots, byte align)
{
	byte tmp[MAX_LENGTH_15];
	byte len;
	byte sto_dot = 0;
	byte sto_aster = 0;
	byte adj = 0;

	#if 0
	if((posi > MAX_LCD_TEXT) || (posi < 1))		/* When the locate position is illegal, return */
		return;
	#endif

	Get_Sto_Flag(&sto_dot, &adj, &sto_aster);

	len = LongAndDot2Str(data, dots, tmp, sto_dot, adj, sto_aster, 0);

	/* Store the data in the lcd dispaly buffer */
	memmove(tmp, tmp+MAX_LENGTH_15-len, len);
	tmp[len] = '\0';
	Lcd_Send_Text_Buff_Str(text_id, posi, tmp, align);
}

void LongLcdFmt_Text_Buff_Q(byte text_id, byte posi, long data, byte dots, byte align)
{
	byte tmp[MAX_LENGTH_15+1];
	byte len;
	byte sto_dot = 0;
	byte sto_aster = 0;
	byte adj = 0;

	#if 0
	if((posi > MAX_LCD_TEXT) || (posi < 1))		/* When the locate position is illegal, return */
		return;
	#endif

	Get_Sto_Flag(&sto_dot, &adj, &sto_aster);

	len = LongAndDot2Str(data, dots, tmp, sto_dot, adj, sto_aster, 0);

	/* Store the data in the lcd dispaly buffer */
	memmove(tmp, tmp+MAX_LENGTH_15-len, len);
//	tmp[len] = 'Q'; //2006-08-29 new add . remove tj 'Q' in report.
	tmp[len] = '\0';
	Lcd_Send_Text_Buff_Str(text_id, posi, tmp, align);
}

/*----------------------------------------------------------------------*
	download the logo to the LCD SDram at the beginning of the ECR power on.
*----------------------------------------------------------------------*/
void Lcd_DownLoad_Logo(byte mode, DWORD Addr)
{	
    return ;
}
void Lcd_Disp_Logo(void)//for Screen protest only
{
}

/**********************************************************************
	设计一个屏保程序,在关机位或空闲状态显示屏保logo

***********************************************************************/
void Lcd_Screen_Protest_Logo(void)
{
	int cnt = 0;
	LOGOSTR_DEF Logo;
    byte i = 0;

	Logo.x = 0;
	Logo.y = 0;
	Logo.mode = LCD_LOGO_STORE_SDRAM;
	Logo.Addr = LCD_LOGO_SDRAM_ADDR;
	Logo.Size = LCD_LOGO_SIZE;

      TS_keyenable = 2;//stop to let the LCD_PORT to receive any code 
	while(1)
	{
	//	if(GetIn() == NG)
	//		continue;
		GetMainMode();
		if(MainMode != X_OFF)
			break;
			
		disint();
		TS_timercnt= 5000;// //1S
		enint();

        {
            void    TFT_Test(byte step);
            TFT_Test(i++);
            if( i >= 8)
                i = 0;
        }
		while((TS_timercnt >5)&&(GetMainMode() == X_OFF));//stop here
	}
   TS_keyenable = 1;
}

void Lcd_Layout_Main(void)
{
	RECT_DEF rect;
    
    Init_Func_Btn();//画出左边的文本框
    
	Lcd_Layout_Draw_Key();
}
/* The layout of register main window */
/*
	画出整个按键与文本显示的框架
	文本框里面的文本显示还需要另外调用函数来显示
*/
void Lcd_PartLayout_Main(void)
{
	RECT_DEF rect;
	Lcd_Layout_Draw_Key();
    return;

	if (Lcd_Mode == LCD_10_INCH) 
    {
		// 把需要的区域清除成白色的
		rect.x1 = (LCD_Xdot/10)*4;
		rect.x2 = LCD_Xdot-1;
		rect.y1 = 0;
		rect.y2 = LCD_Ydot -1;
		rect.color = LIGHTGRAY;
		rect.fill = 1;
		Lcd_Draw_Rect(&rect);
	}
	else 
    { // Lcd_Mode == LCD_7_INCH
		Lcd_Draw_Cls_Ex(BLACK);		/* 清除成黑色 */

		// 把需要的区域清除成白色的
		rect.x1 = 0;
		rect.x2 = 480-1;
		rect.y1 = 0;
		rect.y2 = 234-1;
		rect.color = WHITE;
		rect.fill = 1;
		Lcd_Draw_Rect(&rect);
	}

}

/*
	Initial the sale dispaly.
*/
   void Lcd_Init_SaleHead(void)
{
   byte i;
   return;
   //welcome message
   for(i = 0; i<6; i++)
   {
      if(Get_Desc_Len_Ex(&Wlcm_Msg[i][2], MAX_PRN_LEN, YES) >0)
      {
         Lcd_Send_Text_Buff_Desc(BUF_ID_LCD_TEXT, 1, &Wlcm_Msg[i][2], YES, ALIGN_LEFT);
         Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
      }
   }
   //buttern message
   for(i = 0; i<6; i++)
   {
      if(Get_Desc_Len_Ex(&Btm_Msg[i][2], MAX_PRN_LEN, YES) >0)
      {
         Lcd_Send_Text_Buff_Desc(BUF_ID_LCD_TEXT, 1, &Btm_Msg[i][2], YES, ALIGN_LEFT);
         Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
      }
   }
   //blank line
   Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, 1, Str_Null, ALIGN_LEFT);
   Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
}

void Lcd_Init_Sale(void)
{
    Lcd_Init_SaleHead();
   
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, LCD_POSI_SALE_ITEM, Str_Lcd_Item, ALIGN_LEFT);
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, LCD_POSI_SALE_QTY, Str_Lcd_Qty, ALIGN_LEFT);
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, LCD_POSI_SALE_PRICE, Str_Lcd_PrAmt, ALIGN_LEFT);
	Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, LCD_POSI_SALE_ITEM, "====", ALIGN_LEFT);
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, LCD_POSI_SALE_QTY, "====", ALIGN_LEFT);
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, LCD_POSI_SALE_PRICE, "=====", ALIGN_LEFT);
	Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
}

/*
	Initial the program mode.
*/
void Lcd_Init_Prog(void)
{
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, 1, "Program Main Mode", ALIGN_MID);
	Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, 1, "Press Right Key to Program", ALIGN_LEFT);
	Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
	Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, 1, "...", ALIGN_LEFT);
	Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
}
/*
	Initialize the environment from the system ID
*/
void Lcd_Init_Sys_ID(byte sys_id)
{
    byte i;

    if((hard_plu_mode == 0)&&(Shift_Dept_mode == 0))
    {
        Lcd_Draw_Cls();//清除所有显示
	    Rst_Ts_Lcd();
    }

	Do_Clear();

	if (sys_id == SYS_ID_SALE_MAIN) 
    {
		if (Lcd_Mode == LCD_10_INCH) 
        {
            for (i = 0; i < LCD_LAYOUT_VRT_LINE*LCD_LAYOUT_HOR_LINE; i++)   // 拷贝到一个变量区, 这样在有必要的时候可以进行修改
            {
                Ts_KeyMap[i] = Ts_KeyMap_Sale_Main[i];
            }
			Ts_Key_Tab = Ts_KeyMap;
            Ts_Key_Table_Size = Ts_KeyMap_Sale_Main_Size;
            if(hard_plu_mode == 1)
                Lcd_PartLayout_Main();
            else if(Shift_Dept_mode == 1)

⌨️ 快捷键说明

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