diff --git a/demo/key/test.c b/demo/key/test.c index f3efc38..4ce516c 100644 --- a/demo/key/test.c +++ b/demo/key/test.c @@ -51,6 +51,6 @@ void Test_Key() { while (1) { // 每5ms调用一次key_ticks函数 key_ticks(); -// Sleep(5); // 使用Windows平台的Sleep函数进行5ms延时 + Sleep(5); // 使用Windows平台的Sleep函数进行5ms延时 } } \ No newline at end of file diff --git a/lib/inc/utils/tool.h b/lib/inc/utils/tool.h index 0dc6b27..0b3c6ac 100644 --- a/lib/inc/utils/tool.h +++ b/lib/inc/utils/tool.h @@ -47,27 +47,6 @@ typedef enum { // 定义枚举类型Type_t,包含不同数据类型 float *:6,double *:7, \ default: ((void)0)) -#define MESSAGE(err) \ - ( err==ERROR_NO_MEMORY ? MSG_NO_MEMORY \ - : err==ERROR_INVALID_INDEX ? MSG_INVALID_INDEX \ - : err==ERROR_INVALID_VALUE ? MSG_INVALID_VALUE \ - : 0 ) - -#define TYPE_U8 (unsigned char *) - -#define TYPE_ptr(type) \ - (type==0 ? TYPE_U8 \ - : type==1 ? (unsigned short *) \ - : type==2 ? (unsigned int *) \ - : type==3 ? (char *) \ - : type==4 ? (short *) \ - : type==5 ? (int *) \ - : type==6 ? (float *) \ - : type==7 ? (double *) \ - : ((void)0))\ - - - #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) // 计算数组的元素个数 //#define in , // 定义逗号为in #define _foreach(e, a) for(size_t e = 0; e < ARRAY_SIZE(a); e++) // 实现foreach宏,遍历数组a,e为当前元素下标 @@ -150,7 +129,7 @@ float Str2Float(char *str); **/ #define PRINT_ARRAY(arr, fmt, frame) do { \ printf("\n"#arr ":\n"); \ - for(size_t i = 0; i < ARRAY_SIZE(arr); i++) {\ + _foreach(i,arr) {\ if(i%frame==0&&i!=0) printf("\n");\ printf(fmt " ", arr[i]); }\ printf("\n"); } while (0)