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
8d4e52b7
Commit
8d4e52b7
authored
Sep 18, 2025
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了船的射击根水坦克一样
parent
634d5df3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
36 deletions
+102
-36
version.h
build/include/version.h
+1
-1
main
build/main
+0
-0
ship0301_control.c
drivers/devicecontrol/ship0301_control.c
+82
-31
gpio_control.c
drivers/gpio/gpio_control.c
+3
-2
mqtt_infor_handle.c
modules/mqtt/mqtt_infor_handle.c
+16
-2
No files found.
build/include/version.h
View file @
8d4e52b7
#define PROJECT_VERSION_MAJOR 1
#define PROJECT_VERSION_MINOR 2
#define PROJECT_VERSION_PATCH 1
1
#define PROJECT_VERSION_PATCH 1
2
#define GIT_HASH ""
#define BUILD_TIMESTAMP ""
#define BUILD_USER ""
build/main
View file @
8d4e52b7
No preview for this file type
drivers/devicecontrol/ship0301_control.c
View file @
8d4e52b7
...
...
@@ -68,43 +68,93 @@ void ship0301_mode_right_flont(unsigned char gval) {
}
}
int
ship0301_change_grading
(
int
mode
){
int
mode_val
=
0
;
switch
(
mode
){
case
2
:
mode_val
=
10
;
break
;
case
3
:
mode_val
=
20
;
break
;
case
4
:
mode_val
=
30
;
break
;
case
5
:
mode_val
=
50
;
break
;
default
:
break
;
}
return
mode_val
;
}
void
ship0301_change
(
unsigned
char
*
buf
)
{
unsigned
char
type
=
buf
[
0
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
static
int
modecount_ship0301
;
static
bool
ship0301_steer_t
=
0
;
if
(
mode
==
1
)
{
//mode_lift_flont(val);
ship0301_mode_lift_flont
(
val
);
ship0301_mode_right_flont
(
val
);
modecount_ship0301
=
0
;
ship0301_steer_t
=
1
;
}
else
if
(
mode
==
2
)
{
//mode_lift_back(val);
ship0301_mode_lift_flont
(
val
);
ship0301_mode_right_back
(
val
);
modecount_ship0301
=
1
;
ship0301_steer_t
=
1
;
}
static
int
ship0301_steering_t
=
0
;
static
int
ship0301_front_t
=
0
;
static
int
ship0301_front_val
=
0
;
static
int
ship0301_steering_val
=
0
;
if
((
mode
==
1
||
mode
==
2
)
&&
val
==
0
)
{
modecount_ship0301
=
0
;
ship0301_steer_t
=
0
;
int
ship0301_count
=
40
;
if
(
type
!=
1
)
ship0301_count
=
ship0301_change_grading
(
type
);
if
((
mode
==
1
||
mode
==
2
)
&&
val
==
0
)
ship0301_front_t
=
0
;
if
((
mode
==
3
||
mode
==
4
)
&&
val
==
0
)
ship0301_steering_t
=
0
;
if
(
mode
==
1
&&
val
!=
0
)
{
ship0301_front_val
=
val
;
ship0301_front_t
=
1
;
}
else
if
(
mode
==
2
&&
val
!=
0
)
{
ship0301_front_t
=
2
;
ship0301_front_val
=
val
;
}
if
(
mode
==
3
)
{
if
(
modecount_ship0301
==
0
)
{
if
(
ship0301_steer_t
==
0
)
ship0301_mode_right_flont
(
val
+
35
);
ship0301_mode_lift_flont
(
0
);
}
if
(
modecount_ship0301
==
1
)
ship0301_mode_right_back
(
0
);
}
else
if
(
mode
==
4
)
{
if
(
modecount_ship0301
==
0
)
{
if
(
ship0301_steer_t
==
0
)
ship0301_mode_lift_flont
(
val
+
35
);
ship0301_mode_right_flont
(
0
);
}
if
(
modecount_ship0301
==
1
)
ship0301_mode_lift_back
(
0
);
}
if
(
mode
==
3
&&
val
!=
0
)
{
ship0301_steering_t
=
1
;
ship0301_steering_val
=
val
;
}
else
if
(
mode
==
4
&&
val
!=
0
)
{
ship0301_steering_t
=
2
;
ship0301_steering_val
=
val
;
}
if
(
ship0301_front_t
==
0
&&
ship0301_steering_t
==
0
){
ship0301_mode_lift_flont
(
0
);
ship0301_mode_right_flont
(
0
);
}
else
if
(
ship0301_front_t
==
1
&&
ship0301_steering_t
==
0
){
ship0301_mode_lift_flont
(
ship0301_front_val
);
ship0301_mode_right_flont
(
ship0301_front_val
);
}
else
if
(
ship0301_front_t
==
2
&&
ship0301_steering_t
==
0
){
ship0301_mode_lift_back
(
ship0301_front_val
);
ship0301_mode_right_back
(
ship0301_front_val
);
}
else
if
(
ship0301_front_t
==
0
&&
ship0301_steering_t
==
1
){
ship0301_mode_right_flont
(
ship0301_steering_val
+
ship0301_count
);
ship0301_mode_lift_flont
(
0
);
}
else
if
(
ship0301_front_t
==
0
&&
ship0301_steering_t
==
2
){
ship0301_mode_right_flont
(
0
);
ship0301_mode_lift_flont
(
ship0301_steering_val
+
ship0301_count
+
10
);
}
else
if
(
ship0301_front_t
==
1
&&
ship0301_steering_t
==
1
){
ship0301_mode_right_flont
(
ship0301_steering_val
+
ship0301_count
+
10
);
ship0301_mode_lift_flont
(
ship0301_count
+
15
);
}
else
if
(
ship0301_front_t
==
1
&&
ship0301_steering_t
==
2
){
ship0301_mode_right_flont
(
ship0301_count
+
15
);
ship0301_mode_lift_flont
(
ship0301_steering_val
+
ship0301_count
+
10
);
}
else
if
(
ship0301_front_t
==
2
&&
ship0301_steering_t
==
1
){
ship0301_mode_lift_back
(
ship0301_count
+
15
);
ship0301_mode_right_back
(
ship0301_steering_val
+
ship0301_count
+
10
);
}
else
if
(
ship0301_front_t
==
2
&&
ship0301_steering_t
==
2
){
ship0301_mode_lift_back
(
ship0301_steering_val
+
ship0301_count
+
10
);
ship0301_mode_right_back
(
ship0301_count
+
15
);
}
}
\ No newline at end of file
drivers/gpio/gpio_control.c
View file @
8d4e52b7
...
...
@@ -452,17 +452,18 @@ void ship0301_pwm_value(int pin,int value) { //软件陪我们控制调速
if
(
value
==
1
)
{
if
(
pin
==
27
){
softPwmWrite
(
pin
,
50
);
softPwmWrite
(
26
,
35
);
}
else
{
softPwmWrite
(
pin
,
35
);
my_zlog_debug
(
"pwm:%d"
,
pin
);
}
}
else
if
(
value
==
0
)
{
if
(
pin
==
27
)
softPwmWrite
(
26
,
0
);
softPwmWrite
(
pin
,
0
);
my_zlog_debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_debug
(
"
ship
0301 pwm"
);
my_zlog_debug
(
"
tank
0301 pwm"
);
}
...
...
modules/mqtt/mqtt_infor_handle.c
View file @
8d4e52b7
...
...
@@ -86,6 +86,7 @@ void heartbeat_send() {
//角度发送
void
angle_mqtt_send
()
{
static
int
angle_i
=
0
;
static
double
record_angle_t
=
0
;
cJSON
*
root
=
cJSON_CreateObject
();
char
TOPIC_send_angle
[
26
];
double
rounded_angle
=
tank_angle
();
...
...
@@ -98,7 +99,11 @@ void angle_mqtt_send() {
my_zlog_debug
(
"%s"
,
payload
);
angle_i
=
0
;
}
mosquitto_publish
(
mosq
,
NULL
,
TOPIC_send_angle
,
strlen
(
payload
),
payload
,
0
,
false
);
if
(
fabs
(
rounded_angle
-
record_angle_t
)
>
3
){
mosquitto_publish
(
mosq
,
NULL
,
TOPIC_send_angle
,
strlen
(
payload
),
payload
,
0
,
false
);
}
record_angle_t
=
rounded_angle
;
cJSON_Delete
(
root
);
// 释放 cJSON 对象
}
...
...
@@ -110,7 +115,16 @@ void mqtt_beat_wirte(){
heartbeat_send
();
g_heartbeat_count
=
0
;
}
if
(
g_device_type
==
DEVICE_TANK0202
||
g_device_type
==
DEVICE_TANK0203
)
angle_mqtt_send
();
switch
(
g_device_type
)
{
case
DEVICE_TANK0202
:
case
DEVICE_TANK0203
:
case
DEVICE_TANK0204
:
angle_mqtt_send
();
break
;
default
:
break
;
}
}
...
...
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