📄 test44x_lsd logo.c
字号:
#include "msp430x44x.h"
//****************************************************************************
#define P2_0_RS 0x01
#define P2_1_RW 0x02
#define P2_2_EN 0x04
#define P2_3_CS1 0x08
#define P2_3_CS2 0x40
#define P2_3_RST 0x80
#define P3_0_DB0 0x01
#define P3_1_DB1 0x02
#define P3_2_DB2 0x04
#define P3_3_DB3 0x08
#define P3_4_DB4 0x10
#define P3_5_DB5 0x20
#define P3_6_DB6 0x40
#define P3_7_DB7 0x80
//****************************************************************************
//****************************************************************************
//****************************************************************************
const BYTE Char_Position[4][12]=
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B
};
const BYTE CHAR_0[5]={0x3E,0x51,0x49,0x45,0x3E};
const BYTE CHAR_1[5]={0x00,0x42,0x7F,0x40,0x00};
const BYTE CHAR_2[5]={0x42,0x61,0x51,0x49,0x66};
const BYTE CHAR_3[5]={0x23,0x41,0x45,0x4B,0x31};
const BYTE CHAR_4[5]={0x18,0x14,0x52,0x7F,0x50};
const BYTE CHAR_5[5]={0x27,0x45,0x45,0x45,0x39};
const BYTE CHAR_6[5]={0x3C,0x4A,0x49,0x49,0x30};
const BYTE CHAR_7[5]={0x03,0x71,0x09,0x05,0x03};
const BYTE CHAR_8[5]={0x36,0x49,0x49,0x49,0x36};
const BYTE CHAR_9[5]={0x06,0x49,0x49,0x29,0x1E};
const BYTE CHAR_A[5]={0x7E,0x11,0x11,0x11,0x7E};
const BYTE CHAR_B[5]={0x7F,0x49,0x49,0x49,0x36};
const BYTE CHAR_T[5]={0x03,0x41,0x7F,0x41,0x03};
const BYTE CHAR_E[5]={0x41,0x7F,0x49,0x5D,0x63};
const BYTE CHAR_L[5]={0x41,0x7F,0x41,0x40,0x60};
const BYTE Symbols[20][5]=
{
0x00,0x36,0x36,0x00,0x00, // [0]':'
0x00,0x08,0x08,0x08,0x00 // [1]'-'
};
const BYTE Lierda_13_19[3][38]=
{
0x00,0x10,0x92,0x92,0xD2,0x72,0xFE,0xFB,0x53,0x93,0x90,0x00,0xFC,0xFC,0x00,0x07,0xFF,0xC2,0x00,
0x03,0x03,0x03,0x01,0x00,0x00,0x1F,0x0F,0x00,0x00,0x00,0x08,0x08,0x18,0x18,0x0C,0x0F,0x07,0x00,
0x00,0x10,0x10,0x18,0x08,0x8C,0xC7,0x47,0x04,0xFC,0xFC,0x04,0x44,0xC4,0x84,0x0C,0x7C,0x00,0x00,
0x04,0x04,0x06,0x03,0x03,0x01,0x0C,0x08,0x18,0x1F,0x0F,0x00,0x00,0x00,0x01,0x07,0x0E,0x0E,0x04,
0x00,0x30,0x16,0x16,0x76,0xB4,0x08,0x08,0x0C,0x8C,0xCC,0x7F,0x3F,0x44,0xC4,0x84,0x04,0x00,0x00,
0x06,0x02,0x02,0x02,0x03,0x03,0x02,0x03,0x07,0x05,0x04,0x04,0x0C,0x0C,0x0C,0x1D,0x1F,0x0C,0x0C,
};
const BYTE LSD_ICON[32]=
{
0xE0,0xF0,0xFC,0xFE,0x00,0x9F,0x3F,0x71,0xE7,0xCF,0x00,0xFE,0x0C,0x1C,0xF0,0xE0,
0x07,0x0F,0x3F,0x3F,0x70,0xF7,0xF7,0xF4,0xF7,0xF7,0x00,0x7F,0x38,0x38,0x0F,0x07,
};
//***************************************************************************************************
//***************************************************************************************************
//***************************************************************************************************
static BYTE num;
static BYTE bt_num;
//***************************************************************************************************
//***************************************************************************************************
//***************************************************************************************************
void port_ini( void )
{
P3DIR = 0xFF;
P3OUT = 0x00;
P2DIR = 0xFF;
P2OUT = P2_3_CS1 | P2_3_CS2 | P2_3_RST;
P2OUT &=~P2_3_RST;
_NOP();
_NOP();
P2OUT |= P2_2_EN;
_NOP();
_NOP();
P2OUT &=~P2_2_EN;
_NOP();
_NOP();
P2OUT |= P2_3_RST;
_NOP();
_NOP();
}
void write_command( BYTE nByte )
{
P3DIR = 0xFF;
P2OUT |= P2_3_CS1+P2_3_CS2;
P2OUT &=~(P2_0_RS+P2_1_RW);
P3OUT = nByte;
P2OUT |= P2_2_EN;
P2OUT &=~P2_2_EN;
}
void write_char( BYTE nByte, BYTE CS1, BYTE CS2 )
{
P3DIR = 0xFF;
if(CS1) P2OUT |= P2_3_CS1;
else P2OUT &=~P2_3_CS1;
if(CS2) P2OUT |= P2_3_CS2;
else P2OUT &=~P2_3_CS2;
P2OUT |= P2_0_RS;
P2OUT &=~P2_1_RW;
P3OUT = nByte;
P2OUT |= P2_2_EN;
P2OUT &=~P2_2_EN;
}
void clear_lcd( void )
{
BYTE i,j;
for(i=0;i<8;i++)
{
write_command(i|0xB8);
write_command(0x40);
for(j=0;j<128;j++)
{
if(j<=63) write_char(0,1,0);
else write_char(0,0,1);
_NOP();
}
}
}
void display_hz( BYTE *chr, BYTE nRow, BYTE nCol )
{
BYTE i,tmpCol;
write_command(0xB8|nRow);
tmpCol=nCol;
for(i=0;i<19;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i],0,1);
}
tmpCol++;
}
write_command(0xB8|nRow+1);
tmpCol=nCol;
for(i=0;i<19;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i+19],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i+19],0,1);
}
tmpCol++;
}
}
void display_16_16_icon( BYTE *chr, BYTE nRow, BYTE nCol )
{
BYTE i,tmpCol;
write_command(0xB8|nRow);
tmpCol=nCol;
for(i=0;i<16;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i],0,1);
}
tmpCol++;
}
write_command(0xB8|nRow+1);
tmpCol=nCol;
for(i=0;i<16;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i+16],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i+16],0,1);
}
tmpCol++;
}
}
void display_char( BYTE *chr, BYTE nRow, BYTE nCol )
{
BYTE i,tmpCol;
write_command(0xB8|nRow);
tmpCol=nCol;
for(i=0;i<5;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i],0,1);
}
tmpCol++;
}
}
//***************************************************************************************************
//***************************************************************************************************
//***************************************************************************************************
void main(void)
{
BYTE hAddr;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
FLL_CTL0 |= XCAP14PF;
port_ini();
num=0;
write_command(0xC0);
write_command(0x3F);
clear_lcd();
display_16_16_icon((BYTE *)&LSD_ICON[0],1,5);
display_hz((BYTE *)&Lierda_13_19[0][0],3,30);
display_hz((BYTE *)&Lierda_13_19[1][0],3,60);
display_hz((BYTE *)&Lierda_13_19[2][0],3,90);
display_char((BYTE *)&CHAR_T[0],6,16);
display_char((BYTE *)&CHAR_E[0],6,22);
display_char((BYTE *)&CHAR_L[0],6,28);
hAddr=34;
display_char((BYTE *)&Symbols[0][0],6,hAddr);
display_char((BYTE *)&CHAR_0[0],6,hAddr+6);
display_char((BYTE *)&CHAR_5[0],6,hAddr+12);
display_char((BYTE *)&CHAR_7[0],6,hAddr+18);
display_char((BYTE *)&CHAR_1[0],6,hAddr+24);
display_char((BYTE *)&Symbols[1][0],6,hAddr+30);
display_char((BYTE *)&CHAR_8[0],6,hAddr+36);
display_char((BYTE *)&CHAR_8[0],6,hAddr+42);
display_char((BYTE *)&CHAR_2[0],6,hAddr+48);
display_char((BYTE *)&CHAR_5[0],6,hAddr+54);
display_char((BYTE *)&CHAR_9[0],6,hAddr+60);
display_char((BYTE *)&CHAR_4[0],6,hAddr+66);
display_char((BYTE *)&CHAR_7[0],6,hAddr+72);
display_char((BYTE *)&CHAR_4[0],6,hAddr+78);
// WDTCTL=WDTPW+WDT_ARST_1000;
_EINT(); // Enable interrupts
while(1)
{
_BIC_SR(LPM3);
_NOP();
_NOP();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -