|
@@ -9,9 +9,9 @@
|
|
|
*/
|
|
|
/*
|
|
|
* AppFuncLib.c
|
|
|
- *应用层函数库
|
|
|
- * Created on: 2022年1月21日
|
|
|
- * Author: QiXiang_CHENJIE
|
|
|
+ *应锟矫层函锟斤拷锟斤拷
|
|
|
+ * Created on: 2022锟斤拷1锟斤拷21锟斤拷
|
|
|
+ * Author: QiXiang_CHENJIE master 娴嬭瘯
|
|
|
*/
|
|
|
|
|
|
#include "AppFuncLib.h"
|
|
@@ -68,7 +68,7 @@ unsigned char HexToChar(unsigned char bHex)
|
|
|
{
|
|
|
if ((bHex >= 0) && (bHex <= 9))
|
|
|
bHex += 0x30;
|
|
|
- else if ((bHex >= 10) && (bHex <= 15)) //大写字母
|
|
|
+ else if ((bHex >= 10) && (bHex <= 15)) //锟斤拷写锟斤拷母
|
|
|
bHex += 0x37;
|
|
|
else
|
|
|
bHex = 0xff;
|
|
@@ -78,9 +78,9 @@ unsigned char CharToHex(unsigned char bChar)
|
|
|
{
|
|
|
if ((bChar >= 0x30) && (bChar <= 0x39))
|
|
|
bChar -= 0x30;
|
|
|
- else if ((bChar >= 0x41) && (bChar <= 0x46)) //大写字母
|
|
|
+ else if ((bChar >= 0x41) && (bChar <= 0x46)) //锟斤拷写锟斤拷母
|
|
|
bChar -= 0x37;
|
|
|
- else if ((bChar >= 0x61) && (bChar <= 0x66)) //小写字母
|
|
|
+ else if ((bChar >= 0x61) && (bChar <= 0x66)) //小写锟斤拷母
|
|
|
bChar -= 0x57;
|
|
|
else
|
|
|
bChar = 0xff;
|
|
@@ -91,7 +91,7 @@ uint8 AtStrCompare(const char *a, const char *b)
|
|
|
uint8 out = 1;
|
|
|
while (1)
|
|
|
{
|
|
|
- if (*a == '\0' || *b == '\0') //判断其中是否有字符串结束
|
|
|
+ if (*a == '\0' || *b == '\0') //锟叫讹拷锟斤拷锟斤拷锟角凤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷
|
|
|
{
|
|
|
if (strlen(a) == strlen(b))
|
|
|
{
|
|
@@ -175,10 +175,10 @@ char *Myitoa(int value, char *result, int base)
|
|
|
}
|
|
|
|
|
|
/************************************************************************
|
|
|
- * @brief 整数转字符串
|
|
|
- * @param[in] num 整数
|
|
|
- * @param[out] buf 字符串
|
|
|
- * @return 返回字符串长度
|
|
|
+ * @brief 锟斤拷锟斤拷转锟街凤拷锟斤拷
|
|
|
+ * @param[in] num 锟斤拷锟斤拷
|
|
|
+ * @param[out] buf 锟街凤拷锟斤拷
|
|
|
+ * @return 锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷
|
|
|
************************************************************************/
|
|
|
inline int _itoa(int num, char buf[32])
|
|
|
{
|
|
@@ -186,11 +186,11 @@ inline int _itoa(int num, char buf[32])
|
|
|
}
|
|
|
|
|
|
/************************************************************************
|
|
|
- * @brief 整数转字符串
|
|
|
- * @param[in] num 整数
|
|
|
- * @param[out] buf 字符串
|
|
|
- * @param[in] radix 进位制整数
|
|
|
- * @return 返回字符串长度
|
|
|
+ * @brief 锟斤拷锟斤拷转锟街凤拷锟斤拷
|
|
|
+ * @param[in] num 锟斤拷锟斤拷
|
|
|
+ * @param[out] buf 锟街凤拷锟斤拷
|
|
|
+ * @param[in] radix 锟斤拷位锟斤拷锟斤拷锟斤拷
|
|
|
+ * @return 锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷
|
|
|
************************************************************************/
|
|
|
int _i2a(int num, char buf[32], int radix)
|
|
|
{
|
|
@@ -224,11 +224,11 @@ int _i2a(int num, char buf[32], int radix)
|
|
|
}
|
|
|
|
|
|
/************************************************************************
|
|
|
- * @brief 浮点数转字符串
|
|
|
- * @param[in] val 浮点数
|
|
|
- * @param[out] buf 字符串
|
|
|
- * @param[in] eps 精度(小数位)
|
|
|
- * @return 返回字符串长度
|
|
|
+ * @brief 锟斤拷锟斤拷锟斤拷转锟街凤拷锟斤拷
|
|
|
+ * @param[in] val 锟斤拷锟斤拷锟斤拷
|
|
|
+ * @param[out] buf 锟街凤拷锟斤拷
|
|
|
+ * @param[in] eps 锟斤拷锟斤拷(小锟斤拷位)
|
|
|
+ * @return 锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷
|
|
|
************************************************************************/
|
|
|
int _ftoa(double val, char buf[32], int eps)
|
|
|
{
|
|
@@ -245,11 +245,11 @@ int _ftoa(double val, char buf[32], int eps)
|
|
|
}
|
|
|
|
|
|
/************************************************************************
|
|
|
- * @brief 浮点数转字符串:范围(-1, 1)
|
|
|
- * @param[in] val 浮点数
|
|
|
- * @param[out] buf 字符串
|
|
|
- * @param[in] eps 精度(小数位)
|
|
|
- * @return 返回字符串长度
|
|
|
+ * @brief 锟斤拷锟斤拷锟斤拷转锟街凤拷锟斤拷锟斤拷锟斤拷围(-1, 1)
|
|
|
+ * @param[in] val 锟斤拷锟斤拷锟斤拷
|
|
|
+ * @param[out] buf 锟街凤拷锟斤拷
|
|
|
+ * @param[in] eps 锟斤拷锟斤拷(小锟斤拷位)
|
|
|
+ * @return 锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷
|
|
|
************************************************************************/
|
|
|
int __ftoa(double val, char buf[32], int eps)
|
|
|
{
|
|
@@ -269,8 +269,8 @@ int __ftoa(double val, char buf[32], int eps)
|
|
|
}
|
|
|
|
|
|
/************************************************************************
|
|
|
- * @brief 替换sprintf
|
|
|
- * @ref 可变长参数列表误区与陷阱——va_arg不可接受的类型
|
|
|
+ * @brief 锟芥换sprintf
|
|
|
+ * @ref 锟缴变长锟斤拷锟斤拷锟叫憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟藉—锟斤拷va_arg锟斤拷锟缴斤拷锟杰碉拷锟斤拷锟斤拷
|
|
|
* http://www.cppblog.com/ownwaterloo/archive/2009/04/21/80655.aspx
|
|
|
************************************************************************/
|
|
|
int _sprintf(char *dst, const char *format, ...)
|
|
@@ -292,7 +292,7 @@ int _sprintf(char *dst, const char *format, ...)
|
|
|
++f;
|
|
|
switch (*f)
|
|
|
{
|
|
|
- case 's': // 字符串
|
|
|
+ case 's': // 锟街凤拷锟斤拷
|
|
|
{
|
|
|
const char *p = va_arg(ap, char *);
|
|
|
n = strlen(p);
|
|
@@ -301,7 +301,7 @@ int _sprintf(char *dst, const char *format, ...)
|
|
|
break;
|
|
|
|
|
|
case 'd':
|
|
|
- case 'u': // 整数
|
|
|
+ case 'u': // 锟斤拷锟斤拷
|
|
|
{
|
|
|
char buf[32];
|
|
|
n = _itoa(va_arg(ap, int), buf);
|
|
@@ -309,7 +309,7 @@ int _sprintf(char *dst, const char *format, ...)
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case 'f': // 浮点数
|
|
|
+ case 'f': // 锟斤拷锟斤拷锟斤拷
|
|
|
{
|
|
|
char buf[32];
|
|
|
n = _ftoa(va_arg(ap, double), buf, 6);
|
|
@@ -317,7 +317,7 @@ int _sprintf(char *dst, const char *format, ...)
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case 'x': // 16进制数
|
|
|
+ case 'x': // 16锟斤拷锟斤拷锟斤拷
|
|
|
{
|
|
|
char buf[32];
|
|
|
n = _i2a(va_arg(ap, int), buf, 16);
|
|
@@ -325,13 +325,13 @@ int _sprintf(char *dst, const char *format, ...)
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case 'c': // 字符
|
|
|
+ case 'c': // 锟街凤拷
|
|
|
{
|
|
|
*s = va_arg(ap, int);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case '%': // 百分号
|
|
|
+ case '%': // 锟劫分猴拷
|
|
|
{
|
|
|
*s = '%';
|
|
|
}
|