📄 ui.c
字号:
KybdGetKeyDownTime(&uPressedTime);
if( (0 == NumKeys) && (0 < uPressedTime) )
{
char szInfo[64];
char *szInfo1, *szInfo2;
szInfo1 = szInfo;
szInfo2 = &szInfo[17];
if( UI_COMMAND_COMBO_LEFT == execCommand )
{
sprintf(szInfo1, "Boot: %s ", GetBootCodeVersion());
sprintf(szInfo2, "%s ", GetBootCodeDate());
}
else if( UI_COMMAND_COMBO_RIGHT == execCommand )
{
sprintf(szInfo1, "F/W: %s ", sys_version);
sprintf(szInfo2, "%s ", builddate);
}
else if( UI_COMMAND_COMBO_MENU == execCommand )
{
#if 1
static Uint32 index=0, count=0;
int len, start=0;
count++;
if( 0 == (count % 3) )
{
index++;
if( index >= (strlen(buildloc) + 15) )
{
index = 0;
}
}
strcpy(szInfo1, " Build Path: ");
if( index < 15 )
{
start = 15 - index;
memset(szInfo2, 0x20, start);
strncpy(&szInfo2[start], buildloc, 16);
}
else
{
strncpy(szInfo2, &buildloc[index - 15], 16);
}
len = strlen(szInfo2);
if( 16 > len )
{
memset(szInfo2 + len, 0x20, 16 - len);
}
#else
strncpy(szInfo1, buildloc, 16);
if( 16 < strlen(buildloc) )
{
strcpy(szInfo2, &buildloc[16]);
}
else
{
strcpy(szInfo2, " ");
}
#endif
}
szInfo1[16] = 0x00;
szInfo2[16] = 0x00;
LcdStr(LCD_ROW_1, 0, szInfo1);
LcdStr(LCD_ROW_2, 0, szInfo2);
TASKSLEEP_MILLISECONDS(50);
continue;
}
else
{
execCommand = UI_COMMAND_NONE;
gUIstate.bUpdateInfo = TRUE;
}
}
break;
#endif
#if PHERR_FORCE_CHANGECARTRIDGE
case UI_COMMAND_CHANGE_CARTRIDGE:
{
Uint8 uselKeyState;
uselKeyState = UIPassSelectionKey(PANEL_KEY_UNSPECIFY, FALSE);
// Checking current error state
if( SELECTION_KEY_OK == uselKeyState )
{
OMsetInt(omCOVEROPEN, OMCURRENT, 0);
execCommand = UI_COMMAND_NONE;
gUIstate.bUpdateInfo = TRUE;
}
else
{
char szInfo[]=" Press SELECT when cartridge is installed. Press SELECT";
static Uint32 index=0, count=0;
count++;
if( 0 == (count % 5) )
{
LcdStr(LCD_ROW_1, 0, "INVALID PH ERROR");
LcdStr(LCD_ROW_2, 0, &szInfo[index]);
index++;
if( index > (strlen(szInfo) - 16) )
{
index = 0;
}
}
TASKSLEEP_MILLISECONDS(50);
continue;
}
}
break;
#endif
default:
execCommand = UI_COMMAND_NONE;
break;
}
if( UI_COMMAND_NONE != newCommand )
{
execCommand = newCommand;
}
/* timeout checking */
else if( UI_COMMAND_NONE != execCommand )
{
// Infinite command
if( UI_COMMAND_DEVICE_ERROR == execCommand )
{
TASKSLEEP_MILLISECONDS(20);
continue;
}
// time-out command
else
{
Uint32 uCurTime=TaskGetSystemMilliTicks();
if( UI_TIMEOUT_PERIOD < (uCurTime - gUIstate.lastTime) )
{
execCommand = UI_COMMAND_NONE;
}
}
}
/* Idle state, force to update LCD info. */
else
{
gUIstate.bUpdateInfo = TRUE;
}
}
// original code
else if( API_OK == UIGetCommand(&newCommand) )
{
execCommand = newCommand;
continue;
}
uJobExecState = GetNumberOfActiveJobs();
// Doing job state
if( uJobExecState )
{
#ifdef UI_PANEL_ENABLE
//#if 0
if( !bAlignActive && (NULL != GetActiveJobOfType(JOB_ALIGN_CAR)) )
{
bAlignActive = TRUE;
}
#endif
// Updating Job state
if( JOB_EXEC_STATE_DEV_ERROR == UIUpdateJobInfo() )
{
// Device error
execCommand = UI_COMMAND_DEVICE_ERROR;
gUIstate.bUpdateInfo = TRUE;
continue;
}
}
/* Idle state */
else if( UI_COMMAND_NONE == execCommand )
{
#if PHERR_FORCE_CHANGECARTRIDGE
Uint32 status;
OMgetUint(omPRINTERSTATUS, OMCURRENT, &status);
if( (OM_ALL_PH_ERROR & status) && !(OM_PAPER_JAM_ERROR & status) )
{
// Force cover switch opened
OMsetInt(omCOVEROPEN, OMCURRENT, 1);
if( API_OK == UIDoChangeCartridgeJob() )
{
TASKSLEEP_MILLISECONDS(50);
execCommand = UI_COMMAND_CHANGE_CARTRIDGE;
gUIstate.bUpdateInfo = TRUE;
continue;
}
}
#endif
#ifdef UI_PANEL_ENABLE
// Do manual alignment, setting alignment values
if( bAlignActive )
{
int i, uValue;
bAlignActive = FALSE;
if( g_bMaintainAbort )
{
g_bMaintainAbort = FALSE;
}
else
{
execCommand = UI_COMMAND_SET_ALIGNMENT;
gSelectionNo = UI_ALIGN_INDEX_START;
// Retrieve alignment value from database
OMgetInt(omCMYKHorzAlign, OMCURRENT, &uValue);
gUIstate.alignValue[0] = (Uint8)uValue;
OMgetInt(omCMYKVertAlign, OMCURRENT, &uValue);
gUIstate.alignValue[1] = (Uint8)uValue;
OMgetInt(omDraftBlackCartBidiAlign, OMCURRENT, &uValue);
gUIstate.alignValue[2] = (Uint8)uValue;
OMgetInt(omDraftColorCartNearBidiAlign, OMCURRENT, &uValue);
gUIstate.alignValue[3] = (Uint8)uValue;
OMgetInt(omBlackSkewAdjustment, OMCURRENT, &uValue);
gUIstate.alignValue[4] = (Uint8)uValue;
// Checking alignment value -- if not valid set it's value as default
for( i=UI_ALIGN_INDEX_START; i<=UI_ALIGN_INDEX_END; i++ )
{
gUIstate.alignValue[i] /= UI_ALIGN_DIVIDER[i];
if( gUIstate.alignValue[i] > UI_ALIGN_VALUE_MAX[i] )
{
gUIstate.alignValue[i] = UI_ALIGN_VALUE_DEFAULT[i];
}
}
gSelectionValue = gUIstate.alignValue[UI_ALIGN_INDEX_START];
gUIstate.uTimeoutPeriod = UI_SET_ALIGN_PERIOD;
LcdClrScreen();
LcdStr(LCD_ROW_1, LCD_ALIGN_SET_COL, "Set Alignment");
gUIstate.bUpdateInfo = TRUE;
continue;
}
}
#endif
// Cover open -- do a change cartridge job
if( API_OK == UICoverStateChange() )
{
execCommand = UI_COMMAND_COVER_OPEN;
gUIstate.bUpdateInfo = TRUE;
}
else
{
Uint32 uCurTime=TaskGetSystemMilliTicks();
/* Save mode checking */
if( UI_SAVINGMODE_PERIOD < (uCurTime - gUIstate.lastTime) )
{
UISaveModeInfo();
}
else
{
UIIdleInfo();
}
}
}
/* Setting state */
else
{
; /* Do nothing */
}
////////////////////////////////////////////////////////////////////////////////////////////
// DPS event manipulation
//
////////////////////////////////////////////////////////////////////
if( g_dpsEvent )
{
Uint32 dpsConnected;
g_dpsEvent = 0;
OMgetEnum(omDPSCONNECTED, OMCURRENT, &dpsConnected);
// if there is a DPS connection, do the mode
//
switch( dpsConnected )
{
case DPSPICTBRIDGE:
// job executing, waiting for job completed
#if 0 // jc - pictbridge almost always has at least one job open,
// so the following check may no longer be valid
if( 0 != GetNumberOfActiveJobs() )
{
g_dpsEvent = 1;
break;
}
#endif
gUIstate.opMode = opModeDPS;
gUIstate.lastTime = TaskGetSystemMilliTicks(); /* to ms unit */;
gUIstate.bUpdateInfo = TRUE;
break;
case DPSNONE:
case DPSERROR:
if( g_cardin ) // memory card inserted
{
gUIstate.opMode = opModeMemoryCard;
}
else
{
gUIstate.opMode = opModeNormal;
}
gUIstate.lastTime = TaskGetSystemMilliTicks(); /* to ms unit */;
gUIstate.bUpdateInfo = TRUE;
break;
}
} // end of DPS event manipulation
#if PHOTO_PRINT_ENABLED
////////////////////////////////////////////////////////////////////////////////////////////
// Memory card event manipulation
//
////////////////////////////////////////////////////////////////////
if( g_mcStateEvent )
{
gUIstate.lastTime = TaskGetSystemMilliTicks();/* to ms unit */;
g_mcStateEvent = 0;
OnPhotoCardInsertionEvent(IsPhotoCardIn());
}
#endif
} // end of while (1)
}
#endif
#if 0
/******************************************************************************
* Name: SetupSubscriptions
*
* Description: Setup subscription of related properties
*
* Parameters: None
*
* Return: None
*
* Notes:
******************************************************************************/
void SetupSubscriptions(void)
{
#if PHOTO_PRINT_ENABLED
// memory card properties notification
OMsubscribe(omCARDINSERTSTATE, PropertyEvent, NULL);
OMsubscribe(omNUMPHOTOS, PropertyEvent, NULL);
#endif
// Job status change
OMsubscribe(omJOBSTATUS, PropertyEvent, NULL);
// is a pictbridge in your future?
OMsubscribe(omDPSCONNECTED, PropertyEvent, NULL);
}
/******************************************************************************
* Name: PropertyEvent
*
* Description: Properties callback routine
*
* Parameters: property
* level
* newValue
*
* Return: OMERROR
*
* Notes:
******************************************************************************/
OMERROR PropertyEvent(OMPROPERTY property, OMLEVEL level, POMVARIANT newValue)
{
switch( property )
{
#if PHOTO_PRINT_ENABLED
case omCARDINSERTSTATE:
case omNUMPHOTOS:
g_mcStateEvent = 1; // Memory card state change
gUIstate.bUpdateInfo = TRUE;
break;
#endif
// status change, force to update the display information
case omJOBSTATUS:
gUIstate.bUpdateInfo = TRUE;
break;
case omDPSCONNECTED:
g_dpsEvent = 1; // inside property callback, just flag, wakes up lp task
break;
default:
break;
}
return OMnoError;
}
// Show error message for a period
void ShowErrorMessage(char* szErr, Uint32 elapse)
{
#ifdef UI_PANEL_ENABLE
LcdStr(LCD_ROW_2, 0, szErr);
TASKSLEEP_MILLISECONDS(elapse);
gUIstate.bUpdateInfo = TRUE;
#endif
}
/******************************************************************************
* Name: UIUpdatePersistInfo
*
* Description: Update persist info. to flash
*
* Parameters: None
*
* Return: API_OK
*
* Notes:
******************************************************************************/
API_RET UIUpdatePersistInfo(void)
{
return API_OK;
}
#endif
/******************************************************************************
* Name: NoJobExecuting
*
* Description: Check to see if any job is executing
*
* Parameters: None
*
* Return: TRUE - No job is executing
* FALSE - Some jobs are executing
*
* Notes:
******************************************************************************/
Bool NoJobExecuting(void)
{
return(0 == GetNumberOfActiveJobs());
}
#if 0
/******************************************************************************
*
* Name: UISetDefault
*
* Description: Set default properties
*
* Parameters: None
*
* Return:
*
* Notes:
******************************************************************************/
void UISetDefault(void)
{
#if ENABLE_FIREPULSE_SETTING
int i;
// set prefire/fire width
for( i=0; i<UI_FIRE_PULSE_WIDTH_TYPES; i++ )
{
gUIstate.uBKPreFireWidth[i] = UI_PREFIRE_PULSE_WIDTH_DEF;
gUIstate.uCLRPreFireWidth[i] = UI_PREFIRE_PULSE_WIDTH_DEF;
gUIstate.uBKFireWidth[i] = UI_BLK_FIRE_PULSE_WIDTH_DEF;
gUIstate.uCLRFireWidth[i] = UI_CLR_FIRE_PULSE_WIDTH_DEF;
}
#endif
gUIstate.scaleType = scaleNormal;
gUIstate.scaleValue = 100; /* 100% */
gUIstate.brightness = UI_BRIGHT_NORMAL;
gUIstate.copyNo = 1;
gUIstate.paperSize = paperA4;
gUIstate.paperType = PrintMediaPlain;
gUIstate.imageQuality = PrintQualityNormal;
gUIstate.imageType = ImageModePhoto;
OMsetEnum(omPRINTPRINTSIZE, OMDEFAULT, (Uint32)PSA4);
OMsetEnum(omCOPYPRINTSIZE, OMDEFAULT, (Uint32)PSA4);
OMsetEnum(omPHOTOPRINTSIZE, OMDEFAULT, (Uint32)PS4x6);
OMsetEnum(omPBPHOTOPRINTSIZE, OMDEFAULT, (Uint32)PS4x6);
#if PHOTO_PRINT_ENABLED
gUIstate.ePhotoSize = PHZ4x6;
#endif
#ifdef ADF_SUPPORTED
gUIstate.ScanWithADF = FALSE;
#endif
}
/******************************************************************************
*
* Name: UICopyNoOut
*
* Description: Copies number information output function
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -