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

📄 display.c

📁 关于zigbee厂家jennic的zigbee通信模块JN5139的一些示例程序。
💻 C
字号:
/***************************************************************************//*! *\MODULE              LCD Utilities * *\COMPONENT           $RCSfile: Display.c,v $ * *\VERSION             $Name:  $ * *\REVISION            $Revision: 1.1 $ * *\DATED               $Date: 2008/01/21 10:15:04 $ * *\STATUS              $State: Exp $ * *\AUTHOR              Martin Looker * *\DESCRIPTION         LCD utilities to maintain a single page display. * * This file contains general purpose routines to maintain a single page on the LCD. * * Each line can have a text string and two hexadecimal displayed. Functions * are provided to set each of these items independently and a draw function * is provided to draw the page. *//*\CHANGE HISTORY * * $Log: Display.c,v $ * Revision 1.1  2008/01/21 10:15:04  mlook * Initial checkin * * Revision 1.1  2007/11/02 12:32:52  mlook * Adding new application notes * * * *\LAST MODIFIED BY    $Author: mlook $ *                     $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, 2007. All rights reserved * ****************************************************************************//****************************************************************************//***        Include files                                                 ***//****************************************************************************/#include <jendefs.h>#include <LcdDriver.h>#include "string.h"#include "gdb.h"#include "display.h"/****************************************************************************//***        Macro Definitions                                             ***//****************************************************************************/#define COL_TEXT 28		/**< Column to display text field */#define COL_VAL0 0		/**< Column to display first value field */#define COL_VAL1 103	/**< Column to display second value field */#define MAX_TEXT 22		/**< Maximum characters in text field *//****************************************************************************//***        Type Definitions                                              ***//****************************************************************************//** Row definition */typedef struct{    char   sText[MAX_TEXT+1];	/**< Text for row */    uint16 u16Val0;				/**< First valu for row */    uint16 u16Val1;				/**< Second value for row */    uint8  u8Wid0;				/**< First value number of hex digits */    uint8  u8Wid1;				/**< Second value number of hex digits */} tsRow;/****************************************************************************//***        Local Function Prototypes                                     ***//****************************************************************************/PRIVATE void vDisplay_WriteHex(uint16, uint8, uint8, uint8);/****************************************************************************//***        Exported Variables                                            ***//****************************************************************************//****************************************************************************//***        Local Variables                                               ***//****************************************************************************/PRIVATE tsRow asRow[8];			/**< Data for page, (8 rows) *//**************************************************************************** * * NAME: vDisplay_Init *//*! *\DESCRIPTION  Initialises display *//* PARAMETERS       Name            RW  Usage * None. * * RETURNS: * None. * * NOTES: * None. ****************************************************************************/PUBLIC void vDisplay_Init(void){	vLcdResetDefault();}/**************************************************************************** * * NAME: vDisplay_Text *//*! *\DESCRIPTION Set text for display row *//* PARAMETERS       Name            RW  Usage * None. * * RETURNS: * None. * * NOTES: * None. ****************************************************************************/PUBLIC void vDisplay_Text(uint8 u8Row, 	/**< Row to set text for */						  char  *sText) /**< Text to display */{	if (u8Row < 8)	{		strncpy (asRow[u8Row].sText, sText, MAX_TEXT);	}}/**************************************************************************** * * NAME: vDisplay_Val0 *//*! *\DESCRIPTION Set first value for display row *//* PARAMETERS       Name            RW  Usage * None. * * RETURNS: * None. * * NOTES: * None. ****************************************************************************/PUBLIC void vDisplay_Val0(uint8   u8Row, 		/**< Row to set first value for */						  uint16 u16Val, 		/**< Value to display */						  uint8   u8Wid)		/**< Hex digits to display */{	if (u8Row < 8)	{		asRow[u8Row].u16Val0 = u16Val;		if (u8Wid > 4) 	asRow[u8Row].u8Wid0 = 4;		else			asRow[u8Row].u8Wid0 = u8Wid;	}}/**************************************************************************** * * NAME: vDisplay_Val1 *//*! *\DESCRIPTION Set second value for display row *//* PARAMETERS       Name            RW  Usage * None. * * RETURNS: * None. * * NOTES: * None. ****************************************************************************/PUBLIC void vDisplay_Val1(uint8   u8Row, 		/**< Row to set second value for */						  uint16 u16Val, 		/**< Value to display */						  uint8   u8Wid)		/**< Hex digits to display */{	if (u8Row < 8)	{		asRow[u8Row].u16Val1 = u16Val;		if (u8Wid > 4) 	asRow[u8Row].u8Wid1 = 4;		else			asRow[u8Row].u8Wid1 = u8Wid;	}}/**************************************************************************** * * NAME: vDisplay_Draw *//*! *\DESCRIPTION Draw the display *//* PARAMETERS       Name            RW  Usage * None. * * RETURNS: * None. * * NOTES: * None. ****************************************************************************/PUBLIC void vDisplay_Draw(void){	uint8 u8Row;	/* Clear LCD */	vLcdClear();	/* Loop through LCD lines */	for (u8Row = 0; u8Row < 8; u8Row++)	{		/* Something to Display ? */		if (asRow[u8Row].sText[0] != '\0')		{			/* Ensure termination of line */			asRow[u8Row].sText[MAX_TEXT] = '\0';			/* Write line to Display */			vLcdWriteText(asRow[u8Row].sText, u8Row, COL_TEXT);		}		/* Got a value 0 to Display ? */		if (asRow[u8Row].u8Wid0 != 0)		{			/* Write out value */			vDisplay_WriteHex(asRow[u8Row].u16Val0, asRow[u8Row].u8Wid0, u8Row, COL_VAL0);		}		/* Got a value 1 to Display ? */		if (asRow[u8Row].u8Wid1 != 0)		{			/* Write out value */			vDisplay_WriteHex(asRow[u8Row].u16Val1, asRow[u8Row].u8Wid1, u8Row, COL_VAL1);		}	}	/* Refresh LCD */	vLcdRefreshAll();}/**************************************************************************** * * NAME: vDisplay_WriteHex *//*! *\DESCRIPTION Write a hex value to the display *//* PARAMETERS       Name            RW  Usage * None. * * RETURNS: * None. * * NOTES: * None. ****************************************************************************/PRIVATE void vDisplay_WriteHex(uint16 u16Value, 	/**< Value to display */							   uint8   u8Digits, 	/**< Hex digits to display */							   uint8   u8Row, 		/**< Row to display on */							   uint8   u8Column)	/**< Column to display at */{	uint8  u8Pos;	char  sHex[5];	char   sChar[17] = "0123456789ABCDEF";	/* Sanity check digits */	if (u8Digits > 4) u8Digits = 4;	/* Do hex conversion */	for (u8Pos = 0; u8Pos < u8Digits; u8Pos++)	{		sHex[u8Pos] = sChar[(u16Value >> ((u8Digits-u8Pos-1)*4)) &0xF];		sHex[u8Pos+1] = '\0';	}	/* Write out string */	vLcdWriteText(sHex, u8Row, u8Column);}/****************************************************************************//***        END OF FILE                                                   ***//****************************************************************************/

⌨️ 快捷键说明

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