/// 
/// @file       device_auxswitch.c 
/// @function   顶部辅助电源开关 
/// @author     ypc 
/// @date       2019-05-25
/// @note       v1.0 2019-05-25
///             v2.0 2022-03-23
///

#include "device_auxswitch.h"
//#include "ptz_header_file.h"
#include "ptz_struct.h"

//电源控制初始化
void ptz_aux_switch_init()
{
    //总线时钟使能
  rcu_periph_clock_enable(RCU_GPIOE);
  
  gpio_mode_set(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_3);
  gpio_output_options_set(GPIOE, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, GPIO_PIN_3);
  
  gpio_mode_set(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_2);
  gpio_output_options_set(GPIOE, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, GPIO_PIN_2);
  
  PHOTO_POWER_PHOTO_OFF;
  g_ptz.power.aux_switch_3 = POWER_OFF;
  
  FARIR_POWER_FARIR_OFF;
  g_ptz.power.aux_switch_4 = POWER_OFF;
}

//控制云台辅助开关1到辅助开关4的电源打开和关闭(云台护罩内电源管理)
void ptz_aux_switch(unsigned char SwitchNum, unsigned char Power)
{
  switch(SwitchNum)
  {    
    case 3://辅助开关3打开和关闭（打开可见光相机）
      if(Power == POWER_ON)
      {
        PHOTO_POWER_PHOTO_ON;//打开可见光相机
        g_ptz.power.aux_switch_3 = POWER_ON;
      }
      else
      {
        PHOTO_POWER_PHOTO_OFF;//关闭可见光相机
        g_ptz.power.aux_switch_3 = POWER_OFF;
      }
      break;
      
    case 4://辅助开关4打开和关闭（打开远红外相机）
      if(Power == POWER_ON)
      {
        FARIR_POWER_FARIR_ON;//打开远红外相机
        g_ptz.power.aux_switch_4 = POWER_ON;
      }
      else
      {
        FARIR_POWER_FARIR_OFF;//关闭远红外相机
        g_ptz.power.aux_switch_4 = POWER_OFF;
      }
      break;
   }
}




















