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

📄 disp.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
字号:
#include "ecrsys.h"
#include "data.h"
#include "sysdata.h"
#include "lcd.h"
#include "vfd.h"
#include "vfd_new.h"
#include "disp.h"
#include <string.h>

bool IsVfd(void);

CHR  dsp_piriod[MAX_DISP_NUM];
const char Bit_Point[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
/*---------------------------------------------------------------
*  Period Get,
*  According to the dsp_piriod[0][1] to get the POINT position
*     
*  03-9-8 21:02
*--------------------------------------------------------------*/
CHR   period_get( CHR idx )
{
   char ret;
   
//    #ifdef NEW_VFD
//    idx = MAX_DISP_NUM - idx -1;
//    #endif
   if ( idx < 8 )
   {
      if (dsp_piriod[0] & Bit_Point[idx])
         ret = TRUE;
      else
         ret = FALSE;
   }
   else
   {
      if ( dsp_piriod[1] & Bit_Point[idx-8])
         ret = TRUE;
      else
         ret = FALSE;
   }
   return(ret);
}
/************************************************************************************************
*  Insert One Character to the charged position 
*  Input : dsp_char  - the Character need to Insert.
*        : posi      - the position of the character need to insert.
*
*	Modified on 2004-04-13 9:31
************************************************************************************************/
void  Insert_Char(CHR dsp_char,CHR posi)
{
   CHR   jj;
   
    if(posi >= MAX_DISP_NUM)
   	return;
   jj = period_get(posi);

    #ifdef LCD_DISP
        LCD_DispChar(posi, dsp_char, jj);
    #endif
    #ifdef VFD_DISP
        Vfd_DispChar(posi, dsp_char, jj);
    #endif
}

/*------------------------------------------------------------------------------------------
*  Insert a Numberic on LCD display.
*  Input :  CHR   dsp_data -- the data need display.
*        :  CHR   posi     -- position need display.
*  03-9-8 20:59
*
*	Modified on 2004-04-13 9:29
*------------------------------------------------------------------------------------------*/
void  Insert_Num(CHR dsp_data,CHR posi)
{
   CHR   jj;
   
    if(posi >= MAX_DISP_NUM)
   	return;
   jj = period_get(posi);

    #ifdef LCD_DISP
        LCD_DispChar(posi, dsp_data, jj);
    #endif
    
    #ifdef VFD_DISP
        Vfd_DispChar(posi, dsp_data, jj);
    #endif

}


/*--------------------------------------------------------------------------------*
 *                Insert a sect to the LCD display.
 *--------------------------------------------------------------------------------*/
void Insert_Sect(CHR dsp_data,CHR posi)
{
    CHR   jj;
    if(posi >= MAX_DISP_NUM)
     return;
    jj = period_get(posi);

    #ifdef LCD_DISP
        LCD_Insert_Sect(dsp_data, posi, jj);
    #endif

}


// Insert a string number to LCD display,
// 03-4-1 18:54   by ZhengXC     
void disp_Num_Str(CHR *ptr,CHR posi)
{
    for ( ;  posi < MAX_DISP_NUM ; posi ++ )
    {
   	    if((*ptr >= '0') && (*ptr <= '9'))
   		    Insert_Num((*ptr ++) - 0x30, posi);
   	    else
   		    Insert_Char(*ptr ++, posi);
    }
}
//Insert a string to LCD display
// 03-4-1 15:46   
void disp_Char_Str( CHR* str,CHR posi )
{
   CHR   tmp;
   
    for ( ;(( posi < MAX_DISP_NUM) && (*str != 0)); posi ++ )
   {
      tmp = *str ++;
      if((tmp >= '0') && (tmp <= '9'))
      	Insert_Num(tmp - '0', posi);
      else
      	Insert_Char(tmp, posi);
   }
}
/***************************************************************************************
*  Insert one byte to the LCD
*  In:    the first position
*      the Data need insert;
***************************************************************************************/
void  Insert_Byte(CHR dsp_Byte, CHR posi)
{
   CHR tmp;
   Insert_Num(dsp_Byte >> 4,posi);
   Insert_Num(dsp_Byte&0x0f,posi+1);
}

/*----------------------------------------------------------------------------------------
*  void  LCD_Back(CHAR flag);
*  In:   On / Off the LCD backlight.
*  03-4-2 11:23   by ZhengXC
*---------------------------------------------------------------------------------------*/
void  Disp_Back(CHR flag)
{
    #ifdef LCD_DISP
    LCD_Back(flag);
    #endif
}


/*------------------------------------------------------------------------------------*
 *    Set the LCD backlight base on the flag.
 *------------------------------------------------------------------------------------*/
void LCD_Back_Set(void)
{
    #ifdef LCD_DISP
   if(sysflag->BackLight==1)
   {
      LCD_Back(ON);
   	g_LCDBLCnt = sysflag->LCD_BL_Time;
   }
   else
   {
      LCD_Back(OFF);
      g_LCDBLCnt = 0;
   }
    #endif
}

/*----------------------------------------------------------------------------------------
*  void  Clr_Dsp_Data(void);
*  In:      None
*  Out:  None
*  Clear the Display data.
*---------------------------------------------------------------------------------------*/
void Clr_Dsp_Data(void)
{
   CHR tmp;
    #ifdef  LCD_DISP
        Reset_LCD();
    #endif
   for ( tmp = 0; tmp < MAX_LCD_NUM; tmp ++ )
      Insert_Char(' ',tmp);
}

/*----------------------------------------------------------------------------------------
*   Initialize the LCD controller and clear the display
*---------------------------------------------------------------------------------------*/
void Init_Disp(void)
{
    #ifdef LCD_DISP
    Lcd_Init();
    #endif
    #ifdef VFD_DISP
    Vfd_Init();
    #endif
}
void LCD_Test(void)
{
   WORD  tmp;
   CHR   cntr;

   cntr = 0;
   
   Clr_Dsp_Data();
   disp_Char_Str("ABCDEFGHIJKLM",0);

   for ( tmp = 0; tmp < 0xff; tmp ++ )
      for ( cntr = 0; cntr < 0xff; cntr ++ );
   
}

void  Init_Lcd(void)
{
    #ifdef VFD_DISP
  	    Vfd_Init();
    #endif
    #ifdef LCD_DISP
        LCD_Init();
    #endif
}
/*----------------------------------------------------------------------------*
*  Insert the period to the LCD.   
*  Note: In this function, the radix point only display one times, 
*		and will display the radix point immediately              
*----------------------------------------------------------------------------*/
void Insert_Period(byte posi)
{
    if(posi >= MAX_DISP_NUM)
   	    return;
    
    #ifdef LCD_DISP
    LCD_InsPeriod(posi);
    #endif
    #ifdef VFD_DISP
    Vfd_InsPeriod(posi);
    #endif
}
/*----------------------------------------------------------------------------*
*   Cancel the period displayed in the LCD   
*  Note: This function will clear the radix point dispaly immediately             
*----------------------------------------------------------------------------*/
void Cancel_Period(byte posi)
{
    #ifdef  LCD_DISP
    LCD_ClrPeriod(posi);
    #endif
    #ifdef VFD_DISP
    Vfd_ClrPeriod(posi);
    #endif
}


/*-------------------------------------------------------------------*
 *					Clear the period array, When next display,
 *				will not display the period in the LCD.
 *-------------------------------------------------------------------*/
void Clr_Period(void)
{
	dsp_piriod[0] = 0;
	dsp_piriod[1] = 0;
}


//////////////////////////////////////////////////////////////////////////////
/// 			The display library funcitons, add after 2004-12-09 by JWM
//////////////////////////////////////////////////////////////////////////////

/* Set the default display */
void	Set_Dft_Dsp(void)
{
	Clr_Dsp_Data();
	RightDisp(0, sysflag->sysdots);
}

/* The specify display, only contains left align format */
void	Spec_Disp(dword dsp_data, char len, byte posi)
{
	posi += len - 1;
	while(len --)
	{
		Insert_Num(dsp_data%10, posi --);
		dsp_data /= 10;
	}
}

/*---------------------------------------------------------------------------*
 *          Display the long number in the right position.                   *
 *          num   :  the long number, it can negative.                       *
 *          dots  :  the position of the radix point.                        *
 *---------------------------------------------------------------------------*/
void RightDisp(long num ,char dots)
{
	byte tmp[MAX_LENGTH_15+1];
	byte len;
    
    {//TFT display
	if (num == 0 && dots == sysflag->sysdots)
		Lcd_Tl_Input_Disp(TL_INPUT_CLEAR, 0);
    }

    //LCD / VFD display
	tmp[MAX_LENGTH_15] = 0;
	len = LongAndDot2Str(num, dots, tmp, 0, 0, 0, 0);

	VFDDisplay(tmp+MAX_LENGTH_15-len, NOTCLEARD, RIGHT);

   if(dots > 0)
   {
   	    Insert_Period(MAX_LCD_NUM - dots - 1);			/* Display the dots only once */
   }
}

void	disp_long(DWORD data)
{
	char i;
	
	Clr_Dsp_Data();
	Insert_Byte((CHR)data,8);
	data >>= 8;
	Insert_Byte((CHR)data,6);
	data >>= 8;
	Insert_Byte((CHR)data,4);
	data >>= 8;
	Insert_Byte((CHR)data,2);
	bellcnt = 0xfe;		
	GetKey();
}

/*-------------------------------------------------------------------------------------------------------------*
 *                                                                           												*
 *                   Set the period position:                                												*
 *          position    :  1~16                                              												*
 *          clear       :  CLR      ---clear.                                												*
 *                         SET      ---set.                                  												*
 *                                                                           												*
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
 *    posi:       0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  A  |  B  |  C  |  D  |  E  |  F  *
 *bit(dsp_piriod):b0 |  b1 |  b2 |  b3 |  b4 |  b5 |  b6 |  b7 |  b8 |  b9 |  b8 |  b8 |  b8 |  b8 |  b8 |  b8 *
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
 *                                                                                                             *
 *-------------------------------------------------------------------------------------------------------------*/
void VFDSetPeriod(byte position,byte flag)
/* Note: When used this function, it will display the radix point to the LCD immediately */
{
   if(position > MAX_LCD_NUM-1)
        return;
//#ifdef NEW_VFD
//   position = MAX_DISP_NUM - position -1;
//#endif
   if(flag == CLR)				/* Clear flag */
   {
      if(position < 8)
         dsp_piriod[0] &= (~Bit_Point[position]);
      else
         dsp_piriod[1] &= (~Bit_Point[position-8]);
      Cancel_Period(position);
   }
   else if(flag == SET)			/* Set flag */
   {
      if(position < 8)
         dsp_piriod[0] |= (Bit_Point[position]);
      else
         dsp_piriod[1] |= (Bit_Point[position-8]);
      Insert_Period(position);
   }
   else return;
}


/*----------------------------------------------------------------------------
* Display a character string.
*  
*  IN:      *str     --- > string need display.
*           clear    --- > Flag for clear the current display on LCD or not
*           LeftRight--- > Null flag, will be delete later.
*  03-8-13 10:28  by X.C.Zheng 
*
*	Modified on 2004-04-13 9:22
-----------------------------------------------------------------------------*/
void VFDDisplay(char *str, char clear,byte LeftRight)
{
   int	i;
   char	cch0, len;
   char 	posi;

	if(LeftRight > 2)
		return;

   len = strlen(str);
   if(len > MAX_LCD_NUM )
   	len = MAX_LCD_NUM;
   if( LeftRight == RIGHT )		/* The right position, adjust */
      posi = MAX_LCD_NUM - len;
   else if(LeftRight == ALIGN_MID)
      posi = (MAX_LCD_NUM - len)/2;
   else
        posi = 0;

    if(clear == CLEARD)				/* Clear the previous display */
   	    Clr_Dsp_Data();
    for( i = 0; i < len; i++ )
    {
   	    if(posi >= MAX_LCD_NUM)		/* Out of range, no need to display the remainder data */
   		    break;
   	    cch0 = str[i];
   	    if((cch0 >= '0') && (cch0 <= '9'))
   		    Insert_Num(cch0 - '0', posi ++);
   	    else
   		    Insert_Char(cch0, posi ++);
    }
}

#if 0//check LCD or VFD, 现在不用检测, 但是保留以前的程序. 
//如果需要检测跳线来检测显示屏的类型, 再开放这一段程序, 
//同时要修改LCD_DISP/VFD_DISP 的宏定义方式.
///////////////////////////////////////////////////////////////////////////////
// Description: Check whether VFD display
// In Param:	void
// Out Param:	void
// Return:		TRUE / FALSE
///////////////////////////////////////////////////////////////////////////////
bool IsVfd(void)
{
	return true;
}


///////////////////////////////////////////////////////////////////////////////
// Description:Read Jump set from mainboard.
// In Param:	void
// Out Param:	void
// Return:		TRUE -- VFD / FALSE -- LCD
///////////////////////////////////////////////////////////////////////////////
byte Vfd_ReadJumper(void)
{
	byte i;
	
	pur3 = 0xff;
	for (i=0; i<5; i++);
	
#if	COUNTRY == AMERICA
	if ((Sw_Read() & 0x01) == 0x01)					// tie to GND --- LCD
	{
		vfd_lcd_Disp = LCD_DISP;
	}
	else
	{
		vfd_lcd_Disp = VFD_DISP;
	}
#else
	if ((Sw_Read() & 0x01) == 0x01)					// short with GND --- LCD
	{
		vfd_lcd_Disp = VFD_DISP;
	}
	else
	{
		vfd_lcd_Disp = LCD_DISP;
	}
#endif

	return IsVfd();
}
#endif

⌨️ 快捷键说明

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