📄 mstate.c.bak
字号:
//-----------------------
void MState_switch_test(unsigned char key )
{
switch( MState_inf.Func )
{
case FUNC_TEST:
{
if( key == KEY_CLS ){
MState_inf.State = MACHINE_STATE_MAIN;
MState_inf.Func = FUNC_MAIN;
MState_inf.Fresh = FRESH_ON;
}else if( key == '1' ){
MState_inf.Func = FUNC_TEST_KEY;
MState_inf.Fresh = FRESH_ON;
}else if( key == '2' ){
MState_inf.Func = FUNC_TEST_LCD;
MState_inf.Fresh = FRESH_ON;
}else if( key == '3' ){
MState_inf.Func = FUNC_TEST_PRINT;
MState_inf.Fresh = FRESH_ON;
}else if( key == '4' ){
MState_inf.Func = FUNC_TEST_FILE;
MState_inf.Fresh = FRESH_ON;
}
MState_msg[0] = 0;
break;
}
case FUNC_TEST_KEY:
{
if( key == KEY_CLS ){
MState_inf.State = MACHINE_STATE_TEST;
MState_inf.Func = FUNC_TEST;
MState_inf.Fresh = FRESH_ON;
}else{
MState_msg[0] = key;
MState_inf.Fresh = FRESH_ON;
}
break;
}
case FUNC_TEST_LCD:
{
//--->> any key to quit
MState_inf.State = MACHINE_STATE_TEST;
MState_inf.Func = FUNC_TEST;
MState_inf.Fresh = FRESH_ON;
break;
}
case FUNC_TEST_PRINT:
{
if( key == KEY_F1){
//pape_forward();
}else if( key == KEY_F2 ){
//pape_backward();
}else if( key == KEY_ENTER ){
//pape_print();
}else if( key == KEY_CLS ){
MState_inf.State = MACHINE_STATE_TEST;
MState_inf.Func = FUNC_TEST;
MState_inf.Fresh = FRESH_ON;
}
break;
}
case FUNC_TEST_FILE:
{
if( key == KEY_CLS ){
MState_inf.State = MACHINE_STATE_TEST;
MState_inf.Func = FUNC_TEST;
MState_inf.Fresh = FRESH_ON;
}
break;
}
default:
break;
}
}
//-----------------------
void MState_switch_run(unsigned char key )
{
//--->>Get file failed, any key to quit !
MState_inf.State = MACHINE_STATE_MAIN;
MState_inf.Func = FUNC_MAIN;
MState_inf.Fresh = FRESH_ON;
}
//------------------------------
void MState_key(void)
{
unsigned char key;
key = Key_get();
if(key)
{
switch( MState_inf.State )
{
case MACHINE_STATE_FACE:
{
MState_switch_face( key );
break;
}
case MACHINE_STATE_MAIN:
{
MState_switch_main( key );
break;
}
case MACHINE_STATE_SYSINF:
{
MState_switch_sysinf( key );
break;
}
case MACHINE_STATE_CONFIG:
{
MState_switch_config( key );
break;
}
case MACHINE_STATE_COM:
{
MState_switch_com( key );
break;
}
case MACHINE_STATE_TEST:
{
MState_switch_test( key );
break;
}
case MACHINE_STATE_RUN:
{
MState_switch_run( key );
break;
}
}
}
}
//===============================
//-----------------------
void MState_display_face()
{
unsigned char volt;
volt = ADC_batt();
LCD_face();
volt = ADC_batt();
LCD_pain_batt( volt );
}
//-----------------------
void MState_display_main()
{
unsigned char volt;
volt = ADC_batt();
LCD_clear_screen();
LCD_locate(1,4); LCD_write_string("功能主菜单",0);
LCD_locate(4,2); LCD_write_string("【1】 系统通信",0);
LCD_locate(6,2); LCD_write_string("【2】 系统信息",0);
LCD_locate(8,2); LCD_write_string("【3】 系统设置",0);
LCD_locate(10,2); LCD_write_string("【4】 系统测试",0);
LCD_locate(12,2); LCD_write_string("【5】 运行程序",0);
LCD_locate(18,6); LCD_write_string("【清除】退出",0);
volt = ADC_batt();
LCD_pain_batt( volt );
}
//-----------------------
void MState_display_sysinf()
{
unsigned char i,j,n;
int k,s;
struct FILE_struct File_inf;
switch( MState_inf.Func )
{
case FUNC_SYSINF:
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("系统信息",0);
LCD_locate(4,2); LCD_write_string("【1】 机器信息",0);
LCD_locate(6,2); LCD_write_string("【2】 文件信息",0);
LCD_locate(8,2); LCD_write_string("【3】 系统时间",0);
LCD_locate(10,2); LCD_write_string("【4】 电池状态",0);
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
break;
}
case FUNC_SYSINF_MACH_INF:
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("机器信息",0);
LCD_locate(4,0); LCD_write_string("操作员:",0);
LCD_locate(6,0); LCD_write_string("操作编号:",0);
LCD_locate(8,0); LCD_write_string("机器型号:",0);
LCD_locate(10,0); LCD_write_string("机身编号:",0);
LCD_locate(12,0); LCD_write_string("系统版本:V2.1.0",0);
LCD_locate(14,0); LCD_write_string("发布时间:2008/01/01",0);
LCD_locate(16,0); LCD_write_string("存储容量:8M 字节",0);
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
break;
}
case FUNC_SYSINF_FILE_INF:
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("文件信息",0);
LCD_locate(4,0); LCD_write_string("文件名称:",0);
LCD_locate(12,0); LCD_write_string("文件数量:",0);
LCD_locate(14,0); LCD_write_string("已用空间:",0);
LCD_locate(16,0); LCD_write_string("剩余空间:",0);
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
s = 0;
n = 0;
for(i=0; i<6; i++)
{
k = File_inf_get(i,&File_inf);
if( k>=0 )
{
s += File_inf.Size;
n++;
if( n<4 ){
LCD_locate((4+n*2),4);
for(j=0;j<11;j++) LCD_write_ASCII( (File_inf.Name[j]),0 );
}
}
}
LCD_locate(12,10); LCD_write_ASCII((n+0x30),0);
LCD_locate(14,10); LCD_write_int(s,0);
LCD_locate(16,10); LCD_write_int((0x600000-s),0);
break;
}
case FUNC_SYSINF_TIME_INF:
{
struct RTC_struct RTC_inf;
RTC_get( &RTC_inf );
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("系统时间",0);
Bcd_to_Ascii(RTC_inf.Year, MState_msg);
LCD_locate(4,2); LCD_write_string("20",0);
LCD_locate(4,4); LCD_write_ASCII(MState_msg[0],0);
LCD_locate(4,5); LCD_write_ASCII(MState_msg[1],0);
LCD_locate(4,6); LCD_write_string("年",0);
Bcd_to_Ascii(RTC_inf.Mon, MState_msg);
LCD_locate(4,8); LCD_write_ASCII(MState_msg[0],0);
LCD_locate(4,9); LCD_write_ASCII(MState_msg[1],0);
LCD_locate(4,10); LCD_write_string("月",0);
Bcd_to_Ascii(RTC_inf.Day, MState_msg);
LCD_locate(4,12); LCD_write_ASCII(MState_msg[0],0);
LCD_locate(4,13); LCD_write_ASCII(MState_msg[1],0);
LCD_locate(4,14); LCD_write_string("日",0);
LCD_locate(8,6); LCD_write_string("星期:",0);
LCD_locate(8,12);
switch(RTC_inf.Week)
{
case 1: LCD_write_string("一",0);break;
case 2: LCD_write_string("二",0);break;
case 3: LCD_write_string("三",0);break;
case 4: LCD_write_string("四",0);break;
case 5: LCD_write_string("五",0);break;
case 6: LCD_write_string("六",0);break;
case 7: LCD_write_string("日",0);break;
default: break;
}
Bcd_to_Ascii(RTC_inf.Hour, MState_msg);
LCD_locate(12,4); LCD_write_ASCII(MState_msg[0],0);
LCD_locate(12,5); LCD_write_ASCII(MState_msg[1],0);
LCD_locate(12,6); LCD_write_string(":",0);
Bcd_to_Ascii(RTC_inf.Min, MState_msg);
LCD_locate(12,8); LCD_write_ASCII(MState_msg[0],0);
LCD_locate(12,9); LCD_write_ASCII(MState_msg[1],0);
LCD_locate(12,10); LCD_write_string(":",0);
Bcd_to_Ascii(RTC_inf.Sec, MState_msg);
LCD_locate(12,12); LCD_write_ASCII(MState_msg[0],0);
LCD_locate(12,13); LCD_write_ASCII(MState_msg[1],0);
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
break;
}
case FUNC_SYSINF_BATT_INF:
{
LCD_clear_screen();
//i = ADC_batt();
i = ADC_batt();
LCD_locate(1,4); LCD_write_string("电池状态:",0);
if( i<50 ){
LCD_pain_batt( i );
LCD_locate(8,2); LCD_write_string("电池电压:",0);
LCD_locate(8,12); LCD_write_ASCII( ((i/10)+'0'),0);
LCD_locate(8,13); LCD_write_ASCII('.',0);
LCD_locate(8,14); LCD_write_ASCII( ((i%10)+'0'),0);
}
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
break;
}
default:
break;
}
}
//-----------------------
void MState_display_config()
{
unsigned char i;
//struct CONFIG_struct Config_inf;
switch( MState_inf.Func )
{
case FUNC_CONFIG:
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("系统设置",0);
LCD_locate(4,2); LCD_write_string("【1】 LCD 调节",0);
LCD_locate(6,2); LCD_write_string("【2】 打印机调节",0);
LCD_locate(8,2); LCD_write_string("【3】 FLASH格式化",0);
LCD_locate(10,2); LCD_write_string("【4】 修改秘密",0);
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
break;
}
case FUNC_CONFIG_LCD:
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("LCD对比度",0);
LCD_pain_progress(6,0,7,MState_msg[0]);
LCD_locate(9,0); LCD_write_string("[下翻]-- [上翻]++",0);
LCD_locate(15,1); LCD_write_string("【确认】",0);
LCD_locate(18,3); LCD_write_string("保存",0);
LCD_locate(15,11); LCD_write_string("【清除】",0);
LCD_locate(18,13); LCD_write_string("取消",0);
break;
}
case FUNC_CONFIG_PRINT:
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("打印深度",0);
LCD_pain_progress(6,0,7,MState_msg[0]);
LCD_locate(9,0); LCD_write_string("[下翻]-- [上翻]++",0);
LCD_locate(15,1); LCD_write_string("【确认】",0);
LCD_locate(18,3); LCD_write_string("保存",0);
LCD_locate(15,11); LCD_write_string("【清除】",0);
LCD_locate(18,13); LCD_write_string("取消",0);
break;
}
case FUNC_CONFIG_FORMAT:
{
if( MState_inf.Step == STEP_CONFIG_FORMAT_PSWD )
{ //--->>check password
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("权限检查",0);
LCD_locate(8,2); LCD_write_string("密码:------",0);
LCD_locate(8,8);
for(i=0; i<(MState_msg[0]); i++) LCD_write_string("*",0);
LCD_locate(15,1); LCD_write_string("【确认】",0);
LCD_locate(18,3); LCD_write_string("校验",0);
LCD_locate(15,11); LCD_write_string("【清除】",0);
LCD_locate(18,13); LCD_write_string("退出",0);
}else if( MState_inf.Step == STEP_CONFIG_FORMAT_PSER ) {
//--->>if password error,any key to return
LCD_clear_screen();
LCD_locate(2,6); LCD_write_string("密码错误!",0);
LCD_locate(8,2); LCD_write_string("【任意键】退出",0);
}else if( MState_inf.Step == STEP_CONFIG_FORMAT_WARN ) {
//--->> operator warning
LCD_clear_screen();
LCD_locate(0,0);
for(i=0; i<20; i++) LCD_write_string(" ",1);
LCD_locate(2,0);
for(i=0; i<20; i++) LCD_write_string(" ",1);
LCD_locate(4,0);
for(i=0; i<20; i++) LCD_write_string(" ",1);
LCD_locate(2,8); LCD_write_string("警 告 !",1);
LCD_locate(7,6); LCD_write_string("格式化操作",0);
LCD_locate(10,0); LCD_write_string("将丢失所有文件信息!",0);
LCD_locate(15,1); LCD_write_string("【确认】",0);
LCD_locate(18,2); LCD_write_string("格式化",0);
LCD_locate(15,11); LCD_write_string("【清除】",0);
LCD_locate(18,13); LCD_write_string("退出",0);
}else if( MState_inf.Step == STEP_CONFIG_FORMAT_RUN ) {
//--->>any key to return
LCD_clear_screen();
LCD_locate(2,4); LCD_write_string("格式化完成!",0);
LCD_locate(8,2); LCD_write_string("【任意键】退出",0);
}
break;
}
case FUNC_CONFIG_PSWD:
{
if( MState_inf.Step == STEP_CONFIG_PSWD_OLD )
{ //--->>check password
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("权限检查",0);
LCD_locate(8,4); LCD_write_string("密码:------",0);
LCD_locate(8,10);
for(i=0; i<(MState_msg[0]); i++) LCD_write_string("*",0);
LCD_locate(15,1); LCD_write_string("【确认】",0);
LCD_locate(18,3); LCD_write_string("校验",0);
LCD_locate(15,11); LCD_write_string("【清除】",0);
LCD_locate(18,13); LCD_write_string("退出",0);
}else if( MState_inf.Step == STEP_CONFIG_PSWD_PSER ) {
//--->>if password error,any key to return
LCD_clear_screen();
LCD_locate(2,6); LCD_write_string("输入错误!",0);
LCD_locate(8,2); LCD_write_string("【任意键】退出",0);
}else if( MState_inf.Step == STEP_CONFIG_PSWD_NEW ) {
//--->> new password
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("输入新密码",0);
LCD_locate(8,4); LCD_write_string("密码:------",0);
LCD_locate(8,10);
for(i=0; i<(MState_msg[0]); i++) LCD_write_string("*",0);
LCD_locate(15,1); LCD_write_string("【确认】",0);
LCD_locate(18,3); LCD_write_string("完成",0);
LCD_locate(15,11); LCD_write_string("【清除】",0);
LCD_locate(18,13); LCD_write_string("退出",0);
}else if( MState_inf.Step == STEP_CONFIG_PSWD_AGAIN ) {
//--->>any password again
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("再输入一遍",0);
LCD_locate(8,4); LCD_write_string("密码:------",0);
LCD_locate(8,10);
for(i=0; i<(MState_again[0]); i++) LCD_write_string("*",0);
LCD_locate(15,1); LCD_write_string("【确认】",0);
LCD_locate(18,3); LCD_write_string("校验",0);
LCD_locate(15,11); LCD_write_string("【清除】",0);
LCD_locate(18,13); LCD_write_string("退出",0);
}else if( MState_inf.Step == STEP_CONFIG_PSWD_SAVE ) {
//--->>new password save
LCD_clear_screen();
LCD_locate(2,4); LCD_write_string("密码修改成功!",0);
LCD_locate(8,2); LCD_write_string("【任意键】退出",0);
}
break;
}
default:
break;
}
}
//-----------------------
void MState_display_com()
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("系统通信",0);
LCD_locate(8,4); LCD_write_string("@ ====== &",0);
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
}
//-----------------------
void MState_display_test()
{
unsigned char i;
switch( MState_inf.Func )
{
case FUNC_TEST:
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("系统测试",0);
LCD_locate(4,2); LCD_write_string("【1】 键盘测试",0);
LCD_locate(6,2); LCD_write_string("【2】 LCD 测试",0);
LCD_locate(8,2); LCD_write_string("【3】 打印测试",0);
LCD_locate(10,2); LCD_write_string("【4】 文件测试",0);
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
break;
}
case FUNC_TEST_KEY:
{
LCD_clear_screen();
LCD_locate(1,6); LCD_write_string("键盘测试",0);
LCD_locate(8,2); LCD_write_string("键值:",0);
if( MState_msg[0] )
{
LCD_locate(8,10); LCD_write_string("0x",0);
i = ( MState_msg[0] & 0xF0 ) >> 4;
if( i > 0x09 ) {
i = i - 0x09 + 0x40;
}else{
i += 0x30;
}
LCD_locate(8,13); LCD_write_ASCII(i,0);
i = MState_msg[0] & 0x0F;
if( i > 0x09 ) {
i = i - 0x09 + 0x40;
}else{
i += 0x30;
}
LCD_locate(8,14); LCD_write_ASCII(i,0);
MState_msg[0] = 0;
}
LCD_locate(18,8); LCD_write_string("【清除】退出",0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -