#ifndef __CALC_LIB_H__ #define __CALC_LIB_H__ #ifdef __cplusplus extern "C"{ #endif #include "struct_typedef.h" #include #define rad(code) ((code)*MOTOR_ECD_TO_RAD) #define int_abs(x) ((x) > 0 ? (x) : (-x)) //电机编码值规整 0—8191 #define ecd_format(ecd) \ { \ if ((ecd) > 8191) \ (ecd) -= 8191; \ else if ((ecd) < 0) \ (ecd) += 8191; \ } void user_delay_us(uint16_t us); void user_delay_ms(uint16_t ms); void abs_limit_fp(fp32 *num, fp32 Limit); void abs_limit_int(int64_t *num, int64_t Limit); fp32 loop_fp32_constrain(fp32 Input, fp32 minValue, fp32 maxValue); int32_t loop_int32_constrain(int32_t Input, int32_t minValue, int32_t maxValue); int map(int x, int in_min, int in_max, int out_min, int out_max); fp32 map_fp32(fp32 x, fp32 in_min, fp32 in_max, fp32 out_min, fp32 out_max); #ifdef __cplusplus } #endif #endif