dc550_phonesm_contrast.c
来自「一款经典的数字电话设计资料」· C语言 代码 · 共 222 行
C
222 行
/*****************************************************************************/
/* CONFIDENTIAL */
/* Sigpro Copyright 2003, All rights reserved */
/*****************************************************************************/
/* CLIENT: Telematrix */
/* PROJECT: DC550 Digital Centrex Phone */
/* FILE: dc550_phonesm_contrast.c */
/*****************************************************************************/
/* The Contrast State is only active when the user is adjusting the */
/* contrast. It will only ever be active if it is on top of the state */
/* stack. */
/*****************************************************************************/
#define __DC550_PHONESM_CONTRAST_EXTERN__
#include "dc550_phonesm_contrast.h"
#include "dc550_phonesm_active.h"
#include "dc550_phonesm_idle.h"
#include "dc550_phonesm_init.h"
#include "dc550_phonesm_memory.h"
#include "dc550_phonesm_predial.h"
#include "dc550_phonesm_program.h"
#include "dc550_phonesm_display12.h"
#include "dc550_phonesm_infolevels.h"
#include "dc550_phonesm_infolanguage.h"
#include "dc550_phonesm.h"
#include "dc550_i2cdriver.h"
#include "dc550_display.h"
#include "dc550_leddriver.h"
/******************************************************************************
* GLOBAL VARIABLES
*****************************************************************************/
PHONESM_STATE_E phonesm_contrast_exitstate;
DC550InterruptCounter phonesm_contrast_periodtimeout;
/******************************************************************************
* FUNCTION: void phonesm_contrast_init(void) {
******************************************************************************
* DESCRIPTION:
* This function is called to initialize all of the Contrast State variables.
*****************************************************************************/
void phonesm_contrast_init(void) {
digpot_Contrast( phonesm_infolevels_getcontrastlevel() );
}
/******************************************************************************
* FUNCTION: void phonesm_contrast_state_enter(void)
******************************************************************************
* DESCRIPTION:
* This function is called whenever the telephone enters the Contrast State.
*****************************************************************************/
void phonesm_contrast_state_enter(void) {
phonesm_contrast_periodtimeout = PHONESM_CONTRAST_TIMEOUT;
display_writelineone( 0, phonesm_infolanguage_getlineone_contrast() );
display_writelinetwo(0,
phonesm_infolevels_getlevelline(phonesm_infolevels_getcontrastlevel()) );
// Turn on LCD Backlight
leddriver_setstate(LED_INDICATOR_BACKLIGHT, LED_STATE_ON);
}
/******************************************************************************
* FUNCTION: void phonesm_contrast_state_exit(void)
******************************************************************************
* DESCRIPTION:
* This function is called whenever the telephone exits the Contrast State.
*****************************************************************************/
void phonesm_contrast_state_exit(void) {
phonesm_infolevels_commitcontrastlevel();
}
/******************************************************************************
* FUNCTION: BOOL phonesm_contrast_exec_hookswitch(BOOL updown)
******************************************************************************
* DESCRIPTION:
* This function is called when the hookswitch goes up or down while the
* phone is in Contrast State. The Contrast State always exits with any
* hookswitch activity.
*****************************************************************************/
BOOL phonesm_contrast_exec_hookswitch(BOOL updown) {
phonesm_contrast_state_exit();
phonesm_deactivate_state(PHONESM_STATE_CONTRAST);
return 1;
}
/******************************************************************************
* FUNCTION:
* BOOL phonesm_contrast_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 Contrast State. This function deactivates the Contrast State
* and returns 1 whenever the key pressed is not a scroll key.
*****************************************************************************/
BOOL phonesm_contrast_exec_keypress(unsigned int key, BOOL updown) {
// Declare local variables
DC550Level currentlevel;
// Currently the Contrast State will only respond to key down messages
if(updown == KEYSTATE_DOWN) {
switch(key) {
// The Scroll Keys change the contrast
case KEYPAD_SCROLL_UP:
phonesm_contrast_periodtimeout = PHONESM_CONTRAST_TIMEOUT;
currentlevel = phonesm_infolevels_getcontrastlevel();
if(currentlevel < 15) {
currentlevel += 1;
phonesm_infolevels_setcontrastlevel(currentlevel);
digpot_Contrast( currentlevel );
display_writelinetwo(0,phonesm_infolevels_getlevelline(currentlevel));
}
return 0;
case KEYPAD_SCROLL_DOWN:
phonesm_contrast_periodtimeout = PHONESM_CONTRAST_TIMEOUT;
currentlevel = phonesm_infolevels_getcontrastlevel();
if(currentlevel > 0) {
currentlevel -= 1;
phonesm_infolevels_setcontrastlevel(currentlevel);
digpot_Contrast( currentlevel );
display_writelinetwo(0,phonesm_infolevels_getlevelline(currentlevel));
}
return 0;
case KEYPAD_LOCAL_EXIT:
phonesm_contrast_state_exit();
phonesm_deactivate_state(PHONESM_STATE_CONTRAST);
return 0;
default:
phonesm_contrast_state_exit();
phonesm_deactivate_state(PHONESM_STATE_CONTRAST);
return 1;
}
}
else
return 0;
}
/******************************************************************************
* FUNCTION:
* BOOL phonesm_contrast_exec_modemcommand(DC550MDCMessage command)
******************************************************************************
* DESCRIPTION:
* This function is called when the phone receives a modem command while
* in the Contrast State. It deactivates the Contrast State and returns 1
* regardless of the message received.
*****************************************************************************/
BOOL phonesm_contrast_exec_modemcommand(DC550MDCMessage command) {
// Exit this state
phonesm_contrast_state_exit();
phonesm_deactivate_state(PHONESM_STATE_CONTRAST);
return 1;
}
/******************************************************************************
* FUNCTION:
* BOOL phonesm_contrast_exec_periodic(BOOL firstline, BOOL secondline)
******************************************************************************
* DESCRIPTION:
* This function is called periodically whether or not the phone is in the
* Idle State. Since the Idle State is always active, this function will
* always be called. firstline and secondline will both be 1 when the
* Idle State is "on top". firstline would be 0 during Predial, and
* secondline would also be 0 when the telephone is active. This function
* returns 1 if the periodic function call needs to be repeated due to a
* state change and 0 otherwise.
*****************************************************************************/
BOOL phonesm_contrast_exec_periodic(BOOL firstline, BOOL secondline) {
if(firstline && secondline) {
phonesm_contrast_periodtimeout--;
if(!phonesm_contrast_periodtimeout) {
// Exit this state
phonesm_contrast_state_exit();
phonesm_deactivate_state(PHONESM_STATE_CONTRAST);
return 1;
}
switch(phonesm_contrast_exitstate) {
case PHONESM_STATE_IDLE:
phonesm_idle_exec_periodic(0,0);
break;
case PHONESM_STATE_INIT:
phonesm_init_exec_periodic(0,0);
break;
case PHONESM_STATE_ACTIVE:
phonesm_active_exec_periodic(0,0);
break;
case PHONESM_STATE_PROGRAM:
phonesm_program_exec_periodic(0,0);
break;
case PHONESM_STATE_DISPLAY12:
phonesm_display12_exec_periodic(0,0);
break;
case PHONESM_STATE_MEMORY:
phonesm_memory_exec_periodic(0,0);
break;
case PHONESM_STATE_PREDIAL:
phonesm_predial_exec_periodic(0,0);
break;
case PHONESM_STATE_VOLUME:
case PHONESM_STATE_CONTRAST:
// This should never happen
// Exit this state
phonesm_contrast_state_exit();
phonesm_deactivate_state(PHONESM_STATE_CONTRAST);
return 1;
};
return 0;
}
else {
// Exit this state
phonesm_contrast_state_exit();
phonesm_deactivate_state(PHONESM_STATE_CONTRAST);
return 1;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?