⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dc550_phonesm_infolevels.c

📁 一款经典的数字电话设计资料
💻 C
字号:
/*****************************************************************************/
/*  CONFIDENTIAL                                                             */
/*  Sigpro Copyright 2003, All rights reserved                               */
/*****************************************************************************/
/*  CLIENT:  Telematrix                                                      */
/*  PROJECT: DC550 Digital Centrex Phone                                     */
/*  FILE:    dc550_phonesm_infolevels.c                                      */
/*****************************************************************************/
/*                                                                           */
/*****************************************************************************/

#define __DC550_PHONESM_INFOLEVELS_EXTERN__
#include "dc550_phonesm_infolevels.h"
#include "dc550_phonesm_infoaudio.h"
#include "dc550_i2cdriver.h"


/******************************************************************************
 *  GLOBAL VARIABLES
 *****************************************************************************/
DC550Level phonesm_infolevels_alertervolume;
DC550Level phonesm_infolevels_handsetvolume;
DC550Level phonesm_infolevels_headsetvolume;
DC550Level phonesm_infolevels_speakervolume;
DC550Level phonesm_infolevels_contrastlevel;


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_init(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  This function is called to initialize the settings variables.
 *****************************************************************************/
void phonesm_infolevels_init(void) {
  // Declare function variables
  int i;

  if(eeprom_GetVersion() == EEPROM_VERSION_CURRENT) {
    phonesm_infolevels_alertervolume = 7;
    eeprom_ReadByte(EEPROM_ADDRESS_HANDSETVOL,
                    &phonesm_infolevels_handsetvolume);
    eeprom_ReadByte(EEPROM_ADDRESS_HEADSETVOL,
                    &phonesm_infolevels_headsetvolume);
    eeprom_ReadByte(EEPROM_ADDRESS_SPEAKERVOL,
                    &phonesm_infolevels_speakervolume);
    eeprom_ReadByte(EEPROM_ADDRESS_CONTRAST,
                    &phonesm_infolevels_contrastlevel);
  }
  else {
    phonesm_infolevels_alertervolume = 7;
    phonesm_infolevels_handsetvolume = 7;
    phonesm_infolevels_headsetvolume = 7;
    phonesm_infolevels_speakervolume = 7;
    phonesm_infolevels_contrastlevel = 7;
    for(i = 0; i < 4000; i++);         // Wait 4ms (a write takes over 3ms)
    eeprom_WriteByte(EEPROM_ADDRESS_ALERTERVOL,
                     phonesm_infolevels_alertervolume);
    for(i = 0; i < 4000; i++);         // Wait 4ms (a write takes over 3ms)
    eeprom_WriteByte(EEPROM_ADDRESS_HANDSETVOL,
                     phonesm_infolevels_handsetvolume);
    for(i = 0; i < 4000; i++);         // Wait 4ms (a write takes over 3ms)
    eeprom_WriteByte(EEPROM_ADDRESS_HEADSETVOL,
                     phonesm_infolevels_headsetvolume);
    for(i = 0; i < 4000; i++);         // Wait 4ms (a write takes over 3ms)
    eeprom_WriteByte(EEPROM_ADDRESS_SPEAKERVOL,
                     phonesm_infolevels_speakervolume);
    for(i = 0; i < 4000; i++);         // Wait 4ms (a write takes over 3ms)
    eeprom_WriteByte(EEPROM_ADDRESS_CONTRAST,
                     phonesm_infolevels_contrastlevel);
  }

}


/******************************************************************************
 *  FUNCTION: DC550Level phonesm_infolevels_getalertervolume(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
DC550Level phonesm_infolevels_getalertervolume(void) {
  return phonesm_infolevels_alertervolume;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_setalertervolume(DC550Level volume)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_setalertervolume(DC550Level volume) {
  phonesm_infolevels_alertervolume = volume;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_commitalertervolume(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_commitalertervolume(void) {
  eeprom_SetSetting(EEPROM_ADDRESS_ALERTERVOL,
                    phonesm_infolevels_alertervolume);
}


/******************************************************************************
 *  FUNCTION: DC550Level phonesm_infolevels_getspeakervolume(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
DC550Level phonesm_infolevels_getspeakervolume(void) {
  return phonesm_infolevels_speakervolume;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_setspeakervolume(DC550Level volume)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_setspeakervolume(DC550Level volume) {
  phonesm_infolevels_speakervolume = volume;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_commitspeakervolume(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_commitspeakervolume(void) {
  eeprom_SetSetting(EEPROM_ADDRESS_SPEAKERVOL,
                    phonesm_infolevels_speakervolume);
}


/******************************************************************************
 *  FUNCTION: DC550Level phonesm_infolevels_getheadsetvolume(void);
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
DC550Level phonesm_infolevels_getheadsetvolume(void) {
  return phonesm_infolevels_headsetvolume;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_setheadsetvolume(DC550Level volume)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_setheadsetvolume(DC550Level volume) {
  phonesm_infolevels_headsetvolume = volume;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_commitheadsetvolume(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_commitheadsetvolume(void) {
  eeprom_SetSetting(EEPROM_ADDRESS_HEADSETVOL,
                    phonesm_infolevels_headsetvolume);
}


/******************************************************************************
 *  FUNCTION: DC550Level phonesm_infolevels_gethandsetvolume(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
DC550Level phonesm_infolevels_gethandsetvolume(void) {
  return phonesm_infolevels_handsetvolume;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_sethandsetvolume(DC550Level volume)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_sethandsetvolume(DC550Level volume) {
  phonesm_infolevels_handsetvolume = volume;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_commithandsetvolume(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_commithandsetvolume(void) {
  eeprom_SetSetting(EEPROM_ADDRESS_HANDSETVOL,
                    phonesm_infolevels_handsetvolume);
}


/******************************************************************************
 *  FUNCTION: DC550Level phonesm_infolevels_getcontrastlevel(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  This is an accessor for the contrast level.  Eventually, the contrast level
 *  may be stored in a struct for reading to/writing from the EEPROM or Flash.
 *****************************************************************************/
DC550Level phonesm_infolevels_getcontrastlevel(void) {
  return phonesm_infolevels_contrastlevel;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_setcontrastlevel(DC550Level contrast)
 ******************************************************************************
 *  DESCRIPTION:
 *  This is a mutator for the contrast level.
 *****************************************************************************/
void phonesm_infolevels_setcontrastlevel(DC550Level contrast) {
  phonesm_infolevels_contrastlevel = contrast;
}


/******************************************************************************
 *  FUNCTION: void phonesm_infolevels_commitcontrastlevel(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
void phonesm_infolevels_commitcontrastlevel(void) {
  eeprom_SetSetting(EEPROM_ADDRESS_CONTRAST,
                    phonesm_infolevels_contrastlevel);
}


/******************************************************************************
 *  FUNCTION: char* phonesm_infolevels_getlevelline(DC550Level level);
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
char* phonesm_infolevels_getlevelline(DC550Level level) {
  switch(level) {
    case 0:
      return "[\2\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1]      ";
    case 1:
      return "[\2\2\1\1\1\1\1\1\1\1\1\1\1\1\1\1]      ";
    case 2:
      return "[\2\2\2\1\1\1\1\1\1\1\1\1\1\1\1\1]      ";
    case 3:
      return "[\2\2\2\2\1\1\1\1\1\1\1\1\1\1\1\1]      ";
    case 4:
      return "[\2\2\2\2\2\1\1\1\1\1\1\1\1\1\1\1]      ";
    case 5:
      return "[\2\2\2\2\2\2\1\1\1\1\1\1\1\1\1\1]      ";
    case 6:
      return "[\2\2\2\2\2\2\2\1\1\1\1\1\1\1\1\1]      ";
    case 7:
      return "[\2\2\2\2\2\2\2\2\1\1\1\1\1\1\1\1]      ";
    case 8:
      return "[\2\2\2\2\2\2\2\2\2\1\1\1\1\1\1\1]      ";
    case 9:
      return "[\2\2\2\2\2\2\2\2\2\2\1\1\1\1\1\1]      ";
    case 10:
      return "[\2\2\2\2\2\2\2\2\2\2\2\1\1\1\1\1]      ";
    case 11:
      return "[\2\2\2\2\2\2\2\2\2\2\2\2\1\1\1\1]      ";
    case 12:
      return "[\2\2\2\2\2\2\2\2\2\2\2\2\2\1\1\1]      ";
    case 13:
      return "[\2\2\2\2\2\2\2\2\2\2\2\2\2\2\1\1]      ";
    case 14:
      return "[\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\1]      ";
    case 15:
      return "[\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2]      ";
    default:
      return "[\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1]      ";
  }
}


/******************************************************************************
 *  FUNCTION: char* phonesm_infolevels_getlevelbar(DC550Level level);
 ******************************************************************************
 *  DESCRIPTION:
 *  
 *****************************************************************************/
char* phonesm_infolevels_getlevelbar(DC550Level level) {
  switch(level) {
    case 0:
      return "\2\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1";
    case 1:
      return "\2\2\1\1\1\1\1\1\1\1\1\1\1\1\1\1";
    case 2:
      return "\2\2\2\1\1\1\1\1\1\1\1\1\1\1\1\1";
    case 3:
      return "\2\2\2\2\1\1\1\1\1\1\1\1\1\1\1\1";
    case 4:
      return "\2\2\2\2\2\1\1\1\1\1\1\1\1\1\1\1";
    case 5:
      return "\2\2\2\2\2\2\1\1\1\1\1\1\1\1\1\1";
    case 6:
      return "\2\2\2\2\2\2\2\1\1\1\1\1\1\1\1\1";
    case 7:
      return "\2\2\2\2\2\2\2\2\1\1\1\1\1\1\1\1";
    case 8:
      return "\2\2\2\2\2\2\2\2\2\1\1\1\1\1\1\1";
    case 9:
      return "\2\2\2\2\2\2\2\2\2\2\1\1\1\1\1\1";
    case 10:
      return "\2\2\2\2\2\2\2\2\2\2\2\1\1\1\1\1";
    case 11:
      return "\2\2\2\2\2\2\2\2\2\2\2\2\1\1\1\1";
    case 12:
      return "\2\2\2\2\2\2\2\2\2\2\2\2\2\1\1\1";
    case 13:
      return "\2\2\2\2\2\2\2\2\2\2\2\2\2\2\1\1";
    case 14:
      return "\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\1";
    case 15:
      return "\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2";
    default:
      return "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1";
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -