📄 volumecontrol.c
字号:
/****************************************************************
** *
** FILE : VolumeControl.c *
** *
** By : Cyb 2007.07.01 *
****************************************************************/
#define VOLUMCTRL_GLOBALS
#include "includes.h"
#include "tools.h"
#include "public.h"
#include "uart_drv.h"
#include "cat5112.h"
#include "systime.h"
#include "GpsRecer.h"
#include "VolumeControl.h"
#include "TimeTask.h"
#include "AlmTask.h"
#include "Message.h"
static INT8U CurSectype; // 当前时段类型
static INT8U PreSectype; // 前一时刻时段类型
static TIMEZONE TempPeakSec; // 临时高峰时间段
static TMR_TSK *CheckTimeSecTmr;
static TIME_STRUCT CurSysTime;
BOOLEAN CmpCurTimeFromTimeSec(TIME_STRUCT *BeginTime,TIME_STRUCT *EndTime,TIME_STRUCT *Time)
{
INT8U Result;
Result = CmpString((INT8U *)BeginTime,(INT8U *)Time,sizeof(TIME_STRUCT));
if(Result == STR_GREAT) return FALSE;
Result=CmpString((INT8U *)Time,(INT8U *)EndTime,sizeof(TIME_STRUCT));
if(Result==STR_GREAT) return FALSE;
return TRUE;
}
static void CheckTimeSecFunc(void)
{
INT8U i;
if(!GpsDataValid())
{
return;
}
GetSysTime_Time(&CurSysTime);
for(i=0;i<TimeSec.peaknums;i++)
{
if(CmpCurTimeFromTimeSec(&TimeSec.timesec_peak[i].btime,&TimeSec.timesec_peak[i].etime,&CurSysTime))
{
CurSectype = TIMESEC_PEAK;
if(PreSectype != CurSectype)
{
PreSectype = CurSectype;
OSQPost(AlmTaskMsgQue,MSG_TIMESEC_CHANGE, 0 ,0);
}
return;
}
}
if(CmpCurTimeFromTimeSec(&TimeSec.timesec_night.btime,&TimeSec.timesec_night.etime,&CurSysTime))
{
CurSectype = TIMESEC_NIGHT;
if(PreSectype != CurSectype)
{
PreSectype = CurSectype;
OSQPost(AlmTaskMsgQue,MSG_TIMESEC_CHANGE, 0 ,0);
}
return;
}
if(CmpString((INT8U *)&TempPeakSec.btime,(INT8U *)&TempPeakSec.etime,sizeof(TIME_STRUCT))== STR_EQUAL)
{
CurSectype = TIMESEC_NORMAL;
if(PreSectype != CurSectype)
{
PreSectype = CurSectype;
OSQPost(AlmTaskMsgQue,MSG_TIMESEC_CHANGE, 0 ,0);
}
return;
}
else
{
if(CmpCurTimeFromTimeSec(&TempPeakSec.btime,&TempPeakSec.etime,&CurSysTime))
{
CurSectype = TIMESEC_PEAK;
if(PreSectype != CurSectype)
{
PreSectype = CurSectype;
OSQPost(AlmTaskMsgQue,MSG_TIMESEC_CHANGE, 0 ,0);
}
return;
}
}
}
void InitVolumeControl(void)
{
CurSectype = TIMESEC_NORMAL;
PreSectype = TIMESEC_NORMAL;
memset((INT8U*)&TempPeakSec,0,sizeof(TIMEZONE)); //初始化临时时间段
switch(VolumeControl.CurTimeSec)
{
case TIMESEC_NORMAL:
SetMachineVolume(VolumeControl.normal);
break;
case TIMESEC_PEAK:
SetMachineVolume(VolumeControl.peak);
TurnVolumeToCertainValue(VolumeControl.normal);
VolumeControl.CurTimeSec = TIMESEC_NORMAL;
SetMachineVolume(VolumeControl.normal);
StorePubPara(VOLUME_);
break;
case TIMESEC_NIGHT:
SetMachineVolume(VolumeControl.night);
TurnVolumeToCertainValue(VolumeControl.normal);
VolumeControl.CurTimeSec = TIMESEC_NORMAL;
SetMachineVolume(VolumeControl.normal);
StorePubPara(VOLUME_);
break;
default:
SetMachineVolume(VolumeControl.normal);
break;
}
CheckTimeSecTmr = CreateTimer(CheckTimeSecFunc,0);
StartTmr(CheckTimeSecTmr,MINUTE,1);
}
INT8U GetTimeSec_Volume(void)
{
return CurSectype;
}
void ChangeVolumeInTimeSec(void)
{
switch(CurSectype)
{
case TIMESEC_NORMAL:
TurnVolumeToCertainValue(VolumeControl.normal);
VolumeControl.CurTimeSec = TIMESEC_NORMAL;
SetMachineVolume(VolumeControl.normal);
break;
case TIMESEC_PEAK:
TurnVolumeToCertainValue(VolumeControl.peak);
VolumeControl.CurTimeSec = TIMESEC_PEAK;
SetMachineVolume(VolumeControl.peak);
break;
case TIMESEC_NIGHT:
TurnVolumeToCertainValue(VolumeControl.night);
VolumeControl.CurTimeSec = TIMESEC_NIGHT;
SetMachineVolume(VolumeControl.night);
break;
default:
break;
}
StorePubPara(VOLUME_);
}
void SetTempPeakTimeSec(void)
{
GetSysTime_Time(&CurSysTime);
memcpy((INT8U*)&TempPeakSec.btime,(INT8U*)&CurSysTime,sizeof(TIME_STRUCT));
memcpy((INT8U*)&TempPeakSec.etime,(INT8U*)&CurSysTime,sizeof(TIME_STRUCT));
TempPeakSec.etime.hour +=1;
}
void VolumeStepDown(INT8U value)
{
SetMachineVolume(value);
TurnDownVolumeStepbyStep();
}
void VolumeStepUp(INT8U value)
{
SetMachineVolume(value);
TurnUpVolumeStepbyStep();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -