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

📄 t6963.c

📁 简易数字存储示波器
💻 C
字号:
#include"T6963.h"
#include"regx52.h"
#include "absacc.h"
#include"math.h"

unsigned char xdata ins _at_   0xe000;     //命令写地址
unsigned char xdata dat _at_   0xa000;     //数据写地址
unsigned char xdata ins_R _at_ 0xc000;     //命令读地址

// 外部RAM地址0x800-0xfff

void stste_check(void)  //状态检测
{
	while((ins_R & 0x03) != 0x03); 
}

void ins_write(unsigned char s)      //写一个命令
{
	stste_check();
	ins=s;
}

void dat_write(unsigned char d)      //写一个数据
{
	stste_check();
	dat=d;
}

void set_gra_pos(unsigned char x,unsigned char y)   //x:0-16  y:0-127   设置图形区坐标
{
	unsigned int temp=x+16*y;
	dat_write((unsigned char)(temp&0xff));
	dat_write((unsigned char)(temp>>8)+0x08);  
	ins_write(0x24);
}

void set_text_pos(unsigned char x,unsigned char y)  //x:0-16  y:0-16    设置文本区坐标
{
	unsigned int temp=x+16*y;
	dat_write((unsigned char)(temp&0xff));
	dat_write((unsigned char)(temp>>8));  
	ins_write(0x24);
}
void lcd_init(void)              //初始化LCD
{
	dat_write(0);//设置文本显示区域首地址
	dat_write(0);
	ins_write(0x40);

	dat_write(0x10);//设置文本显示区域宽度
	dat_write(0);   //即一行显示所占的字节数
	ins_write(0x41);

	dat_write(0x0);//设置图形显示区域首地址
	dat_write(0x08);  
	ins_write(0x42);

	dat_write(0x10);//设置图形显示区域宽度
	dat_write(0);   
	ins_write(0x43);
	
	ins_write(0xa1);//光标形状设置

	ins_write(0x80);//显示或合成

	ins_write(0x9c);//显示开关设置

	dat_write(0);//设置显示RAM首地址
	dat_write(0x08);  
	ins_write(0x24);
}

void lcd_char(unsigned char c)
{
	dat_write(c-32);
	ins_write(0xc0);
}

void pixel(unsigned char x,unsigned char y)   //x:0-127  y:0-127   显示一个点
{
	unsigned char temp;
	temp=x>>3;
    set_gra_pos(temp,y);
	temp=(7-(x % 8))&(0x07);
	
    temp = 0xF0 | temp | 0x08; // 字节内位置计算
    ins_write(temp); 
}

void gracls(void)
{
	unsigned char i,j;
	set_gra_pos(0,0);
	ins_write(0xb0);
	for(i=0;i<=33;i++)
	{
		for(j=0;j<=15;j++)
		{
			dat_write(0);	
		}
	}
	ins_write(0xb2);
}

⌨️ 快捷键说明

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