ui.c
来自「这个是单片机4200的ui程序」· C语言 代码 · 共 2,559 行 · 第 1/5 页
C
2,559 行
* Parameters: pkeyType - pointer to new Key type
*
* Return: API_OK - Key is pressed
* API_FAIL - No key is pressed
*
* Notes:
******************************************************************************/
API_RET UIGetNextKey(UIKeyType* pkeyType)
{
#ifdef UI_PANEL_ENABLE
Uint32 uCurTime;
UIKeyType KeyIn;
KybdGetKey(&KeyIn, 2L);
if( KeyIn != KYBD_NO_KEY )
{
/* Keep last time key pressed */
*pkeyType = KeyIn;
gUIstate.HitKey = KeyIn;
uCurTime = TaskGetSystemMilliTicks();/* to ms unit */
gUIstate.lastTime = uCurTime;
gUIstate.lastPressTime = uCurTime;
gUIstate.pressedKeyMode = KEY_PRESSED_MODE_NORMAL;
/* Checking available key for current job */
/* Only Cancel function key can be availed while a job executing */
if( NoJobExecuting() || (PANEL_KEY_CANCEL== KeyIn) || (PANEL_KEY_SELECT== KeyIn) )
{
return(API_OK);
}
}
else
{
Uint32 uPressedTime=0;
KybdGetKeyDownTime(&uPressedTime); /* get the hold time */
/* key still pressed */
if( (uPressedTime > 0) && NoJobExecuting() )
{
Uint32 uCurTime;
uCurTime = TaskGetSystemMilliTicks();
if( KEY_PRESSED_PERIOD < (uCurTime - gUIstate.lastTime) )
{
*pkeyType = gUIstate.HitKey;
gUIstate.lastTime = uCurTime;
if( QUICK_JUMP_PRESSED_TIME < (gUIstate.lastTime - gUIstate.lastPressTime) )
{
gUIstate.pressedKeyMode = KEY_PRESSED_MODE_JUMP;
}
return(API_OK);
}
}
}
return(API_FAIL);
#else
API_RET apiRet=API_FAIL;
#if 0
Uint32 uCurTime;
Uint32* pKey=(Uint32*)0xE4400070;
// Key pressed
if( 0x00000000 == (0x02000000 & *pKey) )
{
Uint32 status;
OMgetUint(omPRINTERSTATUS, OMCURRENT, &status);
if( status & OM_PAPER_OUT_ERROR )
{
status |= OM_PAPER_OUT_RESUME;
OMsetInt(omPRINTERSTATUS, OMCURRENT, status);
}
else if( status & OM_PAPER_JAM_ERROR )
{
status |= OM_PAPER_JAM_RESUME;
OMsetInt(omPRINTERSTATUS, OMCURRENT, status);
}
else if( NoJobExecuting() )
{
if( 0 == gUIstate.lastPressTime )
{
uCurTime = TaskGetSystemMilliTicks();
gUIstate.lastPressTime = uCurTime;
}
}
}
else
{
if( 0 != gUIstate.lastPressTime )
{
Uint32 uElapseTime;
uCurTime = TaskGetSystemMilliTicks();
uElapseTime = uCurTime - gUIstate.lastPressTime;
// > 5000 ms
if( uElapseTime > 5000 )
{
gUIstate.imageType = ImageModePhoto;
gUIstate.imageQuality = PrintQualityDraft;
}
// > 3000 ms
else if( uElapseTime > 3000 )
{
gUIstate.imageType = ImageModeAuto;
gUIstate.imageQuality = PrintQualityBest;
}
else
{
gUIstate.imageType = ImageModePhoto;
gUIstate.imageQuality = PrintQualityBest;
}
*pkeyType = PANEL_KEY_MONO_COPY;
apiRet = API_OK;
gUIstate.lastPressTime = 0;
}
}
#endif
return(apiRet);
#endif
}
/******************************************************************************
*
* Name: UICoverStateChange
*
* Description: Get cover key state
*
* Parameters: None
*
* Return: API_OK - COver Key is pressed
* API_FAIL - No key is pressed
*
* Notes:
******************************************************************************/
API_RET UICoverStateChange(void)
{
#ifdef UI_IGNORE_COVER
return( API_FAIL);
#else
static int g_coverStatus=0;
if( COVER_STATUS() != g_coverStatus )
{
int invert, opened;
g_coverStatus = COVER_STATUS();
OMgetBool(omCoverButtonPolarity, OMCURRENT, &invert);
opened = (g_coverStatus == 0) ^ invert;
OMsetInt(omCOVEROPEN, OMCURRENT, opened);
if( opened )
{
// if cover is opened and no job is active, start a maint. job
// to move the carts to the center, which will show the movie
// unless paper-jammed which case leave the error
//
int jammin;
int ecode;
OMgetInt(omPRINTERSTATUS, OMCURRENT, &jammin);
ecode = jammin;
jammin &= (OM_PAPER_JAM_ERROR | OM_CARRIER_PATH_OBSTRUCTED);
if( !jammin )
{
if( NoJobExecuting() )
{
PSPRINTF("change cart job, open cover, not busy\n");
// actually move the head to the reload position
//DoMaintananceJob(JOB_CHANGE_CAR, "");
return(API_OK);
}
else
{
PSPRINTF("open cover, leave current error message\n");
}
}
}
else
{
PSPRINTF("Cover closed\n");
}
}
return(API_FAIL);
#endif
}
/******************************************************************************
*
* Name: UIGetCommand
*
* Description: Get next input command from control panel
*
* Parameters: pCmdType - pointer to new command type
*
* Return: API_OK - new command in
* API_FAIL - no command in
*
* Notes:
******************************************************************************/
API_RET UIGetCommand(UICommandType* pCmdType)
{
UIKeyType KeyIn;
API_RET result;
result = UIGetNextKey(&KeyIn);
if( opModeDPS == gUIstate.opMode )
{
// Only the CANCEL button is available on DPS mode
if( (API_OK == result) && (PANEL_KEY_CANCEL== KeyIn) )
{
*pCmdType = UI_COMMAND_CANCEL;
return(API_OK);
}
}
else if( API_OK == result )
{
switch( KeyIn )
{
#ifdef UI_ENABLE_COMBO
case KEY_COMBO_LEFT:
*pCmdType = UI_COMMAND_COMBO_LEFT;
break;
case KEY_COMBO_RIGHT:
*pCmdType = UI_COMMAND_COMBO_RIGHT;
break;
case KEY_COMBO_MENU:
*pCmdType = UI_COMMAND_COMBO_MENU;
break;
#endif
case PANEL_KEY_COPIES:
*pCmdType = UI_COMMAND_COPIES;
gSelectionValue = COPY_INCREASE;
break;
case PANEL_KEY_SCROLL_NEXT:
#if PHOTO_PRINT_ENABLED
// memory card in
if( opModeMemoryCard == gUIstate.opMode )
{
if( MemcardReady() )
{
// show next image
*pCmdType = UI_COMMAND_NEXT_IMAGE;
break;
}
gUIstate.opMode = opModeNormal;
gUIstate.bUpdateInfo = TRUE;
}
#endif
*pCmdType = UI_COMMAND_COPIES;
gSelectionValue = COPY_INCREASE;
break;
case PANEL_KEY_SCROLL_PREV:
#if PHOTO_PRINT_ENABLED
// memory card in
if( opModeMemoryCard == gUIstate.opMode )
{
if( MemcardReady() )
{
// show previous image
*pCmdType = UI_COMMAND_PREV_IMAGE;
break;
}
gUIstate.opMode = opModeNormal;
gUIstate.bUpdateInfo = TRUE;
}
#endif
*pCmdType = UI_COMMAND_COPIES;
gSelectionValue = COPY_DECREASE;
break;
case PANEL_KEY_SCALING:
*pCmdType = UI_COMMAND_SCALING;
gSelectionNo = (Uint32)gUIstate.scaleType;
gSelectionValue = (Uint32)gUIstate.scaleValue;
gUIstate.bUpdateInfo = TRUE;
break;
case PANEL_KEY_SETTING:
*pCmdType = UI_COMMAND_SETTING;
gSelectionNo = (Uint32)setAutoAlignCartridge;
#ifdef UI_PANEL_ENABLE
LcdClrScreen();
#endif
gUIstate.bUpdateInfo = TRUE;
break;
case PANEL_KEY_MODE:
*pCmdType = UI_COMMAND_MODE;
break;
case PANEL_KEY_QUALITY:
*pCmdType = UI_COMMAND_QUALITY;
break;
case PANEL_KEY_CANCEL:
*pCmdType = UI_COMMAND_CANCEL;
break;
case PANEL_KEY_BRIGHTNESS:
*pCmdType = UI_COMMAND_BRIGHTNESS;
break;
case PANEL_KEY_PAPER_TYPE:
*pCmdType = UI_COMMAND_PAPER_TYPE;
break;
case PANEL_KEY_COLOR_COPY:
#if PHOTO_PRINT_ENABLED
// memory card in
if( opModeMemoryCard == gUIstate.opMode )
{
if( MemcardReady() )
{
// print selected image
*pCmdType = UI_COMMAND_COLOR_IMAGE_PRINT;
break;
}
gUIstate.opMode = opModeNormal;
gUIstate.bUpdateInfo = TRUE;
}
#endif
*pCmdType = UI_COMMAND_COLOR_COPY;
break;
case PANEL_KEY_MONO_COPY:
#if PHOTO_PRINT_ENABLED
// memory card in
if( opModeMemoryCard == gUIstate.opMode )
{
if( MemcardReady() )
{
// print selected image
*pCmdType = UI_COMMAND_MONO_IMAGE_PRINT;
break;
}
gUIstate.opMode = opModeNormal;
gUIstate.bUpdateInfo = TRUE;
}
#endif
*pCmdType = UI_COMMAND_MONO_COPY;
break;
case PANEL_KEY_SCAN:
#if PHOTO_PRINT_ENABLED
// memory card in
if( opModeMemoryCard == gUIstate.opMode )
{
if( MemcardReady() )
{
// print selected image
*pCmdType = UI_COMMAND_IMAGE_INDEX_PRINT;
break;
}
gUIstate.opMode = opModeNormal;
gUIstate.bUpdateInfo = TRUE;
}
#endif
*pCmdType = UI_COMMAND_SCAN;
break;
case PANEL_KEY_POWER:
*pCmdType = UI_COMMAND_POWER;
break;
/* Not a valid input key */
default:
return(API_FAIL);
}
return(API_OK);
}
return(API_FAIL);
}
/******************************************************************************
**** ****
**** Command Procedures ****
**** ****
******************************************************************************/
/******************************************************************************
*
* Name: UIDoCopiesSelection
*
* Description: Do NO. of copies selection
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void UIDoCopiesSelection(void)
{
Uint32 uStep;
// Determine Inc/Dec step unit
if( KEY_PRESSED_MODE_NORMAL == gUIstate.pressedKeyMode )
{
uStep = 1;
}
else
{
uStep = 5;
}
// Increase copy count
if( COPY_INCREASE == gSelectionValue )
{
if( UI_MAX_COPY_NO < (uStep + gUIstate.copyNo) )
{
gUIstate.copyNo = 1;
}
else
{
gUIstate.copyNo += uStep;
}
}
// Decrease
else
{
if( uStep >= gUIstate.copyNo )
{
gUIstate.copyNo = UI_MAX_COPY_NO;
}
else
{
gUIstate.copyNo -= uStep;
}
}
// Update LCD panel info.
UICopyNoOut();
}
/******************************************************************************
*
* Name: UIDoScalingSelection
*
* Description: Do scaling type/value selection
*
* Parameters: None
*
* Return: UI_STATUS_COMPLETE - Finish the command
* UI_STATUS_CONTINUE - Need more operations
*
* Notes:
******************************************************************************/
API_RET UIDoScalingSelection(UICommandType* pSubCommand)
{
Uint8 uselKeyState;
Uint32 uMinScale[UI_MAX_SCALE_TYPE]={UI_SCALING_VALUE_NORMAL,
UI_SCALING_VALUE_MIN, UI_SCALING_VALUE_MAX, 0,
UI_POSTER_VALUE_MIN, UI_CLONE_VALUE_MIN, UI_SCALING_VALUE_MIN,
UI_SCALING_VALUE_MIN};
Uint32 uMaxScale[UI_MAX_SCALE_TYPE]={UI_SCALING_VALUE_NORMAL,
UI_SCALING_VALUE_MIN, UI_SCALING_VALUE_MAX, 0,
UI_POSTER_VALUE_MAX, UI_CLONE_VALUE_MAX, UI_SCALING_VALUE_MAX,
UI_SCALING_VALUE_MAX};
uselKeyState = UIPassSelectionKey(PANEL_KEY_SCALING, TRUE);
// Scaling type change
if( SELECTION_KEY_SPECIFY == uselKeyState )
{
Uint32 uScaleDef[UI_MAX_SCALE_TYPE]={100, 25, 400, 100, 101, 100, 100, 100};
gSelectionNo++;
if( UI_MAX_SCALE_TYPE == gSelectionNo )
{
gSelectionNo = 0;
}
gSelectionValue = uScaleDef[gSelectionNo];
gUIstate.bUpdateInfo = TRUE;
uselKeyState = SELECTION_KEY_NONE;
}
// Finish the scaling setting
else if( SELECTION_KEY_OK == uselKeyState )
{
gUIstate.scaleType = (ScalingType)gSelectionNo;
gUIstate.scaleValue = gSelectionValue;
return(UI_STATUS_COMPLETE);
}
// Cancel setting
else if( SELECTION_KEY_CANCEL == uselKeyState )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?