📄 smfm.c
字号:
/******************************************************************************
* Copyright (c) 2006 Primax Corporation,Ltd. All rights reserved.
*
* Author: Junny Fu
*
* Description:
*
* Revision History:
* Date Author Description
2006-12-15 Jason Yang
******************************************************************************/
#define __Fax
#include "Standard.h"
#include "Nucleus.h"
#include "Menu.h"
#include "Uinew.h"
#include "Uilcdnew.h"
#include "Ts.h"
#include "Speaker.h"
#include "Faxboard.h"
#include "Scan_manager.h"
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Constants/Macros
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define TEST_OPPANEL_PROC_END 1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Type
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
typedef struct _Diagnostic_TestResult{
Uint8 ADF_TestResult;
Uint8 LCD_TestResult;
Uint8 KeyBoard_TestResult;
Uint8 FB_Scan_TestResult;
Uint8 Speaker_TestResult;
Uint8 FlashChecksum_TestResult;
Uint8 FAX_TestResult;
Uint8 Engine_TestResult;
}Diagnostic_Result, *pDiagnostic_SaveResult;
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Globals
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
char inputbuf2[5];
Uint8 ut;
Diagnostic_Result gDiagnosticResult={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Statics
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
static char Password[5] = "17951";
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Prototypes
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ~~~ export functions declaration ~~~
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Externs
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
extern P_MENUDATA gpMenudata;
extern UIMaintain gUIMain;
extern char firstlinebuf[LINE_BUF_LENGTH];
extern char secondlinebuf[LINE_BUF_LENGTH];
extern Bool password;
extern Bool diagnosismode;
extern Uint8 inputindex;
extern Bool FlashChecksum(Uint32 *R_Checksum);
void ServiceMode(Uint8 action)
{
// char buf[42];
P_MAIN_MENU_LIST currentmenu;
Uint8 AlignL1,AlignL2;
currentmenu = gpMenudata ->ml + gpMenudata ->mlIndex;
AlignL1 = currentmenu->firstline;
AlignL2 = currentmenu->secondline;
switch(currentmenu->type)
{
case MULTI:
MultiType(action);
break;
case STRING:
StringType(action);
// sprintf(buf,"%-20s\n%-20s",firstlinebuf,secondlinebuf);
// DisplayLCD(0, buf, strlen(buf));
LCDDisplayClear();
DisplayLCD(0, firstlinebuf, AlignL1,FALSE);
DisplayLCD(1, secondlinebuf, AlignL2,FALSE);
break;
default:
break;
}
}
void UIAllReset()
{
sprintf(firstlinebuf, "All Setting Reset");
sprintf(secondlinebuf, " ");
LCDDisplayClear();
DisplayLCD(0, firstlinebuf, MIDDLE,FALSE);
DisplayLCD(1, secondlinebuf, MIDDLE,FALSE);
NU_Sleep(500);
SetFactoryDefault();
NVFlashDataWrite(MFPSETTINGS);
SetDefaultFaxMaintenance();
NVFlashDataWrite(FAXMAINTENANCE);
FaxAPI_AllSetUItoFaxParam();
}
void InputPassword(Uint8 action)
{
Uint8 status;
inputbuf2[inputindex] = action + '0';
status = strncmp(Password, inputbuf2,sizeof(inputbuf2));
if(status == 0)
{
password = TRUE;
memset(inputbuf2,0,sizeof(inputbuf2));
}
else
password = FALSE;
if(inputindex<4)
{
if(inputindex == 0)
strcpy(secondlinebuf,"*");
else
sprintf(secondlinebuf,"%s*",secondlinebuf);
inputindex++;
}
else
{
inputindex = 0;
sprintf(secondlinebuf,"%s*",secondlinebuf);
}
}
void ReturnToStandby()
{
password = FALSE;
diagnosismode = FALSE;
MenuListInitSet(COPY_IDLE);
gUIMain.UIstate = STANDBY;
}
/**********************************************************************\
* Replace character of string
*
* Parameter
* pStr : point of string
* c : 'c' will be replaced by 'r'
* r : 'r' will be replace 'c'
* Note
* History
* 2003.01.09 Aceking Wang Create
\**********************************************************************/
static char* strchrReplace(char* pStr, int c, int r)
{
char* pCh;
pCh = strchr(pStr, c);
if (pCh != NULL)
{
*pCh = r;
}
return pCh;
}
BOOL TM_OPPanelKeyTouchProc(char* pStr, UINT8 hitKeyNum, UINT8 type)
{
Uint16 currentbutton = 0, lastbutton = 0xFF;
Uint8 debounce = 0,Error_CNT=0;
char* pCh = NULL;
BOOL KeyBoardResult=TRUE;
while (hitKeyNum)
{
currentbutton = UIGetKey();
//add by jason,if continue to press back key 6 times, system will set the keyboard NG;
if (currentbutton==PANEL_SHARP)
{
Error_CNT++;
if (Error_CNT>=6)
{
KeyBoardResult=FALSE;
break;
}
}
else if (currentbutton!=PANEL_NONE)
Error_CNT=0;
/* solve Button de-bounce start */
if (currentbutton == lastbutton)
{
debounce = 2;
continue;
}
else if (currentbutton == PANEL_NONE)
{
if (debounce) debounce--;
else lastbutton = currentbutton;
}
else
{
debounce = 2;
lastbutton = currentbutton;
}
/* solve Button de-bounce end */
switch (currentbutton)
{
case PANEL_NUM1: pCh = strchrReplace(pStr, '1', ' '); break;
case PANEL_NUM2: pCh = strchrReplace(pStr, '2', ' '); break;
case PANEL_NUM3: pCh = strchrReplace(pStr, '3', ' '); break;
case PANEL_NUM4: pCh = strchrReplace(pStr, '4', ' '); break;
case PANEL_NUM5: pCh = strchrReplace(pStr, '5', ' '); break;
case PANEL_NUM6: pCh = strchrReplace(pStr, '6', ' '); break;
case PANEL_NUM7: pCh = strchrReplace(pStr, '7', ' '); break;
case PANEL_NUM8: pCh = strchrReplace(pStr, '8', ' '); break;
case PANEL_NUM9: pCh = strchrReplace(pStr, '9', ' '); break;
case PANEL_STAR: pCh = strchrReplace(pStr, '*', ' '); break;
case PANEL_NUM0: pCh = strchrReplace(pStr, '0', ' '); break;
case PANEL_SHARP: pCh = strchrReplace(pStr, '#', ' '); break;
case PANEL_START: pCh = strchrReplace(pStr, 'A', ' '); break;
case PANEL_BACK: pCh = strchrReplace(pStr, 'B', ' '); break;
case PANEL_CANCEL: pCh = strchrReplace(pStr, 'C', ' '); break;
case PANEL_SELECT: pCh = strchrReplace(pStr, 'D', ' '); break;
case PANEL_ARROWLEFT: pCh = strchrReplace(pStr, 'E', ' '); break;
case PANEL_ARROWRIGHT: pCh = strchrReplace(pStr, 'F', ' '); break;
case PANEL_PHONEBOOK: pCh = strchrReplace(pStr, 'G', ' '); break;
case PANEL_PAUSE: pCh = strchrReplace(pStr, 'H', ' '); break;
break;
}
if (pCh != NULL)
{
hitKeyNum--;
LCDStringOut(0, 0, pStr, strlen(pStr));
pCh = NULL;
}
/* Be a good OS citizen */
//OSRUN_Sleep(0);
}
return KeyBoardResult;
}
UINT8 TM_OPPanelProc(UINT8 step)
{
// char buf[LCD_LINE_MAX+1];
char buf1[LCD_LINE_MAX*2+2];
UINT8 ret = 0;
switch (step)
{
/*
case 0:
memset(buf, 0xBE, LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,strlen(buf));
DisplayLCD(1, buf, LEFT,strlen(buf));
break;
case 1:
memset(buf, 0xFF, LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,strlen(buf));
DisplayLCD(1, buf, LEFT,strlen(buf));
break;
*/
case 0:
LCDDisplayClear();
NU_Sleep(10);
// TEST MODE for Key
strcpy(buf1, "123456789*0#ABCDEFGH");
LCDStringOut(0, 0, buf1, strlen(buf1));
if (TM_OPPanelKeyTouchProc(buf1, 20, 0))
{
gDiagnosticResult.KeyBoard_TestResult=1;
strcpy(firstlinebuf,GetMsgData(DISP_KEYBOARD_TEST));
strcpy(secondlinebuf,GetMsgData(DISP_MYTECS_REPFAX_OK));
LCDDisplayClear();
DisplayLCD(0, firstlinebuf, MIDDLE, FALSE);
DisplayLCD(1, secondlinebuf, MIDDLE, FALSE);
}
else
{
gDiagnosticResult.KeyBoard_TestResult=0;
strcpy(firstlinebuf,GetMsgData(DISP_KEYBOARD_TEST));
strcpy(secondlinebuf,GetMsgData(DISP_MYTECS_REPFAX_OK));
LCDDisplayClear();
DisplayLCD(0, firstlinebuf, MIDDLE, FALSE);
DisplayLCD(1, secondlinebuf, MIDDLE, FALSE);
}
ret = TEST_OPPANEL_PROC_END;
TASKSLEEP_MILLISECONDS(6000);
break;
}
return ret;
}
/**********************************************************************\
* LCD Test Mode :
*
* Note
* History
* 2006.12.09 Jason Yang Create
\**********************************************************************/
void SM_LCDDiagnostic(void)
{
Uint16 currentbutton = 0;
Uint8 step = 0,step1=0, loop = 1;
char buf[34];
//static Uint8 ut = 0;
memset(buf, 0xBE, LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
ut = 0;
while (loop){
currentbutton = UIGetKey();
switch(step)
{
case 0:
{
/* Process Button Request */
switch (currentbutton)
{
case PANEL_START:
case PANEL_SELECT:
{
switch (step1)
{
case 0:
LCDDisplayClear();
break;
case 1:
memset(buf, '0', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 2:
memset(buf, '1', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 3:
memset(buf, '2', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 4:
memset(buf, '3', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 5:
memset(buf, '4', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 6:
memset(buf, '5', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 7:
memset(buf, '6', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 8:
memset(buf, '7', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 9:
memset(buf, '8', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 10:
memset(buf, '9', LCD_LINE_MAX);
buf[LCD_LINE_MAX] = '\n';
DisplayLCD(0, buf, LEFT,FALSE);
DisplayLCD(1, buf, LEFT,FALSE);
break;
case 11:
step=1;
//TASKSLEEP_MILLISECONDS(3000);
LCDDisplayClear();
strcpy(firstlinebuf,GetMsgData(DISP_TEST_RESULT));
strcpy(secondlinebuf,GetMsgData(Ms_OKNG[ut]));
DisplayLCD(0, firstlinebuf, MIDDLE, FALSE);
DisplayLCD(1, secondlinebuf, MIDDLE, TRUE);
break;
}
step1++;
}
break;
case PANEL_BACK:
{
step=1;
LCDDisplayClear();
strcpy(firstlinebuf,GetMsgData(DISP_TEST_RESULT));
strcpy(secondlinebuf,GetMsgData(Ms_OKNG[ut]));
DisplayLCD(0, firstlinebuf, MIDDLE, FALSE);
DisplayLCD(1, secondlinebuf, MIDDLE, TRUE);
}
break;
}
}
break;
case 1:
{
switch (currentbutton)
{
case PANEL_SELECT:
loop=0;
if(ut == 0)
gDiagnosticResult.LCD_TestResult=1;
else
gDiagnosticResult.LCD_TestResult=0;
break;
case PANEL_ARROWLEFT:
case PANEL_ARROWRIGHT:
if(ut == 0)
ut = 1;
else
ut = 0;
break;
case PANEL_NONE:
continue;
default:
break;
}
LCDDisplayClear();
strcpy(firstlinebuf,GetMsgData(DISP_TEST_RESULT));
strcpy(secondlinebuf,GetMsgData(Ms_OKNG[ut]));
DisplayLCD(0, firstlinebuf, MIDDLE, FALSE);
DisplayLCD(1, secondlinebuf, MIDDLE, TRUE);
}
break;
default:
break;
}
/* Be a good OS citizen */
TASKSLEEP_MILLISECONDS(50);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -