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
073c8e3f
Commit
073c8e3f
authored
Jul 23, 2025
by
学习的菜鸟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
313
parent
5eda44dc
Hide whitespace changes
Inline
Side-by-side
Showing
44 changed files
with
1367 additions
and
201 deletions
+1367
-201
device_id_change.h
app/device_change/device_id_change.h
+2
-1
device_fileopen.c
app/device_identity/device_fileopen.c
+9
-8
device_identity.c
app/device_identity/device_identity.c
+1
-2
main.c
app/main/main.c
+1
-4
main.h
app/main/main.h
+4
-3
pthread_open.c
app/main/pthread_open.c
+9
-9
Makefile
build/Makefile
+81
-0
main
build/main
+0
-0
progress.marks
build/third_party/mosquitto/CMakeFiles/progress.marks
+1
-1
progress.marks
build/third_party/mosquitto/apps/CMakeFiles/progress.marks
+1
-1
progress.make
...osquitto_ctrl/CMakeFiles/mosquitto_ctrl.dir/progress.make
+4
-4
progress.marks
...y/mosquitto/apps/mosquitto_ctrl/CMakeFiles/progress.marks
+1
-1
progress.make
...squitto/client/CMakeFiles/mosquitto_pub.dir/progress.make
+2
-2
progress.marks
build/third_party/mosquitto/client/CMakeFiles/progress.marks
+1
-1
progress.make
...y/mosquitto/lib/CMakeFiles/libmosquitto.dir/progress.make
+8
-8
progress.make
...itto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
+23
-23
progress.marks
build/third_party/mosquitto/lib/CMakeFiles/progress.marks
+1
-1
progress.make
...y/CMakeFiles/mosquitto_dynamic_security.dir/progress.make
+4
-4
progress.make
.../CMakeFiles/mosquitto_message_timestamp.dir/progress.make
+2
-2
progress.make
...arty/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
+49
-49
progress.marks
build/third_party/mosquitto/src/CMakeFiles/progress.marks
+1
-1
car0101_control.c
drivers/devicecontrol/car0101_control.c
+1
-0
car0102_control.c
drivers/devicecontrol/car0102_control.c
+187
-0
car0102_control.h
drivers/devicecontrol/car0102_control.h
+9
-0
car0103_control.c
drivers/devicecontrol/car0103_control.c
+196
-0
car0103_control.h
drivers/devicecontrol/car0103_control.h
+8
-0
car0104_control.c
drivers/devicecontrol/car0104_control.c
+185
-0
car0104_control.h
drivers/devicecontrol/car0104_control.h
+10
-0
ptz0401_control.c
drivers/devicecontrol/ptz0401_control.c
+136
-0
ptz0401_control.h
drivers/devicecontrol/ptz0401_control.h
+9
-0
tank02002_control.c
drivers/devicecontrol/tank02002_control.c
+274
-0
tank02002_control.h
drivers/devicecontrol/tank02002_control.h
+17
-0
device_init.c
drivers/gpio/device_init.c
+52
-48
device_init.h
drivers/gpio/device_init.h
+3
-1
gpio_init.c
drivers/gpio/gpio_init.c
+2
-2
fcsgdevintroduce.md
fcsgdevintroduce.md
+5
-2
common.h
include/common.h
+3
-0
devcontrol_common.h
include/devcontrol_common.h
+15
-1
browser_open.h
modules/browser/browser_open.h
+1
-1
device_time.c
modules/delay/device_time.c
+4
-0
device_time.h
modules/delay/device_time.h
+6
-0
mqtt_infor_handle.c
modules/mqtt/mqtt_infor_handle.c
+24
-20
mqtt_infor_handle.h
modules/mqtt/mqtt_infor_handle.h
+3
-0
mqtt_init.h
modules/mqtt/mqtt_init.h
+12
-1
No files found.
app/device_change/device_id_change.h
View file @
073c8e3f
...
...
@@ -6,6 +6,6 @@
#define DEVICE_NAME_FILE "/home/orangepi/car/master/Deviceld.txt"
int
device_changename_back
(
const
char
*
device_date
,
const
char
*
device_id
);
//设备号备份和写入新设备号
int
file_exists
(
const
char
*
path
);
//文件已经存在
int
create_directory_if_not_exists
(
const
char
*
path
);
//创建目录
//
int create_directory_if_not_exists(const char *path);//创建目录
char
*
read_device_back_fail
();
//读取失败,读取备份内容
#endif
\ No newline at end of file
app/device_identity/device_fileopen.c
View file @
073c8e3f
#include "device_fileopen.h"
#include "device_id_change.h"
#include "common.h"
#include "delay.h"
...
...
@@ -12,14 +13,14 @@ char *g_device_id = NULL;
char
*
device_inspect
()
{
FILE
*
file
;
static
char
s_buffer_device
[
30
];
// 用于存储文件内容
//
char *read_device_back_fail_middle=read_device_back_fail();
char
*
read_device_back_fail_middle
=
read_device_back_fail
();
while
(
1
)
{
file
=
fopen
(
FILENAME
,
"r"
);
// 以只读模式打开文件
if
(
file
==
NULL
)
{
//
if(read_device_back_fail_middle!=NULL) {//回退文件
//
return read_device_back_fail_middle;
//
}
if
(
read_device_back_fail_middle
!=
NULL
)
{
//回退文件
return
read_device_back_fail_middle
;
}
my_zlog_debug
(
"文件 %s 打开失败,等待中..."
,
FILENAME
);
}
else
{
...
...
@@ -30,10 +31,10 @@ char *device_inspect() {
my_zlog_debug
(
"读取到文件内容: %s"
,
s_buffer_device
);
return
s_buffer_device
;
}
else
{
//
if(read_device_back_fail_middle!=NULL) {
//
fclose(file);
//
return read_device_back_fail();
//
}
if
(
read_device_back_fail_middle
!=
NULL
)
{
fclose
(
file
);
return
read_device_back_fail
();
}
my_zlog_debug
(
"文件为空,等待中..."
);
}
fclose
(
file
);
...
...
app/device_identity/device_identity.c
View file @
073c8e3f
...
...
@@ -102,10 +102,9 @@ int hash_insert_init(HashTable_t *HashTable_t) {
int
device_judg
(
CodeEnum_t
code
,
char
*
sub_str
)
{
if
(
code
==
CAR_0101
)
{
device_init
(
DEVICE_CAR0101
);
my_zlog_info
(
"使用型号%s"
,
sub_str
);
}
else
if
(
code
==
CAR_0102
)
{
//car_Init_0102(
);
device_init
(
DEVICE_CAR0102
);
my_zlog_info
(
"使用型号%s"
,
sub_str
);
}
else
if
(
code
==
CAR_0103
)
{
//car_Init_0103();
...
...
app/main/main.c
View file @
073c8e3f
...
...
@@ -11,10 +11,6 @@ int main(){
return
-
2
;
}
if
(
wifi_change_sendmqtt_init
()
!=
0
){
my_zlog_error
(
"WIFI是否更改检查相关,不会到这一步,有问题会直接重启,可能会导致重启,不会因此造成程序停止"
);
}
if
(
device_id_file_init
()
!=
0
){
my_zlog_error
(
"设备id读取失败"
);
return
-
3
;
...
...
@@ -41,6 +37,7 @@ int main(){
int
thread_rc
=
thread_start_init
(
thread_exit_time
,
thread_mqtt_beat
,
thread_open_browser
,
thread_mqtt_reconnect
,
thread_time_calculation
,
thread_play_mp3
);
thread_end_close
();
device_close
();
my_log_close
();
//关闭日志
my_zlog_info
(
"程序关闭成功"
);
return
0
;
...
...
app/main/main.h
View file @
073c8e3f
...
...
@@ -6,9 +6,9 @@
#include "device_identity.h"
#include "pthread_open.h"
#include "http_request.h"
#include "device_wifi_change.h"
#include "softiic.h"
#include "INA226.h"
#include "devcontrol_common.h"
/*设备id读取初始化*/
int
device_id_file_init
();
...
...
@@ -26,8 +26,6 @@ int device_mqtt_topic_init();
int
ina225_init
();
/*wifi改变初始化,放在main开头,必须要等mqtt直播就绪才行*/
int
wifi_change_sendmqtt_init
();
/*线程初始化函数*/
int
thread_start_init
(
ThreadFunc
thread_exit_time
,
ThreadFunc
thread_mqtt_beat
,
...
...
@@ -40,6 +38,9 @@ int request_date();
/*线程关闭函数*/
void
thread_end_close
()
;
/*相关设备线程等关闭函数*/
void
device_close
();
/*关闭log日志记录*/
void
my_log_close
();
...
...
app/main/pthread_open.c
View file @
073c8e3f
...
...
@@ -5,12 +5,11 @@
#include "mqtt_infor_handle.h"
#include "browser_open.h"
#include "mqtt_verify.h"
//
#include "device_wifi_change.h"
#include "device_wifi_change.h"
#include "browser_open.h"
#include "device_init.h"
#include "audioplay.h"
pthread_t
g_thread
[
6
];
// 全局线程句柄数组(或传参)
int
g_webrtc_index
=
0
;
...
...
@@ -59,9 +58,13 @@ void *thread_mqtt_beat(void *arg) {
my_zlog_info
(
"thread_mqtt_beat start"
);
delay_s
(
5
);
g_webrtc_index
=
1
;
/*在这步进行检测,等mqtt连接成功后检查*/
if
(
wifi_change_sendmqtt_init
()
!=
0
){
my_zlog_error
(
"WIFI是否更改检查相关,不会到这一步,有问题会直接重启,可能会导致重启,不会因此造成程序停止"
);
}
while
(
1
)
{
if
(
device_type
==
202
)
delay_ms
(
45
);
if
(
device_type
!=
202
)
delay_ms
(
100
);
if
(
g_
device_type
==
202
)
delay_ms
(
45
);
if
(
g_
device_type
!=
202
)
delay_ms
(
100
);
g_heartbeat_count
++
;
if
(
g_mqtt_grc
==
0
){
...
...
@@ -85,13 +88,10 @@ void *thread_open_browser(void *arg) {
//mqtt异常处理,断开自动重连,简单粗暴
void
*
thread_mqtt_reconnect
(
void
*
arg
)
{
delay_s
(
5
);
if
(
mqtt_init
()
!=
0
)
{
my_zlog_fatal
(
"mqtt_init failed"
);
return
NULL
;
}
while
(
1
)
{
if
(
mosq
==
NULL
)
{
mqtt_init
();
...
...
@@ -124,10 +124,10 @@ void *thread_mqtt_reconnect(void *arg) {
void
*
thread_time_calculation
(
void
*
arg
)
{
while
(
1
)
{
delay_ms
(
5
);
//
device_delay_count++;//设备计时,坦克打击倒退逻辑
g_
device_delay_count
++
;
//设备计时,坦克打击倒退逻辑
g_verify_count
++
;
//验证计时,每15s一次
if
(
g_verify_count
>=
20000
)
g_verify_count
=
20000
;
//if(device_delay_count >= 5000)
device_delay_count = 5000;
if
(
g_device_delay_count
>=
5000
)
g_
device_delay_count
=
5000
;
}
return
NULL
;
}
...
...
build/Makefile
View file @
073c8e3f
...
...
@@ -606,6 +606,54 @@ drivers/devicecontrol/car0104_control.c.s:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/car0104_control.c.s
.PHONY
:
drivers/devicecontrol/car0104_control.c.s
drivers/devicecontrol/ptz0401_control.o
:
drivers/devicecontrol/ptz0401_control.c.o
.PHONY
:
drivers/devicecontrol/ptz0401_control.o
# target to build an object file
drivers/devicecontrol/ptz0401_control.c.o
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/ptz0401_control.c.o
.PHONY
:
drivers/devicecontrol/ptz0401_control.c.o
drivers/devicecontrol/ptz0401_control.i
:
drivers/devicecontrol/ptz0401_control.c.i
.PHONY
:
drivers/devicecontrol/ptz0401_control.i
# target to preprocess a source file
drivers/devicecontrol/ptz0401_control.c.i
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/ptz0401_control.c.i
.PHONY
:
drivers/devicecontrol/ptz0401_control.c.i
drivers/devicecontrol/ptz0401_control.s
:
drivers/devicecontrol/ptz0401_control.c.s
.PHONY
:
drivers/devicecontrol/ptz0401_control.s
# target to generate assembly for a file
drivers/devicecontrol/ptz0401_control.c.s
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/ptz0401_control.c.s
.PHONY
:
drivers/devicecontrol/ptz0401_control.c.s
drivers/devicecontrol/tank02002_control.o
:
drivers/devicecontrol/tank02002_control.c.o
.PHONY
:
drivers/devicecontrol/tank02002_control.o
# target to build an object file
drivers/devicecontrol/tank02002_control.c.o
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank02002_control.c.o
.PHONY
:
drivers/devicecontrol/tank02002_control.c.o
drivers/devicecontrol/tank02002_control.i
:
drivers/devicecontrol/tank02002_control.c.i
.PHONY
:
drivers/devicecontrol/tank02002_control.i
# target to preprocess a source file
drivers/devicecontrol/tank02002_control.c.i
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank02002_control.c.i
.PHONY
:
drivers/devicecontrol/tank02002_control.c.i
drivers/devicecontrol/tank02002_control.s
:
drivers/devicecontrol/tank02002_control.c.s
.PHONY
:
drivers/devicecontrol/tank02002_control.s
# target to generate assembly for a file
drivers/devicecontrol/tank02002_control.c.s
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank02002_control.c.s
.PHONY
:
drivers/devicecontrol/tank02002_control.c.s
drivers/gpio/device_init.o
:
drivers/gpio/device_init.c.o
.PHONY
:
drivers/gpio/device_init.o
...
...
@@ -894,6 +942,30 @@ modules/delay/delay.c.s:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/modules/delay/delay.c.s
.PHONY
:
modules/delay/delay.c.s
modules/delay/device_time.o
:
modules/delay/device_time.c.o
.PHONY
:
modules/delay/device_time.o
# target to build an object file
modules/delay/device_time.c.o
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/modules/delay/device_time.c.o
.PHONY
:
modules/delay/device_time.c.o
modules/delay/device_time.i
:
modules/delay/device_time.c.i
.PHONY
:
modules/delay/device_time.i
# target to preprocess a source file
modules/delay/device_time.c.i
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/modules/delay/device_time.c.i
.PHONY
:
modules/delay/device_time.c.i
modules/delay/device_time.s
:
modules/delay/device_time.c.s
.PHONY
:
modules/delay/device_time.s
# target to generate assembly for a file
modules/delay/device_time.c.s
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/modules/delay/device_time.c.s
.PHONY
:
modules/delay/device_time.c.s
modules/http/http_request.o
:
modules/http/http_request.c.o
.PHONY
:
modules/http/http_request.o
...
...
@@ -1624,6 +1696,12 @@ help:
@
echo
"... drivers/devicecontrol/car0104_control.o"
@
echo
"... drivers/devicecontrol/car0104_control.i"
@
echo
"... drivers/devicecontrol/car0104_control.s"
@
echo
"... drivers/devicecontrol/ptz0401_control.o"
@
echo
"... drivers/devicecontrol/ptz0401_control.i"
@
echo
"... drivers/devicecontrol/ptz0401_control.s"
@
echo
"... drivers/devicecontrol/tank02002_control.o"
@
echo
"... drivers/devicecontrol/tank02002_control.i"
@
echo
"... drivers/devicecontrol/tank02002_control.s"
@
echo
"... drivers/gpio/device_init.o"
@
echo
"... drivers/gpio/device_init.i"
@
echo
"... drivers/gpio/device_init.s"
...
...
@@ -1660,6 +1738,9 @@ help:
@
echo
"... modules/delay/delay.o"
@
echo
"... modules/delay/delay.i"
@
echo
"... modules/delay/delay.s"
@
echo
"... modules/delay/device_time.o"
@
echo
"... modules/delay/device_time.i"
@
echo
"... modules/delay/device_time.s"
@
echo
"... modules/http/http_request.o"
@
echo
"... modules/http/http_request.i"
@
echo
"... modules/http/http_request.s"
...
...
build/main
View file @
073c8e3f
No preview for this file type
build/third_party/mosquitto/CMakeFiles/progress.marks
View file @
073c8e3f
8
2
8
0
build/third_party/mosquitto/apps/CMakeFiles/progress.marks
View file @
073c8e3f
2
4
2
3
build/third_party/mosquitto/apps/mosquitto_ctrl/CMakeFiles/mosquitto_ctrl.dir/progress.make
View file @
073c8e3f
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
80
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_5
=
81
CMAKE_PROGRESS_4
=
81
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_8
=
82
CMAKE_PROGRESS_7
=
82
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_9
=
CMAKE_PROGRESS_10
=
83
CMAKE_PROGRESS_11
=
...
...
build/third_party/mosquitto/apps/mosquitto_ctrl/CMakeFiles/progress.marks
View file @
073c8e3f
2
2
2
1
build/third_party/mosquitto/client/CMakeFiles/mosquitto_pub.dir/progress.make
View file @
073c8e3f
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
93
CMAKE_PROGRESS_1
=
93
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
94
CMAKE_PROGRESS_5
=
...
...
build/third_party/mosquitto/client/CMakeFiles/progress.marks
View file @
073c8e3f
2
3
2
2
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto.dir/progress.make
View file @
073c8e3f
...
...
@@ -14,8 +14,8 @@ CMAKE_PROGRESS_13 =
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_15
=
6
CMAKE_PROGRESS_16
=
CMAKE_PROGRESS_17
=
7
CMAKE_PROGRESS_18
=
CMAKE_PROGRESS_17
=
CMAKE_PROGRESS_18
=
7
CMAKE_PROGRESS_19
=
CMAKE_PROGRESS_20
=
8
CMAKE_PROGRESS_21
=
...
...
@@ -25,19 +25,19 @@ CMAKE_PROGRESS_24 =
CMAKE_PROGRESS_25
=
CMAKE_PROGRESS_26
=
10
CMAKE_PROGRESS_27
=
CMAKE_PROGRESS_28
=
11
CMAKE_PROGRESS_29
=
CMAKE_PROGRESS_28
=
CMAKE_PROGRESS_29
=
11
CMAKE_PROGRESS_30
=
CMAKE_PROGRESS_31
=
12
CMAKE_PROGRESS_32
=
CMAKE_PROGRESS_33
=
CMAKE_PROGRESS_34
=
13
CMAKE_PROGRESS_35
=
CMAKE_PROGRESS_36
=
14
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_37
=
14
CMAKE_PROGRESS_38
=
CMAKE_PROGRESS_39
=
15
CMAKE_PROGRESS_40
=
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_40
=
15
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_42
=
16
CMAKE_PROGRESS_43
=
...
...
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
View file @
073c8e3f
CMAKE_PROGRESS_1
=
17
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
18
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
18
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
19
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_7
=
19
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_9
=
20
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_11
=
21
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_11
=
CMAKE_PROGRESS_12
=
21
CMAKE_PROGRESS_13
=
CMAKE_PROGRESS_14
=
22
CMAKE_PROGRESS_15
=
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_15
=
22
CMAKE_PROGRESS_16
=
CMAKE_PROGRESS_17
=
23
CMAKE_PROGRESS_18
=
CMAKE_PROGRESS_17
=
CMAKE_PROGRESS_18
=
23
CMAKE_PROGRESS_19
=
CMAKE_PROGRESS_20
=
24
CMAKE_PROGRESS_21
=
CMAKE_PROGRESS_22
=
25
CMAKE_PROGRESS_23
=
CMAKE_PROGRESS_22
=
CMAKE_PROGRESS_23
=
25
CMAKE_PROGRESS_24
=
CMAKE_PROGRESS_25
=
26
CMAKE_PROGRESS_26
=
CMAKE_PROGRESS_25
=
CMAKE_PROGRESS_26
=
26
CMAKE_PROGRESS_27
=
CMAKE_PROGRESS_28
=
27
CMAKE_PROGRESS_29
=
CMAKE_PROGRESS_30
=
28
CMAKE_PROGRESS_31
=
CMAKE_PROGRESS_30
=
CMAKE_PROGRESS_31
=
28
CMAKE_PROGRESS_32
=
CMAKE_PROGRESS_33
=
29
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_33
=
CMAKE_PROGRESS_34
=
29
CMAKE_PROGRESS_35
=
CMAKE_PROGRESS_36
=
30
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_37
=
30
CMAKE_PROGRESS_38
=
CMAKE_PROGRESS_39
=
31
CMAKE_PROGRESS_40
=
CMAKE_PROGRESS_41
=
32
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_42
=
32
CMAKE_PROGRESS_43
=
CMAKE_PROGRESS_44
=
33
CMAKE_PROGRESS_44
=
build/third_party/mosquitto/lib/CMakeFiles/progress.marks
View file @
073c8e3f
3
5
3
4
build/third_party/mosquitto/plugins/dynamic-security/CMakeFiles/mosquitto_dynamic_security.dir/progress.make
View file @
073c8e3f
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
85
CMAKE_PROGRESS_2
=
85
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
86
CMAKE_PROGRESS_5
=
86
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_8
=
87
CMAKE_PROGRESS_9
=
...
...
build/third_party/mosquitto/plugins/message-timestamp/CMakeFiles/mosquitto_message_timestamp.dir/progress.make
View file @
073c8e3f
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
89
CMAKE_PROGRESS_1
=
89
CMAKE_PROGRESS_2
=
build/third_party/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
View file @
073c8e3f
CMAKE_PROGRESS_1
=
52
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
53
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_3
=
53
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_5
=
54
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_7
=
54
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_8
=
55
CMAKE_PROGRESS_9
=
CMAKE_PROGRESS_10
=
55
CMAKE_PROGRESS_11
=
CMAKE_PROGRESS_12
=
56
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_11
=
56
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_13
=
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_15
=
57
CMAKE_PROGRESS_16
=
CMAKE_PROGRESS_14
=
57
CMAKE_PROGRESS_15
=
CMAKE_PROGRESS_16
=
58
CMAKE_PROGRESS_17
=
CMAKE_PROGRESS_18
=
58
CMAKE_PROGRESS_19
=
CMAKE_PROGRESS_20
=
59
CMAKE_PROGRESS_18
=
CMAKE_PROGRESS_19
=
59
CMAKE_PROGRESS_20
=
CMAKE_PROGRESS_21
=
CMAKE_PROGRESS_22
=
CMAKE_PROGRESS_23
=
60
CMAKE_PROGRESS_22
=
60
CMAKE_PROGRESS_23
=
CMAKE_PROGRESS_24
=
CMAKE_PROGRESS_25
=
CMAKE_PROGRESS_26
=
61
CMAKE_PROGRESS_27
=
CMAKE_PROGRESS_25
=
61
CMAKE_PROGRESS_26
=
CMAKE_PROGRESS_27
=
62
CMAKE_PROGRESS_28
=
CMAKE_PROGRESS_29
=
62
CMAKE_PROGRESS_30
=
CMAKE_PROGRESS_31
=
63
CMAKE_PROGRESS_29
=
CMAKE_PROGRESS_30
=
63
CMAKE_PROGRESS_31
=
CMAKE_PROGRESS_32
=
CMAKE_PROGRESS_33
=
CMAKE_PROGRESS_34
=
64
CMAKE_PROGRESS_33
=
64
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_35
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_37
=
65
CMAKE_PROGRESS_38
=
CMAKE_PROGRESS_39
=
66
CMAKE_PROGRESS_36
=
65
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_38
=
66
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_40
=
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_42
=
67
CMAKE_PROGRESS_41
=
67
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_43
=
CMAKE_PROGRESS_44
=
CMAKE_PROGRESS_45
=
68
CMAKE_PROGRESS_44
=
68
CMAKE_PROGRESS_45
=
CMAKE_PROGRESS_46
=
CMAKE_PROGRESS_47
=
69
CMAKE_PROGRESS_48
=
CMAKE_PROGRESS_49
=
CMAKE_PROGRESS_50
=
70
CMAKE_PROGRESS_49
=
70
CMAKE_PROGRESS_50
=
CMAKE_PROGRESS_51
=
CMAKE_PROGRESS_52
=
CMAKE_PROGRESS_53
=
71
CMAKE_PROGRESS_52
=
71
CMAKE_PROGRESS_53
=
CMAKE_PROGRESS_54
=
CMAKE_PROGRESS_55
=
CMAKE_PROGRESS_56
=
72
CMAKE_PROGRESS_55
=
72
CMAKE_PROGRESS_56
=
CMAKE_PROGRESS_57
=
CMAKE_PROGRESS_58
=
73
CMAKE_PROGRESS_59
=
CMAKE_PROGRESS_60
=
CMAKE_PROGRESS_61
=
74
CMAKE_PROGRESS_60
=
74
CMAKE_PROGRESS_61
=
CMAKE_PROGRESS_62
=
CMAKE_PROGRESS_63
=
CMAKE_PROGRESS_64
=
75
CMAKE_PROGRESS_63
=
75
CMAKE_PROGRESS_64
=
CMAKE_PROGRESS_65
=
CMAKE_PROGRESS_66
=
76
CMAKE_PROGRESS_67
=
CMAKE_PROGRESS_68
=
CMAKE_PROGRESS_69
=
77
CMAKE_PROGRESS_68
=
77
CMAKE_PROGRESS_69
=
CMAKE_PROGRESS_70
=
CMAKE_PROGRESS_71
=
CMAKE_PROGRESS_72
=
78
CMAKE_PROGRESS_71
=
78
CMAKE_PROGRESS_72
=
CMAKE_PROGRESS_73
=
CMAKE_PROGRESS_74
=
CMAKE_PROGRESS_75
=
79
CMAKE_PROGRESS_74
=
79
CMAKE_PROGRESS_75
=
build/third_party/mosquitto/src/CMakeFiles/progress.marks
View file @
073c8e3f
2
8
2
7
drivers/devicecontrol/car0101_control.c
View file @
073c8e3f
#include "common.h"
#include "car0101_control.h"
#include "gpio_init.h"
/*将角度转化为对应的舵机pwm值*/
...
...
drivers/devicecontrol/car0102_control.c
View file @
073c8e3f
#include "car0102_control.h"
#include "common.h"
#include "gpio_init.h"
void
car0102_calculate_L_R
(
int
angle
)
{
//将角度转化为对应的舵机pwm值
if
(
angle
<
0
)
{
angle
=
0
;
}
else
if
(
angle
>
180
)
{
angle
=
180
;
}
float
pulse_width
=
(
2
/
180
.
0
)
*
angle
+
0
.
5
;
// 周期(ms)
float
period
=
1000
.
0
/
50
;
int
val
=
(
int
)((
pulse_width
/
period
)
*
1000
);
pwmWrite
(
PWM_PIN_CHANGE
,
val
);
}
void
car0102_speed_stop
()
{
//pin_value(26,0);
pwmWrite
(
PWM_PIN_SPEED
,
0
);
car0102_calculate_L_R
(
90
);
}
void
car0102_mode_1_flont
(
unsigned
char
gval
)
{
pin_value
(
26
,
1
);
if
(
gval
==
0
)
{
pin_value
(
26
,
0
);
pwmWrite
(
PWM_PIN_SPEED
,
0
);
}
else
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
);
}
else
if
(
gval
<=
55
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
550
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
550
);
}
else
if
(
gval
<=
65
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
600
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
600
);
}
else
if
(
gval
<=
75
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
650
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
650
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
700
);
}
else
if
(
gval
<=
110
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
700
);
}
else
if
(
gval
<=
120
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
750
);
}
else
if
(
gval
<=
130
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
750
);
}
else
if
(
gval
<=
140
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
800
);
}
else
if
(
gval
<=
150
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
800
);
}
else
if
(
gval
<=
160
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
850
);
}
else
if
(
gval
<=
170
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
900
);
}
else
if
(
gval
<=
180
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
950
);
}
else
if
(
gval
<=
190
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
950
);
}
else
if
(
gval
<=
200
)
{
pwmWrite
(
PWM_PIN_SPEED
,
1000
-
1000
);
}
}
void
car0102_mode_2_back
(
unsigned
char
gval
)
{
int
k
=
5
;
int
b
=
100
;
pin_value
(
26
,
0
);
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
0
);
}
else
if
(
gval
<=
55
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
40
*
k
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
40
*
k
);
}
else
if
(
gval
<=
65
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
40
*
k
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
40
*
k
);
}
else
if
(
gval
<=
75
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
40
*
k
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
40
*
k
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
40
*
k
);
}
else
if
(
gval
<=
110
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
40
*
k
);
}
else
if
(
gval
<=
120
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
45
*
k
);
}
else
if
(
gval
<=
130
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
50
*
k
);
}
else
if
(
gval
<=
140
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
55
*
k
);
}
else
if
(
gval
<=
150
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
60
*
k
);
}
else
if
(
gval
<=
160
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
60
*
k
);
}
else
if
(
gval
<=
170
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
65
*
k
);
}
else
if
(
gval
<=
180
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
70
*
k
);
}
else
if
(
gval
<=
190
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
75
*
k
);
}
else
if
(
gval
<=
200
)
{
pwmWrite
(
PWM_PIN_SPEED
,
b
+
100
*
k
);
}
}
void
car0102_mode_3_left
(
unsigned
char
gval
)
{
if
(
gval
<
45
)
{
car0102_calculate_L_R
(
90
);
}
else
if
(
gval
<=
51
)
{
car0102_calculate_L_R
(
110
);
}
else
if
(
gval
<=
57
)
{
car0102_calculate_L_R
(
120
);
}
else
if
(
gval
<=
63
)
{
car0102_calculate_L_R
(
130
);
}
else
if
(
gval
<=
69
)
{
car0102_calculate_L_R
(
130
);
}
else
if
(
gval
<=
75
)
{
car0102_calculate_L_R
(
140
);
}
else
if
(
gval
<=
81
)
{
car0102_calculate_L_R
(
145
);
}
else
if
(
gval
<=
87
)
{
car0102_calculate_L_R
(
150
);
}
else
if
(
gval
<=
93
)
{
car0102_calculate_L_R
(
150
);
}
else
if
(
gval
<=
100
)
{
car0102_calculate_L_R
(
160
);
}
else
if
(
gval
<=
107
)
{
car0102_calculate_L_R
(
170
);
}
else
if
(
gval
<=
120
)
{
car0102_calculate_L_R
(
180
);
}
}
void
car0102_mode_4_right
(
unsigned
char
gval
)
{
if
(
gval
<
45
)
{
car0102_calculate_L_R
(
90
);
}
else
if
(
gval
<=
51
)
{
car0102_calculate_L_R
(
70
);
}
else
if
(
gval
<=
57
)
{
car0102_calculate_L_R
(
66
);
}
else
if
(
gval
<=
63
)
{
car0102_calculate_L_R
(
62
);
}
else
if
(
gval
<=
69
)
{
car0102_calculate_L_R
(
55
);
}
else
if
(
gval
<=
75
)
{
car0102_calculate_L_R
(
45
);
}
else
if
(
gval
<=
81
)
{
car0102_calculate_L_R
(
40
);
}
else
if
(
gval
<=
87
)
{
car0102_calculate_L_R
(
30
);
}
else
if
(
gval
<=
93
)
{
car0102_calculate_L_R
(
30
);
}
else
if
(
gval
<=
100
)
{
car0102_calculate_L_R
(
20
);
}
else
if
(
gval
<=
107
)
{
car0102_calculate_L_R
(
10
);
}
else
if
(
gval
<=
120
)
{
car0102_calculate_L_R
(
0
);
}
}
void
car0102_speed_change
(
unsigned
char
*
buf
)
{
//车速度和转向引脚数值处理函数
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
switch
(
mode
){
case
1
:
car0102_mode_1_flont
(
val
);
break
;
case
2
:
car0102_mode_2_back
(
val
);
break
;
case
3
:
car0102_mode_3_left
(
val
);
break
;
case
4
:
car0102_mode_4_right
(
val
);
break
;
default:
break
;
}
}
\ No newline at end of file
drivers/devicecontrol/car0102_control.h
View file @
073c8e3f
#ifndef CAR0102_CONTROL_H__
#define CAR0102_CONTROL_H__
void
car0102_speed_stop
();
//小车的停止
void
car0102_speed_change
(
unsigned
char
*
buf
);
//小车的改变值
#endif
\ No newline at end of file
drivers/devicecontrol/car0103_control.c
View file @
073c8e3f
#include "car0103_control.h"
#include "gpio_init.h"
#include "common.h"
int
modecount_car0103
=
0
;
void
car0103_middle
()
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
mode_car0103_lift_flont
(
unsigned
char
gval
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
}
else
if
(
gval
<=
55
)
{
pwmWrite
(
PWM_PIN_SPEED
,
78
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
79
);
}
else
if
(
gval
<=
65
)
{
pwmWrite
(
PWM_PIN_SPEED
,
80
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_SPEED
,
81
);
}
else
if
(
gval
<=
75
)
{
pwmWrite
(
PWM_PIN_SPEED
,
82
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
83
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
84
);
}
else
if
(
gval
<=
110
)
{
pwmWrite
(
PWM_PIN_SPEED
,
85
);
}
else
if
(
gval
<=
120
)
{
pwmWrite
(
PWM_PIN_SPEED
,
86
);
}
else
if
(
gval
<=
130
)
{
pwmWrite
(
PWM_PIN_SPEED
,
87
);
}
else
if
(
gval
<=
140
)
{
pwmWrite
(
PWM_PIN_SPEED
,
88
);
}
else
if
(
gval
<=
150
)
{
pwmWrite
(
PWM_PIN_SPEED
,
89
);
}
else
if
(
gval
<=
160
)
{
pwmWrite
(
PWM_PIN_SPEED
,
90
);
}
else
if
(
gval
<=
170
)
{
pwmWrite
(
PWM_PIN_SPEED
,
91
);
}
else
if
(
gval
<=
180
)
{
pwmWrite
(
PWM_PIN_SPEED
,
92
);
}
else
if
(
gval
<=
190
)
{
pwmWrite
(
PWM_PIN_SPEED
,
93
);
}
else
if
(
gval
<=
200
)
{
pwmWrite
(
PWM_PIN_SPEED
,
94
);
}
}
void
mode_car0103_lift_back
(
unsigned
char
gval
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
}
else
if
(
gval
<=
55
)
{
pwmWrite
(
PWM_PIN_SPEED
,
72
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
71
);
}
else
if
(
gval
<=
65
)
{
pwmWrite
(
PWM_PIN_SPEED
,
70
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_SPEED
,
69
);
}
else
if
(
gval
<=
75
)
{
pwmWrite
(
PWM_PIN_SPEED
,
68
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
67
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
66
);
}
else
if
(
gval
<=
110
)
{
pwmWrite
(
PWM_PIN_SPEED
,
65
);
}
else
if
(
gval
<=
120
)
{
pwmWrite
(
PWM_PIN_SPEED
,
64
);
}
else
if
(
gval
<=
130
)
{
pwmWrite
(
PWM_PIN_SPEED
,
63
);
}
else
if
(
gval
<=
140
)
{
pwmWrite
(
PWM_PIN_SPEED
,
62
);
}
else
if
(
gval
<=
150
)
{
pwmWrite
(
PWM_PIN_SPEED
,
61
);
}
else
if
(
gval
<=
160
)
{
pwmWrite
(
PWM_PIN_SPEED
,
60
);
}
else
if
(
gval
<=
170
)
{
pwmWrite
(
PWM_PIN_SPEED
,
59
);
}
else
if
(
gval
<=
180
)
{
pwmWrite
(
PWM_PIN_SPEED
,
58
);
}
else
if
(
gval
<=
190
)
{
pwmWrite
(
PWM_PIN_SPEED
,
57
);
}
else
if
(
gval
<=
200
)
{
pwmWrite
(
PWM_PIN_SPEED
,
56
);
}
}
void
mode_car0103_right_flont
(
unsigned
char
gval
)
{
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
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
80
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
81
);
}
else
if
(
gval
<=
75
)
{
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
);
}
}
void
mode_car0103_right_back
(
unsigned
char
gval
)
{
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
)
{
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
);
}
}
int
car0103_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
if
(
mode
==
1
)
{
//mode_lift_flont(val);
mode_car0103_right_back
(
val
);
modecount_car0103
=
0
;
}
else
if
(
mode
==
2
)
{
//mode_lift_back(val);
mode_car0103_right_flont
(
val
);
modecount_car0103
=
1
;
}
if
((
mode
==
1
||
mode
==
2
)
&&
val
==
0
)
modecount_car0103
=
0
;
if
(
mode
==
3
)
{
if
(
modecount_car0103
==
0
)
mode_car0103_lift_back
(
val
+
25
);
if
(
modecount_car0103
==
1
)
mode_car0103_lift_flont
(
val
+
25
);
}
else
if
(
mode
==
4
)
{
if
(
modecount_car0103
==
0
)
mode_car0103_lift_flont
(
val
+
25
);
if
(
modecount_car0103
==
1
)
mode_car0103_lift_back
(
val
+
25
);
}
}
\ No newline at end of file
drivers/devicecontrol/car0103_control.h
View file @
073c8e3f
#ifndef CAR0103_CONTROL_H__
#define CAR0104_CONTROL_H__
void
car0103_middle
();
int
car0103_change
(
unsigned
char
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/car0104_control.c
View file @
073c8e3f
#include "common.h"
#include "gpio_init.h"
#include "car0104_control.h"
void
car0104_middle
()
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
car0104_back
(
unsigned
char
gval
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
}
else
if
(
gval
<=
55
)
{
pwmWrite
(
PWM_PIN_SPEED
,
78
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
79
);
}
else
if
(
gval
<=
65
)
{
pwmWrite
(
PWM_PIN_SPEED
,
80
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_SPEED
,
81
);
}
else
if
(
gval
<=
75
)
{
pwmWrite
(
PWM_PIN_SPEED
,
82
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
83
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
84
);
}
else
if
(
gval
<=
110
)
{
pwmWrite
(
PWM_PIN_SPEED
,
85
);
}
else
if
(
gval
<=
120
)
{
pwmWrite
(
PWM_PIN_SPEED
,
86
);
}
else
if
(
gval
<=
130
)
{
pwmWrite
(
PWM_PIN_SPEED
,
87
);
}
else
if
(
gval
<=
140
)
{
pwmWrite
(
PWM_PIN_SPEED
,
88
);
}
else
if
(
gval
<=
150
)
{
pwmWrite
(
PWM_PIN_SPEED
,
89
);
}
else
if
(
gval
<=
160
)
{
pwmWrite
(
PWM_PIN_SPEED
,
90
);
}
else
if
(
gval
<=
170
)
{
pwmWrite
(
PWM_PIN_SPEED
,
91
);
}
else
if
(
gval
<=
180
)
{
pwmWrite
(
PWM_PIN_SPEED
,
92
);
}
else
if
(
gval
<=
190
)
{
pwmWrite
(
PWM_PIN_SPEED
,
93
);
}
else
if
(
gval
<=
200
)
{
pwmWrite
(
PWM_PIN_SPEED
,
94
);
}
}
void
car0104_flont
(
unsigned
char
gval
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
}
else
if
(
gval
<=
55
)
{
pwmWrite
(
PWM_PIN_SPEED
,
72
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
71
);
}
else
if
(
gval
<=
65
)
{
pwmWrite
(
PWM_PIN_SPEED
,
70
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_SPEED
,
69
);
}
else
if
(
gval
<=
75
)
{
pwmWrite
(
PWM_PIN_SPEED
,
68
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
67
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
66
);
}
else
if
(
gval
<=
110
)
{
pwmWrite
(
PWM_PIN_SPEED
,
65
);
}
else
if
(
gval
<=
120
)
{
pwmWrite
(
PWM_PIN_SPEED
,
64
);
}
else
if
(
gval
<=
130
)
{
pwmWrite
(
PWM_PIN_SPEED
,
63
);
}
else
if
(
gval
<=
140
)
{
pwmWrite
(
PWM_PIN_SPEED
,
62
);
}
else
if
(
gval
<=
150
)
{
pwmWrite
(
PWM_PIN_SPEED
,
61
);
}
else
if
(
gval
<=
160
)
{
pwmWrite
(
PWM_PIN_SPEED
,
60
);
}
else
if
(
gval
<=
170
)
{
pwmWrite
(
PWM_PIN_SPEED
,
59
);
}
else
if
(
gval
<=
180
)
{
pwmWrite
(
PWM_PIN_SPEED
,
58
);
}
else
if
(
gval
<=
190
)
{
pwmWrite
(
PWM_PIN_SPEED
,
57
);
}
else
if
(
gval
<=
200
)
{
pwmWrite
(
PWM_PIN_SPEED
,
56
);
}
}
void
car0104_right
(
unsigned
char
gval
)
{
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
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
80
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
81
);
}
else
if
(
gval
<=
75
)
{
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
);
}
}
void
car0104_lift
(
unsigned
char
gval
)
{
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
)
{
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
);
}
}
int
car0104_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
if
(
mode
==
1
)
{
car0104_flont
(
val
);
}
else
if
(
mode
==
2
)
{
car0104_back
(
val
);
}
else
if
(
mode
==
3
)
{
car0104_lift
(
val
+
20
);
}
else
if
(
mode
==
4
)
{
car0104_right
(
val
+
20
);
}
}
drivers/devicecontrol/car0104_control.h
View file @
073c8e3f
#ifndef CAR0104_CONTROL_H__
#define CAR0104_CONTROL_H__
void
car0104_middle
();
int
car0104_change
(
unsigned
char
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/ptz0401_control.c
0 → 100755
View file @
073c8e3f
#include "common.h"
#include "gpio_init.h"
#include "ptz0401_control.h"
#define PWM_PIN_up 21
#define PWM_PIN_down 2
// 舵机最小脉冲宽度(ms)
#define MIN_PULSE_WIDTH 0.5
// 舵机最大脉冲宽度(ms)
#define MAX_PULSE_WIDTH 2.5
float
Initial_value
=
90
;
static
int
val_change
=
90
;
static
int
val_up_down
=
90
;
static
unsigned
char
change_index
=
0
;
static
unsigned
char
up_down_index
=
0
;
void
pwm_PTZ_hz
()
{
int
pwm_clock
=
24000000
/
(
50
*
1000
);
// 定义 PWM 频率为 50Hz
pinMode
(
PWM_PIN_up
,
PWM_OUTPUT
);
pinMode
(
PWM_PIN_down
,
PWM_OUTPUT
);
pwmSetClock
(
PWM_PIN_up
,
pwm_clock
);
//=19200*1000/(hz*2000)
pwmSetRange
(
PWM_PIN_up
,
1024
);
//占空比范围
pwmSetClock
(
PWM_PIN_down
,
pwm_clock
);
//=19200*1000/(hz*2000)
pwmSetRange
(
PWM_PIN_down
,
1024
);
//占空比范围
}
float
calculate_pulse_width
(
int
angle
)
{
if
(
angle
<
0
)
{
angle
=
0
;
}
else
if
(
angle
>
270
)
{
angle
=
270
;
}
return
((
MAX_PULSE_WIDTH
-
MIN_PULSE_WIDTH
)
/
270
.
0
)
*
angle
+
MIN_PULSE_WIDTH
;
}
int
calculate_duty_cycle
(
float
pulse_width
)
{
// 周期(ms)
float
period
=
1000
.
0
/
50
;
return
(
int
)((
pulse_width
/
period
)
*
1024
);
}
void
PTZ_pwm_init
()
{
float
pulse_width
=
calculate_pulse_width
(
Initial_value
);
int
pulse
=
calculate_duty_cycle
(
pulse_width
);
pwmWrite
(
PWM_PIN_up
,
pulse
);
pwmWrite
(
PWM_PIN_down
,
pulse
);
}
void
PTZ_pwm_left
()
{
float
pulse_width
;
int
pulse
;
change_index
++
;
if
(
change_index
>=
1
)
{
change_index
=
0
;
val_change
-=
3
;
if
(
val_change
<=
30
)
val_change
=
30
;
pulse_width
=
calculate_pulse_width
(
val_change
);
pulse
=
calculate_duty_cycle
(
pulse_width
);
}
printf
(
"%d
\n
"
,
pulse
);
pwmWrite
(
PWM_PIN_down
,
pulse
);
}
void
PTZ_pwm_right
()
{
float
pulse_width
;
int
pulse
;
change_index
++
;
if
(
change_index
>=
1
)
{
change_index
=
0
;
val_change
+=
3
;
if
(
val_change
>=
150
)
val_change
=
150
;
pulse_width
=
calculate_pulse_width
(
val_change
);
pulse
=
calculate_duty_cycle
(
pulse_width
);
}
printf
(
"%d
\n
"
,
pulse
);
pwmWrite
(
PWM_PIN_down
,
pulse
);
}
void
PTZ_pwm_up
()
{
float
pulse_width
;
int
pulse
;
up_down_index
++
;
if
(
up_down_index
>=
1
)
{
up_down_index
=
0
;
val_up_down
+=
3
;
if
(
val_up_down
>=
110
)
val_up_down
=
110
;
pulse_width
=
calculate_pulse_width
(
val_up_down
);
pulse
=
calculate_duty_cycle
(
pulse_width
);
}
printf
(
"%d
\n
"
,
pulse
);
pwmWrite
(
PWM_PIN_up
,
pulse
);
}
void
PTZ_pwm_down
()
{
float
pulse_width
;
int
pulse
;
up_down_index
++
;
if
(
up_down_index
>=
1
)
{
up_down_index
=
0
;
val_up_down
-=
3
;
if
(
val_up_down
<=
70
)
val_up_down
=
70
;
pulse_width
=
calculate_pulse_width
(
val_up_down
);
pulse
=
calculate_duty_cycle
(
pulse_width
);
}
printf
(
"%d
\n
"
,
pulse
);
pwmWrite
(
PWM_PIN_up
,
pulse
);
}
void
PTZ_pwm_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
if
(
val
!=
0
)
{
switch
(
mode
)
{
case
1
:
PTZ_pwm_up
();
break
;
case
2
:
PTZ_pwm_down
();
break
;
case
3
:
PTZ_pwm_right
();
break
;
case
4
:
PTZ_pwm_left
();
break
;
default:
break
;
}
}
}
\ No newline at end of file
drivers/devicecontrol/ptz0401_control.h
0 → 100755
View file @
073c8e3f
#ifndef PTZ0401_CONTROL_H__
#define PTZ0401_CONTROL_H__
void
pwm_PTZ_hz
();
void
PTZ_pwm_init
();
void
PTZ_pwm_change
(
unsigned
char
*
buf
)
;
#endif
\ No newline at end of file
drivers/devicecontrol/tank02002_control.c
0 → 100644
View file @
073c8e3f
#include "common.h"
#include "gpio_init.h"
#include "pthrpoll.h"
#include "tank02002_control.h"
int
g_modecount_tank0202
=
0
;
void
tank0202_middle
()
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
return
0
;
}
void
mode_lift_flont
(
unsigned
char
gval
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
}
else
if
(
gval
<=
55
)
{
pwmWrite
(
PWM_PIN_SPEED
,
78
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
79
);
}
else
if
(
gval
<=
65
)
{
pwmWrite
(
PWM_PIN_SPEED
,
80
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_SPEED
,
81
);
}
else
if
(
gval
<=
75
)
{
pwmWrite
(
PWM_PIN_SPEED
,
82
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
83
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
84
);
}
else
if
(
gval
<=
110
)
{
pwmWrite
(
PWM_PIN_SPEED
,
85
);
}
else
if
(
gval
<=
120
)
{
pwmWrite
(
PWM_PIN_SPEED
,
86
);
}
else
if
(
gval
<=
130
)
{
pwmWrite
(
PWM_PIN_SPEED
,
87
);
}
else
if
(
gval
<=
140
)
{
pwmWrite
(
PWM_PIN_SPEED
,
88
);
}
else
if
(
gval
<=
150
)
{
pwmWrite
(
PWM_PIN_SPEED
,
89
);
}
else
if
(
gval
<=
160
)
{
pwmWrite
(
PWM_PIN_SPEED
,
90
);
}
else
if
(
gval
<=
170
)
{
pwmWrite
(
PWM_PIN_SPEED
,
91
);
}
else
if
(
gval
<=
180
)
{
pwmWrite
(
PWM_PIN_SPEED
,
92
);
}
else
if
(
gval
<=
190
)
{
pwmWrite
(
PWM_PIN_SPEED
,
93
);
}
else
if
(
gval
<=
200
)
{
pwmWrite
(
PWM_PIN_SPEED
,
94
);
}
}
void
mode_lift_back
(
unsigned
char
gval
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
}
else
if
(
gval
<=
55
)
{
pwmWrite
(
PWM_PIN_SPEED
,
72
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
71
);
}
else
if
(
gval
<=
65
)
{
pwmWrite
(
PWM_PIN_SPEED
,
70
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_SPEED
,
69
);
}
else
if
(
gval
<=
75
)
{
pwmWrite
(
PWM_PIN_SPEED
,
68
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
67
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
66
);
}
else
if
(
gval
<=
110
)
{
pwmWrite
(
PWM_PIN_SPEED
,
65
);
}
else
if
(
gval
<=
120
)
{
pwmWrite
(
PWM_PIN_SPEED
,
64
);
}
else
if
(
gval
<=
130
)
{
pwmWrite
(
PWM_PIN_SPEED
,
63
);
}
else
if
(
gval
<=
140
)
{
pwmWrite
(
PWM_PIN_SPEED
,
62
);
}
else
if
(
gval
<=
150
)
{
pwmWrite
(
PWM_PIN_SPEED
,
61
);
}
else
if
(
gval
<=
160
)
{
pwmWrite
(
PWM_PIN_SPEED
,
60
);
}
else
if
(
gval
<=
170
)
{
pwmWrite
(
PWM_PIN_SPEED
,
59
);
}
else
if
(
gval
<=
180
)
{
pwmWrite
(
PWM_PIN_SPEED
,
58
);
}
else
if
(
gval
<=
190
)
{
pwmWrite
(
PWM_PIN_SPEED
,
57
);
}
else
if
(
gval
<=
200
)
{
pwmWrite
(
PWM_PIN_SPEED
,
56
);
}
}
void
mode_right_flont
(
unsigned
char
gval
)
{
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
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
80
);
}
else
if
(
gval
<=
70
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
81
);
}
else
if
(
gval
<=
75
)
{
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
);
}
}
void
mode_right_back
(
unsigned
char
gval
)
{
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
)
{
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
);
}
}
int
tank0202_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
if
(
mode
==
1
)
{
//mode_lift_flont(val);
mode_right_flont
(
val
);
g_modecount_tank0202
=
0
;
}
else
if
(
mode
==
2
)
{
//mode_lift_back(val);
mode_right_back
(
val
);
g_modecount_tank0202
=
1
;
}
if
((
mode
==
1
||
mode
==
2
)
&&
val
==
0
)
g_modecount_tank0202
=
0
;
if
(
mode
==
3
)
{
if
(
g_modecount_tank0202
==
0
)
mode_lift_back
(
val
+
25
);
if
(
g_modecount_tank0202
==
1
)
mode_lift_flont
(
val
+
25
);
}
else
if
(
mode
==
4
)
{
if
(
g_modecount_tank0202
==
0
)
mode_lift_flont
(
val
+
25
);
if
(
g_modecount_tank0202
==
1
)
mode_lift_back
(
val
+
25
);
}
}
long
long
shot_device_time_start
=
0
;
long
long
shot_device_time_end
=
0
;
// 函数功能:获取当前精确到毫秒的时间戳
// 返回值:当前时间的毫秒数
long
long
get_current_time_millis
()
{
struct
timeval
tv
;
// 获取当前时间,存储在tv结构体中,第二个参数一般传NULL
if
(
gettimeofday
(
&
tv
,
NULL
)
!=
0
)
{
perror
(
"gettimeofday error"
);
return
-
1
;
}
// 秒数部分转换为毫秒(乘以1000),微秒数部分转换为毫秒(除以1000),然后相加
return
(
long
long
)
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
;
}
void
tank_shot_back_stop_task_function
(
void
*
arg
)
{
//多线程处理坦克发射后退线程池
while
(
1
){
long
long
interval
=
shot_device_time_start
-
shot_device_time_end
;
if
(
g_device_delay_count
>
10
&&
g_device_delay_count
<=
25
)
mode_right_back
(
0
);
if
(
interval
>
100
){
if
(
g_device_delay_count
<=
10
)
{
mode_right_back
(
80
);
my_zlog_debug
(
"操作耗时: %lld 毫秒"
,
interval
);
}
}
}
free
(
arg
);
}
ThreadPool_t
*
pool_tank
;
void
tank_shot_back_stop_task_end
(){
thread_pool_destroy
(
pool_tank
);
}
void
tank_shot_pthrpoll_task_init
(){
int
*
arg
=
malloc
(
sizeof
(
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
(
"线程池打开"
);
}
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引脚"
);
return
1
;
}
if
(
val
==
0
)
{
mode_right_back
(
0
);
shot_count
=
2
;
}
if
(
val
!=
0
)
{
if
(
shot_count
==
0
){
tank_shot_pthrpoll_task_init
();
shot_count
=
1
;
}
shot_count
=
1
;
if
(
shot_count
==
1
){
g_device_delay_count
=
0
;
}
}
shot_device_time_end
=
get_current_time_millis
();
}
/*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/
void
tank0202_thread_close
(){
thread_pool_destroy
(
pool_tank
);
}
\ No newline at end of file
drivers/devicecontrol/tank02002_control.h
0 → 100644
View file @
073c8e3f
#ifndef TANK0202_CONTROL_H__
#define TANK0202_CONTROL_H__
void
tank0202_middle
();
void
tank_shot_back_stop_task_end
();
int
tank0202_change
(
unsigned
char
*
buf
);
int
tank_shot_back_stop
(
int
pin
,
int
val
);
/*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/
void
tank0202_thread_close
();
#endif
\ No newline at end of file
drivers/gpio/device_init.c
View file @
073c8e3f
...
...
@@ -5,7 +5,7 @@
int
abnormal_pin_pwm_stop
=
0
;
int
device_type
=
0
;
int
g_
device_type
=
0
;
const
deviceconfig_t
device_configs
[]
=
{
// car0101配置
...
...
@@ -18,52 +18,56 @@ const deviceconfig_t device_configs[] = {
.
device_control_stop
=
car0101_middle_pwm
,
.
emergency_code
=
101
},
// // car0102配置
// {
// .device_id = 102,
// .device_name = "car0102",
// .gpio_pins = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, 27, -1},
// .device_pwm_init = pwm_init_speed,
// .device_control_stop = car0102_speed_stop,
// .emergency_code = 102
// },
// // car0103配置(根据您的需求补充)
// {
// .device_id = 103,
// .device_name = "car0103",
// .gpio_pins = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, 27,-1},/* 补充GPIO引脚 */
// .device_pwm_init = pwm_init_speed,
// .device_control_stop = ,/* 补充速度控制函数 */
// .emergency_code = 103
// },
// // car0104配置(根据您的需求补充)
// {
// .device_id = 104,
// .device_name = "car0104",
// .gpio_pins = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, 27,-1},/* 补充GPIO引脚 */
// .device_pwm_init = pwm_init_speed,
// .device_control_stop = ,/* 补充速度控制函数 */
// .emergency_code = 103
// },
// // tank0201配置(根据您的需求补充)
// {
// .device_id = 201,
// .device_name = "tank0201",
// .gpio_pins = { 6, 16, 20, 22, 23,-1},/* 补充GPIO引脚 */
// .gpio_pwms = {5 , 7 ,24,26, 27,-1},
// .device_pwm_init = pwm_init_speed,
// .device_control_stop = ,/* 补充速度控制函数 */
// .emergency_code = 103
// },
// // tank0202配置(根据您的需求补充)
// {
// .device_id = 202,
// .device_name = "tank0202",
// .gpio_pins = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, 27,-1},/* 补充GPIO引脚 */
// .device_pwm_init = pwm_init_speed,
// .device_control_stop = ,/* 补充速度控制函数 */
// .emergency_code = 104
// },
// car0102配置
{
.
device_id
=
102
,
.
device_name
=
"car0102"
,
.
gpio_pins
=
{
5
,
6
,
7
,
10
,
16
,
20
,
22
,
23
,
24
,
25
,
26
,
27
,
-
1
},
.
gpio_pwms
=
{
-
1
},
.
device_pwm_init
=
physics_pwm_init
,
.
device_control_stop
=
car0102_speed_stop
,
.
emergency_code
=
102
},
// car0103配置(根据您的需求补充)
{
.
device_id
=
103
,
.
device_name
=
"car0103"
,
.
gpio_pins
=
{
5
,
6
,
7
,
10
,
16
,
20
,
22
,
23
,
24
,
25
,
26
,
27
,
-
1
},
/* 补充GPIO引脚 */
.
gpio_pwms
=
{
-
1
},
.
device_pwm_init
=
physics_pwm_init
,
.
device_control_stop
=
car0103_middle
,
/* 补充速度控制函数 */
.
emergency_code
=
103
},
// car0104配置(根据您的需求补充)
{
.
device_id
=
104
,
.
device_name
=
"car0104"
,
.
gpio_pins
=
{
5
,
6
,
7
,
10
,
16
,
20
,
22
,
23
,
24
,
25
,
26
,
27
,
-
1
},
/* 补充GPIO引脚 */
.
gpio_pwms
=
{
-
1
},
.
device_pwm_init
=
physics_pwm_init
,
.
device_control_stop
=
car0104_middle
,
/* 补充速度控制函数 */
.
emergency_code
=
104
},
// tank0202配置(根据您的需求补充)
{
.
device_id
=
202
,
.
device_name
=
"tank0202"
,
.
gpio_pins
=
{
6
,
16
,
20
,
22
,
23
,
-
1
},
/* 补充GPIO引脚 */
.
gpio_pwms
=
{
5
,
7
,
24
,
26
,
27
,
-
1
},
.
device_pwm_init
=
physics_pwm_init
,
.
device_control_stop
=
tank0202_middle
,
/* 补充速度控制函数 */
.
emergency_code
=
202
},
{
.
device_id
=
401
,
.
device_name
=
"ptz0401"
,
.
gpio_pins
=
{
5
,
6
,
7
,
10
,
16
,
20
,
22
,
23
,
24
,
25
,
26
,
-
1
},
/* 补充GPIO引脚 */
.
gpio_pwms
=
{
27
,
-
1
},
.
device_pwm_init
=
pwm_PTZ_hz
,
.
device_control_stop
=
PTZ_pwm_init
,
/* 补充速度控制函数 */
.
emergency_code
=
401
},
// 结束标记
{
.
device_id
=
-
1
}
};
...
...
@@ -96,7 +100,7 @@ void device_init(int device_id) {
if
(
get_array_length
(
config
->
gpio_pins
)
==
TRUE
)
init_gpiopwm
(
config
->
gpio_pwms
);
// GPIOsoft_pwm初始化
config
->
device_pwm_init
();
// PWM初始化
config
->
device_control_stop
();
// 速度控制初始化
device_type
=
config
->
emergency_code
;
g_
device_type
=
config
->
emergency_code
;
printf
(
"%s initialized successfully!
\n
"
,
config
->
device_name
);
...
...
drivers/gpio/device_init.h
View file @
073c8e3f
#ifndef DEVICE_INIT_H__
#define DEVICE_INIT_H__
extern
int
device_type
;
extern
int
g_device_type
;
extern
int
g_device_delay_count
;
typedef
struct
{
int
device_id
;
// 设备ID (101, 102等)
...
...
drivers/gpio/gpio_init.c
View file @
073c8e3f
...
...
@@ -70,8 +70,8 @@ void pwm_value(int pin,int value) { //软件陪我们控制调速
softPwmWrite
(
pin
,
shot_speed
);
my_zlog_debug
(
"pin:%d,%d"
,
pin
,
shot_speed
);
}
else
{
if
(
device_type
==
DEVICE_TANK0202
)
softPwmWrite
(
pin
,
30
);
if
(
device_type
!=
DEVICE_TANK0202
)
softPwmWrite
(
pin
,
shot_speed
);
if
(
g_
device_type
==
DEVICE_TANK0202
)
softPwmWrite
(
pin
,
30
);
if
(
g_
device_type
!=
DEVICE_TANK0202
)
softPwmWrite
(
pin
,
shot_speed
);
}
...
...
fcsgdevintroduce.md
View file @
073c8e3f
...
...
@@ -25,4 +25,7 @@
-
car0102 为小车 最大速度为200
-
car0103 为挖机 最大速度为200,更据电池电压具体调速。原电池为7.6v,大概为140左右
-
car0104 为推土机 最大速度为200,更据电池电压具体调速。原电池为7.6v,大概为140左右
-
ptz0401 为炮台,有限位。
\ No newline at end of file
-
ptz0401 为炮台,有限位。
## 国内国外二进制介绍
-
mqtt_init.h改变里面的一个MQTT_IPMODE,游览器改变browser_open.h中的BROWSER_MODE
\ No newline at end of file
include/common.h
View file @
073c8e3f
...
...
@@ -36,6 +36,9 @@
#include "delay.h"
#include "mylog.h"
#include "device_time.h"
// ========== 香橙派优化宏 ==========
// #define ORANGE_GPIO_SET(pin, val) { \
// pinMode(pin, OUTPUT); \
...
...
include/devcontrol_common.h
View file @
073c8e3f
#ifndef DEVCONTROL_COMMON_H
#define DEVCONTROL_COMMON_H
#include "device_init.h"
#include "car0101_control.h"
#include "car0102_control.h"
#include "car0103_control.h"
#include "car0104_control.h"
#include "ptz0401_control.h"
#include "tank02002_control.h"
#define DEVICE_CAR0101 101
#define DEVICE_CAR0102 102
#define DEVICE_CAR0103 103
#define DEVICE_CAR0104 104
#define DEVICE_TANK0201 201
#define DEVICE_TANK0202
101
#define DEVICE_TANK0202
202
#define DEVICE_PAO_PTZ0401 401
/*关闭相关的设备需要关闭的,比如线程池等*/
void
device_close
(){
if
(
g_device_type
==
DEVICE_TANK0202
)
tank0202_thread_close
();
}
#endif
\ No newline at end of file
modules/browser/browser_open.h
View file @
073c8e3f
...
...
@@ -2,7 +2,7 @@
#define BROWSER_OPEN_H__
/*打开摄像头函数,当MODE为1时候为国内网址,2时为国外网址*/
#define BROWSER_MODE
1
#define BROWSER_MODE
2
int
opencamsh
();
...
...
modules/delay/device_time.c
0 → 100644
View file @
073c8e3f
#include "device_time.h"
int
g_device_delay_count
=
0
;
\ No newline at end of file
modules/delay/device_time.h
0 → 100644
View file @
073c8e3f
#ifndef DEVICE_TIME_H
#define DEVICE_TIME_H
extern
int
g_device_delay_count
;
#endif
\ No newline at end of file
modules/mqtt/mqtt_infor_handle.c
View file @
073c8e3f
...
...
@@ -13,12 +13,12 @@
#include "device_fileopen.h"
#include "devcontrol_common.h"
#include "device_wifi_change.h"
#include "device_id_change.h"
#include "audioplay.h"
#include "gpio_init.h"
#include "device_init.h"
bool
g_verified_mode
=
TRUE
;
//控制是否需要验证
int
g_heartbeat_count
=
0
;
...
...
@@ -79,16 +79,20 @@ void heartbeat_send() {
cJSON_Delete
(
root
);
// 释放 cJSON 对象
}
#define DEVICE_CAR0102 102
#define DEVICE_CAR0103 103
#define DEVICE_CAR0104 104
#define DEVICE_TANK0201 201
#define DEVICE_TANK0202 101
#define DEVICE_PAO_PTZ0401 401
//mqtt设备行走驱动函数
void
device_driver
(){
if
(
device_type
==
DEVICE_CAR0101
)
car0101_control_change
(
g_valt
)
;
// if(AppExit_pin_pwm == 102) car0102_speed_change(valt) ;
// if(AppExit_pin_pwm == 103 ) car0103_change(valt) ;
// if(AppExit_pin_pwm == 104 ) car0104_change(valt) ;
// if(AppExit_pin_pwm == 202) tank0202_change(valt);
// if(AppExit_pin_pwm == 301) ship_speed_change(valt) ;
// if(AppExit_pin_pwm == 401) PTZ_pwm_change(valt);
if
(
device_type
==
DEVICE_CAR0102
)
car0102_speed_change
(
g_valt
)
;
if
(
device_type
==
DEVICE_CAR0103
)
car0103_change
(
g_valt
)
;
if
(
device_type
==
DEVICE_CAR0104
)
car0104_change
(
g_valt
)
;
if
(
device_type
==
DEVICE_TANK0202
)
tank0202_change
(
g_valt
);
if
(
device_type
==
DEVICE_PAO_PTZ0401
)
PTZ_pwm_change
(
g_valt
);
}
//角度发送
...
...
@@ -181,7 +185,7 @@ void message_4(cJSON *body){//message 为4时候
//当接收到2时候验证
void
message_2_judyverify
(
cJSON
*
body
){
if
(
g_verified_mode
==
FALSE
)
{
if
(
VERIFIED_MODE
==
FALSE
)
{
refresh_cam
();
my_zlog_warn
(
"不使用验证"
);
return
;
...
...
@@ -197,7 +201,7 @@ void message_2_judyverify(cJSON *body){
//当接收到3时候验证
void
message_3_judyverify
(
cJSON
*
body
){
if
(
g_verified_mode
==
FALSE
)
{
if
(
VERIFIED_MODE
==
FALSE
)
{
message_3
(
body
);
my_zlog_warn
(
"不使用验证"
);
return
;
...
...
@@ -213,7 +217,7 @@ void message_3_judyverify(cJSON *body){
//当接收到4时候验证
void
message_4_judyverify
(
cJSON
*
body
){
if
(
g_verified_mode
==
FALSE
)
{
if
(
VERIFIED_MODE
==
FALSE
)
{
message_4
(
body
);
my_zlog_warn
(
"不使用验证"
);
return
;
...
...
@@ -230,14 +234,14 @@ void message_4_judyverify(cJSON *body){
//接收到设备改名函数
int
device_mqttchange_name
(
cJSON
*
device_id
){
//
cJSON *id = cJSON_GetObjectItem(device_id, "id");// 提取ID
//
cJSON *date = cJSON_GetObjectItem(device_id, "date");// 提取日期
//
char *device_change_id=id->valuestring;
//
char *device_change_date=date->valuestring;
//
device_changename_back(device_change_date,device_change_id);
//
//
输出提取的数据
//
my_zlog_debug("设备ID: %s", device_change_id);
//
my_zlog_debug("日期: %s", device_change_date);
cJSON
*
id
=
cJSON_GetObjectItem
(
device_id
,
"id"
);
// 提取ID
cJSON
*
date
=
cJSON_GetObjectItem
(
device_id
,
"date"
);
// 提取日期
char
*
device_change_id
=
id
->
valuestring
;
char
*
device_change_date
=
date
->
valuestring
;
device_changename_back
(
device_change_date
,
device_change_id
);
// 输出提取的数据
my_zlog_debug
(
"设备ID: %s"
,
device_change_id
);
my_zlog_debug
(
"日期: %s"
,
device_change_date
);
return
0
;
}
...
...
@@ -274,7 +278,7 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
my_zlog_debug
(
"进入音频播放"
);
break
;
case
2002
:
//
device_mqttchange_name(body);
device_mqttchange_name
(
body
);
my_zlog_debug
(
"进入修改设备号"
);
break
;
case
2003
:
...
...
modules/mqtt/mqtt_infor_handle.h
View file @
073c8e3f
...
...
@@ -3,6 +3,9 @@
#include "cjson/cJSON.h"
/*1为打开验证0为关闭验证*/
#define VERIFIED_MODE 1
extern
int
g_heartbeat_count
;
extern
int
g_devcontrol_exit_count
;
...
...
modules/mqtt/mqtt_init.h
View file @
073c8e3f
...
...
@@ -6,7 +6,18 @@
//extern ThreadPool *pool;
#define BROKER_ADDRESS "119.45.167.177"
#define MQTT_IPMODE 2 // 或通过编译选项 -DMODE=1 指定
#if MQTT_IPMODE == 1
#define BROKER_ADDRESS "119.45.167.177"
#elif MQTT_IPMODE == 2
#define BROKER_ADDRESS "mqtt.luckycar.top"
#else
#define BROKER_ADDRESS "127.0.0.1" // 默认地址
#endif
//#define BROKER_ADDRESS "119.45.167.177"
#define BROKER_PORT 1883
#define USERNAME "admin" // 替换为你的用户名
#define PASSWORD "admin" // 替换为你的密码
...
...
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