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

📄 zkblcd.c

📁 该代码为Jennic公司芯片JN5121
💻 C
字号:
/****************************************************************************
 *
 * MODULE:             LCD Driver for Wireless Keyboard Application
 *
 * COMPONENT:          $RCSfile$
 *
 * VERSION:            $Name$
 *
 * REVISION:           $Revision$
 *
 * DATED:              $Date$
 *
 * STATUS:             $State$
 *
 * AUTHOR:             APV Ward
 *
 * DESCRIPTION:
 * Provides an LCD character output service for wireless keyboard keycodes.
 *
 * LAST MODIFIED BY:   $Author$
 *                     $Modtime$
 *
 ****************************************************************************
 *
 * This software is owned by Jennic and/or its supplier and is protected
 * under applicable copyright laws. All rights are reserved. We grant You,
 * and any third parties, a license to use this software solely and
 * exclusively on Jennic products. You, and any third parties must reproduce
 * the copyright and warranty notice and any other legend of ownership on each
 * copy or partial copy of the software.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS". JENNIC MAKES NO WARRANTIES, WHETHER
 * EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
 * ACCURACY OR LACK OF NEGLIGENCE. JENNIC SHALL NOT, IN ANY CIRCUMSTANCES,
 * BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, SPECIAL,
 * INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER.
 *
 * Copyright Jennic Ltd 2005, 2006. All rights reserved
 *
 ****************************************************************************/

/****************************************************************************/
/***        Include files                                                 ***/
/****************************************************************************/

#include "jendefs.h"
#include "ZKBlcd.h"
#include "LcdDriver.h"
#include "JennicLogo.h"
#include <LcdFont.h>

/****************************************************************************/
/***        Type Definitions                                              ***/
/****************************************************************************/

/* virtual display driver variables */
typedef struct
{
    uint8   u8Row;
    uint8   u8Col;
} tsVdu;

/****************************************************************************/
/***        Local Variables                                               ***/
/****************************************************************************/

PRIVATE	tsVdu    sVdu;

/****************************************************************************/
/***        Local functions                                               ***/
/****************************************************************************/

PRIVATE void vVduWrite    (uint8 u8Char);
PRIVATE void vScroll      (void);

/****************************************************************************
 *
 * NAME: vZKBlcdInit
 *
 * DESCRIPTION:
 * Initialises the LCD character handler.
 *
 * PARAMETERS:  None
 *
 * RETURNS:		void
 *
 ****************************************************************************/

PUBLIC void vZKBlcdInit(void)
{
	/* initialise the LCD panel */
    vLcdReset(3, 3); /* for UC1601 type displays */
    vLcdClear();

	/* write the Jennic logo */
    vLcdWriteBitmap(&sJennicLogo, 0, 0);
    vLcdWriteText("Wireless keyboard", 4, 0);
    vLcdRefreshAll();

	/* initialise the virtual display driver, only use half	*/
	/* the screen to display keyboard codes.				*/
	sVdu.u8Row = 5;
	sVdu.u8Col = 0;
}

/****************************************************************************
 *
 * NAME: vZKBlcdOutc
 *
 * DESCRIPTION:
 * Sends an ASCII character to the LCD character handler.
 *
 * PARAMETERS:  Name      		R/W 	Usage
 *              u8Char			R   	Null ASCII encoded character
 * RETURNS:
 * void
 *
 ****************************************************************************/

PUBLIC void vZKBlcdOutc(uint8 u8Char)
{
	vVduWrite(u8Char);

	/* copy LCD shadow memory to the panel - takes approx 4.5 mS */
	vLcdRefreshAll();
}

/****************************************************************************
 *
 * NAME: vVduWrite
 *
 * DESCRIPTION:
 * A virtual VDU manager.  Provides scrolling, line-wrap and character/font
 * translation.  The top four lines ofd the display do not scroll, the bottom
 * four do.
 *
 * PARAMETERS:  Name	RW  Usage
 *              u8Char	R   character to display
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/

PRIVATE void vVduWrite(uint8 u8Char)
{
    char acText[2];
    char *pu8CharMap;
    uint8 u8CharWidth;

	if (u8Char == '\n')
	{
		vScroll();
	}
	else if (u8Char == '\r')
	{
		sVdu.u8Col = 0;
		vScroll();
	}
	else if ((u8Char == ' ')
         || ((u8Char >= '0') && (u8Char <= '9'))
         || ((u8Char >= 'a') && (u8Char <= 'z'))
         || ((u8Char >= 'A') && (u8Char <= 'Z')))
    {
        acText[0] = u8Char;
        acText[1] = 0;

        /* Get charcter width */
        pu8CharMap = pu8LcdFontGetChar(u8Char);
        u8CharWidth = *pu8CharMap;

        /* Check if character will fit on current row, change row if not */
        if ((sVdu.u8Col + u8CharWidth) > 127)
        {
            sVdu.u8Col = 0;
			vScroll();
        }

        /* Write character and undate column position */
        vLcdWriteText(acText, sVdu.u8Row, sVdu.u8Col);
        sVdu.u8Col = sVdu.u8Col + u8CharWidth + 1;
    }
}

/****************************************************************************
 *
 * NAME: vScroll
 *
 * DESCRIPTION:
 * Handles VDU scrolling.
 *
 * PARAMETERS:  void
 *
 * RETURNS:		void
 *
 ****************************************************************************/

PRIVATE void vScroll(void)
{
	if (sVdu.u8Row == 7)
	{
		/* Scroll screen up from row 2, ie rows 0 and 1 don't scroll */
		vLcdScrollUp(4);
	}
	else
	{
		sVdu.u8Row = (sVdu.u8Row + 1) % 8;
    }
}

⌨️ 快捷键说明

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