Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
car-controlserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenzhongjian
car-controlserver
Commits
ee329e98
You need to sign in or sign up before continuing.
Commit
ee329e98
authored
May 21, 2025
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:加入了发炮后坐力
parent
2842a9b4
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
23 deletions
+36
-23
version.h
build/include/version.h
+1
-1
main
build/main
+0
-0
mqtt.c
src/mqtt.c
+2
-4
thread_main.c
src/thread_main.c
+2
-2
gpio_common.c
system/gpio/gpio_common.c
+1
-0
gpio_common.h
system/gpio/gpio_common.h
+7
-6
gpio_pwm_tank0202.c
system/gpio/gpio_pwm_tank0202.c
+20
-10
main.c
usr/main.c
+3
-0
No files found.
build/include/version.h
View file @
ee329e98
...
...
@@ -2,5 +2,5 @@
#define PROJECT_VERSION_MINOR 1
#define PROJECT_VERSION_PATCH 2
#define GIT_HASH ""
#define BUILD_TIMESTAMP "2025-05-
19T12:32:09
"
#define BUILD_TIMESTAMP "2025-05-
20T12:37:15
"
#define BUILD_USER "orangepi"
build/main
View file @
ee329e98
No preview for this file type
src/mqtt.c
View file @
ee329e98
...
...
@@ -80,9 +80,7 @@ void mqtt_wirte(){//心跳格式,每5s一次心跳
char
current_str
[
20
];
// 足够存储转换后的字符串的缓冲区
sprintf
(
current_str
,
"%.2f"
,
current
);
if
(
AppExit_pin_pwm
!=
102
||
AppExit_pin_pwm
!=
202
||
AppExit_pin_pwm
!=
301
||
AppExit_pin_pwm
!=
401
)
{
alarm_control
(
voltage
);
//判断电压警报
}
if
(
gPwmCount
>=
5
)
alarm_control
(
voltage
);
//判断电压警报
/*读取程序版本号*/
char
*
version_num
=
program_version
();
...
...
@@ -298,7 +296,7 @@ void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_messag
device_mqttchange_name
(
device_id
);
my_zlog_debug
(
"接收到设备号更改"
);
}
else
{
// 提取 head 对象
if
(
download_message
(
json
)
!=
1
)
my_zlog_debug
(
"接收到dowwnload下载"
);
if
(
download_message
(
json
)
==
0
)
my_zlog_debug
(
"接收到dowwnload下载"
);
if
(
device_message
(
json
)
!=
0
)
my_zlog_debug
(
"没有接收到控制信息,代码编号:%d"
,
device_message
(
json
));
}
// 释放 payload 字符串
...
...
src/thread_main.c
View file @
ee329e98
...
...
@@ -95,9 +95,9 @@ void *Mqtt_onnect(void *arg) {//mqtt异常处理,断开自动重连,简单
void
*
delay_count
(
void
*
arg
)
{
//专门用于计时的线程
while
(
1
)
{
Delay_Ms
(
0
,
1
);
Delay_Ms
(
0
,
5
);
device_delay_count
++
;
if
(
device_delay_count
>=
10000
)
device_delay_count
=
10
000
;
if
(
device_delay_count
>=
5000
)
device_delay_count
=
5
000
;
}
}
...
...
system/gpio/gpio_common.c
View file @
ee329e98
...
...
@@ -44,6 +44,7 @@ void init_gpioPwm(int *values_pwm) {
void
pin_all_default
()
{
//全部至低电平,车和坦克共用
for
(
int
i
=
0
;
i
<
gpioCount
;
i
++
)
{
if
(
gpioWPi
[
i
]
==
16
||
gpioWPi
[
i
]
==
20
||
gpioWPi
[
i
]
==
22
)
continue
;
digitalWrite
(
gpioWPi
[
i
],
LOW
);
}
}
...
...
system/gpio/gpio_common.h
View file @
ee329e98
/*
此文件为通用文件,一般用于50hz的驱动等和引脚高低,适合车和船使用,
如果有其他需求,此文件就不需要使用
*/
#ifndef GPIO_COMMON_H__
#define GPIO_COMMON_H__
extern
int
device_delay_count
;
//延时计算函数,使用前必须置0
// 定义 PWM 引脚的 WiringPi 编号
#define PWM_PIN_SPEED 21
#define PWM_PIN_CHANGE 2
extern
int
device_delay_count
;
//延时计算函数,使用前必须置0
void
Device_exit_end
();
//main最后结束需要调用的函数
...
...
@@ -22,7 +28,3 @@ void pwm_init_speed();
void
pwm_value
(
int
pin
,
int
value
);
//软件陪我们控制调速
#endif
/*
此文件为通用文件,一般用于50hz的驱动等和引脚高低,适合车和船使用,
如果有其他需求,此文件就不需要使用
*/
\ No newline at end of file
system/gpio/gpio_pwm_tank0202.c
View file @
ee329e98
...
...
@@ -10,9 +10,6 @@ int tank0202_middle() {
return
0
;
}
long
long
shot_device_time_start
;
long
long
shot_device_time_end
=
0
;
void
mode_lift_flont
(
unsigned
char
gval
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -199,6 +196,9 @@ int tank0202_change(unsigned char *buf) {
}
long
long
shot_device_time_start
=
0
;
long
long
shot_device_time_end
=
0
;
// 函数功能:获取当前精确到毫秒的时间戳
// 返回值:当前时间的毫秒数
long
long
get_current_time_millis
()
{
...
...
@@ -213,11 +213,16 @@ long long get_current_time_millis() {
}
void
tank_shot_back_stop_task_function
(
void
*
arg
)
{
if
(
device_delay_count
>=
20
&&
device_delay_count
<=
40
)
{
while
(
1
){
long
long
interval
=
shot_device_time_start
-
shot_device_time_end
;
if
(
device_delay_count
>
10
&&
device_delay_count
<=
25
)
mode_right_back
(
0
);
if
(
interval
>
100
){
if
(
device_delay_count
<=
10
)
{
mode_right_back
(
80
);
my_zlog_debug
(
"操作耗时: %lld 毫秒"
,
interval
);
}
if
(
device_delay_count
>
40
)
{
mode_right_back
(
0
);
}
}
}
...
...
@@ -228,15 +233,15 @@ void tank_shot_back_stop_task_end(){
int
tank_shot_back_stop
(
int
pin
,
int
val
){
static
int
shot_count
=
0
;
shot_device_time_start
=
get_current_time_millis
();
if
(
pin
!=
27
){
my_zlog_debug
(
"非27引脚
\n
"
);
my_zlog_debug
(
"非27引脚"
);
return
1
;
}
if
(
val
==
0
)
{
mode_right_back
(
0
);
shot_count
=
1
;
shot_count
=
2
;
//thread_pool_destroy(pool);
}
if
(
val
!=
0
)
{
...
...
@@ -244,10 +249,14 @@ int tank_shot_back_stop(int pin,int val){
int
arg
=
1
;
pool_tank
=
thread_pool_init
(
1
,
1
);
thread_pool_add_task
(
pool_tank
,
tank_shot_back_stop_task_function
,
&
arg
);
my_zlog_debug
(
"线程池打开"
);
shot_count
=
1
;
}
if
(
shot_count
==
1
){
}
shot_count
=
1
;
if
(
shot_count
==
1
){
device_delay_count
=
0
;
}
}
shot_device_time_end
=
get_current_time_millis
();
}
\ No newline at end of file
usr/main.c
View file @
ee329e98
...
...
@@ -69,6 +69,8 @@ int main(int argc, char *argv[]) {
my_zlog_info
(
"程序关闭成功"
);
my_log_close
();
//关闭日志
Device_exit_end
();
//结束相应的设备的程序执行
//printf("程序关闭成功\n");
return
EXIT_SUCCESS
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment