初始化仓库
This commit is contained in:
85
code/button.c
Normal file
85
code/button.c
Normal file
@@ -0,0 +1,85 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* button.c
|
||||
*
|
||||
* Created on: 2025<32><35>4<EFBFBD><34>19<31><39>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
|
||||
#include "button.h"
|
||||
|
||||
gpio_pin_enum BUTTON_PIN[BUTTON_PIN_NUM] = BUTTON_PINS;
|
||||
uint8 button_state[BUTTON_PIN_NUM]; // <20><><EFBFBD><EFBFBD>״̬
|
||||
uint16 button_last_time[BUTTON_PIN_NUM]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
|
||||
void Button_Init(void)
|
||||
{
|
||||
for(int i = 0; i < BUTTON_PIN_NUM; i++)
|
||||
{
|
||||
gpio_init(BUTTON_PIN[i], GPI, GPIO_LOW, GPI_PULL_UP); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD>ʼ<EFBFBD><CABC>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
memset(button_state, 0, sizeof(button_state)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
memset(button_last_time, 0, sizeof(button_last_time)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD>״̬
|
||||
}
|
||||
|
||||
void Button_Scan()
|
||||
{
|
||||
for(int i = 0; i < BUTTON_PIN_NUM; i++)
|
||||
{
|
||||
if(gpio_get_level(BUTTON_PIN[i]) == GPIO_LOW) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
button_last_time[i] += BUTTON_SCAN_TIME; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
else // <20><><EFBFBD><EFBFBD><EFBFBD>ɿ<EFBFBD>
|
||||
{
|
||||
if(button_last_time[i] >= BUTTON_SHORT_PRESS_TIME && button_last_time[i] < BUTTON_LONG_PRESS_TIME) // <20>̰<EFBFBD>
|
||||
{
|
||||
button_state[i] = BUTTON_SHORT_PRESS; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD>̰<EFBFBD>״̬
|
||||
}
|
||||
else // δ<><CEB4><EFBFBD><EFBFBD>
|
||||
{
|
||||
if(button_state[i] == BUTTON_LONG_PRESS || button_state[i] == BUTTON_LONG_PRESS_GOT) // <20><><EFBFBD><EFBFBD>֮ǰ<D6AE>dz<EFBFBD><C7B3><EFBFBD>״̬
|
||||
{
|
||||
button_state[i] = BUTTON_RELEASE;
|
||||
}
|
||||
// button_state[i] = BUTTON_RELEASE; // <20><><EFBFBD><EFBFBD>Ϊδ<CEAA><CEB4><EFBFBD><EFBFBD>״̬
|
||||
}
|
||||
button_last_time[i] = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
if(button_last_time[i] >= BUTTON_LONG_PRESS_TIME) // <20><><EFBFBD><EFBFBD>
|
||||
{
|
||||
if(button_state[i] != BUTTON_LONG_PRESS_GOT) // <20><><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD>dz<EFBFBD><C7B3><EFBFBD>GOT״̬
|
||||
{
|
||||
button_state[i] = BUTTON_LONG_PRESS; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>״̬
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
uint8 Button_Get_State(uint8 button_num)
|
||||
{
|
||||
if(button_num >= BUTTON_PIN_NUM) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>
|
||||
{
|
||||
return -1; // <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>
|
||||
}
|
||||
uint8 tmp_sta = button_state[button_num];
|
||||
if(button_state[button_num] == BUTTON_LONG_PRESS)
|
||||
{
|
||||
button_state[button_num] = BUTTON_LONG_PRESS_GOT;
|
||||
}
|
||||
return tmp_sta; // <20><><EFBFBD>ذ<EFBFBD><D8B0><EFBFBD>״̬
|
||||
}
|
||||
|
||||
|
||||
void Button_Reset(uint8 button_num)
|
||||
{
|
||||
if(button_num >= BUTTON_PIN_NUM) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>
|
||||
{
|
||||
return ; // <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>
|
||||
}
|
||||
button_state[button_num] = BUTTON_RELEASE; // <20><><EFBFBD>ð<EFBFBD><C3B0><EFBFBD>״̬Ϊδ<CEAA><CEB4><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
37
code/button.h
Normal file
37
code/button.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* button.h
|
||||
*
|
||||
* Created on: 2025<32><35>4<EFBFBD><34>19<31><39>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
#ifndef CODE_BUTTON_H_
|
||||
#define CODE_BUTTON_H_
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
|
||||
#define BUTTON_PIN_NUM 5 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define BUTTON_PINS {P02_4, P02_5,P02_6,P02_7,P02_8}
|
||||
|
||||
#define BUTTON_SCAN_TIME 5 // <20><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC>λms
|
||||
#define BUTTON_SHORT_PRESS_TIME 30 // <20><><EFBFBD><EFBFBD><EFBFBD>̰<EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC>λms
|
||||
#define BUTTON_LONG_PRESS_TIME 1000 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC>λms
|
||||
|
||||
#define BUTTON_SHORT_PRESS 1 // <20>̰<EFBFBD>
|
||||
#define BUTTON_LONG_PRESS 2 // <20><><EFBFBD><EFBFBD>
|
||||
#define BUTTON_RELEASE 0 // <20>ɿ<EFBFBD>
|
||||
#define BUTTON_LONG_PRESS_GOT 3
|
||||
|
||||
extern gpio_pin_enum BUTTON_PIN[BUTTON_PIN_NUM]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
// extern uint8 button_state[BUTTON_PIN_NUM]; // <20><><EFBFBD><EFBFBD>״̬
|
||||
// extern uint16 button_last_time[BUTTON_PIN_NUM]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
|
||||
void Button_Init(void); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void Button_Scan(void); // <20><><EFBFBD><EFBFBD>ɨ<EFBFBD>躯<EFBFBD><E8BAAF>
|
||||
uint8 Button_Get_State(uint8 button_num); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
||||
void Button_Reset(uint8 button_num);
|
||||
|
||||
#endif /* CODE_BUTTON_H_ */
|
||||
71
code/filter.c
Normal file
71
code/filter.c
Normal file
@@ -0,0 +1,71 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* filter.c
|
||||
*
|
||||
* Created on: 2025<32><35>4<EFBFBD><34>6<EFBFBD><36>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
#include "filter.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn Init_lowPass_alpha
|
||||
* @brief <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ͨ<EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
* @param filter <20>˲<EFBFBD><CBB2><EFBFBD>
|
||||
* @param ts <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>λs
|
||||
* @return fc <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5> <20><>λhz
|
||||
******************************************************************************/
|
||||
void Init_lowPass_alpha(low_pass_filter_t* const filter,const float ts, const float fc)
|
||||
{
|
||||
float b=2*M_PI*fc*ts;
|
||||
filter->ts=ts;
|
||||
filter->fc=fc;
|
||||
filter->lastYn=0;
|
||||
filter->alpha=b/(b+1);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn Low_pass_filter
|
||||
* @brief <20><>ͨ<EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param data <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return <20>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
******************************************************************************/
|
||||
float Low_pass_filter(low_pass_filter_t* const filter, const float data)
|
||||
{
|
||||
float tem=filter->lastYn+(filter->alpha*(data-filter->lastYn));
|
||||
filter->lastYn=tem;
|
||||
return tem;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn Init_hightPass_alpha
|
||||
* @brief <20><>ʼ<EFBFBD><CABC>ͨ<EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
* @param filter <20>˲<EFBFBD><CBB2><EFBFBD>
|
||||
* @param ts <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>λs
|
||||
* @return fc <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5> <20><>λhz
|
||||
******************************************************************************/
|
||||
void Init_hightPass_alpha(hight_pass_filter_t* const filter,const float ts, const float fc)
|
||||
{
|
||||
float b=2*M_PI*fc*ts;
|
||||
filter->ts=ts;
|
||||
filter->fc=fc;
|
||||
filter->lastYn=0;
|
||||
filter->lastXn=0;
|
||||
filter->alpha=1/(1+b);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn Hight_pass_filter
|
||||
* @brief <20><>ͨ<EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param data <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return <20>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
******************************************************************************/
|
||||
float Hight_pass_filter(hight_pass_filter_t* const filter, const float data)
|
||||
{
|
||||
float tem=((filter->alpha)*(filter->lastYn))+((filter->alpha)*(data-(filter->lastXn)));
|
||||
filter->lastYn=tem;
|
||||
filter->lastXn=data;
|
||||
return tem;
|
||||
|
||||
}
|
||||
47
code/filter.h
Normal file
47
code/filter.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* filter.h
|
||||
*
|
||||
* Created on: 2025<32><35>4<EFBFBD><34>6<EFBFBD><36>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
#ifndef CODE_FILTER_H_
|
||||
#define CODE_FILTER_H_
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI (3.141592f)
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float ts; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(s)
|
||||
float fc; //<2F><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>(hz)
|
||||
float lastYn; //<2F><>һ<EFBFBD><D2BB><EFBFBD>˲<EFBFBD>ֵ
|
||||
float alpha; //<2F>˲<EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
} low_pass_filter_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float ts; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(s)
|
||||
float fc; //<2F><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>(hz)
|
||||
float lastYn; //<2F><>һ<EFBFBD><D2BB><EFBFBD>˲<EFBFBD>ֵ
|
||||
float lastXn; //<2F><>һ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>ֵ
|
||||
float alpha; //<2F>˲<EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
} hight_pass_filter_t;
|
||||
|
||||
|
||||
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
void Init_lowPass_alpha(low_pass_filter_t* const filter,const float ts, const float fc);
|
||||
//<2F><>ͨ<EFBFBD>˲<EFBFBD>
|
||||
float Low_pass_filter(low_pass_filter_t* const filter, const float data);
|
||||
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
void Init_hightPass_alpha(hight_pass_filter_t* const filter,const float ts, const float fc);
|
||||
//<2F><>ͨ<EFBFBD>˲<EFBFBD>
|
||||
float Hight_pass_filter(hight_pass_filter_t* const filter, const float data);
|
||||
|
||||
|
||||
#endif /* CODE_FILTER_H_ */
|
||||
136
code/pid.c
Normal file
136
code/pid.c
Normal file
@@ -0,0 +1,136 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* pid.c
|
||||
*
|
||||
* Created on: 2025<32><35>3<EFBFBD><33>25<32><35>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
#include "pid.h"
|
||||
#include "math.h"
|
||||
|
||||
|
||||
void PID_Init(PID *pid, float kp, float ki, float kd, float integral_max, float output_max, float output_min)
|
||||
{
|
||||
pid->kp = kp;
|
||||
pid->ki = ki;
|
||||
pid->kd = kd;
|
||||
|
||||
pid->integral_max = integral_max;
|
||||
|
||||
pid->output_max = output_max;
|
||||
pid->output_min = output_min;
|
||||
|
||||
pid->p_output = 0;
|
||||
pid->i_output = 0;
|
||||
pid->d_output = 0;
|
||||
pid->output = 0;
|
||||
|
||||
pid->err = 0;
|
||||
pid->err_last = 0;
|
||||
pid->last_derivative = 0;
|
||||
pid->integral = 0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>float constrain_float(float amt, float low, float high)
|
||||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>
|
||||
* @param amt <20><> <20><><EFBFBD><EFBFBD>
|
||||
* @param low <20><> <20><><EFBFBD><EFBFBD>ֵ
|
||||
* @param high <20><> <20><><EFBFBD><EFBFBD>ֵ
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>
|
||||
*************************************************************************/
|
||||
float constrain_float(float amt, float low, float high)
|
||||
{
|
||||
return ((amt)<(low)?(low):((amt)>(high)?(high):(amt)));
|
||||
}
|
||||
|
||||
|
||||
void PID_Reset(PID *pid)
|
||||
{
|
||||
pid->p_output = 0;
|
||||
pid->i_output = 0;
|
||||
pid->d_output = 0;
|
||||
pid->output = 0;
|
||||
|
||||
pid->err = 0;
|
||||
pid->err_last = 0;
|
||||
pid->last_derivative = 0;
|
||||
pid->integral = 0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>float PidLocCtrl(pid_param_t * pid, float err)
|
||||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>pidλ<64><CEBB>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>
|
||||
* @param pid pid<69><64><EFBFBD><EFBFBD>
|
||||
* @param err pid<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>PID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*************************************************************************/
|
||||
|
||||
float PID_Loc_Ctrl(PID * pid, float err)
|
||||
{
|
||||
/* <20>ۻ<EFBFBD><DBBB><EFBFBD><EFBFBD><EFBFBD> */
|
||||
pid->err = err;
|
||||
pid->integral += pid->err;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
|
||||
pid->integral=constrain_float(pid->integral, -pid->integral_max, pid->integral_max);
|
||||
pid->p_output = pid->kp * pid->err;
|
||||
pid->i_output = pid->ki * pid->integral;
|
||||
pid->d_output = pid->kd * (pid->err - pid->err_last);
|
||||
|
||||
pid->err_last = pid->err;
|
||||
|
||||
pid->output = constrain_float(pid->p_output + pid->i_output + pid->d_output,pid->output_min,pid->output_max);
|
||||
|
||||
return pid->output;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>PidIncCtrl(pid_param_t * pid, float err)
|
||||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>pid<69><64><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>
|
||||
* @param pid pid<69><64><EFBFBD><EFBFBD>
|
||||
* @param err pid<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>PID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴν<CFB4><CEBD><EFBFBD>
|
||||
*************************************************************************/
|
||||
float PID_Inc_Ctrl(PID * pid, float err)
|
||||
{
|
||||
pid->p_output = pid->kp * (err - pid->err_last);
|
||||
// pid->i_output = pid->ki * err;
|
||||
pid->i_output = pid->ki * constrain_float(err, -pid->integral_max, pid->integral_max);
|
||||
pid->d_output = pid->kd * ((err - pid->err_last) - pid->last_derivative);
|
||||
|
||||
pid->last_derivative = err - pid->err_last;
|
||||
pid->err_last = err;
|
||||
|
||||
pid->output += pid->p_output + pid->i_output + pid->d_output;
|
||||
pid->output = constrain_float(pid->output,pid->output_min,pid->output_max);
|
||||
return pid->output;
|
||||
}
|
||||
|
||||
|
||||
float PID_ChangeIntegral_Inc_Ctrl(PID * pid, float err, float change_integral_b, float change_integral_k)
|
||||
{
|
||||
pid->p_output = pid->kp * (err - pid->err_last);
|
||||
// pid->i_output = pid->ki * err;
|
||||
float ki_c = pid->ki;
|
||||
if(err + pid->err_last > 0)
|
||||
{
|
||||
ki_c = pid->ki - pid->ki / (1 + expf(change_integral_b - fabsf(err) * change_integral_k));
|
||||
}
|
||||
pid->i_output = ki_c * constrain_float(err, -pid->integral_max, pid->integral_max);
|
||||
pid->d_output = pid->kd * ((err - pid->err_last) - pid->last_derivative);
|
||||
|
||||
pid->last_derivative = err - pid->err_last;
|
||||
pid->err_last = err;
|
||||
|
||||
pid->output += pid->p_output + pid->i_output + pid->d_output;
|
||||
pid->output = constrain_float(pid->output,pid->output_min,pid->output_max);
|
||||
return pid->output;
|
||||
}
|
||||
|
||||
42
code/pid.h
Normal file
42
code/pid.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* pid.h
|
||||
*
|
||||
* Created on: 2025<32><35>3<EFBFBD><33>25<32><35>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
#ifndef CODE_PID_H_
|
||||
#define CODE_PID_H_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float kp;
|
||||
float ki;
|
||||
float kd;
|
||||
|
||||
float p_output;
|
||||
float i_output;
|
||||
float d_output;
|
||||
float output;
|
||||
|
||||
float integral_max;
|
||||
|
||||
float err;
|
||||
float err_last;
|
||||
float last_derivative;
|
||||
float integral;
|
||||
|
||||
float output_max;
|
||||
float output_min;
|
||||
} PID;
|
||||
|
||||
void PID_Init(PID *pid, float kp, float ki, float kd, float integral_max, float output_max, float output_min);
|
||||
void PID_Reset(PID *pid);
|
||||
float PID_Loc_Ctrl(PID * pid, float err);
|
||||
float PID_Inc_Ctrl(PID * pid, float err);
|
||||
float PID_ChangeIntegral_Inc_Ctrl(PID * pid, float err, float change_integral_b, float change_integral_k);
|
||||
float constrain_float(float amt, float low, float high);
|
||||
|
||||
|
||||
#endif /* CODE_PID_H_ */
|
||||
39
code/status_led.c
Normal file
39
code/status_led.c
Normal file
@@ -0,0 +1,39 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* status_led.c
|
||||
*
|
||||
* Created on: 2025<32><35>3<EFBFBD><33>19<31><39>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "status_led.h"
|
||||
|
||||
|
||||
|
||||
void Status_LED_Init(void)
|
||||
{
|
||||
gpio_init((gpio_pin_enum)STATUS_LED_1, GPO, GPIO_HIGH, GPO_PUSH_PULL);
|
||||
gpio_init((gpio_pin_enum)STATUS_LED_2, GPO, GPIO_HIGH, GPO_PUSH_PULL);
|
||||
gpio_init((gpio_pin_enum)STATUS_LED_3, GPO, GPIO_HIGH, GPO_PUSH_PULL);
|
||||
gpio_init((gpio_pin_enum)STATUS_LED_4, GPO, GPIO_HIGH, GPO_PUSH_PULL);
|
||||
gpio_init((gpio_pin_enum)STATUS_LED_5, GPO, GPIO_HIGH, GPO_PUSH_PULL);
|
||||
}
|
||||
|
||||
void Flash_LED(status_led_index_enum led)
|
||||
{
|
||||
gpio_toggle_level((gpio_pin_enum)led);
|
||||
}
|
||||
|
||||
void ON_LED(status_led_index_enum led)
|
||||
{
|
||||
gpio_set_level((gpio_pin_enum)led,0);
|
||||
}
|
||||
|
||||
void OFF_LED(status_led_index_enum led)
|
||||
{
|
||||
gpio_set_level((gpio_pin_enum)led,1);
|
||||
}
|
||||
|
||||
35
code/status_led.h
Normal file
35
code/status_led.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* status_led.h
|
||||
*
|
||||
* Created on: 2025<32><35>3<EFBFBD><33>19<31><39>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
#ifndef CODE_STATUS_LED_H_
|
||||
#define CODE_STATUS_LED_H_
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
|
||||
typedef enum // ö<><C3B6>LED
|
||||
{
|
||||
STATUS_LED_1 = P13_0, //GREEN
|
||||
STATUS_LED_2 = P13_1, //BLUE
|
||||
STATUS_LED_3 = P13_2, //OLIVEDRAB
|
||||
STATUS_LED_4 = P13_3, //YELLOW
|
||||
STATUS_LED_5 = P11_2, //ORANGE
|
||||
STATUS_LED_6 = P11_3, //PERPLE
|
||||
STATUS_LED_7 = P11_6, //WHITE
|
||||
STATUS_LED_8 = P11_9, //WARMWHITE
|
||||
STATUS_LED_9 = P10_1, //ICEBLUE
|
||||
STATUS_LED_20 = P10_2, //PINK
|
||||
}status_led_index_enum;
|
||||
|
||||
|
||||
void Status_LED_Init(void);
|
||||
void Flash_LED(status_led_index_enum led);
|
||||
void ON_LED(status_led_index_enum led);
|
||||
void OFF_LED(status_led_index_enum led);
|
||||
|
||||
|
||||
#endif /* CODE_STATUS_LED_H_ */
|
||||
231
code/vofa_client.c
Normal file
231
code/vofa_client.c
Normal file
@@ -0,0 +1,231 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* vofa_client.c
|
||||
*
|
||||
* Created on: 2025<32><35>4<EFBFBD><34>4<EFBFBD><34>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
#include "vofa_client.h"
|
||||
|
||||
|
||||
float vofa_data[VOFA_RECEIVE_CH] = {0}; // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
float vofa_last_data = 0;
|
||||
uint8 vofa_last_ch = -1;
|
||||
uint8 vofa_receive_new_data[VOFA_RECEIVE_CH] = {0}; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD>־λ
|
||||
uint8 rev_count = 0; // <20><><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>
|
||||
uint8 rev_buffer[8] = {0}; // <20><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
uint8 failed_flag = 1;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8 send[4];
|
||||
float data;
|
||||
}float_data;
|
||||
|
||||
float_data fdata[VOFA_RECEIVE_CH + 1];
|
||||
uint8 endian_flag = 0; // <20><>С<EFBFBD>˱<EFBFBD>־λ
|
||||
uint8 tail[4] = {0x00, 0x00, 0x80, 0x7f};
|
||||
|
||||
static inline void Chage_BS(uint8 *data)
|
||||
{
|
||||
if(endian_flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 2; i++)
|
||||
{
|
||||
uint8 temp = data[i];
|
||||
data[i] = data[3 - i];
|
||||
data[3 - i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
void VOFA_Data_Init()
|
||||
{
|
||||
unsigned int x = 1;
|
||||
uint8 *endian_check = (uint8*)&x;
|
||||
if(endian_check[0] != 1)
|
||||
{
|
||||
endian_flag = 0;
|
||||
}
|
||||
// printf("flag:%d\n\r",endian_flag);
|
||||
memcpy(fdata[VOFA_SEND_CH].send, tail, sizeof(tail));
|
||||
|
||||
memset(vofa_data, 0, sizeof(vofa_data)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
memset(vofa_receive_new_data, 0, sizeof(vofa_receive_new_data)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD>־λ
|
||||
}
|
||||
|
||||
|
||||
uint8 VOFA_Connection_Init()
|
||||
{
|
||||
#if VOFA_CLIENT_COM_INTERFACE == 0
|
||||
// ʹ<>ô<EFBFBD><C3B4><EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
uart_init(VOFA_CLIENT_UART_PORT, VOFA_CLIENT_UART_BAUDRATE, VOFA_CLIENT_UART_RX, VOFA_CLIENT_UART_TX); // <20><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
uart_rx_interrupt(VOFA_CLIENT_UART_PORT, 1);
|
||||
#elif VOFA_CLIENT_COM_INTERFACE == 1
|
||||
// ʹ<><CAB9>WIFI SPIͨ<49><CDA8>
|
||||
uint32 failure_count = 0;
|
||||
while(wifi_spi_init(VOFA_CLIENT_WIFI_SSID, VOFA_CLIENT_WIFI_PASSWORD))
|
||||
{
|
||||
#if VOFA_CLIENT_WIFI_ENABLE_PRINTF
|
||||
printf("\r\n connect wifi failed. \r\n");
|
||||
#endif
|
||||
failure_count ++;
|
||||
if(failure_count > VOFA_CLIENT_WIFI_FAILURE_RETRY) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
system_delay_ms(100); // <20><>ʼ<EFBFBD><CABC>ʧ<EFBFBD><CAA7> <20>ȴ<EFBFBD> 100ms
|
||||
}
|
||||
|
||||
#if VOFA_CLIENT_WIFI_ENABLE_PRINTF
|
||||
printf("\r\n module version:%s",wifi_spi_version); // ģ<><C4A3><EFBFBD>̼<EFBFBD><CCBC>汾
|
||||
printf("\r\n module mac :%s",wifi_spi_mac_addr); // ģ<><C4A3> MAC <20><>Ϣ
|
||||
printf("\r\n module ip :%s",wifi_spi_ip_addr_port); // ģ<><C4A3> IP <20><>ַ
|
||||
#endif
|
||||
failure_count = 0;
|
||||
if(0 == WIFI_SPI_AUTO_CONNECT) // <20><><EFBFBD><EFBFBD>û<EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF> IP
|
||||
{
|
||||
while(wifi_spi_socket_connect( // <20><>ָ<EFBFBD><D6B8>Ŀ<EFBFBD><C4BF> IP <20>Ķ˿ڽ<CBBF><DABD><EFBFBD> TCP <20><><EFBFBD><EFBFBD>
|
||||
"TCP", // ָ<><D6B8>ʹ<EFBFBD><CAB9>TCP<43><50>ʽͨѶ
|
||||
VOFA_CLIENT_WIFI_TARGET_IP, // ָ<><D6B8>Զ<EFBFBD>˵<EFBFBD>IP<49><50>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>д<EFBFBD><D0B4>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>IP<49><50>ַ
|
||||
VOFA_CLIENT_WIFI_TARGET_PORT, // ָ<><D6B8>Զ<EFBFBD>˵Ķ˿ںţ<DABA><C5A3><EFBFBD>д<EFBFBD><D0B4>λ<EFBFBD><CEBB><EFBFBD>Ķ˿ںţ<DABA>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>8080
|
||||
VOFA_CLIENT_WIFI_LOCAL_PORT)) // ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ˿ں<CBBF>
|
||||
{
|
||||
#if VOFA_CLIENT_WIFI_ENABLE_PRINTF
|
||||
printf("\r\n socket connect failed. \r\n");
|
||||
#endif
|
||||
failure_count ++;
|
||||
if(failure_count > VOFA_CLIENT_WIFI_FAILURE_RETRY) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
system_delay_ms(100); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7> <20>ȴ<EFBFBD> 100ms
|
||||
}
|
||||
}
|
||||
|
||||
#elif VOFA_CLIENT_COM_INTERFACE == 2
|
||||
// <20><>д<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ӿڵij<DAB5>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#endif
|
||||
failed_flag = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint8 VOFA_Client_Init()
|
||||
{
|
||||
VOFA_Data_Init();
|
||||
return VOFA_Connection_Init();
|
||||
}
|
||||
|
||||
void VOFA_Sender(uint8 *p, uint32 len)
|
||||
{
|
||||
if(failed_flag) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><F2B2BBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if VOFA_CLIENT_COM_INTERFACE == 0
|
||||
uart_write_buffer(VOFA_CLIENT_UART_PORT,p,len);
|
||||
#elif VOFA_CLIENT_COM_INTERFACE == 1
|
||||
wifi_spi_send_buffer(p,len);
|
||||
#elif VOFA_CLIENT_COM_INTERFACE == 2
|
||||
// <20><>д<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ӿڵķ<DAB5><C4B7>ʹ<EFBFBD><CDB4><EFBFBD>
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void VOFA_Receiver_Callback()
|
||||
{
|
||||
if(failed_flag) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><F2B2BBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint8 rev_tmp = 0;
|
||||
uint8 tmp[4] = {0};
|
||||
#if VOFA_CLIENT_COM_INTERFACE == 0
|
||||
while(uart_query_byte(VOFA_CLIENT_UART_PORT, &rev_tmp))
|
||||
#elif VOFA_CLIENT_COM_INTERFACE == 1
|
||||
while(wifi_spi_read_buffer(&rev_tmp,1))
|
||||
#elif VOFA_CLIENT_COM_INTERFACE == 2
|
||||
// <20><>д<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ӿڵĽ<DAB5><C4BD>մ<EFBFBD><D5B4><EFBFBD>,ÿ<>λ<EFBFBD>ȡһ<C8A1><D2BB><EFBFBD>ֽ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
|
||||
#endif
|
||||
{
|
||||
if(rev_tmp == 0xA6 && rev_buffer[0] != 0xA6) // <20>ж<EFBFBD>֡ͷ
|
||||
{
|
||||
rev_count = 0; // δ<>յ<EFBFBD>֡ͷ<D6A1><CDB7><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>֡ͷ<D6A1><CDB7><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
||||
}
|
||||
rev_buffer[rev_count++] = rev_tmp; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(rev_count >= 7) // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>յ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
if(rev_buffer[0] == 0xA6) // <20>ж<EFBFBD>֡ͷ<D6A1>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ
|
||||
{
|
||||
if(rev_buffer[1] == rev_buffer[6] && rev_buffer[1] < VOFA_RECEIVE_CH)
|
||||
{
|
||||
tmp[0] = rev_buffer[2]; // <20><><EFBFBD>ֽ<EFBFBD>
|
||||
tmp[1] = rev_buffer[3]; // <20><><EFBFBD>ֽ<EFBFBD>
|
||||
tmp[2] = rev_buffer[4]; // <20><><EFBFBD>ֽ<EFBFBD>
|
||||
tmp[3] = rev_buffer[5]; // <20><><EFBFBD>ֽ<EFBFBD>
|
||||
// Chage_BS(tmp);
|
||||
vofa_last_ch = rev_buffer[1]; // <20><><EFBFBD><EFBFBD><EFBFBD>ϴν<CFB4><CEBD><EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
memcpy(&vofa_data[vofa_last_ch], tmp, 4); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
vofa_receive_new_data[rev_buffer[1]] = 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD>־λ<D6BE><CEBB>λ
|
||||
vofa_last_data = vofa_data[vofa_last_ch]; // <20><><EFBFBD><EFBFBD><EFBFBD>ϴν<CFB4><CEBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
}
|
||||
rev_count = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
rev_buffer[0] = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VOFA_Set_JustFloat_Data(int CH, float data)
|
||||
{
|
||||
fdata[CH].data = data;
|
||||
// Chage_BS(fdata[CH].send);
|
||||
}
|
||||
|
||||
void VOFA_Set_JustFloat_Datas_From_Start(int num,...)
|
||||
{
|
||||
va_list Valist;
|
||||
int i = 0;
|
||||
va_start(Valist, num);
|
||||
|
||||
for(i = 0; i < num; ++i)
|
||||
{
|
||||
fdata[i].data = va_arg(Valist, float);
|
||||
Chage_BS(fdata[i].send);
|
||||
}
|
||||
va_end(Valist);
|
||||
}
|
||||
|
||||
void VOFA_Send_Datas(int num)
|
||||
{
|
||||
uint8 *p = fdata[0].send;
|
||||
memcpy(fdata[num].send, tail, sizeof(tail));
|
||||
VOFA_Sender(p, 4 * (num + 1));
|
||||
}
|
||||
|
||||
|
||||
void VOFA_Send_JustFloat_Image(int IMG_ID, int IMG_WIDTH, int IMG_HEIGHT,int IMG_DATA_SIZE, ImgFormat IMG_FORMAT,uint8* IMG_DATA)
|
||||
{
|
||||
int preFrame[7] = {
|
||||
IMG_ID,
|
||||
IMG_DATA_SIZE,
|
||||
IMG_WIDTH,
|
||||
IMG_HEIGHT,
|
||||
(int)IMG_FORMAT,
|
||||
0x7F800000,
|
||||
0x7F800000
|
||||
};
|
||||
uint8 preFrameData[28] = {0};
|
||||
memcpy(preFrameData, preFrame, sizeof(int)*7); // <20><><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
VOFA_Sender(preFrameData, sizeof(int)*7); // <20><><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
VOFA_Sender(IMG_DATA, IMG_DATA_SIZE); // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
97
code/vofa_client.h
Normal file
97
code/vofa_client.h
Normal file
@@ -0,0 +1,97 @@
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: GB18030
|
||||
/*
|
||||
* vofa_client.h
|
||||
*
|
||||
* Created on: 2025<32><35>4<EFBFBD><34>4<EFBFBD><34>
|
||||
* Author: LHYe200
|
||||
*/
|
||||
|
||||
#ifndef CODE_VOFA_CLIENT_H_
|
||||
#define CODE_VOFA_CLIENT_H_
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
|
||||
#define VOFA_CLIENT_COM_INTERFACE (1) // 0:<3A><><EFBFBD><EFBFBD> 1:WIFI<46><49><EFBFBD><EFBFBD>SPI 2:<3A>Զ<EFBFBD><D4B6><EFBFBD>
|
||||
#define VOFA_RECEIVE_CH (64) // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>256<35><36>ͨ<EFBFBD><CDA8>
|
||||
#define VOFA_SEND_CH (32) // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
|
||||
|
||||
#if VOFA_CLIENT_COM_INTERFACE == 0
|
||||
|
||||
#define VOFA_CLIENT_UART_PORT UART_0 // <20><><EFBFBD>ں<EFBFBD>
|
||||
#define VOFA_CLIENT_UART_BAUDRATE 115200 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define VOFA_CLIENT_UART_RX UART0_RX_P14_1 // <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define VOFA_CLIENT_UART_TX UART0_TX_P14_0 // <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#elif VOFA_CLIENT_COM_INTERFACE == 1
|
||||
|
||||
#define VOFA_CLIENT_WIFI_SSID "tu-car" // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>WiFi SSID
|
||||
#define VOFA_CLIENT_WIFI_PASSWORD "tu12345678" // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>WiFi<46><69><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻ΪNULL
|
||||
#define VOFA_CLIENT_WIFI_TARGET_IP "192.168.0.104" // <20><>д<EFBFBD><D0B4>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>IP<49><50>ַ
|
||||
#define VOFA_CLIENT_WIFI_TARGET_PORT "1347" // <20><>д<EFBFBD><D0B4>λ<EFBFBD><CEBB><EFBFBD>Ķ˿ں<CBBF>
|
||||
#define VOFA_CLIENT_WIFI_LOCAL_PORT "6666" // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ķ˿ں<CBBF>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д,<2C><><EFBFBD>Dz<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
|
||||
#define VOFA_CLIENT_WIFI_FAILURE_RETRY (3) // <20><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
|
||||
#define VOFA_CLIENT_WIFI_ENABLE_PRINTF (0) // <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>WiFi<46><69>ӡ<EFBFBD><D3A1>Ϣ
|
||||
|
||||
#elif VOFA_CLIENT_COM_INTERFACE == 2
|
||||
// <20><>д<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ӿڵ<D3BF><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
|
||||
#endif
|
||||
|
||||
extern float vofa_data[VOFA_RECEIVE_CH]; // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern uint8 vofa_receive_new_data[VOFA_RECEIVE_CH]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD>־λ,<2C><><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern float vofa_last_data; // <20><><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern uint8 vofa_last_ch; // <20><><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
|
||||
typedef enum{
|
||||
Format_Invalid,
|
||||
Format_Mono,
|
||||
Format_MonoLSB,
|
||||
Format_Indexed8,
|
||||
Format_RGB32,
|
||||
Format_ARGB32,
|
||||
Format_ARGB32_Premultiplied,
|
||||
Format_RGB16,
|
||||
Format_ARGB8565_Premultiplied,
|
||||
Format_RGB666,
|
||||
Format_ARGB6666_Premultiplied,
|
||||
Format_RGB555,
|
||||
Format_ARGB8555_Premultiplied,
|
||||
Format_RGB888,
|
||||
Format_RGB444,
|
||||
Format_ARGB4444_Premultiplied,
|
||||
Format_RGBX8888,
|
||||
Format_RGBA8888,
|
||||
Format_RGBA8888_Premultiplied,
|
||||
Format_BGR30,
|
||||
Format_A2BGR30_Premultiplied,
|
||||
Format_RGB30,
|
||||
Format_A2RGB30_Premultiplied,
|
||||
Format_Alpha8,
|
||||
Format_Grayscale8,
|
||||
|
||||
// <20><><EFBFBD>¸<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>IMG_WIDTH<54><48>IMG_HEIGHT<48><54><EFBFBD><EFBFBD>Ҫǿ<D2AA><C7BF>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ-1<><31><EFBFBD><EFBFBD>
|
||||
Format_BMP,
|
||||
Format_GIF,
|
||||
Format_JPG,
|
||||
Format_PNG,
|
||||
Format_PBM,
|
||||
Format_PGM,
|
||||
Format_PPM,
|
||||
Format_XBM,
|
||||
Format_XPM,
|
||||
Format_SVG,
|
||||
} ImgFormat ;
|
||||
|
||||
extern uint8 rev_count;
|
||||
|
||||
void VOFA_Data_Init(void);
|
||||
uint8 VOFA_Connection_Init(void);
|
||||
uint8 VOFA_Client_Init(void); // VOFA<46>ͻ<EFBFBD><CDBB>˳<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void VOFA_Set_JustFloat_Data(int CH, float data); // <20><><EFBFBD><EFBFBD>ijͨ<C4B3><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void VOFA_Set_JustFloat_Datas_From_Start(int num,...); // <20><><EFBFBD>ôӵ<C3B4>һ<EFBFBD><D2BB>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>ʼ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void VOFA_Send_Datas(int num); // <20>ӵ<EFBFBD>һ<EFBFBD><D2BB>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void VOFA_Send_JustFloat_Image(int IMG_ID, int IMG_WIDTH, int IMG_HEIGHT, int IMG_DATA_SIZE, ImgFormat IMG_FORMAT,uint8 *IMG_DATA); // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void VOFA_Receiver_Callback(void); // <20><><EFBFBD>ջص<D5BB><D8B5><EFBFBD><EFBFBD><EFBFBD>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>е<EFBFBD><D0B5><EFBFBD>
|
||||
|
||||
#endif /* CODE_VOFA_CLIENT_H_ */
|
||||
|
||||
3
code/本文件夹作用.txt
Normal file
3
code/本文件夹作用.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CODE<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD>Ҫ<EFBFBD>ٴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD>ֱ<EFBFBD>ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CODE<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><EFBFBD><EFBFBD>
|
||||
Reference in New Issue
Block a user