This commit is contained in:
air 2025-05-08 22:12:34 +08:00
commit 35816f15af
5 changed files with 21 additions and 25 deletions

View File

@ -180,7 +180,7 @@ void FoodCube::connectMqtt(String topicSub)
log("MQTT Server Connect Failed. Client State:"); log("MQTT Server Connect Failed. Client State:");
logln(mqttClient->state()); logln(mqttClient->state());
_tm_mqttconnect = millis(); _tm_mqttconnect = millis();
playText("服务器断开尝试重新连接");
// delay(3000); // delay(3000);
} }
} }
@ -306,6 +306,7 @@ void FoodCube::playText(String str, bool flying)
{ {
command[index++] = (int)vstr[i]; command[index++] = (int)vstr[i];
} }
logln("playText");
/* /*
log("sendplay:"); log("sendplay:");
for (int i = 0; i < sizeof(command); i++) { for (int i = 0; i < sizeof(command); i++) {
@ -694,7 +695,7 @@ void FoodCube::mav_channels_override(uint16_t chan[])
mavlink_message_t msg; // mavlink协议信息(msg) mavlink_message_t msg; // mavlink协议信息(msg)
uint8_t buf[MAVLINK_MAX_PACKET_LEN]; // 发送的缓存 uint8_t buf[MAVLINK_MAX_PACKET_LEN]; // 发送的缓存
// 控制油门 // 控制油门
mavlink_msg_rc_channels_override_pack(MAVLINK_SYSTEM_ID, MAVLINK_COMPONENT_ID, &msg, 1, 1, chan[0], chan[1], chan[2], chan[3], 0xffff, 0xffff, 0xffff, 0xffff); mavlink_msg_rc_channels_override_pack(0xFF, 0xBE, &msg, 1, 1, chan[0], chan[1], chan[2], chan[3], 0xffff, 0xffff, 0xffff, 0xffff);
int len = mavlink_msg_to_send_buffer(buf, &msg); int len = mavlink_msg_to_send_buffer(buf, &msg);
// 通过串口发送 // 通过串口发送
SWrite(buf, len, mavlinkSerial); SWrite(buf, len, mavlinkSerial);

View File

@ -20,9 +20,9 @@ static const char *MOUDLENAME = "COMMSER";
// char* password = "63587839ab"; //wifi密码 // char* password = "63587839ab"; //wifi密码
char *ssid = "flicube"; // wifi帐号 char *ssid = "flicube"; // wifi帐号
char *password = "fxmf0622"; // wifi密码 char *password = "fxmf0622"; // wifi密码
// char *ssid = "fxmf_sc01"; // 4g wifi帐号 // char *ssid = "fxmf_sc02"; // 4g wifi帐号
// char *password = "12345678"; // 4g wifi密码 // char *password = "12345678"; // 4g wifi密码
char *mqttServer = "szdot.top"; // mqtt地址 char *mqttServer = "wxsky.com"; // mqtt地址
int mqttPort = 1883; // mqtt端口 int mqttPort = 1883; // mqtt端口
char *mqttName = "admin"; // mqtt帐号 char *mqttName = "admin"; // mqtt帐号
char *mqttPassword = "123456"; // mqtt密码 char *mqttPassword = "123456"; // mqtt密码
@ -416,6 +416,16 @@ void mavlink_receiveCallback(uint8_t c)
// printf("mav_id:%d\n",msg.msgid); // printf("mav_id:%d\n",msg.msgid);
switch (msg.msgid) switch (msg.msgid)
{ {
// case MAVLINK_MSG_ID_RC_CHANNELS: // #65 遥控通道数据
// {
// Serial.println(msg.msgid);
// mavlink_rc_channels_t rc_channels;
// mavlink_msg_rc_channels_decode(&msg, &rc_channels);
// uint16_t throttle_value = rc_channels.chan3_raw; // ch3_raw 是油门通道的原始输
// Serial.println(throttle_value);
// }
// break;
case MAVLINK_MSG_ID_HOME_POSITION: // #242 返航点位置 case MAVLINK_MSG_ID_HOME_POSITION: // #242 返航点位置
{ {
char buf[120]; char buf[120];

View File

@ -4,7 +4,7 @@
/// ///
// //
#define VERSION "0.90" // 软件版本 #define VERSION "0.90" // 软件版本
#define VERSION_HW 1 // 硬件版本1:第一块硬件 2:目前版本 #define VERSION_HW 2 // 硬件版本1:第一块硬件 2:目前版本
// 硬件接口定义//////////////////////////// // 硬件接口定义////////////////////////////
// 按钮 // 按钮
#define BTN_UP 23 // 收线开关 接线BTN_UP---GND #define BTN_UP 23 // 收线开关 接线BTN_UP---GND

View File

@ -401,11 +401,7 @@ void loop()
// sercomm.getcommand(); // 得到控制命令 // sercomm.getcommand(); // 得到控制命令
button_checktop.tick(); // 按钮 button_checktop.tick(); // 按钮
button_down.tick(); // 按钮 button_down.tick(); // 按钮
fc.logln("hello"); button_up.tick(); // 按钮
fc.logln("hello");
fc.logln("hello");
fc.logln("hello");
button_up.tick(); // 按钮
button_test.tick(); button_test.tick();
motocontrol.setweight(pullweight); // 告诉电机拉的重量 motocontrol.setweight(pullweight); // 告诉电机拉的重量
motocontrol.update(); // 电机控制 motocontrol.update(); // 电机控制
@ -433,9 +429,8 @@ void loop()
} }
} }
} }
check_tare(); // 检查看是否需要校准称重 check_tare(); // 检查看是否需要校准称重
// 检测执行初始化工作 checkinited(); // 检测执行初始化工作
checkinited();
delay(1); delay(1);
} }
// 在核心0上执行耗时长的低优先级的 // 在核心0上执行耗时长的低优先级的
@ -648,16 +643,6 @@ void up_action(float motospeed)
// 放线按钮--单击 // 放线按钮--单击
void downbtn_click() void downbtn_click()
{ {
fc.logln("downbtn_click");
fc.logln("downbtn_click");
fc.logln("downbtn_click");
fc.logln("downbtn_click");
fc.logln("downbtn_click");
fc.logln("downbtn_click");
fc.logln("downbtn_click");
fc.logln("downbtn_click");
fc.logln("downbtn_click");
fc.logln("downbtn_click");
ESP_LOGD(MOUDLENAME, "Down_click"); ESP_LOGD(MOUDLENAME, "Down_click");
_checkweightcal = true; // 检测是否需要校准称重传感器--在下放停止时检测 _checkweightcal = true; // 检测是否需要校准称重传感器--在下放停止时检测
_checkweighttimes = 0; _checkweighttimes = 0;

View File

@ -5,8 +5,8 @@
#include <ESP32Servo.h> #include <ESP32Servo.h>
#define ROPE_MAXLENGTH 700 // 最多能放700cm---实际绳子应该比这个长750之类的 #define ROPE_MAXLENGTH 700 // 最多能放700cm---实际绳子应该比这个长750之类的
// #define WHEEL_DIAMETER 3.8 // 轮子直径cm 3公斤载重飞机 大轮 // #define WHEEL_DIAMETER 3.8 // 轮子直径cm
#define WHEEL_DIAMETER 2.3 // 轮子直径cm 10公斤载重飞机 小轮 #define WHEEL_DIAMETER 2.3 // 轮子直径cm 小轮子直径
#define WHEEL_PERIMETER (WHEEL_DIAMETER * 3.1416) // 轮子周长 #define WHEEL_PERIMETER (WHEEL_DIAMETER * 3.1416) // 轮子周长
#define ROPE_MAXCOUNT (ROPE_MAXLENGTH / WHEEL_PERIMETER) // 最大圈数 #define ROPE_MAXCOUNT (ROPE_MAXLENGTH / WHEEL_PERIMETER) // 最大圈数