吉林工程技术师范学院校徽的显示代码在51单片机l12864上
时间: 2024-02-29 11:51:37 浏览: 184
以下是基于51单片机的12864显示吉林工程技术师范学院校徽的示例代码:
```c
#include <reg51.h>
#include <intrins.h>
#define LCD_PORT P0
sbit LCD_RS = P2^6;
sbit LCD_RW = P2^5;
sbit LCD_EN = P2^7;
sbit LCD_CS1 = P1^0;
sbit LCD_CS2 = P1^1;
sbit LCD_RST = P1^2;
unsigned char code logo[1024] = {
// 这里是校徽的点阵数据,由于篇幅原因,我就不一一列举了
};
void delay_us(unsigned int t) {
while(t--);
}
void delay_ms(unsigned int t) {
unsigned int i, j;
for(i=0; i<t; i++) {
for(j=0; j<114; j++);
}
}
void lcd_write_cmd(unsigned char cmd) {
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 1;
LCD_PORT = cmd;
_nop_();
LCD_EN = 0;
}
void lcd_write_data(unsigned char dat) {
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
LCD_PORT = dat;
_nop_();
LCD_EN = 0;
}
void lcd_init() {
LCD_RST = 0;
delay_ms(20);
LCD_RST = 1;
lcd_write_cmd(0x3f);
lcd_write_cmd(0xc0);
lcd_write_cmd(0xb8);
lcd_write_cmd(0x40);
}
void lcd_set_xy(unsigned char x, unsigned char y) {
if(x < 64) {
LCD_CS1 = 1;
LCD_CS2 = 0;
lcd_write_cmd(0x40 | x);
} else {
LCD_CS1 = 0;
LCD_CS2 = 1;
lcd_write_cmd(0x40 | (x - 64));
}
lcd_write_cmd(0xb8 | y);
}
void lcd_display(unsigned char *dat) {
unsigned int i;
for(i=0; i<1024; i++) {
lcd_write_data(dat[i]);
}
}
void main() {
lcd_init();
lcd_set_xy(0, 0);
lcd_display(logo);
while(1);
}
```
需要注意的是,这段代码中只给出了校徽的点阵数据,并没有包含完整的12864显示屏初始化和显示代码。如果需要完整的代码,可以参考相关的教程和资料。
阅读全文