📄 h_lcdshow.c
字号:
#include "DSP281x_Device.h"
//#include "DSP281x_Examples.h"
#include "V_PLC.h"
#pragma CODE_SECTION(Dot, "DOT_HJF");
#pragma CODE_SECTION(Clr_screen, "CLRSCREEN_HJF");
#pragma CODE_SECTION(Clr_block, "CLRBLOCK_HJF");
#pragma CODE_SECTION(Print_line, "PRINTLINE_HJF");
#pragma CODE_SECTION(Text_block, "TEXTBLOCK_HJF");
#pragma CODE_SECTION(Zuhekuang_block, "ZUHEKUANGBLOCK_HJF");
#pragma CODE_SECTION(Disp_word, "DISPWORD_HJF");
#pragma CODE_SECTION(Disp_four_word, "DISPFOURWORD_HJF");
//#pragma CODE_SECTION(Disp_key, "DISPKEY_HJF");
//#pragma CODE_SECTION(Cha_value, "CHAVALUE_HJF");
//#pragma CODE_SECTION(Disp_numdata, "DISPNUMDATA_HJF");/**/
// unsigned int lcd_cmd;
void Dot(unsigned int x, unsigned int y, unsigned int color)
{
/* 画点时,先输入x和y的坐标值,再输入颜色值
当x或y的值写入行列地址寄存器时,需要加上偏移量*/
Lcd.x = X_bias + x;
Lcd.y = Y_bias + y;
Lcd.data = color;
}
void Clr_screen(unsigned int color,unsigned int cmd)
{
unsigned int x, y;
for(y = 0; y < 481; y++)
{
Lcd.x = X_bias;//-1
Lcd.y = Y_bias + y;
Lcd.cmd = X_AUTO + cmd;
for(x = 0; x < 640; x++)
{
Lcd.data = color;
asm(" RPT #32 || NOP ");
}
}
}
void Clr_block(unsigned int x0,unsigned int y0,unsigned int x1,
unsigned int y1,unsigned int color,unsigned int cmd)
{
unsigned int h, l,temp;
if(x0 > x1)
{
temp=x0; x0=x1; x1=temp;
}
if(y0 > y1)
{
temp=y0; y0=y1; y1=temp;
}
for(h = y0; h < y1; h++)
{
Lcd.x = X_bias + x0;//- 1
Lcd.y = Y_bias + h;
Lcd.cmd = X_AUTO + cmd;
for(l = x0; l < x1; l++)
{
Lcd.data = color;
asm(" RPT #32 || NOP ");
}
}
}
void Print_line(unsigned int x0,unsigned int y0,unsigned int x1,
unsigned int y1,unsigned int color,unsigned int cmd)
{
unsigned int j,temp;
int dx, dy, n, k, i, x, y, f;
Lcd.cmd = X_AUTO + cmd;
if(y0 == y1)
{
for(j=x0;j<=x1;j++)
{
Dot(j,y0,color);
}
}
else
{
if(x0 > x1)
{
temp = x0; x0 = x1; x1 = temp;
temp = y0; y0 = y1; y1 = temp;
}
dx = x1 - x0; dy = abs(y1 - y0); n = dx + dy;
k = y1 >= y0 ? 1 : 4; x = x0; y = y0;
for(i = 0, f = 0; i < n; i++)
{
if(f >= 0)
switch(k)
{
case 1: Dot(x++, y, color); f -= dy;
if(dx == 0) { x--; i--; } break;
case 4: Dot(x, y--, color); f -= dx; break;
}
else
switch(k)
{
case 1: Dot(x, y++, color); f += dx; break;
case 4: Dot(x++, y, color); f += dy; break;
}
}
}
}
void Text_block(unsigned int x0,unsigned int y0,unsigned int x1,
unsigned int y1,unsigned int color,unsigned int cmd)
{
Print_line(x0, y0, x0, y1, color, cmd);
Print_line(x0, y0, x1, y0, color, cmd);
Print_line(x1, y0, x1, y1, color, cmd);
Print_line(x0, y1, x1, y1, color, cmd);
}
void Zuhekuang_block(unsigned int x0,unsigned int x1,unsigned int x2,
unsigned int x3,unsigned int y0,unsigned int y1,
unsigned int color,unsigned int cmd)
{
Print_line(x0,y0,x1,y0,color,cmd); // 上面左边横线
Print_line(x2,y0,x3,y0,color,cmd); // 上面右边横线
Print_line(x0,y1,x3,y1,color,cmd); // 下面横线
Print_line(x0,y1,x0,y0,color,cmd); // 左边竖线
Print_line(x3,y0,x3,y1,color,cmd); // 右边竖线
}
/*void Disp_numdata(unsigned int x0,unsigned int y0,unsigned long num,
unsigned char n,unsigned int color)
{
unsigned int tw,tq,tb,ts,tg;// 万位数,千位数,百位数,十位数,个位数
tw = num / 10000;
tq = num / 1000 % 10;
tb = num / 100 % 10;;
ts = num / 10 % 10;;
tg = num % 10;
//-- n 表示显示的数据类型,显示数据 -------
if(!n) // 例如 xxxxx
{
if(tw) // 例如 46888
{
Disp_word(x0,y0,color,disp_num[tw]);
Disp_word(x0+8,y0,color,disp_num[tq]);
Disp_word(x0+16,y0,color,disp_num[tb]);
Disp_word(x0+24,y0,color,disp_num[ts]);
Disp_word(x0+32,y0,color,disp_num[tg]);
}
else if(tq) // 例如 2212
{
Disp_word(x0,y0,color,disp_num[tq]);
Disp_word(x0+9,y0,color,disp_num[tb]);
Disp_word(x0+18,y0,color,disp_num[ts]);
Disp_word(x0+27,y0,color,disp_num[tg]);
}
else if(tb) // 例如 843
{
Disp_word(x0,y0,color,disp_num[tb]);
Disp_word(x0+9,y0,color,disp_num[ts]);
Disp_word(x0+18,y0,color,disp_num[tg]);
}
else if(ts) // 例如 23
{
Disp_word(x0,y0,color,disp_num[ts]);
Disp_word(x0+9,y0,color,disp_num[tg]);
}
else // 例如 6
{
Disp_word(x0,y0,color,disp_num[tg]);
}
}
else if(n == 1) // 例如 xxx.x
{
if(tq) // 例如 460.3
{
Disp_word(x0,y0,color,disp_num[tq]);
Disp_word(x0+9,y0,color,disp_num[tb]);
Disp_word(x0+18,y0,color,disp_num[ts]);
Disp_word(x0+27,y0,color,disp_num[10]);
Disp_word(x0+36,y0,color,disp_num[tg]);
}
else if(tb) // 例如 42.6
{
Disp_word(x0,y0,color,disp_num[tb]);
Disp_word(x0+9,y0,color,disp_num[ts]);
Disp_word(x0+18,y0,color,disp_num[10]);
Disp_word(x0+27,y0,color,disp_num[tg]);
}
else if(ts) // 例如 2.2
{
Disp_word(x0,y0,color,disp_num[ts]);
Disp_word(x0+9,y0,color,disp_num[10]);
Disp_word(x0+18,y0,color,disp_num[tg]);
}
else // 例如 0.3
{
Disp_word(x0,y0,color,disp_num[0]);
Disp_word(x0+9,y0,color,disp_num[10]);
Disp_word(x0+18,y0,color,disp_num[tg]);
}
}
else if(n == 2) // 例如 xx.xx
{
if(tq) // 例如 15.63
{
Disp_word(x0,y0,color,disp_num[tq]);
Disp_word(x0+9,y0,color,disp_num[tb]);
Disp_word(x0+18,y0,color,disp_num[10]);
Disp_word(x0+27,y0,color,disp_num[ts]);
Disp_word(x0+36,y0,color,disp_num[tg]);
}
else if(tb) // 例如 5.23
{
Disp_word(x0,y0,color,disp_num[tb]);
Disp_word(x0+9,y0,color,disp_num[10]);
Disp_word(x0+18,y0,color,disp_num[ts]);
Disp_word(x0+27,y0,color,disp_num[tg]);
}
else if(ts) // 例如 0.23
{
Disp_word(x0,y0,color,disp_num[0]);
Disp_word(x0+9,y0,color,disp_num[10]);
Disp_word(x0+18,y0,color,disp_num[ts]);
Disp_word(x0+27,y0,color,disp_num[tg]);
}
else // 例如 0.03
{
Disp_word(x0,y0,color,disp_num[0]);
Disp_word(x0+9,y0,color,disp_num[10]);
Disp_word(x0+18,y0,color,disp_num[0]);
Disp_word(x0+27,y0,color,disp_num[tg]);
}
}
else if(n == 3) // 例如 0x
{
if(ts) // 例如 12
{
Disp_word(x0,y0,color,disp_num[ts]);
Disp_word(x0+9,y0,color,disp_num[tg]);
}
else // 例如 02
{
Disp_word(x0,y0,color,disp_num[0]);
Disp_word(x0+9,y0,color,disp_num[tg]);
}
}
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -