atmega 8 루틴: 5110 액정 드라이버
/*****************************************************************
* :ATMEGA8 NOKIA 5110LCD
* : v1.0
* :
* : 2011 08 03
*
* :
*
* :
*
******************************************************************
* :
*******************************************************************/
#include "includes.h"
int main(void)
{
LCD_INIT();
LCD_Write_Chinese_String(10,0,12,4,Chinese_Font,0,5);
LCD_Write_Chinese_String(10,2,12,4,Chinese_Font,4,5);
LCD_Write_Chinese_String(15,4,12,3,Chinese_Font,8,5);
while(1);
return 0;
}
//5110.c
#include "includes.h"
uint8 ASSIC_Font[][6] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // sp
{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, // !
{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, // "
{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // #
{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $
{ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 }, // %
{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, // &
{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, // '
{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, // (
{ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, // )
{ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, // *
{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, // +
{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, // ,
{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, // -
{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, // .
{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, // /
{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0
{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1
{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2
{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3
{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4
{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5
{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6
{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7
{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8
{ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9
{ 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, // :
{ 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, // ;
{ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, // <
{ 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, // =
{ 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, // >
{ 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, // ?
{ 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, // @
{ 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, // A
{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B
{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C
{ 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D
{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E
{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F
{ 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G
{ 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H
{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I
{ 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J
{ 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K
{ 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L
{ 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M
{ 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N
{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O
{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P
{ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q
{ 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R
{ 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, // S
{ 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T
{ 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U
{ 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V
{ 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W
{ 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, // X
{ 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y
{ 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z
{ 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [
{ 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 }, // 55
{ 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ]
{ 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^
{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, // _
{ 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, // '
{ 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 }, // a
{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, // c
{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, // d
{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, // e
{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f
{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, // g
{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h
{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i
{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, // j
{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k
{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l
{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m
{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, // o
{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, // p
{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, // q
{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r
{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, // s
{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t
{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u
{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v
{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w
{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, // x
{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, // y
{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, // z
{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } // horiz lines
};
uint8 Chinese_Font[][25] =
{
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x00,0x48,0x48,0xDE,0xFE,0xF4,0xFE,0x76,0x24,0x04,0x04,0x00,0x00,0x02,0x03,0x03,
0x01,0x03,0x03,0x02,0x02,0x02,0x03,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x10,0x94,0xD4,0xD4,0xF8,0xFF,0xCE,0xFC,0xFC,0xFC,0xFC,0x00,0x01,0x03,0x03,0x01,
0x01,0x07,0x07,0x03,0x02,0x07,0x07,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x04,0xFC,0xFC,0xFC,0xFC,0xD4,0xF4,0xF4,0xFE,0x56,0x42,0x00,0x01,0x01,0x01,0x07,
0x07,0x06,0x03,0x01,0x01,0x03,0x02,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x00,0x00,0x20,0x20,0xE2,0xFE,0xFE,0x90,0x10,0x10,0x00,0x00,0x00,0x04,0x06,0x07,
0x03,0x01,0x01,0x03,0x03,0x06,0x04,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x04,0x04,0x04,0x04,0x04,0x7E,0xFE,0xBE,0x3C,0x2C,0x84,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x03,0x02,0x02,0x03,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x00,0x80,0xCC,0x3C,0x3C,0x7E,0xFE,0xBE,0x5E,0x46,0x40,0x00,0x00,0x01,0x01,0x01,
0x03,0x02,0x02,0x02,0x03,0x03,0x02,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x00,0x20,0x20,0x30,0x11,0xFF,0xFF,0xD4,0xD4,0x90,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0x07,0x00,0x00,0x00,0x00,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x00,0x20,0xB0,0xF8,0x1F,0xFF,0xFA,0x48,0xD8,0x98,0x88,0x00,0x00,0x00,0x01,0x01,
0x02,0x07,0x07,0x00,0x00,0x01,0x01,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x00,0x00,0x08,0x08,0x08,0xFC,0xFC,0x04,0x04,0x04,0x00,0x00,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x40,0x70,0x38,0xFE,0xF6,0x38,0xFF,0xFF,0xFA,0xA8,0xA8,0x00,0x00,0x00,0x03,0x03,
0x01,0x00,0x07,0x07,0x03,0x00,0x00,0x00
},
/*-- : --*/
/*-- 9; : x =12x12 --*/
/*-- 8 , : x =12x16 --*/
{
0x00,0x18,0x1C,0x4C,0x7C,0xFE,0xFE,0x7C,0x4C,0x0C,0x0C,0x00,0x00,0x04,0x04,0x05,
0x05,0x07,0x07,0x07,0x03,0x06,0x04,0x00
},
};
/*------------------------------------------------
:void LCD_Write_Byte(uint8 dat, uint8 command)
:
:dat ,command
:
:
: ,
------------------------------------------------*/
void LCD_Write_Byte(uint8 dat, uint8 command)
{
uint8 i = 0;
/* */
//LCD_CE = 0;
Clr_CE;
/* */
if (command == 0)
{
//LCD_DC = 0;
Clr_DC;
}
else
{
//LCD_DC = 1;
Set_DC;
}
for (i = 0;i < 8;i++)
{
/* */
if(dat & 0x80)
{
//LCD_SDIN = 1;
Set_SDIN;
}
else
{
//LCD_SDIN = 0;
Clr_SDIN;
}
/*( )*/
//LCD_SCLK = 0;
Clr_SCLK;
dat = dat << 1;
//LCD_SCLK = 1;
Set_SCLK;
}
/* */
//LCD_CE = 1;
Set_CE;
}
/*------------------------------------------------
:void LCD_Set_XY(uint8 X, uint8 Y)
:
:X,Y
:
:
------------------------------------------------*/
void LCD_Set_XY(uint8 X, uint8 Y)
{
LCD_Write_Byte(0x40 | Y, 0);
LCD_Write_Byte(0x80 | X, 0);
}
/*------------------------------------------------
:void LCD_Clear(void)
:
:
:
:
------------------------------------------------*/
void LCD_Clear(void)
{
uint16 i = 0;
/* */
//LCD_Write_Byte(0x0c, 0);
/* 0 */
LCD_Set_XY(0,0);
/* 0 ,0 ,1 */
for (i = 0; i < 504; i++)
{
LCD_Write_Byte(0, 1);
}
}
/*------------------------------------------------
:void LCD_Init(void)
:
:
:
:
------------------------------------------------*/
/*------------------------------------------------
,LCD :
1:
2:
3:
------------------------------------------------*/
void LCD_INIT(void)
{
Set_DDR_CE;
Set_DDR_RST;
Set_DDR_DC;
Set_DDR_SDIN;
Set_DDR_SCLK;
/* */
//LCD_RST = 0;
Clr_RST;
//Delay_Nus(1);
asm("nop");
/* */
//LCD_RST = 1;
Set_RST;
//LCD_CE = 0;
Clr_CE;
//Delay_Nus(1);
asm("nop");
//LCD_CE = 1;
Set_CE;
//Delay_Nus(1);
asm("nop");
/* */
LCD_Write_Byte(0x21, 0);
/* */
LCD_Write_Byte(0xd0, 0);
/* */
//LCD_Write_Byte(0x06, 0);
/*1:48*/
//LCD_Write_Byte(0x13, 0);
/* */
LCD_Write_Byte(0x20, 0);
/* */
LCD_Write_Byte(0x0c, 0);
/* */
LCD_Clear();
//LCD_CE = 0;
Clr_CE;
//Delay_Nus(1);
asm("nop");
}
/*------------------------------------------------
:void LCD_Write_Char(uint8 c)
:
:c
:
:
------------------------------------------------*/
void LCD_Write_Char(uint8 c)
{
uint8 line = 0;
c -= 32;
for (line=0; line<6; line++)
{
LCD_Write_Byte(ASSIC_Font[c][line], 1);
}
}
/*------------------------------------------------
:void LCD_Write_English_String(uint8 X,uint8 Y,char *s)
:
:X,Y s
:
:
: , , ‘\0’!!
------------------------------------------------*/
void LCD_Write_English_String(uint8 X,uint8 Y,char *s)
{
LCD_Set_XY(X,Y);
while (*s)
{
LCD_Write_Char(*s);
s++;
}
}
/*------------------------------------------------
:void LCD_Write_Chinese_String(uint8 X, uint8 Y, uint8 ch_with,
uint8 num,uint8 line,uint8 row)
:
:X,Y ,ch_with ,num
line ,
:
:
------------------------------------------------*/
void LCD_Write_Chinese_String(uint8 X, uint8 Y,uint8 ch_with,
uint8 num,uint8 *s,uint8 line,uint8 row)
{
uint8 i = 0;
uint8 n = 0;
uint8 (*catch)[25] = s;
LCD_Set_XY(X,Y);
/* */
for (i = 0;i < num;)
{
for (n = 0; n < ch_with * 2; n++)
{
if (n == ch_with)
{
if (i == 0)
{
LCD_Set_XY(X,Y + 1);
}
else
{
LCD_Set_XY((X + (ch_with + row) *i),Y + 1);
}
}
LCD_Write_Byte(catch[line + i][n],1);
}
i++;
LCD_Set_XY((X + (ch_with + row) * i),Y);
}
}
//5110.h
/***********************************************************************
* 5110
************************************************************************/
//IO
#define uint8 unsigned char
#define uint16 unsigned int
#define uint32 unsigned long
#define sint8 signed char
#define sint16 signed int
#define sint32 signed long
#define PORTX PORTB
#define CE PB0
#define RST PB1
#define DC PB2
#define SDIN PB3
#define SCLK PB4
//LCD_CE ( )
#define Set_CE PORTX |= (1 << CE)
#define Clr_CE PORTX &= ~(1 << CE)
//LCD_RST ( )
#define Set_RST PORTX |= (1 << RST)
#define Clr_RST PORTX &= ~(1 << RST)
//LCD_DC /
#define Set_DC PORTX |= (1 << DC)
#define Clr_DC PORTX &= ~(1 << DC)
//LCD_SDIN
#define Set_SDIN PORTX |= (1 << SDIN)
#define Clr_SDIN PORTX &= ~(1 << SDIN)
//LCD_SCLK ( )
#define Set_SCLK PORTX |= (1 << SCLK)
#define Clr_SCLK PORTX &= ~(1 << SCLK)
//IO
#define DDRX DDRB
#define Set_DDR_CE DDRX |= (1 << DDB0)
#define Set_DDR_RST DDRX |= (1 << DDB1)
#define Set_DDR_DC DDRX |= (1 << DDB2)
#define Set_DDR_SDIN DDRX |= (1 << DDB3)
#define Set_DDR_SCLK DDRX |= (1 << DDB4)
//
void LCD_INIT(void); //
void LCD_Clear(void); //
void LCD_Write_Char(uint8 c); //
void LCD_Set_XY(uint8 X, uint8 Y); //
void LCD_Write_Byte(uint8 dat, uint8 command);//
void LCD_Write_English_String(uint8 X,uint8 Y,char *s); //
void LCD_Write_Chinese_String(uint8 X, uint8 Y, uint8 ch_with,uint8 num,uint8 *s,uint8 line,uint8 row);//
extern uint8 Chinese_Font[][25];
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Docker를 사용한 React 및 .NET Core 6.0 샘플 프로젝트 - 1부이 기사에서는 Entity Framework Core Code First 접근 방식을 사용하는 ASP.NET Core 6.0 WEP API의 CRUD(만들기, 읽기, 업데이트 및 삭제) 작업에 대해 설명합니다. 웹 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.