📄 ch452.h
字号:
struct LED_BITS {
Uint16 LED_Run:1;
Uint16 DIVERCE_COMMNUICATION:1;
Uint16 DIVERCE_ALARME:1;
Uint16 PROTECT_ACTION:1;
Uint16 OUT_FZ:1;
Uint16 OUT_HZ:1;
Uint16 FZ_POZITION:1;
Uint16 HZ_POZITION:1;
Uint16 rsvd1:8;
};
#define INVALID 0x007f
#define DELAY_Ltime 0x60
#define DELAY_Stime 0x30
#define CH452Dout GpioDataRegs.GPFDAT.bit.GPIOF2
#define CH452reset GpioDataRegs.GPBSET.bit.GPIOB15
#define CH452Din_1 GpioDataRegs.GPFDAT.bit.GPIOF0=1
#define CH452Din_0 GpioDataRegs.GPFDAT.bit.GPIOF0=0
#define CH452clk_1 GpioDataRegs.GPFDAT.bit.GPIOF1=1
#define CH452clk_0 GpioDataRegs.GPFDAT.bit.GPIOF1=0
#define CH452lod_1 GpioDataRegs.GPFDAT.bit.GPIOF3=1
#define CH452lod_0 GpioDataRegs.GPFDAT.bit.GPIOF3=0
/* 常量定义 */
/* CH451和CH452的常用命令码 */
#define CH452_SPACE 0x00 // display no
#define CH452_NOP 0x0000 // 空操作
#define CH452_RESET 0x0201 // 复位
#define CH452_LEVEL 0x0100 // 加载光柱值,需另加7位数据
#define CH452_CLR_BIT 0x0180 // 段位清0,需另加6位数据
#define CH452_SET_BIT 0x01C0 // 段位置1,需另加6位数据
#define CH452_SLEEP 0x0202 // 进入睡眠状态
#define CH452_LEFTMOV 0x0300 // 设置移动方式-左移
#define CH452_LEFTCYC 0x0301 // 设置移动方式-左循环
#define CH452_RIGHTMOV 0x0302 // 设置移动方式-右移
#define CH452_RIGHTCYC 0x0303 // 设置移动方式-右循环
#define CH452_SELF_BCD 0x0380 // 自定义BCD码,需另加7位数据
#define CH452_SYSOFF 0x0400 // 关闭显示、关闭键盘
#define CH452_SYSON1 0x0401 // 开启显示
#define CH452_SYSON2 0x0403 // 开启显示、键盘
#define CH452_SYSON4W 0x0413 // 开启显示、键盘\快速
#define CH452_SYSON2W 0x0423 // 开启显示、键盘, 真正2线接口
#define CH452_NO_BCD 0x0570 // 设置默认显示方式,可另加3位扫描极限
#define CH452_BCD 0x05F0 // 设置BCD译码方式,可另加3位扫描极限
#define CH452_TWINKLE 0x0600 // 设置闪烁控制,需另加8位数据
#define CH452_GET_KEY 0x0700 // 获取按键,返回按键代码
#define CH452_DIG0 0x0800 // 数码管位0显示,需另加8位数据
#define CH452_DIG1 0x0900 // 数码管位1显示,需另加8位数据
#define CH452_DIG2 0x0a00 // 数码管位2显示,需另加8位数据
#define CH452_DIG3 0x0b00 // 数码管位3显示,需另加8位数据
#define CH452_DIG4 0x0c00 // 数码管位4显示,需另加8位数据
#define CH452_DIG5 0x0d00 // 数码管位5显示,需另加8位数据
#define CH452_DIG6 0x0e00 // 数码管位6显示,需另加8位数据
//#define CH452_DIG7 0x0f00 // 数码管位7显示,需另加8位数据
#define charU 0x3e
#define charI 0x06
#define charA 0x77
#define charB 0x7f
#define charC 0x39
#define chara 0xdf
#define charb 0xfc
#define charc 0xd8
#define charP 0x73
#define charQ 0x67
#define charf 0x71
#define charOs 0x6d
#define SHOW_Ua CH452_Write(CH452_DIG5 | charU);CH452_Write(CH452_DIG4 | chara);
#define SHOW_Ub CH452_Write(CH452_DIG5 | charU);CH452_Write(CH452_DIG4 | charb);
#define SHOW_Uc CH452_Write(CH452_DIG5 | charU);CH452_Write(CH452_DIG4 | charc);
#define SHOW_Ia CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | chara);
#define SHOW_Ib CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | charb);
#define SHOW_Ic CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | charc);
#define SHOW_Cos CH452_Write(CH452_DIG5 | charC);CH452_Write(CH452_DIG4 | charOs | 0x80);
#define SHOW_P CH452_Write(CH452_DIG5 | charP | 0x80);
#define SHOW_Q CH452_Write(CH452_DIG5 | charQ | 0x80);
#define SHOW_f CH452_Write(CH452_DIG5 | charf | 0x80);
#define SHOW_MIa CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | charA | 0x80);
#define SHOW_MIb CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | charB | 0x80);
#define SHOW_MIc CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | charC | 0x80);
#define SHOW_Uab CH452_Write(CH452_DIG5 | charU);CH452_Write(CH452_DIG4 | 0x06);
#define SHOW_Ubc CH452_Write(CH452_DIG5 | charU);CH452_Write(CH452_DIG4 | 0x5b);
#define SHOW_Uca CH452_Write(CH452_DIG5 | charU);CH452_Write(CH452_DIG4 | 0x4f);
#define SHOW_U0 CH452_Write(CH452_DIG5 | charU);CH452_Write(CH452_DIG4 | 0x3f);
#define SHOW_Iab CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | 0x06);
#define SHOW_Ibc CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | 0x5b);
#define SHOW_Ica CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | 0x4f);
#define SHOW_I0 CH452_Write(CH452_DIG5 | charI);CH452_Write(CH452_DIG4 | 0x3f| 0x80);
// BCD译码方式下的特殊字符
#define CH452_BCD_SPACE 0x10
#define CH452_BCD_PLUS 0x11
#define CH452_BCD_MINUS 0x12
#define CH452_BCD_EQU 0x13
#define CH452_BCD_LEFT 0x14
#define CH452_BCD_RIGHT 0x15
#define CH452_BCD_UNDER 0x16
#define CH452_BCD_CH_H 0x17
#define CH452_BCD_CH_L 0x18
#define CH452_BCD_CH_P 0x19
#define CH452_BCD_DOT 0x1A
#define CH452_BCD_SELF 0x1E
#define CH452_BCD_TEST 0x88
#define CH452_BCD_DOT_X 0x80
// 有效按键代码
#define CH452_KEY_MIN 0x47
#define CH452_KEY_MAX 0x7F
#define CH452_KEY_SUBB 0x37
#define CH452_KEY_ADD 0x2F
#define CH452_KEY_DOWN 0x3F
#define CH452_KEY_UP 0x1F
#define CH452_KEY_ENTER 0x0f
#define CH452_KEY_CANCEL 0x07
#define CH452_KEY_LEFT 0x27
#define CH452_KEY_RIGHT 0x17
/*
#define Rst452 GpioDataRegs.GPBDAT.bit.GPIOB1
#define Dout452 GpioDataRegs.GPBDAT.bit.GPIOB2
#define Load452 GpioDataRegs.GPBDAT.bit.GPIOB3
#define Din452 GpioDataRegs.GPBDAT.bit.GPIOB4
#define Clk452 GpioDataRegs.GPBDAT.bit.GPIOB5
*/
#define AI_SHOW_Ia 0
#define AI_SHOW_Ib 1
#define AI_SHOW_Ic 2
#define AI_SHOW_Ua 3
#define AI_SHOW_Ub 4
#define AI_SHOW_Uc 5
#define AI_SHOW_Uab 6
#define AI_SHOW_Ubc 7
#define AI_SHOW_Uca 8
#define AI_SHOW_I0s 9
#define AI_SHOW_U0 10
#define AI_SHOW_U2 11
#define AI_SHOW_Ux 12
#define AI_SHOW_I0zc 13
#define AI_SHOW_F 14
#define AI_SHOW_I2 15
#define AI_SHOW_Ua1 16
#define AI_SHOW_Iab 17
#define AI_SHOW_Ibc 18
#define AI_SHOW_Ica 19
#define AI_SHOW_MIa 20
#define AI_SHOW_MIb 21
#define AI_SHOW_MIc 22
#define AI_SHOW_P 23
#define AI_SHOW_Q 24
#define AI_SHOW_COS 25
#define SET_RunLed CH452_Write(CH452_SET_BIT | 0x3e); /* turn off the point */
#define Clear_RunLed CH452_Write(CH452_CLR_BIT | 0x3e); /* turn on the point */
#define Set_CommLed CH452_Write(CH452_SET_BIT | 0x36); /* turn on the point */
#define Clear_CommLed CH452_Write(CH452_CLR_BIT | 0x36); /* turn off the point */
#define Set_AlarmLed CH452_Write(CH452_SET_BIT | 0x2e); /* turn on the point */
#define Clear_AlarmLed CH452_Write(CH452_CLR_BIT | 0x2e); /* turn off the point */
#define Set_ProLed CH452_Write(CH452_SET_BIT | 0x26); /* turn on the point */
#define Clear_ProLed CH452_Write(CH452_CLR_BIT | 0x26); /* turn off the point */
#define Set_OpenSwitchLed CH452_Write(CH452_SET_BIT | 0x1e); /* turn on the point */
#define Clear_OpenSwitchLed CH452_Write(CH452_CLR_BIT | 0x1e); /* turn off the point */
#define Set_CloseSwitchLed CH452_Write(CH452_SET_BIT | 0x16); /* turn on the point */
#define Clear_CloseSwitchLed CH452_Write(CH452_CLR_BIT | 0x16); /* turn off the point */
#define Set_OpenPosiLed CH452_Write(CH452_SET_BIT | 0x0e); /* turn on the point */
#define Clear_OpenPosiLed CH452_Write(CH452_CLR_BIT | 0x0e); /* turn off the point ` */
#define Set_ClosePosiLed CH452_Write(CH452_SET_BIT | 0x06); /* turn on the point */
#define Clear_ClosePosiLed CH452_Write(CH452_CLR_BIT | 0x06); /* turn off the point ` */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -