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
066bebf9
Commit
066bebf9
authored
Oct 17, 2025
by
957dd
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/self_control' into 'master'
加入了自控模式 See merge request
!75
parents
f71fe029
8d95ee6d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
29 deletions
+87
-29
main
build/main
+0
-0
gpio_control.c
drivers/gpio/gpio_control.c
+41
-1
self_devicecontrol.c
drivers/selfcontrol/self_devicecontrol.c
+46
-28
No files found.
build/main
View file @
066bebf9
No preview for this file type
drivers/gpio/gpio_control.c
View file @
066bebf9
...
...
@@ -13,6 +13,7 @@ const gpiocontrol_t *gpio_control_config_t = NULL ;//gpio结构体标识
ThreadPool_t
*
g_pool_device_gpio_control_t
;
//gpio限位线程池标识,只在特地设备中打开
void
public_pin_value
(
int
pin
,
int
value
);
void
car0102_pin_value
(
int
pin
,
int
value
);
void
car0103_pin_value
(
int
pin
,
int
value
);
void
car0104_pin_value
(
int
pin
,
int
value
);
...
...
@@ -160,7 +161,7 @@ const gpiocontrol_t gpio_configs[] = {
{
.
device_id
=
DEVICE_CAR0102
,
.
category_id
=
LAND_CAR
,
.
device_pin_value
=
public
_pin_value
,
.
device_pin_value
=
car0102
_pin_value
,
.
device_pwm_value
=
public_pwm_value
},
{
...
...
@@ -272,6 +273,45 @@ void public_pin_value(int pin,int value) { //引脚控制
}
/*
* @brief 小车pin控制
*/
void
car0102_pin_value
(
int
pin
,
int
value
)
{
//引脚控制
for
(
int
i
=
0
;
i
<=
g_gpiocount
;
i
++
)
{
if
(
pin
==
g_gpiowpi
[
i
])
{
break
;
}
if
(
i
==
g_gpiocount
)
{
return
;
}
}
if
(
value
==
1
)
{
digitalWrite
(
pin
,
HIGH
);
if
(
pin
==
26
){
static
int
i
=
0
;
i
++
;
if
(
i
>
10
)
{
my_zlog_info
(
"pin:%d,%d"
,
pin
,
HIGH
);
i
=
0
;
}
return
;
}
my_zlog_info
(
"pin:%d,%d"
,
pin
,
HIGH
);
}
else
if
(
value
==
0
)
{
digitalWrite
(
pin
,
LOW
);
if
(
pin
==
26
){
static
int
i
=
0
;
i
++
;
if
(
i
>
10
)
{
my_zlog_info
(
"pin:%d,%d"
,
pin
,
HIGH
);
i
=
0
;
}
return
;
}
my_zlog_info
(
"pin:%d,%d"
,
pin
,
LOW
);
}
}
/*挖机pin控制*/
void
car0103_pin_value
(
int
pin
,
int
value
){
if
(
pin
==
26
&&
value
==
1
)
{
...
...
drivers/selfcontrol/self_devicecontrol.c
View file @
066bebf9
...
...
@@ -68,14 +68,17 @@ void self_device_control_task(){
int
time_now
=
g_self_control_time_count
*
20
;
if
(
i
>
=
g_self_device_control_date
->
id_run_count
){
if
(
i
>
g_self_device_control_date
->
id_run_count
){
if
(
g_self_control_interval
<
time_now
){
if
(
g_self_control_interval
>
time_now
){
return
;
}
g_self_control_time_count
=
0
;
//将计时重置
i
=
0
;
}
time_now
=
g_self_control_time_count
*
20
;
if
(
time_now
>
g_self_device_control_date
->
run_cool
[
i
]
&&
time_now
<=
(
g_self_device_control_date
->
run_cool
[
i
]
+
g_self_device_control_date
->
timed_run
[
i
]))
{
...
...
@@ -86,11 +89,12 @@ void self_device_control_task(){
if
(
valt
[
2
]
>
2
)
device_walk_control
(
g_device_type
,
valt
);
else
if
(
valt
[
2
]
<=
2
)
device_gpio_control
(
g_device_type
,
valt
[
1
],
valt
[
2
]);
my_zlog_debug
(
"date:%d"
,
g_automatic_date_t
[
g_self_device_control_date
->
id_run
[
i
]].
action_count
);
my_zlog_debug
(
"m
ode:%d"
,
g_automatic_date_t
[
g_self_device_control_date
->
id_run
[
i
]].
mode
[
j
]);
my_zlog_debug
(
"val:%d"
,
g_automatic_date_t
[
g_self_device_control_date
->
id_run
[
i
]].
val
[
j
]);
my_zlog_debug
(
"m
:%d,v:%d"
,
valt
[
1
],
valt
[
2
]);
}
}
else
if
(
time_now
>
(
g_self_device_control_date
->
run_cool
[
i
]
+
g_self_device_control_date
->
timed_run
[
i
]))
{
...
...
@@ -100,8 +104,9 @@ void self_device_control_task(){
pthread_mutex_lock
(
&
g_self_control_time_count_mutex
);
g_self_control_time_count
=
0
;
//将计时重置
pthread_mutex_unlock
(
&
g_self_control_time_count_mutex
);
i
=
i
+
1
;
++
i
;
}
}
...
...
@@ -267,7 +272,7 @@ void receive_self_contorl_mqtt(cJSON *body){
for
(
int
i
=
0
;
i
<
size
&&
i
<
DEVICE_WALK_SIGN_MAX
;
i
++
)
{
cJSON
*
item
=
cJSON_GetArrayItem
(
id_run
,
i
);
g_self_device_control_date
->
id_run
[
i
]
=
item
->
valueint
;
g_self_device_control_date
->
id_run_count
++
;
g_self_device_control_date
->
id_run_count
=
i
;
}
}
...
...
@@ -311,35 +316,48 @@ void receive_self_contorl_date_mqtt(cJSON *body){
return
;
}
static
int
s_action_id
=
0
;
cJSON
*
switch_status
=
cJSON_GetObjectItem
(
body
,
"switch_status"
);
if
(
switch_status
==
NULL
)
return
;
static
int
s_switch_status
=
0
;
s_switch_status
=
switch_status
->
valueint
;
cJSON
*
action_id
=
cJSON_GetObjectItem
(
body
,
"action_id"
);
static
int
s_action_id
=
0
;
s_action_id
=
action_id
->
valueint
;
if
(
s_switch_status
==
1
){
// 2️ id_run 数组
cJSON
*
action_combination
=
cJSON_GetObjectItem
(
body
,
"action_combination"
);
if
(
cJSON_IsArray
(
action_combination
))
{
int
size
=
cJSON_GetArraySize
(
action_combination
);
for
(
int
i
=
0
;
i
<
size
&&
i
<
DEVICE_WALK_SIGN_MAX
;
i
++
)
{
cJSON
*
item
=
cJSON_GetArrayItem
(
action_combination
,
i
);
g_automatic_date_t
[
s_action_id
].
mode
[
i
]
=
item
->
valueint
;
}
}
cJSON
*
config
=
cJSON_GetObjectItem
(
body
,
"config"
);
if
(
config
==
NULL
)
return
;
if
(
cJSON_IsArray
(
config
))
{
int
config_size
=
cJSON_GetArraySize
(
config
);
for
(
int
i
=
0
;
i
<
config_size
&&
i
<
DEVICE_WALK_SIGN_MAX
;
i
++
)
{
cJSON
*
config_item
=
cJSON_GetArrayItem
(
config
,
i
);
cJSON
*
action_id
=
cJSON_GetObjectItemCaseSensitive
(
config_item
,
"action_id"
);
s_action_id
=
action_id
->
valueint
;
cJSON
*
action_array
=
cJSON_GetObjectItemCaseSensitive
(
config_item
,
"action"
);
if
(
cJSON_IsArray
(
action_array
)){
int
action_size
=
cJSON_GetArraySize
(
action_array
);
for
(
int
j
=
0
;
j
<
action_size
&&
j
<
DEVICE_WALK_SIGN_MAX
;
j
++
)
{
cJSON
*
item
=
cJSON_GetArrayItem
(
action_array
,
j
);
// 获取 combination 和 speed
cJSON
*
combination
=
cJSON_GetObjectItemCaseSensitive
(
item
,
"combination"
);
cJSON
*
speed
=
cJSON_GetObjectItemCaseSensitive
(
item
,
"speed"
);
g_automatic_date_t
[
s_action_id
].
mode
[
j
]
=
combination
->
valueint
;
g_automatic_date_t
[
s_action_id
].
val
[
j
]
=
speed
->
valueint
;
cJSON
*
action_speed
=
cJSON_GetObjectItem
(
body
,
"action_speed"
);
if
(
cJSON_IsArray
(
action_speed
))
{
int
size
=
cJSON_GetArraySize
(
action_speed
);
for
(
int
i
=
0
;
i
<
size
&&
i
<
DEVICE_WALK_SIGN_MAX
;
i
++
)
{
cJSON
*
item
=
cJSON_GetArrayItem
(
action_speed
,
i
);
g_automatic_date_t
[
s_action_id
].
action_count
++
;
g_automatic_date_t
[
s_action_id
].
val
[
i
]
=
item
->
valueint
;
g_automatic_date_t
[
s_action_id
].
action_count
++
;
my_zlog_debug
(
"combination:%d"
,
g_automatic_date_t
[
s_action_id
].
mode
[
j
]);
my_zlog_debug
(
"speed:%d"
,
g_automatic_date_t
[
s_action_id
].
val
[
j
]);
}
}
}
}
...
...
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