Commit 0ece4fc3 authored by 957dd's avatar 957dd

Merge branch 'feature/trim_waji' into 'master'

Feature/trim waji See merge request !56
parents d560ae7c 550c1523
cmake_minimum_required(VERSION 3.10)
project(car
VERSION 1.2.3
VERSION 1.2.4
LANGUAGES C
)
......
#define PROJECT_VERSION_MAJOR 1
#define PROJECT_VERSION_MINOR 2
#define PROJECT_VERSION_PATCH 1
#define PROJECT_VERSION_PATCH 4
#define GIT_HASH ""
#define BUILD_TIMESTAMP ""
#define BUILD_USER ""
No preview for this file type
......@@ -8,14 +8,14 @@ void car0103_middle() {
}
void mode_car0103_lift_flont(unsigned char gval) {
int b=0;
int b=1;
if (gval < 50) {
pwmWrite(PWM_PIN_SPEED, 75);
}
else if (gval <= 60) {
pwmWrite(PWM_PIN_SPEED, 79);
pwmWrite(PWM_PIN_SPEED, 79+b);
}else if (gval <= 70) {
pwmWrite(PWM_PIN_SPEED, 80);
pwmWrite(PWM_PIN_SPEED, 80+b);
}else if(gval >70){
int flont_speed = 80+(gval-70)/10+b;
pwmWrite(PWM_PIN_SPEED, flont_speed);
......@@ -23,13 +23,13 @@ void mode_car0103_lift_flont(unsigned char gval) {
}
void mode_car0103_lift_back(unsigned char gval) {
int b=0;
int b=1;
if (gval < 50) {
pwmWrite(PWM_PIN_SPEED, 75);
} else if (gval <= 60) {
pwmWrite(PWM_PIN_SPEED, 71);
pwmWrite(PWM_PIN_SPEED, 71-b);
}else if (gval <= 70) {
pwmWrite(PWM_PIN_SPEED, 70);
pwmWrite(PWM_PIN_SPEED, 70-b);
} else if(gval >70){
int back_speed = 70 - (gval-70)/10-b;
pwmWrite(PWM_PIN_SPEED, back_speed);
......
......@@ -42,82 +42,33 @@ void car0104_flont(unsigned char gval) {
}
void car0104_right(unsigned char gval) {
int b=5;
if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75);
} else if (gval <= 55) {
pwmWrite(PWM_PIN_CHANGE, 78);
} else if (gval <= 60) {
pwmWrite(PWM_PIN_CHANGE, 79);
} else if (gval <= 65) {
}
else if (gval <= 60) {
pwmWrite(PWM_PIN_CHANGE, 80);
} else if (gval <= 70) {
pwmWrite(PWM_PIN_CHANGE, 81);
} else if (gval <= 75) {
}else if (gval <= 90) {
pwmWrite(PWM_PIN_CHANGE, 82);
} else if (gval <= 90) {
pwmWrite(PWM_PIN_CHANGE, 83);
} else if (gval <= 100) {
pwmWrite(PWM_PIN_CHANGE, 84);
} else if (gval <= 110) {
pwmWrite(PWM_PIN_CHANGE, 85);
} else if (gval <= 120) {
pwmWrite(PWM_PIN_CHANGE, 86);
} else if (gval <= 130) {
pwmWrite(PWM_PIN_CHANGE, 87);
} else if (gval <= 140) {
pwmWrite(PWM_PIN_CHANGE, 88);
} else if (gval <= 150) {
pwmWrite(PWM_PIN_CHANGE, 89);
} else if (gval <= 160) {
pwmWrite(PWM_PIN_CHANGE, 90);
} else if (gval <= 170) {
pwmWrite(PWM_PIN_CHANGE, 91);
} else if (gval <= 180) {
pwmWrite(PWM_PIN_CHANGE, 92);
} else if (gval <= 190) {
pwmWrite(PWM_PIN_CHANGE, 93);
} else if (gval <= 200) {
pwmWrite(PWM_PIN_CHANGE, 94);
}
}else if(gval >90){
int flont_speed = 82+(gval-70)/10+b;
if(flont_speed>95) flont_speed = 95;
pwmWrite(PWM_PIN_CHANGE, flont_speed);
}
}
void car0104_lift(unsigned char gval) {
int b=5;
if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75);
} else if (gval <= 55) {
pwmWrite(PWM_PIN_CHANGE, 71);
} else if (gval <= 60) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 65) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 70) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 75) {
pwmWrite(PWM_PIN_CHANGE, 69);
} else if (gval <= 90) {
}else if (gval <= 90) {
pwmWrite(PWM_PIN_CHANGE, 68);
} else if (gval <= 100) {
pwmWrite(PWM_PIN_CHANGE, 68);
} else if (gval <= 110) {
pwmWrite(PWM_PIN_CHANGE, 66);
} else if (gval <= 120) {
pwmWrite(PWM_PIN_CHANGE, 65);
} else if (gval <= 130) {
pwmWrite(PWM_PIN_CHANGE, 64);
} else if (gval <= 140) {
pwmWrite(PWM_PIN_CHANGE, 62);
} else if (gval <= 150) {
pwmWrite(PWM_PIN_CHANGE, 60);
} else if (gval <= 160) {
pwmWrite(PWM_PIN_CHANGE, 59);
} else if (gval <= 170) {
pwmWrite(PWM_PIN_CHANGE, 58);
} else if (gval <= 180) {
pwmWrite(PWM_PIN_CHANGE, 57);
} else if (gval <= 190) {
pwmWrite(PWM_PIN_CHANGE, 56);
} else if (gval <= 200) {
pwmWrite(PWM_PIN_CHANGE, 55);
} else if(gval >90){
int back_speed = 68 - (gval-70)/10-b;
if(back_speed<55) back_speed =55;
pwmWrite(PWM_PIN_CHANGE, back_speed);
}
}
......
......@@ -16,11 +16,11 @@ void tank0206_mode_lift_flont(unsigned char gval) {
else if (gval <= 55) {
pwmWrite(PWM_PIN_SPEED, 80);
}else if (gval <= 90) {
pwmWrite(PWM_PIN_SPEED, 79);
pwmWrite(PWM_PIN_SPEED, 80);
}else if (gval <= 100) {
pwmWrite(PWM_PIN_SPEED, 79);
pwmWrite(PWM_PIN_SPEED, 80);
}else if(gval >100){
int flont_speed = 79+(gval-70)/10+b;
int flont_speed = 80+(gval-70)/10+b;
if(flont_speed>95) flont_speed = 95;
pwmWrite(PWM_PIN_SPEED, flont_speed);
}
......@@ -33,11 +33,11 @@ void tank0206_mode_lift_back(unsigned char gval) {
} else if (gval <= 60) {
pwmWrite(PWM_PIN_SPEED, 70);
}else if (gval <= 90) {
pwmWrite(PWM_PIN_SPEED, 71);
pwmWrite(PWM_PIN_SPEED, 70);
}else if (gval <= 100) {
pwmWrite(PWM_PIN_SPEED, 71);
pwmWrite(PWM_PIN_SPEED, 70);
} else if(gval >100){
int back_speed = 71 - (gval-70)/10-b;
int back_speed = 70 - (gval-70)/10-b;
if(back_speed<55) back_speed =55;
pwmWrite(PWM_PIN_SPEED, back_speed);
}
......@@ -80,7 +80,7 @@ void tank0206_change(unsigned char *buf) {
if(mode == 1 ) {
//tank0203_mode_lift_flont(val);
tank0206_mode_right_flont(val);
tank0206_mode_right_flont(val);
modecount_tank0206=0;
}else if(mode == 2 ) {
//tank0203_mode_lift_back(val);
......@@ -91,12 +91,12 @@ void tank0206_change(unsigned char *buf) {
if((mode == 1||mode ==2)&&val == 0) modecount_tank0206=0;
if(mode == 3) {
if(modecount_tank0206 == 0) tank0206_mode_lift_flont(val);
if(modecount_tank0206 == 1) tank0206_mode_lift_back(val);
if(modecount_tank0206 == 0) tank0206_mode_lift_flont(val+10);
if(modecount_tank0206 == 1) tank0206_mode_lift_back(val+10);
}else if(mode == 4) {
if(modecount_tank0206 == 0) tank0206_mode_lift_back(val);
if(modecount_tank0206 == 1) tank0206_mode_lift_flont(val);
if(modecount_tank0206 == 0) tank0206_mode_lift_back(val+10);
if(modecount_tank0206 == 1) tank0206_mode_lift_flont(val+10);
}
}
......
......@@ -17,18 +17,21 @@ void tank_shot_back(unsigned char gval) {
int b=0;
if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0203) pwmWrite(PWM_PIN_SPEED, 75);
pwmWrite(PWM_PIN_SPEED, 75);
}else if (gval <= 60) {
pwmWrite(PWM_PIN_CHANGE, 79);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0202) pwmWrite(PWM_PIN_CHANGE, 71);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0203) pwmWrite(PWM_PIN_CHANGE, 79);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0203) pwmWrite(PWM_PIN_SPEED, 71);
}else if (gval <= 70) {
pwmWrite(PWM_PIN_CHANGE, 80);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0202) pwmWrite(PWM_PIN_CHANGE, 70);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0203)pwmWrite(PWM_PIN_CHANGE, 80);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0203) pwmWrite(PWM_PIN_SPEED, 70);
}else if(gval >70){
int change_1 = 80+(gval-70)/10+b;
int speed_2= 70 - (gval-70)/10-b;
if(g_tank_common_config_t->device_id ==DEVICE_TANK0202) pwmWrite(PWM_PIN_CHANGE, speed_2);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0203) pwmWrite(PWM_PIN_SPEED, speed_2);
pwmWrite(PWM_PIN_CHANGE, change_1);
if(g_tank_common_config_t->device_id ==DEVICE_TANK0203) pwmWrite(PWM_PIN_CHANGE, change_1);
}
}
......
......@@ -116,7 +116,7 @@ void device_init(int device_id) {
// 执行初始化流程
if(get_array_length(config->gpio_pins)==TRUE)init_gpiowpi(config->gpio_pins); // GPIO初始化
if(get_array_length(config->gpio_pins)==TRUE)init_gpiopwm(config->gpio_pwms); // GPIOsoft_pwm初始化
if(get_array_length(config->gpio_pins)==TRUE)init_gpiopwm(config->gpio_pwms); // GPIOsoft_pwm初始化
config->device_pwm_init(); // PWM初始化
config->device_control_stop(); // 速度控制初始化
g_device_type =config->emergency_code;
......
......@@ -7,6 +7,9 @@
#include "http_request.h"
#include "delay.h"
#define GPIO_ID_THREAD_COUNT 2
int gpio_device_id[GPIO_ID_THREAD_COUNT]={DEVICE_TANK0202,DEVICE_TANK0203};
const gpiocontrol_t *gpio_control_config_t = NULL ;
......@@ -16,6 +19,9 @@ static bool s_poll_tank_index =0;
void public_pin_value(int pin,int value);
void car0103_pin_value(int pin,int value);
void car0104_pin_value(int pin,int value);
void public_pwm_value(int pin ,int value);
void tank0202_pwm_value(int pin,int value);
void tank0203_pwm_value(int pin,int value);
......@@ -69,12 +75,12 @@ const gpiocontrol_t gpio_configs[] = {
},
{
.device_id = DEVICE_CAR0103,
.device_pin_value =public_pin_value,
.device_pin_value =car0103_pin_value,
.device_pwm_value =public_pwm_value
},
{
.device_id = DEVICE_CAR0104,
.device_pin_value =public_pin_value,
.device_pin_value =car0104_pin_value,
.device_pwm_value =public_pwm_value
},
{
......@@ -114,12 +120,12 @@ void device_gpio_control(int device_id,int pin,int val) {
break;
}
}
if(gpio_control_config_t&&
(device_id ==DEVICE_TANK0202 || device_id ==DEVICE_TANK0203))
{
my_zlog_info("线程函数:%d\n", device_id);
gpio_control_config_t->device_gpio_pthread_create(); //创建线程,线程关闭在tank.common.h中何tank需要的其他线程关闭
for(int i=0;i<GPIO_ID_THREAD_COUNT;i++ ){
if(gpio_control_config_t&&device_id == gpio_device_id[i]){
my_zlog_info("线程函数:%d\n", device_id);
gpio_control_config_t->device_gpio_pthread_create(); //创建线程,线程关闭在tank.common.h中何tank需要的其他线程关闭
}
}
}
......@@ -150,6 +156,40 @@ void public_pin_value(int pin,int value) { //引脚控制
}
/*挖机pin控制*/
void car0103_pin_value(int pin,int value){
if(pin == 26 && value==1) {
public_pin_value(27,1);
public_pin_value(pin,value);
}else if(pin == 26 && value==0){
public_pin_value(27,0);
public_pin_value(pin,value);
}else if(pin == 253 && value==1){
public_pin_value(27,0);
public_pin_value(26,1);
public_pin_value(24,1);
}else if(pin == 254 && value==1){
public_pin_value(27,1);
public_pin_value(26,0);
public_pin_value(24,0);
}else if((pin == 254||pin == 253) && value==0){
public_pin_value(27,0);
public_pin_value(26,0);
public_pin_value(24,0);
}else {
public_pin_value(pin,value);
}
}
/*推土机pin控制*/
void car0104_pin_value(int pin,int value){
if(pin==24){
public_pin_value(26,value);
}else if(pin==26){
public_pin_value(24,value);
}else public_pin_value(pin,value);
}
void public_pwm_value(int pin ,int value){
for(int i = 0 ; i <= g_gpio_softpwmcount ; i++) {
if(pin == g_gpioPwm[i]) {
......@@ -191,7 +231,7 @@ void tank0202_pwm_value(int pin,int value) { //软件陪我们控制调速
if(value==1) {
if(pin == 27){
softPwmWrite(pin, 45);
softPwmWrite(pin, 30);
} else {
softPwmWrite(pin, 40);
my_zlog_debug("pwm:%d",pin);
......@@ -216,7 +256,7 @@ void tank0203_pwm_value(int pin,int value) { //软件陪我们控制调速
if(value==1) {
if(pin == 27){
softPwmWrite(pin, 45);
softPwmWrite(pin, 38);
} else {
softPwmWrite(pin, 35);
my_zlog_debug("pwm:%d",pin);
......
......@@ -107,9 +107,9 @@ void audioplay_cycle(){
int audio_init() {
int adino_jude = system("pactl load-module module-alsa-source device=hw:2,0");
int adino_jude = system("pactl load-module module-alsa-sink device=hw:2,0");
delay_s(3);
int adino_play_jude =system("pactl load-module module-alsa-sink device=hw:2,0");
int adino_play_jude =system("pactl load-module module-alsa-source device=hw:2,0");
if (adino_jude == 0 && adino_play_jude==0 ) {
my_zlog_debug("命令执行成功!");
......
#ifndef BROWSER_OPEN_H__
#define BROWSER_OPEN_H__
/*打开摄像头函数,当MODE为1时候为国内网址,2时为国外网址*/
/*打开摄像头函数,当MODE为1时候为国内网址,2时为泰国网址*/
#define BROWSER_MODE 1
int opencamsh();
......
......@@ -6,13 +6,15 @@
//extern ThreadPool *pool;
/*2为国外1为国内*/
#define MQTT_IPMODE 1 // 或通过编译选项 -DMODE=1 指定
/*2为泰国1为国内,3为中东*/
#define MQTT_IPMODE 1 // 或通过编译选项 -DMODE=1 指定
#if MQTT_IPMODE == 1
#define BROKER_ADDRESS "119.45.167.177"
#elif MQTT_IPMODE == 2
#define BROKER_ADDRESS "mqtt.luckycar.top"
#elif MQTT_IPMODE == 3
#define BROKER_ADDRESS "47.91.125.224"
#else
#define BROKER_ADDRESS "127.0.0.1" // 默认地址
......
......@@ -15,4 +15,5 @@ extern int g_verify_index;//判断是否验证成功
int receive_jwt(cJSON *body);//jwt验证
int message2006_verify(cJSON *body);
#endif
\ No newline at end of file
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