📄 mmitimers.c
字号:
$Description: Destroys the timer window and frees up memory
$Returns: nothing
$Arguments: Window
*******************************************************************************/
void timer_destroy(MfwHnd own_window)
{
T_MFW_WIN * win_data;
tTimerData * data = NULL; // NDH SPR#1741 : Removed 'cut & paste' error
if (own_window)
{
win_data = ((T_MFW_HDR *)own_window)->data;
if (win_data != NULL)
data = ( tTimerData *)win_data->user;
if (data)
{
TRACE_FUNCTION ("timer_destroy()");
win_delete (data->win);
// Free Memory
FREE_MEMORY (( void *)data, sizeof( tTimerData));
}
else
{
TRACE_EVENT ("timer_destroy() called twice");
}
}
}
/*******************************************************************************
$Function: timer_cb
$Description: Callback func for the info display screen
$Returns: status int
$Arguments: Window, Identifier (which timer), Reason (which key pressed)
*******************************************************************************/
static int timer_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
{
T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
tTimerData *data = (tTimerData *) win_data->user;
switch (Reason)
{
case INFO_KCD_LEFT:
timer_destroy(win);
break;
case INFO_KCD_RIGHT:
reset_timer_OK(win, data->timer_type);
timer_destroy(win);
break;
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: setIncomingCallsDuration
$Description: Adds call time to Incoming Calls total
$Returns: none
$Arguments: call time
*******************************************************************************/
void setIncomingCallsDuration(long call_time)
{
TRACE_FUNCTION("setIncomingCallsDuration()");
//add call time to existing call time
call_time = call_time + getIncomingCallsDuration();
//save new value to flash
FFS_flashData.incoming_calls_duration = call_time;
flash_write();
return;
}
/*******************************************************************************
$Function: setOutgoingCalls
$Description: Adds call time to Outgoing Calls total
$Returns: none
$Arguments: call time
*******************************************************************************/
void setOutgoingCallsDuration(long call_time)
{
TRACE_FUNCTION("setOutgoingCallsDuration()");
//add call time to current total
call_time = call_time + getOutgoingCallsDuration();
FFS_flashData.outgoing_calls_duration = call_time;
//write to flash
flash_write();
return;
}
/*******************************************************************************
$Function: reset_timer_OK
$Description: displays "Are you sure you want to reset this timer" window
$Returns: none
$Arguments: parent window, identifier (which timer)
*******************************************************************************/
void reset_timer_OK(T_MFW_HND parent, UBYTE identifier)
{
T_DISPLAY_DATA display_info;
T_MFW_HND win = timer_create(parent);
T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
tTimerData *data = (tTimerData *) win_data->user;
dlg_initDisplayData_TextId( &display_info, TxtSoftOK, TxtReset, TxtPressOk, TxtReset, COLOUR_STATUS);
dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) timer_reset_OK_cb, FOUR_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
display_info.Identifier = identifier;
info_dialog( win, &display_info );
}
/*******************************************************************************
$Function: reset_timer_OK_cb
$Description: Callback function for "OK to Delete timer" window
$Returns: status int
$Arguments: window, identifier (which timer), Reason (which key pressed)
*******************************************************************************/
static int timer_reset_OK_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
{
switch (Reason)
{
case INFO_KCD_LEFT:
{
switch (Identifier)
{
case LAST_CALL:
setLastCallDuration(0, INVALID);
reset_timer(win);
timer_destroy(win);
break;
case INCOMING_CALLS:
resetIncomingCallsDuration();
reset_timer(win);
timer_destroy(win);
break;
case OUTGOING_CALLS:
resetOutgoingCallsDuration();
reset_timer(win);
timer_destroy(win);
break;
}
}
break;
case INFO_KCD_RIGHT:
{
timer_destroy(win);
}
break;
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: reset_timer
$Description: Dsiplays confirmation that timer has been reset.
$Returns: none
$Arguments: parent window
*******************************************************************************/
void reset_timer(T_MFW_HND parent)
{
T_DISPLAY_DATA display_info;
T_MFW_HND win = timer_create(parent);
T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
tTimerData *data = (tTimerData *) win_data->user;
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtTimerReset, TxtNull, COLOUR_STATUS);
dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
info_dialog( parent, &display_info );
}
/*******************************************************************************
$Function: resetIncomingCallsDuration
$Description: Resets incoming call total to 0
$Returns: nothing
$Arguments: none
*******************************************************************************/
void resetIncomingCallsDuration( void )
{
TRACE_FUNCTION("resetIncomingCallsDuration()");
FFS_flashData.incoming_calls_duration =0;
flash_write();
}
/*******************************************************************************
$Function: resetOutgoingCallsDuration
$Description: Resets outgoing call total to 0
$Returns: nothing
$Arguments: none
*******************************************************************************/
void resetOutgoingCallsDuration( void )
{
TRACE_FUNCTION("resetOutgoingCallsDuration()");
FFS_flashData.outgoing_calls_duration = 0;
flash_write;
return;
}
/*******************************************************************************
$Function: getLastCallDuration
$Description: gets the length of the last call made/received from PCM storage
$Returns: length of call (long)
$Arguments: none
*******************************************************************************/
unsigned long getLastCallDuration()
{
return FFS_flashData.last_call_duration;;
}
/*******************************************************************************
$Function: getIncomingCallsDuration
$Description: gets the total length of incoming calls received from PCM storage
$Returns: length of calls (long)
$Arguments: none
*******************************************************************************/
unsigned long getIncomingCallsDuration()
{
return FFS_flashData.incoming_calls_duration;
}
/*******************************************************************************
$Function: getOutgoingCallsDuration
$Description: gets the total length of incoming calls received from PCM storage
$Returns: length of calls (long)
$Arguments: none
*******************************************************************************/
unsigned long getOutgoingCallsDuration()
{
return FFS_flashData.outgoing_calls_duration;
}
/*******************************************************************************
$Function: getTimerString
$Description: Converts a time in seconds into a string denoting hours, minutes and seconds
$Returns: none,
$Arguments: time pointer to string to store time
*******************************************************************************/
void getTimerString(unsigned long time, char* timeString)
{
char* debug_buf;
int hour,min,sec;
TRACE_FUNCTION("getTimerString()");
hour = time/3600;
min = (time-hour*3600)/60;
sec = (time-hour*3600-min*60);
//this prevents the time being too wide for the LCD display
if (hour > 999999)
hour = 999999;
sprintf(timeString,"%02d:%02d:%02d",hour,min,sec);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -