ui.c
来自「这个是单片机4200的ui程序」· C语言 代码 · 共 2,559 行 · 第 1/5 页
C
2,559 行
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UICopyNoOut(void)
{
#ifdef UI_PANEL_ENABLE
char szCopies[12];
if( 1 == gUIstate.copyNo )
{
sprintf(szCopies, " 1 Copy ");
}
else
{
sprintf(szCopies, "%2u Copies", gUIstate.copyNo);
}
LcdStr(LCD_ROW_1, LCD_COPY_COL, szCopies);
#endif
}
/******************************************************************************
*
* Name: UIQualityOut
*
* Description: Quality LED control function
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UIQualityOut(void)
{
#ifdef UI_PANEL_ENABLE
LedGrpSet(0, gUIstate.imageQuality, LED_ON);
#endif
}
/******************************************************************************
*
* Name: UIModeOut
*
* Description: Mode LED control function
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UIModeOut(void)
{
#ifdef UI_PANEL_ENABLE
LedGrpSet(1, gUIstate.imageType, LED_ON);
#endif
}
/******************************************************************************
*
* Name: UIPaperTypeOut
*
* Description: Paper type information output function
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UIPaperTypeOut(void)
{
#ifdef UI_PANEL_ENABLE
static char* szPaperType[UI_MAX_PAPER_TYPE]={" Plain ", " Coated ",
" Transp", " Photo "};
LcdStr(LCD_ROW_2, LCD_PAPERTYPE_COL, szPaperType[gUIstate.paperType]);
#endif
}
/******************************************************************************
*
* Name: UIBrightnessOut
*
* Description: Brightness information output control function
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UIBrightnessOut(void)
{
#ifdef UI_PANEL_ENABLE
Uint8 i;
char szBrightness[8];
for( i=0; i<7; i++ )
{
szBrightness[i] = CHAR_BRIGHTNESS;
}
szBrightness[7] = '\0';
szBrightness[gUIstate.brightness] = CHAR_BRIGHTNESS_FOCUS;
LcdStr(LCD_ROW_1, LCD_BRIGHTNESS_COL, szBrightness);
#endif
}
/******************************************************************************
*
* Name: UISaveModeInfo
*
* Description: Update IDLE information
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UISaveModeInfo(void)
{
/* First time from Idle mode to Save mode, gUIstate.bUpdateInfo is FALSE,
so we check it and update save mode info.
Setting gUIstate.bUpdateInfo to TRUE cause the Idle info. be out properly
while chnaging from Save mode to Idle mode */
if( FALSE == gUIstate.bSaveMode )
{
#ifdef UI_PANEL_ENABLE
/* Save mode info. */
char szSaveText[17]=" Power-Save Mode";
LcdClrScreen();
LcdStr(LCD_ROW_1, LCD_SAVINGMODE_COL, szSaveText);
#endif
gUIstate.bUpdateInfo = TRUE;
gUIstate.bSaveMode = TRUE;
}
}
/******************************************************************************
*
* Name: UIIdleInfo
*
* Description: Update IDLE information
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UIIdleInfo(void)
{
if( TRUE == gUIstate.bUpdateInfo )
{
#ifdef UI_PANEL_ENABLE
// DPS camera is connected
if( opModeDPS == gUIstate.opMode )
{
LcdStr(LCD_ROW_1, LCD_DPS_VALUE_COL, "PicBridge Camera");
LcdStr(LCD_ROW_2, LCD_DPS_VALUE_COL, " is Connected ");
}
#if PHOTO_PRINT_ENABLED
// Memory card is inserted
else if( opModeMemoryCard == gUIstate.opMode )
{
IFSResultType ifs_res;
Uint32 fileSize;
char szImgInfo[24];
e_omCARDINSERTSTATE rv;
UICopyNoOut();
UIBrightnessOut();
rv = GetMemcardState();
if( MEMORYCARDERROR == rv )
{
LcdStr(LCD_ROW_2, LCD_PHOTO_IMG_INFO, " Card Error !!! ");
}
else if( TOOMANYMEMORYCARDS == rv )
{
LcdStr(LCD_ROW_2, LCD_PHOTO_IMG_INFO, "Too many card in");
}
#if 1
else if( (READINGMEMORYCARD == rv) || (MEMORYCARDINSERTED == rv) )
{
LcdStr(LCD_ROW_2, LCD_PHOTO_IMG_INFO, "Reading card ...");
}
#else
else if( MEMORYCARDINSERTED == rv )
{
LcdStr(LCD_ROW_2, LCD_PHOTO_IMG_INFO, " Card inserted ");
}
else if( READINGMEMORYCARD == rv )
{
LcdStr(LCD_ROW_2, LCD_PHOTO_IMG_INFO, "Reading card ...");
}
#endif
// DONEREADINGMEMORYCARD
else
{
Uint32 uImageNo=GetNumberOfImages();
if( 0 == uImageNo )
{
LcdStr(LCD_ROW_2, LCD_PHOTO_IMG_INFO, "No image in card");
}
else
{
LcdClrLine(LCD_ROW_2);
sprintf(szImgInfo, "%lu-%lu", g_ImageNumber, uImageNo);
LcdStr(LCD_ROW_2, (8 - strlen(szImgInfo)) >> 1, szImgInfo);
//LcdStr(LCD_ROW_2, LCD_PHOTO_IMG_INFO, szImgInfo);
// Get image size
ifs_res = IFSGetImageFileSize(g_ImageNumber, &fileSize);
// Get image label
ifs_res = GetLabel(g_ImageNumber, szImgInfo);
if( IFS_OK != ifs_res )
{
strcpy(szImgInfo, "Bad Image ");
}
else
{
// remove the file extension
char* pData;
pData = szImgInfo + strlen(szImgInfo) - 1;
while( pData > szImgInfo )
{
if( '.' == *pData )
{
*pData = 0x00;
break;
}
pData--;
}
}
LcdStr(LCD_ROW_2, 16 - strlen(szImgInfo), szImgInfo);
//LcdStr(LCD_ROW_2, LCD_PHOTO_IMG_FILE, szImgInfo);
VopuIFDisplayJpeg(g_ImageNumber);
}
}
}
#endif // end of #if PHOTO_PRINT_ENABLED
// Normal mode operation
else
{
char szScaling[10];
switch( gUIstate.scaleType )
{
case scaleNormal:
strcpy(szScaling, " Normal ");
break;
case scaleMin:
strcpy(szScaling, " Min(25%)");
break;
case scaleMax:
strcpy(szScaling, "Max(400%)");
break;
case scaleAutoFit:
strcpy(szScaling, " AutoFit ");
break;
case scalePoster:
strcpy(szScaling, " Poster ");
break;
case scaleClone:
strcpy(szScaling, " Clone ");
break;
case scaleMirror:
strcpy(szScaling, " Mirror ");
break;
case scaleCustom:
sprintf(szScaling, " %3lu%c ", gUIstate.scaleValue, '%');
break;
}
/* Idle info. out */
UICopyNoOut();
UIBrightnessOut();
LcdStr(LCD_ROW_2, LCD_SCALING_VALUE_COL, szScaling);
UIPaperTypeOut();
} // end of normal mode operation
#endif
gUIstate.bUpdateInfo = FALSE;
gUIstate.bSaveMode = FALSE;
gUIstate.uJobStartExecTime = NO_JOB_EXEC_TIME;
gUIstate.uTimeoutPeriod = UI_OK_PERIOD;
}
}
/******************************************************************************
*
* Name: UIUpdateJobInfo
*
* Description: Update Job executing information
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
JobExecState UIUpdateJobInfo(void)
{
Uint32 status;
OMgetUint(omPRINTERSTATUS, OMCURRENT, &status);
//#if PHERR_FORCE_CHANGECARTRIDGE
if( (OM_PRT_ERROR_MASK & status) && (FALSE == gUIstate.bAborted) && !(OM_ALL_PH_ERROR & status) ) // ignore print head error
//#else
// if ( (OM_PRT_ERROR_MASK & status) && (FALSE == gUIstate.bAborted) )
//#endif
{
return JOB_EXEC_STATE_DEV_ERROR;
}
else
{
/* Get Job information and update display info. */
if( NO_JOB_EXEC_TIME == gUIstate.uJobStartExecTime )
{
gUIstate.uJobStartExecTime = TaskGetSystemMilliTicks();
gUIstate.bAborted = FALSE;
}
#ifdef UI_PANEL_ENABLE
else if( TRUE == gUIstate.bAborted )
{
LcdStr(LCD_ROW_2, 0, "Canceling Job...");
}
else
{
static Uint32 uLastTime=0xFFFFFFFF;
volatile Uint32 uCurTime, u32t1, u32t2, u32t3, u32t4;
char szCurTime[20];
// Calculate job executing time
u32t1 = TaskGetSystemMilliTicks();
u32t2 = gUIstate.uJobStartExecTime;
u32t3 = u32t1 - u32t2;
u32t4 = u32t3 / 1000;
uCurTime = u32t4;
if( uLastTime != uCurTime )
{
uLastTime = uCurTime;
if( uCurTime >= 60 )
{
sprintf(szCurTime, " Elapse %lu:%02lu ", uCurTime / 60, uCurTime % 60);
}
else
{
sprintf(szCurTime, " Elapse %lu sec. ", uCurTime);
}
/* Call UI Driver module to update LCD infor. */
if( GetActiveJobOfType(JOB_ALIGN_CAR) )
{
LcdStr(LCD_ROW_1, 0, "Doing Auto Align ");
LcdStr(LCD_ROW_2, 0, szCurTime);
}
else if( GetActiveJobOfType(JOB_CLEAN_CAR) )
{
LcdStr(LCD_ROW_1, 0, " Doing Clean ");
LcdStr(LCD_ROW_2, 0, szCurTime);
}
else if( GetActiveJobOfType(JOB_CHANGE_CAR) )
{
LcdStr(LCD_ROW_1, 0, " Change Cartridge");
LcdStr(LCD_ROW_2, 0, szCurTime);
}
else if( GetActiveJobOfType(JOB_COPY) )
{
LcdStr(LCD_ROW_1, 0, " Printing Pages ");
LcdStr(LCD_ROW_2, 0, szCurTime);
}
else if( GetActiveJobOfType(JOB_SCAN) )
{
LcdStr(LCD_ROW_1, 0, " Scanning ");
LcdStr(LCD_ROW_2, 0, szCurTime);
}
else if( GetActiveJobOfType(JOB_PRINT) )
{
LcdStr(LCD_ROW_1, 0, " Printing ");
LcdStr(LCD_ROW_2, 0, szCurTime);
}
else if( GetActiveJobOfType(JOB_PHOTOPRINT) )
{
LcdStr(LCD_ROW_1, 0, " File Printing ");
LcdStr(LCD_ROW_2, 0, szCurTime);
}
}
}
#endif
gUIstate.lastTime = TaskGetSystemMilliTicks();
return JOB_EXEC_STATE_NORMAL;
}
}
/******************************************************************************
*
* Name: UpdateDeviceStatus
*
* Description: Update Device status information
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UpdateDeviceStatus(void)
{
// Device status updating
}
/******************************************************************************
*
* Name: UIPassSelectionKey
*
* Description: Pass the input key for selection command
*
* Parameters: uSpecifyKey - a specify key to check
*
* Return: SELECTION_KEY_OK - OK Key is pressed
* SELECTION_KEY_CALCEL - Cancel Key is pressed
* SELECTION_KEY_PREV - Prev Key is pressed
* SELECTION_KEY_NEXT - Next Key is pressed
* SELECTION_KEY_SPECIFY- Some other key is pressed, show presets
* SELECTION_KEY_NONE - No valid key is pressed
*
* Notes:
******************************************************************************/
Uint8 UIPassSelectionKey(Uint8 uSpecifyKey, Bool bCheckTimeOut)
{
UIKeyType keyPressed;
Uint8 uKeyState=SELECTION_KEY_NONE;
if( API_OK == UIGetNextKey(&keyPressed) )
{
switch( keyPressed )
{
case PANEL_KEY_SELECT:
uKeyState = SELECTION_KEY_OK;
break;
case PANEL_KEY_CANCEL:
uKeyState = SELECTION_KEY_CANCEL;
break;
case PANEL_KEY_SCROLL_PREV:
uKeyState = SELECTION_KEY_PREV;
break;
case PANEL_KEY_SCROLL_NEXT:
uKeyState = SELECTION_KEY_NEXT;
break;
default:
if( uSpecifyKey == keyPressed )
{
uKeyState = SELECTION_KEY_SPECIFY;
}
break;
}
}
else if( TRUE == bCheckTimeOut )
{
Uint32 uCurTime=TaskGetSystemMilliTicks();
//if (UI_OK_PERIOD < (uCurTime - gUIstate.lastTime))
if( gUIstate.uTimeoutPeriod < (uCurTime - gUIstate.lastTime) )
{
uKeyState = SELECTION_KEY_OK;
}
}
return(uKeyState);
}
/******************************************************************************
*
* Name: UIGetNextKey
*
* Description: Get next input key from control panel
*
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?