variation int16_t -> int32_t, BLE上报2字节->3字节,去掉±32767截断
This commit is contained in:
@@ -516,6 +516,7 @@ void usart_packet_processing_acs_loop(uint8_t flag)
|
|||||||
|
|
||||||
g_tmp_report_buf.buf[i++] = (uint8_t)g_loop_acs_info.variation;
|
g_tmp_report_buf.buf[i++] = (uint8_t)g_loop_acs_info.variation;
|
||||||
g_tmp_report_buf.buf[i++] = (g_loop_acs_info.variation >> 8) % 0x100;
|
g_tmp_report_buf.buf[i++] = (g_loop_acs_info.variation >> 8) % 0x100;
|
||||||
|
g_tmp_report_buf.buf[i++] = (g_loop_acs_info.variation >> 16) % 0x100;
|
||||||
|
|
||||||
|
|
||||||
g_tmp_report_buf.len = i;
|
g_tmp_report_buf.len = i;
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* dbn_ble_srv.c
|
||||||
|
*
|
||||||
|
* Created on: Aug 27, 2024
|
||||||
|
* Author: Thinkpad
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dbn_ble_srv.h"
|
||||||
|
#include "cmcng.h"
|
||||||
|
#include "storage.h"
|
||||||
|
#include "CH59x_common.h"
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t g_flag_notify_temp = 0; //
|
||||||
@@ -163,7 +163,7 @@ typedef struct _LOOP_ACS_INFO
|
|||||||
uint8_t flag_change;
|
uint8_t flag_change;
|
||||||
uint32_t frequent;
|
uint32_t frequent;
|
||||||
uint32_t loop_capvd;
|
uint32_t loop_capvd;
|
||||||
int16_t variation;
|
int32_t variation;
|
||||||
uint32_t event_counter;
|
uint32_t event_counter;
|
||||||
uint32_t report_counter;
|
uint32_t report_counter;
|
||||||
} Loop_ACS_Info;
|
} Loop_ACS_Info;
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* storage.h
|
||||||
|
*
|
||||||
|
* Created on: Aug 27, 2024
|
||||||
|
* Author: Thinkpad
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDE_STORAGE_H_
|
||||||
|
#define INCLUDE_STORAGE_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
// #define Addr_Loop_PlanB_Cng_Offset 0x10
|
||||||
|
// #define Addr_Flag_Sample_In 0x10
|
||||||
|
// #define Addr_Sample_Max_Amplitude 0x11
|
||||||
|
// #define Addr_Flag_Balance_Ori_In 0x13
|
||||||
|
// #define Addr_Balance_Ori_In_Max_Cnt 0x14
|
||||||
|
// #define Addr_Flag_Release_Ori_PlanB 0x16
|
||||||
|
// #define Addr_Release_Ori_PlanB_TimeOut 0x17
|
||||||
|
// #define Addr_Release_Ori_PlanB_Weight 0x18
|
||||||
|
// #define Addr_Release_Ori_Amplitude 0x19
|
||||||
|
// #define Addr_Flag_Release_Rate 0x1B
|
||||||
|
// #define Addr_Release_Rate_First 0x1C
|
||||||
|
// #define Addr_Release_Rate_Second 0x1D
|
||||||
|
// #define Addr_Release_Rate_Weight 0x1E
|
||||||
|
// #define Addr_Release_Rate_Mode 0x1F
|
||||||
|
|
||||||
|
#define Addr_Loop_Sens_List_Offset 0x20
|
||||||
|
|
||||||
|
#define Addr_Sens_Array_In 0x20
|
||||||
|
#define Addr_Sens_Array_Out 0x30
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_LOOP_SENS_AMOUNT 3 // 4 // 5
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
typedef struct _Loop_Sample_CNG_
|
||||||
|
{
|
||||||
|
uint8_t flag;
|
||||||
|
uint16_t max_amplitude; //
|
||||||
@@ -581,9 +581,7 @@ void vd1_task(void){
|
|||||||
if (g_loop_acs_info.flag_change == 0) {
|
if (g_loop_acs_info.flag_change == 0) {
|
||||||
int32_t _var = (int32_t)loop1_Origin - (int32_t)loop1_CAPVD;
|
int32_t _var = (int32_t)loop1_Origin - (int32_t)loop1_CAPVD;
|
||||||
g_loop_acs_info.loop_capvd = loop1_CAPVD;
|
g_loop_acs_info.loop_capvd = loop1_CAPVD;
|
||||||
if (_var > 32767) _var = 32767;
|
g_loop_acs_info.variation = _var;
|
||||||
if (_var < -32768) _var = -32768;
|
|
||||||
g_loop_acs_info.variation = (int16_t)_var;
|
|
||||||
if (g_flag_bt_state && (_var > VARIATION_EVENT_TH || _var < -VARIATION_EVENT_TH)) {
|
if (g_flag_bt_state && (_var > VARIATION_EVENT_TH || _var < -VARIATION_EVENT_TH)) {
|
||||||
g_loop_acs_info.flag_event = 1;
|
g_loop_acs_info.flag_event = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/********************************** (C) COPYRIGHT *******************************
|
||||||
|
* File Name : peripheral_main.c
|
||||||
|
* Author : WCH / wangfq
|
||||||
|
* Version : V2.0 (algorithm ported from DLD154V4B)
|
||||||
|
* Date : 2026/07/18
|
||||||
|
* Description : DLD110SV4
|
||||||
Reference in New Issue
Block a user