This commit is contained in:
parent
96575c2dc9
commit
98b9efdc2d
|
@ -167,8 +167,8 @@ extern SIG_TRANSMISSION sig_trans; //通讯模式
|
|||
#define LVGL_TASK_PERIOD 5 //LVGL任务周期
|
||||
#define MENU_TASK_PERIOD 500 //显示内容设置周期
|
||||
#define BLE_TASK_PERIOD 10 //蓝牙任务周期
|
||||
#define HART_TASK_PERIOD 5 //HART任务周期
|
||||
#define RS485_TASK_PERIOD 5 //485任务周期
|
||||
#define HART_TASK_PERIOD 10 //HART任务周期
|
||||
#define RS485_TASK_PERIOD 10 //485任务周期
|
||||
#define MUX_TASK_PERIOD 50 //多通道输入输出任务周期
|
||||
|
||||
//屏幕显示
|
||||
|
|
|
@ -1,434 +0,0 @@
|
|||
// LCM resolution:240x320,
|
||||
// driver IC:ST7789V,
|
||||
|
||||
#include <chinese_code.h>
|
||||
|
||||
// 液晶屏IC所需要的信号线的接口定义
|
||||
/*
|
||||
sbit DC0 = P3 ^ 4;
|
||||
sbit WR0 = P3 ^ 0;
|
||||
sbit RD0 = P3 ^ 1;
|
||||
sbit CS0 = P3 ^ 5;
|
||||
sbit reset = P3 ^ 3;
|
||||
sbit IM1 = P3 ^ 6;
|
||||
sbit IM2 = P3 ^ 7;
|
||||
sbit key = P2 ^ 0; // P2.0口与GND之间接一个按键
|
||||
*/
|
||||
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
typedef struct ST_TEST
|
||||
{
|
||||
unsigned char ucA:1;
|
||||
unsigned char ucB:1;
|
||||
unsigned char ucC:1;
|
||||
unsigned char ucD:1;
|
||||
unsigned char ucE:1;
|
||||
unsigned char ucF:1;
|
||||
unsigned char ucG:1;
|
||||
unsigned char ucH:1;
|
||||
} ST_TEST;
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
union data_port
|
||||
{
|
||||
uint8_t data;
|
||||
#pragma pack(push,1)
|
||||
struct
|
||||
{
|
||||
uint8_t bit0 : 1;
|
||||
uint8_t bit1 : 1;
|
||||
uint8_t bit2 : 1;
|
||||
uint8_t bit3 : 1;
|
||||
uint8_t bit4 : 1;
|
||||
uint8_t bit5 : 1;
|
||||
uint8_t bit6 : 1;
|
||||
uint8_t bit7 : 1;
|
||||
} bit;
|
||||
#pragma pack(pop)
|
||||
}
|
||||
|
||||
transfer_command(int com1)
|
||||
{
|
||||
CS0 = 0;
|
||||
DC0 = 0;
|
||||
RD0 = 1;
|
||||
P1 = com1;
|
||||
WR0 = 0;
|
||||
delay_us(1);
|
||||
WR0 = 1;
|
||||
CS0 = 1;
|
||||
}
|
||||
|
||||
void transfer_data(int data1)
|
||||
{
|
||||
CS0 = 0;
|
||||
DC0 = 1;
|
||||
RD0 = 1;
|
||||
P1 = data1;
|
||||
WR0 = 0;
|
||||
WR0 = 1;
|
||||
CS0 = 1;
|
||||
}
|
||||
|
||||
// 连写2个字节(即16位)数据到LCD模块
|
||||
void transfer_data_16(uint data_16bit)
|
||||
{
|
||||
transfer_data(data_16bit >> 8);
|
||||
transfer_data(data_16bit);
|
||||
}
|
||||
|
||||
void delay(long i)
|
||||
{
|
||||
int j, k;
|
||||
for (j = 0; j < i; j++)
|
||||
for (k = 0; k < 110; k++)
|
||||
;
|
||||
}
|
||||
|
||||
void delay_us(long i)
|
||||
{
|
||||
int j, k;
|
||||
for (j = 0; j < i; j++)
|
||||
;
|
||||
for (k = 0; k < 1; k++)
|
||||
;
|
||||
}
|
||||
|
||||
void Switch()
|
||||
{
|
||||
repeat:
|
||||
if (key == 1)
|
||||
goto repeat;
|
||||
else
|
||||
delay(1000);
|
||||
if (key)
|
||||
goto repeat;
|
||||
else
|
||||
;
|
||||
}
|
||||
|
||||
void lcd_initial()
|
||||
{
|
||||
reset = 0;
|
||||
delay(200);
|
||||
reset = 1;
|
||||
delay(200);
|
||||
//************* Start Initial Sequence **********//
|
||||
|
||||
//------------------------------display and color format setting--------------------------------//
|
||||
transfer_command(0x36); // 行扫描顺序及RGB,列扫描顺序,横放/竖放
|
||||
transfer_data(0x00);
|
||||
transfer_data(0x48);
|
||||
|
||||
transfer_command(0xB6); // 显示功能设置:列/行 显示顺序
|
||||
transfer_data(0x0A);
|
||||
transfer_data(0x82); // 改变SOURCE线的方向:0xa2:左到右,0x82:右到左
|
||||
|
||||
transfer_command(0x3a); // 256K 16bit/pixel
|
||||
transfer_data(0x05);
|
||||
//--------------------------------ST7789V Frame rate setting----------------------------------//
|
||||
transfer_command(0xb2);
|
||||
transfer_data(0x0c);
|
||||
transfer_data(0x0c);
|
||||
transfer_data(0x00);
|
||||
transfer_data(0x33);
|
||||
transfer_data(0x33);
|
||||
transfer_command(0xb7);
|
||||
transfer_data(0x35);
|
||||
//---------------------------------ST7789V Power setting--------------------------------------//
|
||||
transfer_command(0xbb);
|
||||
transfer_data(0x28);
|
||||
transfer_command(0xc0);
|
||||
transfer_data(0x2c);
|
||||
transfer_command(0xc2);
|
||||
transfer_data(0x01);
|
||||
transfer_command(0xc3);
|
||||
transfer_data(0x10);
|
||||
transfer_command(0xc4);
|
||||
transfer_data(0x20);
|
||||
transfer_command(0xc6);
|
||||
transfer_data(0x0f);
|
||||
transfer_command(0xd0);
|
||||
transfer_data(0xa4);
|
||||
transfer_data(0xa1);
|
||||
//--------------------------------ST7789V gamma setting---------------------------------------//
|
||||
transfer_command(0xe0);
|
||||
transfer_data(0xd0);
|
||||
transfer_data(0x00);
|
||||
transfer_data(0x02);
|
||||
transfer_data(0x07);
|
||||
transfer_data(0x0a);
|
||||
transfer_data(0x28);
|
||||
transfer_data(0x32);
|
||||
transfer_data(0x44);
|
||||
transfer_data(0x42);
|
||||
transfer_data(0x06);
|
||||
transfer_data(0x0e);
|
||||
transfer_data(0x12);
|
||||
transfer_data(0x14);
|
||||
transfer_data(0x17);
|
||||
|
||||
transfer_command(0xe1);
|
||||
transfer_data(0xd0);
|
||||
transfer_data(0x00);
|
||||
transfer_data(0x02);
|
||||
transfer_data(0x07);
|
||||
transfer_data(0x0a);
|
||||
transfer_data(0x28);
|
||||
transfer_data(0x31);
|
||||
transfer_data(0x54);
|
||||
transfer_data(0x47);
|
||||
transfer_data(0x0e);
|
||||
transfer_data(0x1c);
|
||||
transfer_data(0x17);
|
||||
transfer_data(0x1b);
|
||||
transfer_data(0x1e);
|
||||
|
||||
transfer_command(0x11); // 退出睡眠
|
||||
delay(200);
|
||||
transfer_command(0x29); // 打开显示
|
||||
}
|
||||
|
||||
// 定义窗口坐标:开始坐标(XS,YS)以及窗口大小(x_total,y_total)
|
||||
void lcd_address(int XS, int YS, int x_total, int y_total)
|
||||
{
|
||||
int XE, YE;
|
||||
XE = XS + x_total - 1;
|
||||
YE = YS + y_total - 1;
|
||||
transfer_command(0x2a); // 设置X开始及结束的地址
|
||||
transfer_data_16(XS); // X开始地址(16位)
|
||||
transfer_data_16(XE); // X结束地址(16位)
|
||||
|
||||
transfer_command(0x2b); // 设置Y开始及结束的地址
|
||||
transfer_data_16(YS); // Y开始地址(16位)
|
||||
transfer_data_16(YE); // Y结束地址(16位)
|
||||
|
||||
transfer_command(0x2c); // 写数据开始
|
||||
}
|
||||
|
||||
void mono_transfer_data_16(int mono_data, int font_color, int back_color)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (mono_data & 0x80)
|
||||
{
|
||||
transfer_data_16(font_color); // 当数据是1时,显示字体颜色
|
||||
}
|
||||
else
|
||||
{
|
||||
transfer_data_16(back_color); // 当数据是0时,显示底色
|
||||
}
|
||||
mono_data <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 全屏显示一种颜色
|
||||
void display_color(int color_data)
|
||||
{
|
||||
int i, j;
|
||||
lcd_address(0, 0, 240, 320);
|
||||
for (i = 0; i < 240; i++)
|
||||
{
|
||||
for (j = 0; j < 320; j++)
|
||||
{
|
||||
transfer_data_16(color_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void display_black(void)
|
||||
{
|
||||
int i, j, k;
|
||||
transfer_command(0x2c); // 写数据开始
|
||||
for (i = 0; i < 240; i++)
|
||||
{
|
||||
transfer_data_16(0xffff);
|
||||
}
|
||||
for (i = 0; i < 318; i++)
|
||||
{
|
||||
for (k = 0; k < 1; k++)
|
||||
{
|
||||
transfer_data_16(0xffff);
|
||||
}
|
||||
for (j = 0; j < 238; j++)
|
||||
{
|
||||
transfer_data_16(0x0000);
|
||||
}
|
||||
for (k = 0; k < 1; k++)
|
||||
{
|
||||
transfer_data_16(0xffff);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 320; i++)
|
||||
{
|
||||
transfer_data_16(0xffff);
|
||||
}
|
||||
}
|
||||
|
||||
// 显示8x16点阵的字符串
|
||||
void disp_string_8x16(int x, int y, char *text, int font_color, int back_color)
|
||||
{
|
||||
int i = 0, j, k;
|
||||
while (text[i] > 0x00)
|
||||
{
|
||||
if ((text[i] >= 0x20) && (text[i] <= 0x7e))
|
||||
{
|
||||
j = text[i] - 0x20;
|
||||
lcd_address(x, y, 8, 16);
|
||||
for (k = 0; k < 16; k++)
|
||||
{
|
||||
mono_transfer_data_16(ascii_table_8x16[j * 16 + k], font_color, back_color); //?a??"ascii_table_8x16[]"?a??êy×é?ú"ASCII_TABLE_5X8_8X16_horizontal.h"à?
|
||||
}
|
||||
x += 8;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void display_string_16x16(int x, int y, uchar *text, int font_color, int back_color)
|
||||
{
|
||||
uchar i, j, k;
|
||||
uint address;
|
||||
j = 0;
|
||||
while (text[j] != '\0') //'\0' 字符串结束标志
|
||||
{
|
||||
i = 0;
|
||||
address = 1;
|
||||
while (Chinese_horizontal_text_16x16[i] > 0x7e) // >0x7f即说明不是ASCII码字符
|
||||
{
|
||||
if (Chinese_horizontal_text_16x16[i] == text[j])
|
||||
{
|
||||
if (Chinese_horizontal_text_16x16[i + 1] == text[j + 1])
|
||||
{
|
||||
address = i * 16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i += 2;
|
||||
}
|
||||
if (y > 320)
|
||||
{
|
||||
y = 0;
|
||||
x += 16;
|
||||
}
|
||||
|
||||
if (address != 1) // 显示汉字
|
||||
{
|
||||
lcd_address(x, y, 16, 16);
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
for (k = 0; k < 16; k++)
|
||||
{
|
||||
mono_transfer_data_16(Chinese_horizontal_code_16x16[address], font_color, back_color);
|
||||
address++;
|
||||
}
|
||||
}
|
||||
j += 2;
|
||||
}
|
||||
else // 显示空白字符
|
||||
{
|
||||
lcd_address(x, y, 16, 16);
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
for (k = 0; k < 16; k++)
|
||||
{
|
||||
mono_transfer_data_16(0x00, font_color, back_color);
|
||||
}
|
||||
}
|
||||
j += 2;
|
||||
}
|
||||
x = x + 16;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示32x32点阵的单色的图像
|
||||
void disp_32x32(int x, int y, char *dp, int font_color, int back_color)
|
||||
{
|
||||
int i, j;
|
||||
lcd_address(x, y, 32, 32);
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
mono_transfer_data_16(*dp, font_color, back_color);
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示一幅彩图
|
||||
void display_image(int x, int y, uchar *dp)
|
||||
{
|
||||
uchar i, j, k = 0;
|
||||
lcd_address(x, y, 120, 160);
|
||||
for (i = 0; i < 120; i++)
|
||||
{
|
||||
for (j = 0; j < 160; j++)
|
||||
{
|
||||
transfer_data(*dp); // 传一个像素的图片数据的高位
|
||||
dp++;
|
||||
transfer_data(*dp); // 传一个像素的图片数据的低位
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
P1M1 = 0x00;
|
||||
P1M0 = 0x00; // P1配置为准双向
|
||||
P2M1 = 0x00;
|
||||
P2M0 = 0x00; // P2配置为准双向
|
||||
P3M1 = 0x00;
|
||||
P3M0 = 0x00; // P3配置为准双向
|
||||
IM1 = 0; // IM1=0、IM2=0并行接口;IM1=1、IM2=1串行接口
|
||||
IM2 = 0;
|
||||
lcd_initial();
|
||||
while (1)
|
||||
{
|
||||
display_color(blue);
|
||||
disp_32x32(40 + 32 * 0, 8, jing_32x32, white, blue);
|
||||
disp_32x32(40 + 32 * 1, 8, lian_32x32, white, blue);
|
||||
disp_32x32(40 + 32 * 2, 8, xun_32x32, white, blue);
|
||||
disp_32x32(40 + 32 * 3, 8, dian_32x32, white, blue);
|
||||
disp_32x32(40 + 32 * 4, 8, zi_32x32, white, blue);
|
||||
|
||||
display_string_16x16(24, 56, "深圳市晶联讯电子有限公司", white, blue);
|
||||
display_string_16x16(48, 88, "型号", white, blue);
|
||||
disp_string_8x16(80, 88, ":JLX240-00303-BN", white, blue);
|
||||
display_string_16x16(48, 120, "视窗", white, blue);
|
||||
disp_string_8x16(80, 120, ":36.7x48.9mm", white, blue);
|
||||
display_string_16x16(48, 152, "驱动", white, blue);
|
||||
disp_string_8x16(80, 152, "IC:ST7789V", white, blue);
|
||||
|
||||
display_string_16x16(0, 184, "经营宗旨:制造高品质产品及服务", white, blue);
|
||||
display_string_16x16(0, 216, "质量方针:客户至上,质量保证", white, blue);
|
||||
display_string_16x16(79, 236, "持续改进,服务到位", white, blue);
|
||||
display_string_16x16(0, 270, "经营目标:做最好的液晶模块厂家", white, blue);
|
||||
display_string_16x16(79, 292, "做客户信得过的企业", white, blue);
|
||||
Switch();
|
||||
|
||||
display_image(0, 0, pic1);
|
||||
display_image(120, 0, pic1);
|
||||
display_image(0, 160, pic1);
|
||||
display_image(120, 160, pic1);
|
||||
Switch();
|
||||
|
||||
display_color(0xf800);
|
||||
Switch();
|
||||
display_color(0x07e0);
|
||||
Switch();
|
||||
display_color(0x001f);
|
||||
Switch();
|
||||
display_black();
|
||||
Switch();
|
||||
display_color(0xffff);
|
||||
Switch();
|
||||
}
|
||||
}
|
|
@ -1,397 +0,0 @@
|
|||
//LCM resolution:240x320,
|
||||
//driver IC:ST7789V,
|
||||
|
||||
#include <STC15F2K60S2.H>
|
||||
#include <chinese_code.h>
|
||||
|
||||
//液晶屏IC所需要的信号线的接口定义
|
||||
sbit cs1=P3^5;
|
||||
sbit reset=P3^3;
|
||||
sbit rs=P3^0;
|
||||
sbit sclk=P3^4;
|
||||
sbit sid=P3^2;
|
||||
sbit IM1=P3^6;
|
||||
sbit IM2=P3^7;
|
||||
sbit key=P2^0; //P2.0口与GND之间接一个按键
|
||||
|
||||
/*写指令到LCD模块*/
|
||||
void transfer_command(int data1)
|
||||
{
|
||||
char i;
|
||||
cs1=0;
|
||||
rs=0;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
sclk=0;
|
||||
if(data1&0x80) sid=1;
|
||||
else sid=0;
|
||||
sclk=1;
|
||||
data1=data1<<=1;
|
||||
}
|
||||
cs1=1;
|
||||
}
|
||||
|
||||
/*写数据到LCD模块*/
|
||||
void transfer_data(int data1)
|
||||
{
|
||||
char i;
|
||||
cs1=0;
|
||||
rs=1;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
sclk=0;
|
||||
if(data1&0x80) sid=1;
|
||||
else sid=0;
|
||||
sclk=1;
|
||||
data1=data1<<=1;
|
||||
}
|
||||
cs1=1;
|
||||
}
|
||||
|
||||
//连写2个字节(即16位)数据到LCD模块
|
||||
void transfer_data_16(uint data_16bit)
|
||||
{
|
||||
transfer_data(data_16bit>>8);
|
||||
transfer_data(data_16bit);
|
||||
}
|
||||
|
||||
void delay(long i)
|
||||
{
|
||||
int j,k;
|
||||
for(j=0;j<i;j++)
|
||||
for(k=0;k<110;k++);
|
||||
}
|
||||
|
||||
void Switch()
|
||||
{
|
||||
repeat:
|
||||
if (key==1) goto repeat;
|
||||
else delay(1000);
|
||||
if (key) goto repeat;
|
||||
else ;
|
||||
}
|
||||
|
||||
void lcd_initial()
|
||||
{
|
||||
reset=0;
|
||||
delay(200);
|
||||
reset=1;
|
||||
delay(200);
|
||||
//************* Start Initial Sequence **********//
|
||||
|
||||
//------------------------------display and color format setting--------------------------------//
|
||||
transfer_command(0x36); //行扫描顺序及RGB,列扫描顺序,横放/竖放
|
||||
transfer_data(0x00);
|
||||
transfer_data(0x48);
|
||||
|
||||
transfer_command(0xB6); //显示功能设置:列/行 显示顺序
|
||||
transfer_data(0x0A);
|
||||
transfer_data(0x82); //改变SOURCE线的方向:0xa2:左到右,0x82:右到左
|
||||
|
||||
transfer_command(0x3a); //256K 16bit/pixel
|
||||
transfer_data(0x05);
|
||||
//--------------------------------ST7789V Frame rate setting----------------------------------//
|
||||
transfer_command(0xb2);
|
||||
transfer_data(0x0c);
|
||||
transfer_data(0x0c);
|
||||
transfer_data(0x00);
|
||||
transfer_data(0x33);
|
||||
transfer_data(0x33);
|
||||
transfer_command(0xb7);
|
||||
transfer_data(0x35);
|
||||
//---------------------------------ST7789V Power setting--------------------------------------//
|
||||
transfer_command(0xbb);
|
||||
transfer_data(0x28);
|
||||
transfer_command(0xc0);
|
||||
transfer_data(0x2c);
|
||||
transfer_command(0xc2);
|
||||
transfer_data(0x01);
|
||||
transfer_command(0xc3);
|
||||
transfer_data(0x10);
|
||||
transfer_command(0xc4);
|
||||
transfer_data(0x20);
|
||||
transfer_command(0xc6);
|
||||
transfer_data(0x0f);
|
||||
transfer_command(0xd0);
|
||||
transfer_data(0xa4);
|
||||
transfer_data(0xa1);
|
||||
//--------------------------------ST7789V gamma setting---------------------------------------//
|
||||
transfer_command(0xe0);
|
||||
transfer_data(0xd0);
|
||||
transfer_data(0x00);
|
||||
transfer_data(0x02);
|
||||
transfer_data(0x07);
|
||||
transfer_data(0x0a);
|
||||
transfer_data(0x28);
|
||||
transfer_data(0x32);
|
||||
transfer_data(0x44);
|
||||
transfer_data(0x42);
|
||||
transfer_data(0x06);
|
||||
transfer_data(0x0e);
|
||||
transfer_data(0x12);
|
||||
transfer_data(0x14);
|
||||
transfer_data(0x17);
|
||||
|
||||
transfer_command(0xe1);
|
||||
transfer_data(0xd0);
|
||||
transfer_data(0x00);
|
||||
transfer_data(0x02);
|
||||
transfer_data(0x07);
|
||||
transfer_data(0x0a);
|
||||
transfer_data(0x28);
|
||||
transfer_data(0x31);
|
||||
transfer_data(0x54);
|
||||
transfer_data(0x47);
|
||||
transfer_data(0x0e);
|
||||
transfer_data(0x1c);
|
||||
transfer_data(0x17);
|
||||
transfer_data(0x1b);
|
||||
transfer_data(0x1e);
|
||||
|
||||
transfer_command(0x11); //退出睡眠
|
||||
delay(200);
|
||||
transfer_command(0x29); //打开显示
|
||||
}
|
||||
|
||||
//定义窗口坐标:开始坐标(XS,YS)以及窗口大小(x_total,y_total)
|
||||
void lcd_address(int XS,int YS,int x_total,int y_total)
|
||||
{
|
||||
int XE,YE;
|
||||
XE=XS+x_total-1;
|
||||
YE=YS+y_total-1;
|
||||
transfer_command(0x2a); // 设置X开始及结束的地址
|
||||
transfer_data_16(XS); // X开始地址(16位)
|
||||
transfer_data_16(XE); // X结束地址(16位)
|
||||
|
||||
transfer_command(0x2b); // 设置Y开始及结束的地址
|
||||
transfer_data_16(YS); // Y开始地址(16位)
|
||||
transfer_data_16(YE); // Y结束地址(16位)
|
||||
|
||||
transfer_command(0x2c); // 写数据开始
|
||||
}
|
||||
|
||||
void mono_transfer_data_16(int mono_data,int font_color,int back_color)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
if(mono_data&0x80)
|
||||
{
|
||||
transfer_data_16(font_color); //当数据是1时,显示字体颜色
|
||||
}
|
||||
else
|
||||
{
|
||||
transfer_data_16(back_color); //当数据是0时,显示底色
|
||||
}
|
||||
mono_data<<=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//全屏显示一种颜色
|
||||
void display_color(int color_data)
|
||||
{
|
||||
int i,j;
|
||||
lcd_address(0,0,240,320);
|
||||
for(i=0;i<240;i++)
|
||||
{
|
||||
for(j=0;j<320;j++)
|
||||
{
|
||||
transfer_data_16(color_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void display_black(void)
|
||||
{
|
||||
int i,j,k;
|
||||
transfer_command(0x2c); // 写数据开始
|
||||
for(i=0;i<240;i++)
|
||||
{
|
||||
transfer_data_16(0xffff);
|
||||
}
|
||||
for(i=0;i<318;i++)
|
||||
{
|
||||
for(k=0;k<1;k++)
|
||||
{
|
||||
transfer_data_16(0xffff);
|
||||
}
|
||||
for(j=0;j<238;j++)
|
||||
{
|
||||
transfer_data_16(0x0000);
|
||||
}
|
||||
for(k=0;k<1;k++)
|
||||
{
|
||||
transfer_data_16(0xffff);
|
||||
}
|
||||
}
|
||||
for(i=0;i<320;i++)
|
||||
{
|
||||
transfer_data_16(0xffff);
|
||||
}
|
||||
}
|
||||
|
||||
//显示8x16点阵的字符串
|
||||
void disp_string_8x16(int x,int y,char *text,int font_color,int back_color)
|
||||
{
|
||||
int i=0,j,k;
|
||||
while(text[i]>0x00)
|
||||
{
|
||||
if((text[i]>=0x20)&&(text[i]<=0x7e))
|
||||
{
|
||||
j=text[i]-0x20;
|
||||
lcd_address(x,y,8,16);
|
||||
for(k=0;k<16;k++)
|
||||
{
|
||||
mono_transfer_data_16(ascii_table_8x16[j*16+k],font_color,back_color); //?a??"ascii_table_8x16[]"?a??êy×é?ú"ASCII_TABLE_5X8_8X16_horizontal.h"à?
|
||||
}
|
||||
x+=8;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void display_string_16x16(int x,int y,uchar *text,int font_color,int back_color)
|
||||
{
|
||||
uchar i,j,k;
|
||||
uint address;
|
||||
j = 0;
|
||||
while(text[j] != '\0') //'\0' 字符串结束标志
|
||||
{
|
||||
i = 0;
|
||||
address = 1;
|
||||
while(Chinese_horizontal_text_16x16[i] > 0x7e) // >0x7f即说明不是ASCII码字符
|
||||
{
|
||||
if(Chinese_horizontal_text_16x16[i] == text[j])
|
||||
{
|
||||
if(Chinese_horizontal_text_16x16[i + 1] == text[j + 1])
|
||||
{
|
||||
address = i * 16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i += 2;
|
||||
}
|
||||
if(y > 320)
|
||||
{
|
||||
y=0;
|
||||
x+=16;
|
||||
}
|
||||
|
||||
if(address != 1)// 显示汉字
|
||||
{
|
||||
lcd_address(x,y,16,16);
|
||||
for(i=0;i<2;i++)
|
||||
{
|
||||
for(k = 0; k <16; k++)
|
||||
{
|
||||
mono_transfer_data_16(Chinese_horizontal_code_16x16[address],font_color,back_color);
|
||||
address++;
|
||||
}
|
||||
}
|
||||
j+=2;
|
||||
}
|
||||
else //显示空白字符
|
||||
{
|
||||
lcd_address(x,y,16,16);
|
||||
for(i = 0; i <2; i++)
|
||||
{
|
||||
for(k = 0; k < 16; k++)
|
||||
{
|
||||
mono_transfer_data_16(0x00,font_color,back_color);
|
||||
}
|
||||
}
|
||||
j+=2;
|
||||
}
|
||||
x=x+16;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//显示32x32点阵的单色的图像
|
||||
void disp_32x32(int x,int y,char *dp,int font_color,int back_color)
|
||||
{
|
||||
int i,j;
|
||||
lcd_address(x,y,32,32);
|
||||
for(i=0;i<32;i++)
|
||||
{
|
||||
for(j=0;j<4;j++)
|
||||
{
|
||||
mono_transfer_data_16(*dp,font_color,back_color);
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//显示一幅彩图
|
||||
void display_image(int x,int y,uchar *dp)
|
||||
{
|
||||
uchar i,j,k=0;
|
||||
lcd_address(x,y,120,160);
|
||||
for(i=0;i<120;i++)
|
||||
{
|
||||
for(j=0;j<160;j++)
|
||||
{
|
||||
transfer_data(*dp); //传一个像素的图片数据的高位
|
||||
dp++;
|
||||
transfer_data(*dp); //传一个像素的图片数据的低位
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
P1M1=0x00;
|
||||
P1M0=0x00; //P1配置为准双向
|
||||
P2M1=0x00;
|
||||
P2M0=0x00; //P2配置为准双向
|
||||
P3M1=0x00;
|
||||
P3M0=0x00; //P3配置为准双向
|
||||
IM1=1; //IM1=0、IM2=0并行接口;IM1=1、IM2=1串行接口
|
||||
IM2=1;
|
||||
lcd_initial();
|
||||
while(1)
|
||||
{
|
||||
display_color(blue);
|
||||
disp_32x32(40+32*0,8,jing_32x32,white,blue);
|
||||
disp_32x32(40+32*1,8,lian_32x32,white,blue);
|
||||
disp_32x32(40+32*2,8,xun_32x32,white,blue);
|
||||
disp_32x32(40+32*3,8,dian_32x32,white,blue);
|
||||
disp_32x32(40+32*4,8,zi_32x32,white,blue);
|
||||
|
||||
display_string_16x16(24,56,"深圳市晶联讯电子有限公司",white,blue);
|
||||
display_string_16x16(48,88,"型号",white,blue);
|
||||
disp_string_8x16(80,88,":JLX240-00303-BN",white,blue);
|
||||
display_string_16x16(48,120,"视窗",white,blue);
|
||||
disp_string_8x16(80,120,":36.7x48.9mm",white,blue);
|
||||
display_string_16x16(48,152,"驱动",white,blue);
|
||||
disp_string_8x16(80,152,"IC:ST7789V",white,blue);
|
||||
|
||||
display_string_16x16(0,184,"经营宗旨:制造高品质产品及服务",white,blue);
|
||||
display_string_16x16(0,216,"质量方针:客户至上,质量保证",white,blue);
|
||||
display_string_16x16(79,236,"持续改进,服务到位",white,blue);
|
||||
display_string_16x16(0,270,"经营目标:做最好的液晶模块厂家",white,blue);
|
||||
display_string_16x16(79,292,"做客户信得过的企业",white,blue);
|
||||
Switch();
|
||||
|
||||
display_image(0,0,pic1);
|
||||
display_image(120,0,pic1);
|
||||
display_image(0,160,pic1);
|
||||
display_image(120,160,pic1);
|
||||
Switch();
|
||||
|
||||
display_color(0xf800);
|
||||
Switch();
|
||||
display_color(0x07e0);
|
||||
Switch();
|
||||
display_color(0x001f);
|
||||
Switch();
|
||||
display_black();
|
||||
Switch();
|
||||
display_color(0xffff);
|
||||
Switch();
|
||||
}
|
||||
}
|
40672
App/LCD/chinese_code.h
40672
App/LCD/chinese_code.h
File diff suppressed because it is too large
Load Diff
|
@ -148,6 +148,7 @@ void readcoilstate_rtu(uint8_t * upRxdbuf, uint16_t wRxdLen)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -227,6 +228,7 @@ void readdisinputstate_rtu(uint8_t * upRxdbuf, uint16_t wRxdLen)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -289,6 +291,7 @@ void readholdreg_rtu(uint8_t * upRxdbuf, uint16_t wRxdLen)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -350,6 +353,7 @@ void readinputreg_rtu(uint8_t * upRxdbuf, uint16_t wRxdLen)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -403,6 +407,7 @@ void writesinglereg_rtu(uint8_t * upRxdbuf, uint16_t wRxdLen)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -457,6 +462,7 @@ void writemultireg_rtu(uint8_t * upRxdbuf, uint16_t wRxdLen)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -508,6 +514,7 @@ void writesinglecoil_rtu(uint8_t * upRxdbuf, uint16_t wRxdLen)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -586,6 +593,7 @@ void writemulticoil_rtu(uint8_t * upRxdbuf, uint16_t wRxdLen)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
|
||||
|
||||
return;
|
||||
|
@ -630,6 +638,7 @@ void modbus_errfunction_rtu(uint8_t uCmdCode, uint8_t uErrorCode)
|
|||
// uart_send(&MODBUS_HUART, MODBUS_UART.tx_buf, MODBUS_UART.tx_size);
|
||||
scom2_rs485.tx_len = (uCommIndexNum <= MAX_SIZE)?(uCommIndexNum):(MAX_SIZE);
|
||||
memcpy(scom2_rs485.tx_buff, upTxdbuf, scom2_rs485.tx_len);
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -167,7 +167,7 @@ void StartDefaultTask(void const * argument)
|
|||
/* Infinite loop */
|
||||
for (;;)
|
||||
{
|
||||
osDelay(500);
|
||||
osDelay(5000);
|
||||
}
|
||||
/* USER CODE END StartDefaultTask */
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ void start_task_monitor(void const * argument)
|
|||
//vTaskList(task_status);
|
||||
//HAL_UART_Transmit(&huart3, (uint8_t *)task_status, 255, 0xFFFF);
|
||||
|
||||
//osDelay(3000);
|
||||
osDelay(3000);
|
||||
}
|
||||
/* USER CODE END start_task_monitor */
|
||||
}
|
||||
|
|
|
@ -245,6 +245,26 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>fre_set,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>18</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>CoilState</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>19</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>DisState</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>20</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>InputReg,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>21</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>HoldReg,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue