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

📄 char_set.c

📁 不包含识别算法
💻 C
字号:
/*********************************************************************
 *
 * Copyright:
 *	MOTOROLA, INC. All Rights Reserved.  
 *  You are hereby granted a copyright license to use, modify, and
 *  distribute the SOFTWARE so long as this entire notice is
 *  retained without alteration in any modified and/or redistributed
 *  versions, and that such modified versions are clearly identified
 *  as such. No licenses are granted by implication, estoppel or
 *  otherwise under any patents or trademarks of Motorola, Inc. This 
 *  software is provided on an "AS IS" basis and without warranty.
 *
 *  To the maximum extent permitted by applicable law, MOTOROLA 
 *  DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING 
 *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
 *  PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE 
 *  SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY 
 *  ACCOMPANYING WRITTEN MATERIALS.
 * 
 *  To the maximum extent permitted by applicable law, IN NO EVENT
 *  SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING 
 *  WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS 
 *  INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
 *  LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.   
 * 
 *  Motorola assumes no responsibility for the maintenance and support
 *  of this software
 ********************************************************************/
 
 /*
 * File:	char_set.c
 *
 * Purpose:	Contains the functions that generate characters and
 *		graphical bitmaps.
 *
 * Notes:
 *
 * Modifications:
 *
 */

#define _CHARSET_H
#define _LCD_H

#include "mcf5249.h"
#include "char_set.h"
#include "lcd.h"

/*--- Global Variables ---*/
/*--- Function Prototypes ---*/

/* Smallchar selects the character from the Small character map.*/
void Smallchar(uint8 letter, uint16 column);


/********************************************************************/


void StringPrint(int8 message[], uint8 Xloc, uint8 Yloc)
{
/*Selects the individual letters from the input string.

Parameters:	message[]:	this array holds the complete message string to be printed
		Xloc:		defines the offet from the left on the X axis (0 to 132)
		Yloc:		defines the offset from the top on the Y axis (0 to 4)

Single characters are selected from mesage[] and passed into Smalchar or Bigchar until
the NULL at the end of the string is reached. At this point the LCD row defined by Yloc is
cleared to the end of the screen*/

	uint8 i = 0;
	uint16 column;

	WriteLCDByte((LCD_PAGE + Yloc),LCD_CTRL);		//Select page
	WriteLCDByte((LCD_COL_MSB + (Xloc >> 4)),LCD_CTRL);	//Set Column MSB
	WriteLCDByte((LCD_COL_LSB + Xloc),LCD_CTRL);		//Set Column LSB

	column = ((Xloc * 0x08) + Yloc);
	while (message[i])
	{
		Smallchar(message[i], column);
		i++;
	}
	while (column < END)
	{
		WriteLCDByte(0x00, LCD_DATA);

		column = (column + 0x08);
	}
}
	
void Smallchar(uint8 letter, uint16 column)
{

/*Selects the character from the Small character map.

Parameters:	letter:		passed from String_Print or Var_Print

The value in letter is compared to ASCII values and the correct letter number or symbol in the
character map is selected accordingly. Only the small character set is used. Checks for the end
of the screen are carried out and single letters are thus prevented from going over the
boundaries. Bytes within the character aray are cycled through and passed to WriteLCDByte until
completion.*/

	uint8 ind_letter, length;
	const uint8 *letter_bits;
	uint8 index = 0;
	uint8 data_loop = 0;
	
	if (letter < 0x7B)
	{
		if (letter > 0x60)
			ind_letter = (letter - 0x47);
		else
		if (letter < 0x60)
		{
			if (letter > 0x5D)
				ind_letter = (letter - 0x0E);
			else
			if (letter == 0x5C)
				ind_letter = (letter - 0x0D);
			else
			if (letter < 0x5B)
			{
				if (letter > 0x40)
					ind_letter = (letter - 0x41);
				else
				if (letter < 0x40)
				{

					if (letter > 0x3B)
						ind_letter = (letter + 0x0F);
					else
					if (letter == 0x3A)
						ind_letter = (letter + 0x10);
					else
					if (letter < 0x3A)
					{
						if (letter > 0x2F)
							ind_letter = (letter + 0x04);
						else
						if (letter > 0x27)
							ind_letter = (letter + 0x1A);
						else
						if (letter < 0x26)
						{
							if (letter > 0x22)
								ind_letter = (letter + 0x1C);
							else
							if (letter == 0x21)
								ind_letter = (letter + 0x1D);
							if (letter == 0x20)
								ind_letter = (letter + 0x32);
						}
					}
				}
			}
		}
	}
	else
	ind_letter = 0x52;
	length = (*small_pointer [ind_letter]);
	if (( column + ((length - 1) * 0x08)) <= END)
	{
		while (index < length)
		{
			data_loop++;
			letter_bits = ((small_pointer[ind_letter]) + data_loop);

			WriteLCDByte(*letter_bits, LCD_DATA);

			index++;
		}
	}
}

void BitmapPrint(uint8 *bitmap, uint8 Xloc, uint8 Yloc)
{
/*Outputs a bitmap from top left at starting location.

Paramenters:	*bitmap:	holds the address of the desired bitmap
		Xloc:		defines the offet from the left on the X axis (0 tp 132)
		Yloc:		defines the offset from the top on the Y axis (0 to 4)

The bitmap array contains the width and height of the bitmap which is usedto split the array
into sections and outputted as per the big character map. The startposition should be defined
as the top left byte of the bitmap*/

	uint8 width, height;
	uint8 *bitmap_bits;
	uint8 index = 0;
	uint8 count = 0;
	uint16 data_loop = 1;

	WriteLCDByte((LCD_PAGE + Yloc),LCD_CTRL);		//Select page
	WriteLCDByte((LCD_COL_MSB + (Xloc >> 4)),LCD_CTRL);	//Set Column MSB
	WriteLCDByte((LCD_COL_LSB + Xloc),LCD_CTRL);		//Set Column LSB

	width = *bitmap;
	bitmap_bits = (bitmap + 0x01);
	height = *bitmap_bits;
	
	while (count < height)
	{
		while (index < width)
		{
			data_loop++;
			bitmap_bits = (bitmap + data_loop);

			WriteLCDByte(*bitmap_bits, LCD_DATA);

			index++;
		}
		index = 0;
		count++;
		WriteLCDByte((LCD_PAGE + Yloc + count),LCD_CTRL);	//Select page
		WriteLCDByte((LCD_COL_MSB + (Xloc >> 4)),LCD_CTRL);	//Set Column MSB
		WriteLCDByte((LCD_COL_LSB + Xloc),LCD_CTRL);		//Set Column LSB
	}
}


/*
StringPrint("FAULT: Safety Margin", 0, 0);
StringPrint("Power supply A lost", 0, 0);
BitmapPrint(power, 71, 6);
*/

⌨️ 快捷键说明

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