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

📄 volumecontrolpage.c

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 C
字号:
/****************************************************************
**                                                              *
**  FILE         : VolumeControlPage.c                          *
**                                                              *
**  By : Cyb 2007.07.01                                         *
****************************************************************/
#define  VOLUMECONTROL_GLOBALS

#include "includes.h"
#include "timetask.h"
#include "almtask.h"
#include "message.h"
#include "errcode.h"
#include "errtask.h"
#include "public.h"
#include "uart_drv.h"
#include "hardware.h"
#include "LedDrv.h"
#include "DisplayTask.h"
#include "alarmer.h"
#include "watchdog.h"
#include "audio.h"
#include "FormPage.h"
#include "WinStack.h"
#include "_keyboard.h"
#include "VolumeControl.h"
#include "LedDrv.h"
#include "cat5112.h"

#define  VOLUMECONTROLPAGE_DEBUG   1

static FORMPAGE  *VolumeControlPage;
static INT8U     ICON_VOLUME[2]  = {0x14,0x16};  
static INT8U     Status;


static void UpdateVolumeDispay(INT8U type,INT8U volumevalue)
{
    INT8U index;
    
    switch(type)
    {
      case TIMESEC_NORMAL:
      index = 0;
      break;
      case TIMESEC_PEAK:
      index = 1;
      break;
      case TIMESEC_NIGHT:
      index = 2;
      break;
      default:
      index = 0;
      break; 
    }
    
    SendLedDisplay(&NUMBER[index],1,2,2);
    
    if(volumevalue>CAT5112_STEP_MAX-1)  // 最多为8档(0~7)
    {
       index = CAT5112_STEP_MAX-1;
    }
    
    index = volumevalue;
   
    SendLedDisplay(&NUMBER[index],1,3,3);
   
}
static void VolumeControlPageInitFunc(void)
{
    INT8U timesectype;
    INT8U volumevalue;
    
    ClearLedDisplay();
    timesectype = GetTimeSec_Volume();
    volumevalue = GetMachineVolume();
    
    SendLedDisplay(ICON_VOLUME,2,0,1);
    
    UpdateVolumeDispay(timesectype,volumevalue);
    
    Status = 0;    // 初始状态

}

static void HdlTurnUpVolume(void)
{
    INT8U timesectype;
    INT8U volumevalue;
    
    timesectype = GetTimeSec_Volume();
    
     switch(timesectype)
     {
          case TIMESEC_NORMAL:
          VolumeControl.normal++;
          
          if(VolumeControl.normal>CAT5112_STEP_MAX-1)
          {
             VolumeControl.normal = 0;
          }
#if VOLUMECONTROLPAGE_DEBUG >0
          PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\nVolumeControl.normal=");
          SendFromUART_HEX(DEBUG_UARTNo_DISPLAYTASK, VolumeControl.normal);
#endif  
      
          volumevalue = VolumeControl.normal; 
          break;
          case TIMESEC_PEAK:
          VolumeControl.peak++;
          
          if(VolumeControl.peak>CAT5112_STEP_MAX-1)
          {
             VolumeControl.peak = 0;
          }
#if VOLUMECONTROLPAGE_DEBUG >0
          PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\nVolumeControl.peak=");
          SendFromUART_HEX(DEBUG_UARTNo_DISPLAYTASK, VolumeControl.peak);
#endif 
          volumevalue = VolumeControl.peak;
          break;
          case TIMESEC_NIGHT:
          VolumeControl.night++;
          
          if(VolumeControl.night>CAT5112_STEP_MAX-1)
          {
             VolumeControl.night = 0;
          }
#if VOLUMECONTROLPAGE_DEBUG >0
          PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\nVolumeControl.night=");
          SendFromUART_HEX(DEBUG_UARTNo_DISPLAYTASK, VolumeControl.night);
#endif           
          volumevalue = VolumeControl.night;
          break;
          default:
          break;
   
    }
    
    UpdateVolumeDispay(timesectype, volumevalue);
    
    if((Status == 0)||(Status == timesectype))
    {
       
       OSQPost(AlmTaskMsgQue,MSG_VOLUME_STEPUP, volumevalue ,0);
       
    }
   
}

static void HdlTurnDownVolume(void)
{
    INT8U timesectype;
    INT8U volumevalue;
    
    timesectype = GetTimeSec_Volume();
    
     switch(timesectype)
     {
          case TIMESEC_NORMAL:
          if(VolumeControl.normal==0)
          {
             VolumeControl.normal = CAT5112_STEP_MAX-1;
          }
          else
          {
             VolumeControl.normal--;
          }
#if VOLUMECONTROLPAGE_DEBUG >0
          PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\nVolumeControl.normal=");
          SendFromUART_HEX(DEBUG_UARTNo_DISPLAYTASK, VolumeControl.normal);
#endif
          volumevalue = VolumeControl.normal; 
          break;
          case TIMESEC_PEAK:
          if(VolumeControl.peak==0)
          {
             VolumeControl.peak = CAT5112_STEP_MAX-1;
          }
          else
          {
             VolumeControl.peak--;
          }
 #if VOLUMECONTROLPAGE_DEBUG >0
          PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\nVolumeControl.peak=");
          SendFromUART_HEX(DEBUG_UARTNo_DISPLAYTASK, VolumeControl.peak);
#endif
          volumevalue = VolumeControl.peak; 
          break;
          break;
          case TIMESEC_NIGHT:
          if(VolumeControl.night==0)
          {
             VolumeControl.night = CAT5112_STEP_MAX-1;
          }
          else
          {
             VolumeControl.night--;
          }
#if VOLUMECONTROLPAGE_DEBUG >0
          PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\nVolumeControl.night=");
          SendFromUART_HEX(DEBUG_UARTNo_DISPLAYTASK, VolumeControl.night);
#endif 
          volumevalue = VolumeControl.night; 
          break;
          break;
          default:
          break;
   
    }
    
    UpdateVolumeDispay(timesectype, volumevalue);
    
    if((Status == 0)||(Status == timesectype))
    {
       
       OSQPost(AlmTaskMsgQue,MSG_VOLUME_STEPDOWN, volumevalue ,0);
       
    }
}

static void VolumeControlPageHdlKeyFunc(void)
{
    INT8U key;
    
    key = GetCurKey();
    
    switch(key)
    {
       case KEY_1:
#if VOLUMECONTROLPAGE_DEBUG >0
       PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\n选择改变[正常时间段]音量!");
#endif
       Status = TIMESEC_NORMAL;
       break;
       case KEY_2:
#if VOLUMECONTROLPAGE_DEBUG >0
       PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\n选择改变[高峰时间段]音量!");
#endif       
       Status = TIMESEC_PEAK;
       break;
       case KEY_3:
#if VOLUMECONTROLPAGE_DEBUG >0
       PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\n选择改变[夜晚时间段]音量!");
#endif        
       Status = TIMESEC_NIGHT;
       break;
       case KEY_5:
       HdlTurnUpVolume();
       StorePubPara(VOLUME_);
       break;
       case KEY_6:
       HdlTurnDownVolume();
       StorePubPara(VOLUME_);
       break;
       case KEY_SHIFT:
#if VOLUMECONTROLPAGE_DEBUG >0
       PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "\n退出音量控制页面!");
#endif
       CloseFormPage();
       break;
       default:
       break;
  
    }
}

static void VolumeControlPageResumeFunc(void)
{
    INT8U timesectype;
    INT8U volumevalue;
    
    timesectype = GetTimeSec_Volume();
    volumevalue = GetMachineVolume();
    
    SendLedDisplay(ICON_VOLUME,2,0,1);
    
    UpdateVolumeDispay(timesectype,volumevalue);
    
    Status = 0;    // 初始状态

}

static void VolumeControlPageDestroyFunc(void)
{
    ClearLedDisplay();
}

void  CreateVolumeControlPage(void)
{
#if VOLUMECONTROLPAGE_DEBUG >0
    PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "进入音量控制页面!!!\n");
#endif     
    VolumeControlPage =  AllocateFormPage();
    VolumeControlPage ->initfunc    = VolumeControlPageInitFunc;
    VolumeControlPage ->createfunc  = NULL;
    VolumeControlPage ->hdlkeyfunc  = VolumeControlPageHdlKeyFunc;
    VolumeControlPage ->resumefunc  = VolumeControlPageResumeFunc;
    VolumeControlPage ->destroyfunc = VolumeControlPageDestroyFunc;
    CreateFormPage();  
}

⌨️ 快捷键说明

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