📄 dc550_phonesm_idle.c
字号:
/*****************************************************************************/
/* CONFIDENTIAL */
/* Sigpro Copyright 2003, All rights reserved */
/*****************************************************************************/
/* CLIENT: Telematrix */
/* PROJECT: DC550 Digital Centrex Phone */
/* FILE: dc550_phonesm_idle.c */
/*****************************************************************************/
/* The Idle State is always active, but it is the only state active when */
/* the phone is not off hook or doing something other than just showing the */
/* time and date. */
/*****************************************************************************/
#define __DC550_PHONESM_IDLE_EXTERN__
#include "dc550_phonesm_idle.h"
#include "dc550_phonesm.h"
#include "dc550_phonesm_infosettings.h"
#include "dc550_phonesm_infoonetouch.h"
#include "dc550_leddriver.h"
#include "dc550_display.h"
#include "dc550_usartdriver.h"
#include "dc550_modemcontroller.h"
/******************************************************************************
* GLOBAL VARIABLES
*****************************************************************************/
// The Idle State has no exit state
/******************************************************************************
* FUNCTION: void phonesm_idle_init(void) {
******************************************************************************
* DESCRIPTION:
* This function is called to initialize all of the Idle State variables.
*****************************************************************************/
void phonesm_idle_init(void) {
}
/******************************************************************************
* FUNCTION: void phonesm_idle_state_enter(void)
******************************************************************************
* DESCRIPTION:
* This function is called whenever the telephone enters the Idle State.
*****************************************************************************/
void phonesm_idle_state_enter(void) {
// Declare function variables
char timebuffer[TIMEDATE_ARRAY_SIZE];
// Clear the display
display_cleardisplay();
// Get the time and display it
phonesm_infosettings_getformattedtime(timebuffer);
display_writelinetwo( (24 - TIMEDATE_STRING_LENGTH), timebuffer);
// Update the Voicemail LED
switch(phonesm_infoonetouch_getledstate()) {
case LED_STATE_OFF:
leddriver_setstate(LED_INDICATOR_VOICEMAIL, LED_STATE_OFF);
break;
case LED_STATE_WINK:
case LED_STATE_FLASH:
case LED_STATE_ON:
leddriver_setstate(LED_INDICATOR_VOICEMAIL, LED_STATE_WINK);
break;
}
// Turn off LCD Backlight
leddriver_setstate(LED_INDICATOR_BACKLIGHT, LED_STATE_OFF);
}
/******************************************************************************
* FUNCTION: void phonesm_exec_hookswitch(unsigned int updown)
******************************************************************************
* DESCRIPTION:
* This function is called when the hookswitch goes up or down while the
* phone is in Idle State. If the Idle State activates another state while
* executing this function, the function will return 1. Otherwise, it will
* return 0.
*****************************************************************************/
BOOL phonesm_idle_exec_hookswitch(BOOL updown) {
// This checks if the hookswitch went down
if(updown == HOOKSTATE_DOWN) {
// Upon leaving the Active State, the phone should have reported a
// hookswitch down event. If the phone is plugged in while the handset
// is off hook, it should go to the Idle State.
return 0;
}
// This checks if the hookswitch went up
else {
phonesm_activate_state(PHONESM_STATE_ACTIVE);
return 1;
}
}
/******************************************************************************
* FUNCTION: BOOL phonesm_idle_exec_keypress(unsigned int key, BOOL updown)
******************************************************************************
* DESCRIPTION:
* This function is called whenever a key goes up or down while the phone
* is in the Idle State. This function returns 1 if the keypress causes a
* Phone SM state change and 0 otherwise. This function is fairly big and
* hairy, but not quite as large as the modemcommand(.) function.
*****************************************************************************/
BOOL phonesm_idle_exec_keypress(unsigned int key, BOOL updown) {
// Currently the Idle State will only respond to key down messages
if(updown == KEYSTATE_DOWN) {
switch(key) {
// These keys activate the Predial State
case KEYPAD_DIGIT_0:
case KEYPAD_DIGIT_1:
case KEYPAD_DIGIT_2:
case KEYPAD_DIGIT_3:
case KEYPAD_DIGIT_4:
case KEYPAD_DIGIT_5:
case KEYPAD_DIGIT_6:
case KEYPAD_DIGIT_7:
case KEYPAD_DIGIT_8:
case KEYPAD_DIGIT_9:
case KEYPAD_DIGIT_STAR:
case KEYPAD_DIGIT_POUND:
case KEYPAD_LOCAL_PAUSE:
if( phonesm_infosettings_getpredialenabled() ) {
phonesm_activate_state(PHONESM_STATE_PREDIAL);
return 1;
}
else
return 0;
case KEYPAD_LOCAL_STORENUM:
phonesm_activate_state(PHONESM_STATE_PREDIAL);
return 1;
// The Program Key activates the Program State
case KEYPAD_LOCAL_PROGRAM:
phonesm_activate_state(PHONESM_STATE_PROGRAM);
return 1;
// The Memory Key activates the Memory State
case KEYPAD_LOCAL_MEMORY:
phonesm_activate_state(PHONESM_STATE_MEMORY);
return 1;
// The Scroll Keys activate the Contrast State
case KEYPAD_SCROLL_UP:
case KEYPAD_SCROLL_DOWN:
phonesm_activate_state(PHONESM_STATE_CONTRAST);
return 1;
// These keys activate the Active State
case KEYPAD_FEATURE_01:
case KEYPAD_AUDIO_HEADSET:
case KEYPAD_AUDIO_SPEAKER:
// Send the key to the Central Office
phonesm_activate_state(PHONESM_STATE_ACTIVE);
return 1;
// These keys are sent to the DMS switch, but do not exit the Idle State
case KEYPAD_FEATURE_02:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_02);
return 0;
case KEYPAD_FEATURE_03:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_03);
return 0;
case KEYPAD_FEATURE_04:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_04);
return 0;
case KEYPAD_FEATURE_05:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_05);
return 0;
case KEYPAD_FEATURE_06:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_06);
return 0;
case KEYPAD_FEATURE_07:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_07);
return 0;
case KEYPAD_FEATURE_08:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_08);
return 0;
case KEYPAD_FEATURE_09:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_09);
return 0;
case KEYPAD_FEATURE_10:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_10);
return 0;
case KEYPAD_FEATURE_11:
modemcontroller_send_modemmessage(MDC_CPE_FEATURE_11);
return 0;
// The Volume Keys activate the Volume State
case KEYPAD_VOLUME_UP:
case KEYPAD_VOLUME_DOWN:
phonesm_activate_state(PHONESM_STATE_VOLUME);
return 1;
// The rest of the keys do nothing
case KEYPAD_LOCAL_EXIT:
case KEYPAD_LOCAL_SELECT:
case KEYPAD_LOCAL_SAVE:
case KEYPAD_FEATURE_HOLD:
case KEYPAD_FEATURE_RELEASE:
case KEYPAD_AUDIO_MUTE:
case KEYPAD_FEATURE_VOICEMAIL:
// Do nothing
// return 0;
break;
}
}
return 0;
}
/******************************************************************************
* FUNCTION: BOOL phonesm_idle_exec_modemcommand(DC550MDCMessage command)
******************************************************************************
* DESCRIPTION:
* This function is called when the phone receives a modem command while
* in the Idle State. This function returns 1 if the keypress causes a
* Phone SM state change and 0 otherwise. This function evaluates the
* command against every possible modem command. If code efficiency were
* not as much of a concern, this function might have been split into
* several functions.
*****************************************************************************/
BOOL phonesm_idle_exec_modemcommand(DC550MDCMessage command) {
switch(command) {
case MDC_DMS_SOFT_RESET:
case MDC_DMS_HARD_RESET:
// These two commands reset all of the indicators.
// Hard Reset should also knock the phone back to the the Idle State,
// but this is already the Idle State.
leddriver_setstate(LED_INDICATOR_FEATURE01, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE02, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE03, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE04, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE05, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE06, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE07, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE08, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE09, LED_STATE_OFF);
leddriver_setstate(LED_INDICATOR_FEATURE10, LED_STATE_OFF);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -