Commit a7402f23 authored by 957dd's avatar 957dd

修改船逻辑bug

parent e89c7df3
......@@ -18,9 +18,9 @@
#include "INA226.h"
#define filename "/home/orangepi/car/master/Deviceld.txt"
pthread_t thread[4];
//开启线程
int thread_start(void *AppExit(void *arg),void *Mqttbeat(void *arg),void *opensh(void *arg),void *Mqtt_onnect(void *arg))
{
......
......@@ -23,6 +23,7 @@ extern char* TOPIC3;//= "controlcar0004"
#define BROKER_ADDRESS "119.45.167.177"
#define BROKER_PORT 1883
extern uint8_t AppExit_pin_pwm;
#define USERNAME "admin" // 替换为你的用户名
#define PASSWORD "admin" // 替换为你的密码
......
No preview for this file type
......@@ -6,7 +6,7 @@
const int gpioWPi[] = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, 27};//车能使用高低引脚
const int gpioWPi_ship[] = {6, 10, 16, 20, 22, 23, 25, 27};//船能使用高低引脚
const int gpioWPi_ship[] = {5, 6, 7,10, 16, 20, 22, 23, 24,25,26, 27};//船能使用高低引脚
void pin_init()//初始化引脚,车和坦克共用
{
......@@ -464,7 +464,7 @@ void ship_mode_2_back(unsigned char gval)
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
digitalWrite(24, LOW);
digitalWrite(26, HIGH);
digitalWrite(26,HIGH );
if(gval<50)
{
......@@ -560,15 +560,15 @@ void ship_mode_2_back(unsigned char gval)
void ship_mode_3_left(unsigned char gval)
{
digitalWrite(5, LOW);
digitalWrite(7, LOW);
digitalWrite(24, LOW);
digitalWrite(26, LOW);
}
void ship_mode_4_right(unsigned char gval)
{
digitalWrite(24, LOW);
digitalWrite(26, LOW);
digitalWrite(5, LOW);
digitalWrite(7, LOW);
}
void ship_speed_change(unsigned char *buf)//船速度和转向引脚数值处理函数
......
No preview for this file type
......@@ -7,6 +7,8 @@ char* TOPIC3;
int gPwmCount = 0; // 计数
int gmessage_type=10086;
uint8_t AppExit_pin_pwm=0;//判断坦克或者车的退出
int rc=0;//判断mqtt是否成功创建
unsigned char modeTemp=0;
......@@ -107,7 +109,8 @@ void message_3(cJSON *body,cJSON *pwm_ctrl)//message_type为3,控制pwm
printf("typeTemp:%d\n",gvalt[0]);
printf("modeTemp:%d\n",gvalt[1]);
printf("valTemp:%d\n",gvalt[2]);
speed_change(gvalt);
if(AppExit_pin_pwm==1)speed_change(gvalt);
if(AppExit_pin_pwm==3)ship_speed_change(gvalt);
}
void message_4(cJSON *body, cJSON *pin_setctrl)//message 为4时候
......
No preview for this file type
#include "main.h"
char buffer[30]; // 用于存储文件内容
uint8_t AppExit_pin_pwm=0;//判断坦克或者车的退出
void *AppExit(void *arg)//出现意外自动停止
{
......
No preview for this file type
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