Commit 4aa470f0 authored by 957dd's avatar 957dd

水坦克加入了冷却

parent cee16774
No preview for this file type
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
#include "gpio_control.h" #include "gpio_control.h"
#define GPIO_ID_THREAD_COUNT 3 #define GPIO_ID_THREAD_COUNT 3
#define GPIO_ID_SHOT_ONLYCOOL_COUNT 4 //仅需要打开射击冷却的设备数量
int gpio_device_id[GPIO_ID_THREAD_COUNT]={DEVICE_TANK0202,DEVICE_TANK0203,DEVICE_TANK0204};//需要打开线程池设备号 int gpio_device_id[GPIO_ID_THREAD_COUNT]={DEVICE_TANK0202,DEVICE_TANK0203,DEVICE_TANK0204};//需要打开线程池设备号
int gpio_device_cool_id[GPIO_ID_SHOT_ONLYCOOL_COUNT]={DEVICE_TANK0202,DEVICE_TANK0203,DEVICE_TANK0204,DEVICE_TANK0206};//仅需要打开射击冷却的设备号
const gpiocontrol_t *gpio_control_config_t = NULL ;//gpio结构体标识 const gpiocontrol_t *gpio_control_config_t = NULL ;//gpio结构体标识
...@@ -34,11 +36,20 @@ TankFireControl g_device_shot_t; // 真正的结构体变量 ...@@ -34,11 +36,20 @@ TankFireControl g_device_shot_t; // 真正的结构体变量
* @param shot_duration_ms 射击持续时间(毫秒) * @param shot_duration_ms 射击持续时间(毫秒)
*/ */
void device_shot_fire_init(TankFireControl* this) { void device_shot_fire_init(TankFireControl* this) {
this->last_shot_end_time = 0; if(g_device_type==DEVICE_TANK0206){
this->shooting_start_time = 0; this->last_shot_end_time = 0;
this->state = TANK_STATE_READY; this->shooting_start_time = 0;
this->shot_interval_ms = 5000; this->state = TANK_STATE_READY;
this->shot_duration_ms = 1000; this->shot_interval_ms = 1000;
this->shot_duration_ms = 600;
}else{
this->last_shot_end_time = 0;
this->shooting_start_time = 0;
this->state = TANK_STATE_READY;
this->shot_interval_ms = 5000;
this->shot_duration_ms = 1000;
}
} }
/* /*
...@@ -46,8 +57,8 @@ void device_shot_fire_init(TankFireControl* this) { ...@@ -46,8 +57,8 @@ void device_shot_fire_init(TankFireControl* this) {
**对需要射击冷却的进行初始化 **对需要射击冷却的进行初始化
*/ */
int device_shot_cooling_init(){ int device_shot_cooling_init(){
for(int i=0;i<GPIO_ID_THREAD_COUNT;i++){ for(int i=0;i<GPIO_ID_SHOT_ONLYCOOL_COUNT;i++){
if(g_device_type==gpio_device_id[i]){ if(g_device_type==gpio_device_cool_id[i]){
my_zlog_info("using %d shot init",g_device_type); my_zlog_info("using %d shot init",g_device_type);
device_shot_fire_init(&g_device_shot_t); device_shot_fire_init(&g_device_shot_t);
return 0; return 0;
...@@ -57,7 +68,7 @@ int device_shot_cooling_init(){ ...@@ -57,7 +68,7 @@ int device_shot_cooling_init(){
} }
/** /**
* @brief 检查坦克射击状态 * @brief 检查射击状态
* @param this 控制器指针 * @param this 控制器指针
* @return 0=允许射击, -1=禁止射击(冷却中或射击中) * @return 0=允许射击, -1=禁止射击(冷却中或射击中)
*/ */
...@@ -522,7 +533,7 @@ void tank0206_pwm_value(int pin,int value) { //软件陪我们控制调速 ...@@ -522,7 +533,7 @@ void tank0206_pwm_value(int pin,int value) { //软件陪我们控制调速
if(value==1) { if(value==1) {
if(pin == 27){ if(pin == 27){
softPwmWrite(26, 35); device_shoting_check(26, 35);
} else { } else {
softPwmWrite(pin, 35); softPwmWrite(pin, 35);
my_zlog_info("pwm:%d",pin); my_zlog_info("pwm:%d",pin);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment