depth.c
This commit is contained in:
parent
905f936721
commit
c53933c3c6
@ -27,7 +27,7 @@
|
||||
#define DEPTH_RESET_ADDR 510
|
||||
#define REBOOT_REW_ADDR 511
|
||||
|
||||
|
||||
#define TIME 264
|
||||
typedef struct
|
||||
{
|
||||
uint16_t magic;
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "esp_timer.h"
|
||||
|
||||
static const char *TAG = "depth";
|
||||
|
||||
@ -118,6 +118,7 @@ typedef struct{
|
||||
uint8_t TAG;
|
||||
int16_t flow[2];
|
||||
uint32_t total_flow[2];
|
||||
uint16_t time;
|
||||
}send_to_bt_t2;
|
||||
#pragma pack()
|
||||
|
||||
@ -128,8 +129,9 @@ typedef struct
|
||||
int16_t depth; // 14
|
||||
uint16_t sample_count; // 15
|
||||
uint16_t depth_flow[2]; // 16~17
|
||||
uint32_t last_total_flow[2]; // 18~21
|
||||
uint32_t last_total_flow[2]; //
|
||||
int16_t depth_offset; // 22
|
||||
uint16_t one_pile_work_time;//23 系统工作时间
|
||||
// uint32_t update_time;
|
||||
// int16_t tilt_x;
|
||||
// int16_t tilt_y;
|
||||
@ -336,6 +338,11 @@ void send_data_to_bt(void){
|
||||
send_to_bt2.flow[1] = pflow[1].flow;
|
||||
send_to_bt2.total_flow[0] = pflow[0].total_flow;
|
||||
send_to_bt2.total_flow[1] = pflow[1].total_flow;
|
||||
|
||||
/*计算开启后持续时间,并传给EC600U*/
|
||||
uint16_t time = 0;
|
||||
gWordVar[TIME] = time;
|
||||
send_to_bt2.time = time;
|
||||
#endif
|
||||
ESP_LOGI(TAG, "flow 1 :%d\n",send_to_bt2.flow[0]);
|
||||
ESP_LOGI(TAG, "flow 2 :%d\n",send_to_bt2.flow[1]);
|
||||
@ -371,7 +378,7 @@ void depth_task(void *arg)
|
||||
int time_diff = 0;
|
||||
int speed_timeout = 0;
|
||||
int last_speed_enc_value = 0; // 上次速度计算的编码器值
|
||||
int speed_enc_update_time = 0; // 上次速度计算的编码器值
|
||||
int speed_enc_update_time = 0;
|
||||
int speed_calc_count = 0;
|
||||
int enc_value = 0;
|
||||
//int count = 0;
|
||||
@ -383,9 +390,14 @@ void depth_task(void *arg)
|
||||
//send_to_bt1.pile_id = ++last_pile_id;
|
||||
|
||||
gWordVar[LAST_PILE_ID_ADDR] = last_pile_id;
|
||||
|
||||
/*获取当前时间*/
|
||||
uint16_t last_work_time = 0;
|
||||
uint16_t current_work_time = 0;
|
||||
uint8_t is_work = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
{
|
||||
if (_enc1_update_time != enc1_update_time)
|
||||
{
|
||||
ESP_LOGI(TAG, "_enc1_update_time != enc1_update_time\n");
|
||||
@ -445,8 +457,26 @@ void depth_task(void *arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (depth_data->up_down > STOP)
|
||||
{
|
||||
is_work ++;
|
||||
if(is_work == 1){
|
||||
depth_data->one_pile_work_time = 0;
|
||||
last_work_time = (uint16_t)(esp_timer_get_time()/1000000);
|
||||
}
|
||||
if(is_work > 1){
|
||||
current_work_time = (uint16_t)(esp_timer_get_time()/1000000);
|
||||
depth_data->one_pile_work_time = current_work_time - last_work_time;
|
||||
if(depth_data->one_pile_work_time < 0){
|
||||
depth_data->one_pile_work_time = 0;
|
||||
}
|
||||
last_work_time = current_work_time;
|
||||
}
|
||||
|
||||
depth_data->one_pile_work_time = current_work_time - last_work_time;
|
||||
|
||||
last_work_time = current_work_time;
|
||||
ESP_LOGI(TAG, "depth_data->up_down > STOP\n");
|
||||
if (enc_value > last_enc_value)
|
||||
{ // 下钻,深度增加
|
||||
@ -545,6 +575,10 @@ void depth_task(void *arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
is_work = 0;
|
||||
depth_data->one_pile_work_time = 0;
|
||||
}
|
||||
prev_depth = depth_data->depth;
|
||||
prev_update_time = enc_update_time;
|
||||
last_enc_value = enc_value;
|
||||
|
Loading…
Reference in New Issue
Block a user