//***************************************************************
// File Name : LED.c
// Author : Steaven
// Created : 2008-07-26
// Modified :
// Revision : V0.0
//***************************************************************
#include "iom16v.h"
#include "DataType.h"
#include "app.h"
#include "LED.h"
//constant definition
const INT8U Char_I[] = {0x00,0x00,0x82,0xFE,0x82,0x00,0x00,0x00};/*"I",0*/
const INT8U Char_L[] = {0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00};/*"L",0*/
const INT8U Char_V[] = {0x00,0xF0,0x08,0x04,0x04,0x08,0xF0,0x00};/*"V",0*/
const INT8U Char_E[] = {0x00,0x00,0xFE,0x92,0x92,0x82,0x00,0x00};/*"E",0*/
const INT8U Char_Y[] = {0x00,0xC0,0x20,0x1E,0x20,0xC0,0x00,0x00};/*"Y",0*/
const INT8U Char_O[] = {0x00,0x00,0xFE,0x82,0x82,0xFE,0x00,0x00};/*"O",0*/
const INT8U Char_U[] = {0x00,0x00,0xFC,0x02,0x02,0xFC,0x00,0x00};/*"U",0*/
const INT8U Space[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/*" ",0*/
//struct definition
struct DataBaseIndex
{
INT8U Code;
const INT8U *Ptr;
};
//char code database list
const struct DataBaseIndex DataBaseIndexList[] =
{
'I', Char_I,
'L', Char_L,
'O', Char_O,
'V', Char_V,
'E', Char_E,
'Y', Char_Y,
'U', Char_U,
0 , 0
};
//global variables definition
const INT8U *pBufStr; //字符指针
const char String1[] = {"ILOVEYOU"}; //字符串
INT8U DisplayCnt; //显示计数器
INT8U Buffer[8]; //显示缓冲区
INT8U Length_of_DataBase; //字符数据库长度
//***************************************************************
// Function : Display_Init
// Input : none
// Output : none
// Description : Display Initialization
//***************************************************************
void Display_Init(void)
{
INT8U Index = 0;
for(Index = 0;Index < 8;Index++)
{
Buffer[Index] = 0;
}
pBufStr = String1;
DisplayCnt = 0;
Length_of_DataBase = Search_DataBase_Length();
}
//***************************************************************
// Function : DotTest
// Input : none
// Output : none
// Description : LED Display Test
//***************************************************************
void Buffer_IN(INT8U Index)
{
const INT8U *pdata;
INT8U Count = 0;
pdata = SearchCharIndex(*pBufStr);
if(pdata != (INT8U *)0)
{
for(Count = 0;Count < 7;Count++)
{
Buffer[Count] = Buffer[Count+1];
}
Buffer[7] = *(pdata + Index);
}
}
//***************************************************************
// Function : SearchCharIndex
// Input : CharCode - Char to be displayed
// Output : Pointer to the display code of the input char
// Description : Get the pointer of the display char code
//***************************************************************
const INT8U *SearchCharIndex(INT8U CharCode)
{
INT8U Index;
const struct DataBaseIndex *pDataBasePtr;
pDataBasePtr = DataBaseIndexList;
for(Index = 0;Index <= Length_of_DataBase;Index++)
{
if(pDataBasePtr->Code == CharCode)
{
return(pDataBasePtr->Ptr);
}
else
{
pDataBasePtr++ ;
}
}
return(0);
}
//***************************************************************
// Function : Search_DataBase_Length
// Input : none
// Output : Length of database list
// Description : Search DataBase Length
//***************************************************************
INT8U Search_DataBase_Length(void)
{
INT8U Index = 0;
const struct DataBaseIndex *pDataBasePtr;
pDataBasePtr = DataBaseIndexList;
while(pDataBasePtr->Code != 0)
{
Index++;
pDataBasePtr++;
}
return(Index);
}
//***************************************************************
// Function : DotTest
// Input : none
// Output : none
// Description : LED Display Test
//***************************************************************
void DotTest(void)
{
INT8U Select = 0;
INT8U Index = 0;
INT32U wDelayCnt = 0;
for(Select = 0;Select < 8;Select++)
{
for(Index = 0;Index < 8;Index++)
{
PORTA = 1 << Index;
PORTD = ~(1 << Select);
for(wDelayCnt = 0;wDelayCnt < 90000;wDelayCnt++) {;}
}
}
}
//=========================END OF FILE=========================//