diff --git a/Project/Src/MyWin/MyWinCore/mywin_draw.c b/Project/Src/MyWin/MyWinCore/mywin_draw.c index 1b08635..ffda4be 100644 --- a/Project/Src/MyWin/MyWinCore/mywin_draw.c +++ b/Project/Src/MyWin/MyWinCore/mywin_draw.c @@ -42,7 +42,7 @@ void WIN_DrawPointSafe (int x,int y,int mode) // LCD_DrawPointSafe (x,y,0); ewin->lcd->drawPoint(x,y,mode); } - + } void WIN_DrawPointNormal (int x,int y,int mode) @@ -58,7 +58,7 @@ void WIN_DrawPointColorSafe (int x,int y,u32 color) { ewin->lcd->drawPointColor(x,y,color); } - + } void WIN_DrawPointColorNormal (int x,int y,u32 color) @@ -165,7 +165,7 @@ void WIN_DrawTxtCenterAtRect (char *txt,int x,int y,int x_size,int y_size) char *txt_ptr=txtbuff; while (*txt) { - if (line_i>=line_max) + if (line_i>=line_max) {line_i--;break;} if ((*txt&0x80)==0) { @@ -175,7 +175,7 @@ void WIN_DrawTxtCenterAtRect (char *txt,int x,int y,int x_size,int y_size) line_i++; txt_ptr=txtbuff+(char_max+1)*line_i; x_s=x; - if (*txt=='\n') + if (*txt=='\n') { txt++; } continue; } @@ -268,42 +268,42 @@ void WIN_DrawVLine (int x,int y_s,int y_e) -//画线 x1,y1:起点坐标 x2,y2:终点坐标 +//画线 x1,y1:起点坐标 x2,y2:终点坐标 void WIN_DrawLine(int x1, int y1, int x2, int y2) { - int t; - int xerr=0,yerr=0,delta_x,delta_y,distance; - int incx,incy,uRow,uCol; - delta_x=x2-x1; //计算坐标增量 - delta_y=y2-y1; - uRow=x1; - uCol=y1; - if(delta_x>0)incx=1; //设置单步方向 - else if(delta_x==0)incx=0;//垂直线 - else {incx=-1;delta_x=-delta_x;} - if(delta_y>0)incy=1; - else if(delta_y==0)incy=0;//水平线 - else{incy=-1;delta_y=-delta_y;} - if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴 - else distance=delta_y; - for(t=0;t<=distance+1;t++ )//画线输出 - { + int t; + int xerr=0,yerr=0,delta_x,delta_y,distance; + int incx,incy,uRow,uCol; + delta_x=x2-x1; //计算坐标增量 + delta_y=y2-y1; + uRow=x1; + uCol=y1; + if(delta_x>0)incx=1; //设置单步方向 + else if(delta_x==0)incx=0;//垂直线 + else {incx=-1;delta_x=-delta_x;} + if(delta_y>0)incy=1; + else if(delta_y==0)incy=0;//水平线 + else{incy=-1;delta_y=-delta_y;} + if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴 + else distance=delta_y; + for(t=0;t<=distance+1;t++ )//画线输出 + { //WIN_GetWinStruct()->drawPoint (uRow,uCol,1); WIN_DrawPointSafe (uRow,uCol,1); - xerr+=delta_x ; - yerr+=delta_y ; - if(xerr>distance) - { - xerr-=distance; - uRow+=incx; - } - if(yerr>distance) - { - yerr-=distance; - uCol+=incy; - } - } -} + xerr+=delta_x ; + yerr+=delta_y ; + if(xerr>distance) + { + xerr-=distance; + uRow+=incx; + } + if(yerr>distance) + { + yerr-=distance; + uCol+=incy; + } + } +} @@ -314,7 +314,7 @@ void WIN_DrawCircle(int x0,int y0,int r) int di; int c_x=0; int c_y=0; - a=0;b=r; + a=0;b=r; di=3-(r<<1); //判断下个点位置的标志 while(a<=b) { @@ -337,15 +337,15 @@ void WIN_DrawCircle(int x0,int y0,int r) c_x=x0-b;c_y=y0-a; WIN_DrawPointSafe (c_x,c_y,1); a++; - //使用Bresenham算法画圆 - if(di<0)di +=4*a+6; + //使用Bresenham算法画圆 + if(di<0)di +=4*a+6; else { - di+=10+4*(a-b); + di+=10+4*(a-b); b--; - } + } } -} +} @@ -399,7 +399,7 @@ void WIN_DrawRect (int x,int y,int x_size,int y_size) WIN_PlaneAAStruct *WIN_CreatPlaneAA(int x,int y,int x_size,int y_size,int accuracy) { WIN_PlaneAAStruct *ret=mymalloc(sizeof(WIN_PlaneAAStruct)+x_size*y_size); - + if(ret) { ret->x=x; @@ -452,22 +452,22 @@ void WIN_DrawPointAA(WIN_PlaneAAStruct *p,int x,int y) int x_e=x_s+1;int y_e=y_s+1; if(x_sx||x_s>p->x+p->x_size-1) return; if(y_sy||y_s>p->y+p->y_size-1) return; - + //每个像素的细分程度,除以一个p->accuracy是这个虚拟像素在实际像素里的分量 //再除以一个p->accuracy是因为上层步进值 - int accuracy=p->accuracy;//*p->accuracy; + int accuracy=p->accuracy;//*p->accuracy; int alpha_x=16-(x%p->accuracy)*16/p->accuracy; int alpha_y=16-(y%p->accuracy)*16/p->accuracy; - + u8 *point=0; int point_=0; - - + + point=&p->alpha[p->x_size*(y_s-p->y)+(x_s-p->x)]; point_=*point+alpha_x*alpha_y/accuracy; if(point_>0xff) point_=0xff; *point=point_; - + if(x_ex+p->x_size) { point=&p->alpha[p->x_size*(y_s-p->y)+(x_e-p->x)]; @@ -494,46 +494,46 @@ void WIN_DrawPointAA(WIN_PlaneAAStruct *p,int x,int y) -//在平面内画线 x1,y1:起点坐标 x2,y2:终点坐标 +//在平面内画线 x1,y1:起点坐标 x2,y2:终点坐标 static void WIN_PlaneDrawLine(WIN_PlaneAAStruct *p,int x1, int y1, int x2, int y2) { if(p==0) return; - - int t; - int xerr=0,yerr=0,delta_x,delta_y,distance; - int incx,incy,uRow,uCol; - delta_x=x2-x1; //计算坐标增量 - delta_y=y2-y1; - uRow=x1; - uCol=y1; - if(delta_x>0)incx=1; //设置单步方向 - else if(delta_x==0)incx=0;//垂直线 - else {incx=-1;delta_x=-delta_x;} - if(delta_y>0)incy=1; - else if(delta_y==0)incy=0;//水平线 - else{incy=-1;delta_y=-delta_y;} - if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴 - else distance=delta_y; - for(t=0;t<=distance+1;t++ )//画线输出 - { + + int t; + int xerr=0,yerr=0,delta_x,delta_y,distance; + int incx,incy,uRow,uCol; + delta_x=x2-x1; //计算坐标增量 + delta_y=y2-y1; + uRow=x1; + uCol=y1; + if(delta_x>0)incx=1; //设置单步方向 + else if(delta_x==0)incx=0;//垂直线 + else {incx=-1;delta_x=-delta_x;} + if(delta_y>0)incy=1; + else if(delta_y==0)incy=0;//水平线 + else{incy=-1;delta_y=-delta_y;} + if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴 + else distance=delta_y; + for(t=0;t<=distance+1;t++ )//画线输出 + { WIN_DrawPointAA(p,uRow,uCol); - xerr+=delta_x ; - yerr+=delta_y ; - if(xerr>distance) - { - xerr-=distance; - uRow+=incx; - } - if(yerr>distance) - { - yerr-=distance; - uCol+=incy; - } - } + xerr+=delta_x ; + yerr+=delta_y ; + if(xerr>distance) + { + xerr-=distance; + uRow+=incx; + } + if(yerr>distance) + { + yerr-=distance; + uCol+=incy; + } + } -} +} //抗锯齿画线 @@ -545,7 +545,7 @@ void WIN_DrawLineAA(int x1, int y1, int x2, int y2,int accuracy) int y_size=y1-y2;if(y_size<0) y_size=-y_size; x_size++;y_size++; WIN_PlaneAAStruct *p=WIN_CreatPlaneAA(x,y,x_size,y_size,4); - + if(p) { x1*=p->accuracy; @@ -568,13 +568,13 @@ void WIN_FillRectByColor (int x,int y,int x_size,int y_size) RECT_Struct r1; RECT_Struct r2; RECT_Struct ret; - + r1.x=x;r1.x_size=x_size;r1.y=y;r1.y_size=y_size; r2.x=WIN_GetWinStruct()->Invalid_x; r2.x_size=WIN_GetWinStruct()->Invalid_x_size; r2.y=WIN_GetWinStruct()->Invalid_y; r2.y_size=WIN_GetWinStruct()->Invalid_y_size; - + //绘制新矩形 if (POS_RectIntersection(&ret,&r1,&r2)) { @@ -590,13 +590,13 @@ void WIN_FillRectByColorAlpha (int x,int y,int x_size,int y_size,u8 alpha) RECT_Struct r1; RECT_Struct r2; RECT_Struct ret; - + r1.x=x;r1.x_size=x_size;r1.y=y;r1.y_size=y_size; r2.x=WIN_GetWinStruct()->Invalid_x; r2.x_size=WIN_GetWinStruct()->Invalid_x_size; r2.y=WIN_GetWinStruct()->Invalid_y; r2.y_size=WIN_GetWinStruct()->Invalid_y_size; - + //绘制新矩形 if (POS_RectIntersection(&ret,&r1,&r2)) { @@ -612,14 +612,14 @@ void WIN_FillRect (int x,int y,int x_size,int y_size,u16 *buff,u16 pic_x,u16 pic RECT_Struct r1; RECT_Struct r2; RECT_Struct ret; - + r1.x=x;r1.x_size=x_size;r1.y=y;r1.y_size=y_size; - + r2.x=WIN_GetWinStruct()->Invalid_x; r2.x_size=WIN_GetWinStruct()->Invalid_x_size; r2.y=WIN_GetWinStruct()->Invalid_y; r2.y_size=WIN_GetWinStruct()->Invalid_y_size; - + //绘制新矩形 if (POS_RectIntersection(&ret,&r1,&r2)) { @@ -641,14 +641,14 @@ void WIN_FillRectAlpha (int x,int y,int x_size,int y_size,void *buff,u16 pic_x,u RECT_Struct r1; RECT_Struct r2; RECT_Struct ret; - + r1.x=x;r1.x_size=x_size;r1.y=y;r1.y_size=y_size; - + r2.x=WIN_GetWinStruct()->Invalid_x; r2.x_size=WIN_GetWinStruct()->Invalid_x_size; r2.y=WIN_GetWinStruct()->Invalid_y; r2.y_size=WIN_GetWinStruct()->Invalid_y_size; - + //绘制新矩形 if (POS_RectIntersection(&ret,&r1,&r2)) { @@ -807,20 +807,20 @@ void WIN_FillPolygon(POINT_Struct *Points, int PointCount) //此函数效率比较低,只用于绘制小图标,绘制图片使用矩形填充函数 void WIN_DrawImag (int x,int y,int xsize,int ysize,const u8 *buff) { - + if (buff==0) return ; - + u8 scan=buff[0]; u8 gray=buff[1]; u16 w=*((u16*)&buff[2]); u16 h=*((u16*)&buff[4]); u8 is565=buff[6]; u8 rgb=buff[7]; - + //必须所有参数都符合要求 if ((scan!=0x00)||(gray!=0x10)||(w>WIN_IMAGE_MAXSIZE)||(h>WIN_IMAGE_MAXSIZE)||(is565!=0x01)||(rgb!=0x1b)) return; - + u16 *imag=(u16 *)(buff+8); if (xsize>w) xsize=w; @@ -841,20 +841,20 @@ void WIN_DrawImag (int x,int y,int xsize,int ysize,const u8 *buff) //绘制图标,但是不绘制指定颜色 void WIN_DrawImagButColor (int x,int y,int xsize,int ysize,const u8 *buff,u16 color) { - + if (buff==0) return ; - + u8 scan=buff[0]; u8 gray=buff[1]; u16 w=*((u16*)&buff[2]); u16 h=*((u16*)&buff[4]); u8 is565=buff[6]; u8 rgb=buff[7]; - + //必须所有参数都符合要求 if ((scan!=0x00)||(gray!=0x10)||(w>WIN_IMAGE_MAXSIZE)||(h>WIN_IMAGE_MAXSIZE)||(is565!=0x01)||(rgb!=0x1b)) return; - + u16 *imag=(u16 *)(buff+8); if (xsize>w) xsize=w; @@ -866,7 +866,7 @@ void WIN_DrawImagButColor (int x,int y,int xsize,int ysize,const u8 *buff,u16 co if (imag[i]!=color) //WIN_GetWinStruct()->drawPointColor (i+x,j,imag[i]); WIN_DrawPointColorSafe (i+x,j,imag[i]); - + } imag+=w; } @@ -880,20 +880,20 @@ void WIN_DrawImagButColor (int x,int y,int xsize,int ysize,const u8 *buff,u16 co //此函数效率比较低,只用于绘制小图标,绘制图片使用矩形填充函数 void WIN_DrawImagByColor (int x,int y,int xsize,int ysize,const u8 *buff,u16 color) { - + if (buff==0) return ; - + u8 scan=buff[0]; u8 gray=buff[1]; u16 w=*((u16*)&buff[2]); u16 h=*((u16*)&buff[4]); u8 is565=buff[6]; u8 rgb=buff[7]; - + //必须所有参数都符合要求 if ((scan!=0x00)||(gray!=0x10)||(w>WIN_IMAGE_MAXSIZE)||(h>WIN_IMAGE_MAXSIZE)||(is565!=0x01)||(rgb!=0x1b)) return; - + u16 *imag=(u16 *)(buff+8); if (xsize>w) xsize=w; @@ -916,20 +916,20 @@ void WIN_DrawImagByColor (int x,int y,int xsize,int ysize,const u8 *buff,u16 col //此函数效率比较低,只用于绘制小图标,绘制图片使用矩形填充函数 void WIN_DrawImagByAlpha (int x,int y,int xsize,int ysize,const u8 *buff,u16 color) { - + if (buff==0) return ; - + u8 scan=buff[0]; u8 gray=buff[1]; u16 w=*((u16*)&buff[2]); u16 h=*((u16*)&buff[4]); u8 is565=buff[6]; u8 rgb=buff[7]; - + //必须所有参数都符合要求 if ((scan!=0x00)||(gray!=0x10)||(w>WIN_IMAGE_MAXSIZE)||(h>WIN_IMAGE_MAXSIZE)||(is565!=0x01)||(rgb!=0x1b)) return; - + u16 *imag=(u16 *)(buff+8); u8 r,g,b; u8 alpha=0; @@ -968,20 +968,20 @@ void WIN_DrawImagByAlpha (int x,int y,int xsize,int ysize,const u8 *buff,u16 col //此函数效率比较低,只用于绘制小图标,绘制图片使用矩形填充函数 void WIN_DrawImagByAlphaAnti (int x,int y,int xsize,int ysize,const u8 *buff,u16 color) { - + if (buff==0) return ; - + u8 scan=buff[0]; u8 gray=buff[1]; u16 w=*((u16*)&buff[2]); u16 h=*((u16*)&buff[4]); u8 is565=buff[6]; u8 rgb=buff[7]; - + //必须所有参数都符合要求 if ((scan!=0x00)||(gray!=0x10)||(w>WIN_IMAGE_MAXSIZE)||(h>WIN_IMAGE_MAXSIZE)||(is565!=0x01)||(rgb!=0x1b)) return; - + u16 *imag=(u16 *)(buff+8); u8 r,g,b; u8 alpha=0; @@ -1067,7 +1067,7 @@ void WIN_GetTxtRectSize (char *txt,int *x_size,int *y_size) //获得图像数据的尺寸,返回0,成功,非0,失败 int WIN_GetImageSize (u8 *buff,int *xsize,int *ysize) { - + if (buff==0) return -1; u8 scan=buff[0]; u8 gray=buff[1]; @@ -1075,11 +1075,11 @@ int WIN_GetImageSize (u8 *buff,int *xsize,int *ysize) u16 h=*((u16*)&buff[4]); u8 is565=buff[6]; u8 rgb=buff[7]; - + //必须所有参数都符合要求 if ((scan!=0x00)||(gray!=0x10)||(is565!=0x01)||(rgb!=0x1b)) return -1; - + *xsize=w; *ysize=h; return 0; diff --git a/Project/Src/MyWin/mywin_cfg.c b/Project/Src/MyWin/mywin_cfg.c index 91c0854..89cdc07 100644 --- a/Project/Src/MyWin/mywin_cfg.c +++ b/Project/Src/MyWin/mywin_cfg.c @@ -1,4 +1,4 @@ -#include "mywin_inc.h" +#include "mywin_inc.h" #include "rtthread.h" #include "main.h" #include "system_updata.h" @@ -36,7 +36,7 @@ void WIN_FontInit (char *path,char *en_path) ft_error=FT_New_Face (g_ft_library,path,0,&ft_face); if (ft_error==0) { - + if(g_ft_face) {FT_Done_Face(g_ft_face);g_ft_face=0;} g_ft_face=ft_face; } @@ -100,7 +100,7 @@ void WIN_InitCfg (void) g_lcd.exitLayerBuff=LCD_ExitLayerBuff; //g_lcd.setScreenDis=LCD_SetScreenDis; g_lcd.setWindow=LCD_SetWindow; - g_lcd.setDrawMode=LCD_SetLcdDrawMode; + g_lcd.setDrawMode=LCD_SetLcdDrawMode; g_lcd.getLcdSizeX=LCD_GetLcdSizeX; g_lcd.getLcdSizeY=LCD_GetLcdSizeY; // g_lcd.getWindowSizeX=LCD_GetWindowSizeX; @@ -110,22 +110,22 @@ void WIN_InitCfg (void) g_lcd.setLcdColor=(u16(*)(u16))LCD_SetLcdColor16; g_lcd.setLcdBkColor=(u16(*)(u16))LCD_SetLcdBkColor16; ewin->lcd=&g_lcd; - + //字体初始化 WIN_FontInit("simfang.ttf",0); // WIN_FontInit("0:/ttf/simsun6.ttc",0); // WIN_FontInit("0:/ttf/华文中宋.ttf","0:/ttf/Agency-FB.ttf"); - + WIN_FontDrawFunStruct *font=&WIN_GetWinStruct()->font; // font->malloc=mymalloc_ccm; // font->free=myfree_ccm; font->malloc=mymalloc_exm; font->free=myfree; - + //设置默认字体 WIN_SetFontSize(24); WIN_SetFontType(WIN_FONT_TYPE_NORMAL); - + } @@ -153,15 +153,15 @@ void WIN_Delay_ms (u32 ms) static struct rt_semaphore g_gui={0}; static rt_err_t g_gui_err=RT_ERROR; - + #define GUI_CREAT() {g_gui_err=rt_sem_init(&g_gui,"g_gui",1,RT_IPC_FLAG_FIFO);\ rt_sem_take (&g_gui,RT_WAITING_FOREVER);} #define GUI_DELETE() {g_gui_err=rt_sem_release (&g_gui);\ if (g_gui_err==RT_EOK) rt_sem_detach(&g_gui);} #define GUI_WAIT() {while (g_gui_err==RT_ERROR) rt_thread_delay(10);\ - rt_sem_take (&g_gui,RT_WAITING_FOREVER);} + rt_sem_take (&g_gui,RT_WAITING_FOREVER);} #define GUI_WAIT_END() {} - + #else #define GUI_CREAT() {} @@ -213,7 +213,7 @@ WIN_WorkFunStruct *WIN_CreatThread (int (*fun)(void *),void *ptr,int *ret) mymemset (handle,0,sizeof (WIN_ThreadHandle)); handle->tackSize=4096; handle->tack=mymalloc (handle->tackSize); - + WIN_WorkFunStruct *work=mymalloc (sizeof (WIN_WorkFunStruct)); mymemset (work,0,sizeof (WIN_WorkFunStruct)); work->fun=fun; @@ -240,7 +240,7 @@ WIN_WorkFunStruct *WIN_CreatThreadPro (int (*fun)(void *),void *ptr,int *ret,u8 mymemset (handle,0,sizeof (WIN_ThreadHandle)); handle->tackSize=4096; handle->tack=mymalloc (handle->tackSize); - + WIN_WorkFunStruct *work=mymalloc (sizeof (WIN_WorkFunStruct)); mymemset (work,0,sizeof (WIN_WorkFunStruct)); work->fun=fun; @@ -284,8 +284,8 @@ void WIN_ExWorkFunClear (WIN_WorkFunStruct *w) //解码png图片,成功返回1,失败返回0 static int decode_png(WIN_PicStruct *pic,const char *name) { - - + + int png_err=0; png_image image; /* The control structure used by libpng */ @@ -331,7 +331,7 @@ int WIN_DecodeImg(WIN_PicStruct *pic,const char *name) //判断图片格式 int str_len=strlen(name); const char *p_str=&name[str_len-4]; - + //解码时显示提示,这个函数是阻塞的 if (strcmp (p_str,".png")==0) { @@ -395,35 +395,35 @@ int WIN_DecodeImg(WIN_PicStruct *pic,const char *name) //根据字体类型获取字模数据 int WIN_GetWordData(u8 size,u8 type,unsigned char *buff, int word, int buff_size) { - + u8 gbk[4]={0}; u8 uni[3]={0}; - + if (word>0x80) { gbk[0]=(word>>16)&0xff; gbk[1]=(word>>8)&0xff; - gbk[2]=word&0xff; + // gbk[2]=word&0xff; } else { gbk[0]=word; } - - utf82uni_str(gbk,uni); - + gbk2uni_str(gbk,uni); + + if (g_ft_face) { FT_Error ft_error=0; - + load_char: ft_error=FT_Set_Pixel_Sizes(g_ft_face, size, size); if(type==WIN_FONT_TYPE_BITMAP) ft_error=FT_Load_Char (g_ft_face,(uni[0]<<8)|uni[1],FT_LOAD_RENDER|FT_LOAD_MONOCHROME); else ft_error=FT_Load_Char (g_ft_face,(uni[0]<<8)|uni[1],FT_LOAD_RENDER); -// if(ft_error) +// if(ft_error) // { // printf("%s:err,ft_error=0x%02x,c=%s,uni=%02x,%02x\r\n",__func__,ft_error,gbk,uni[0],uni[1]); // WIN_FontInit("华文中宋.ttf",0); @@ -431,7 +431,7 @@ int WIN_GetWordData(u8 size,u8 type,unsigned char *buff, int word, int buff_size // } FT_GlyphSlot slot = g_ft_face->glyph; - + int w_byte=slot->bitmap.pitch; u8 *buf=slot->bitmap.buffer; mymemcpy (buff,buf,buff_size-5); @@ -440,7 +440,7 @@ int WIN_GetWordData(u8 size,u8 type,unsigned char *buff, int word, int buff_size buff[buff_size-3]=slot->bitmap.pitch; buff[buff_size-2]=slot->bitmap_left; buff[buff_size-1]=slot->bitmap_top; - + return slot->bitmap.width; } else diff --git a/Project/Src/MyWinApp/mywin_user_filder.c b/Project/Src/MyWinApp/mywin_user_filder.c index c1f167d..6e19946 100644 --- a/Project/Src/MyWinApp/mywin_user_filder.c +++ b/Project/Src/MyWinApp/mywin_user_filder.c @@ -14,6 +14,7 @@ #include "nrf.h" #include "mywin_user_debug.h" #include "string.h" +#include "char_encode.h" // 文件管理器 diff --git a/Project/Src/MyWinApp/mywin_user_filder.h b/Project/Src/MyWinApp/mywin_user_filder.h index 9ae002b..8c450c2 100644 --- a/Project/Src/MyWinApp/mywin_user_filder.h +++ b/Project/Src/MyWinApp/mywin_user_filder.h @@ -1,22 +1,17 @@ #ifndef MYWIN_USER_FILDER_H__ #define MYWIN_USER_FILDER_H__ +// 定义列表中最大显示文件数 +#define FILDER_FILE_MAXNUM 1000 +// 定义最大路径深度 +#define FILDER_DIR_DEPTH 10 +// 定义文件类型 +#define FILDER_FILE_TYPE 1 +#define FILDER_DIR_TYPE 0 - -//定义列表中最大显示文件数 -#define FILDER_FILE_MAXNUM 1000 - -//定义最大路径深度 -#define FILDER_DIR_DEPTH 10 - -//定义文件类型 -#define FILDER_FILE_TYPE 1 -#define FILDER_DIR_TYPE 0 - - -//路径栈 +// 路径栈 typedef struct { int index[FILDER_DIR_DEPTH]; @@ -24,18 +19,12 @@ typedef struct int fileNum; } Filder_Path; - - - typedef struct { char name[256]; - int type; //1,文件,0,文件夹 + int type; // 1,文件,0,文件夹 uint64_t size; -}Filder_FildInfo; - - - +} Filder_FildInfo; typedef struct { @@ -44,79 +33,69 @@ typedef struct char *imgFile; char *imgDir; char dirName[256]; - char fileName[256];//文件路径 + char fileName[256]; // 文件路径 Filder_Path path; int index; - int fileNum; //条目数 - int dirNum; //文件夹数目 + int fileNum; // 条目数 + int dirNum; // 文件夹数目 int titleHight; int itemHight; int itemIndent; - int scrollbar_xsize;//滚动条宽度 - int itemNumOnePage; //每页显示条目数 - int firstItemOnPage;//显示在页首的条目编号 - - int scroll_x; //滚动显示的x坐标 - int scroll_xsize; //混动显示的x长度 - int scroll_timer; //滚动显示使用的定时器 - - int y_off; //支持触屏 -}WIN_FilderStruct; + int scrollbar_xsize; // 滚动条宽度 + int itemNumOnePage; // 每页显示条目数 + int firstItemOnPage; // 显示在页首的条目编号 + int scroll_x; // 滚动显示的x坐标 + int scroll_xsize; // 混动显示的x长度 + int scroll_timer; // 滚动显示使用的定时器 + int y_off; // 支持触屏 +} WIN_FilderStruct; -WIN_FilderStruct *WIN_CreatFilder (WIN_WindowStruct *base, - void (*msgLoop)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg), - int x,int y,int x_size,int y_size); +WIN_FilderStruct *WIN_CreatFilder(WIN_WindowStruct *base, + void (*msgLoop)(struct _WIN_WindowStruct *win, WIN_MsgStruct *msg), + int x, int y, int x_size, int y_size); +// 设置文件路径,同时扫描路径下的文件 +void FILDER_SetFileDir(WIN_FilderStruct *filder, char *dir); - +// 入栈 +int FILDER_PathPush(WIN_FilderStruct *filder); -//设置文件路径,同时扫描路径下的文件 -void FILDER_SetFileDir (WIN_FilderStruct *filder,char *dir); +// 出栈 +int FILDER_PathPull(WIN_FilderStruct *filder); -//入栈 -int FILDER_PathPush (WIN_FilderStruct *filder); - -//出栈 -int FILDER_PathPull (WIN_FilderStruct *filder); - -//把文件名追加到目录,同时扫描路径下的文件 -int FILDER_DirAppend (WIN_FilderStruct *filder,Filder_FildInfo *file); - -//剪短一层目录,同时扫描目录下的文件 -int FILDER_DirCut (WIN_FilderStruct *filder); - -//生成文件路径 -void FILDER_GetFileRoute (WIN_FilderStruct *filder); - -//清空条目 -void FILDER_ClearItem (WIN_FilderStruct *filder); - - -//添加一个文件条目 -void FILDER_AddItem (WIN_FilderStruct *filder,Filder_FildInfo *file); +// 把文件名追加到目录,同时扫描路径下的文件 +int FILDER_DirAppend(WIN_FilderStruct *filder, Filder_FildInfo *file); - -//在指定位置插入一个条目 -void FILDER_InsertItem (WIN_FilderStruct *filder,Filder_FildInfo *file,int index); - - -//扫描文件 -void FILDER_ScanFile (WIN_FilderStruct *filder); +// 剪短一层目录,同时扫描目录下的文件 +int FILDER_DirCut(WIN_FilderStruct *filder); -//打开文件 -void FILDER_OpenFile (WIN_FilderStruct *filder); +// 生成文件路径 +void FILDER_GetFileRoute(WIN_FilderStruct *filder); -//消息框的绘制函数 -void FILDER_DefaultPaint (WIN_FilderStruct *filder); +// 清空条目 +void FILDER_ClearItem(WIN_FilderStruct *filder); -//消息框的消息处理函数 -void FILDER_defaultMsgLoop (WIN_FilderStruct *filder,WIN_MsgStruct *msg); +// 添加一个文件条目 +void FILDER_AddItem(WIN_FilderStruct *filder, Filder_FildInfo *file); -//选则文件 -int FILDER_ChooseFile (WIN_WindowStruct *win,char *dir); +// 在指定位置插入一个条目 +void FILDER_InsertItem(WIN_FilderStruct *filder, Filder_FildInfo *file, int index); +// 扫描文件 +void FILDER_ScanFile(WIN_FilderStruct *filder); + +// 打开文件 +void FILDER_OpenFile(WIN_FilderStruct *filder); + +// 消息框的绘制函数 +void FILDER_DefaultPaint(WIN_FilderStruct *filder); + +// 消息框的消息处理函数 +void FILDER_defaultMsgLoop(WIN_FilderStruct *filder, WIN_MsgStruct *msg); + +// 选则文件 +int FILDER_ChooseFile(WIN_WindowStruct *win, char *dir); #endif - diff --git a/Project/Src/MyWinApp/mywin_user_set.c b/Project/Src/MyWinApp/mywin_user_set.c index 27785f0..fd30fd7 100644 --- a/Project/Src/MyWinApp/mywin_user_set.c +++ b/Project/Src/MyWinApp/mywin_user_set.c @@ -35,21 +35,21 @@ const static MENU_ItemStruct ptr[]={ //进入设置页面 -WIN_MenuStruct *MENU_Setting (WIN_WindowStruct *base,WIN_PicStruct *pic) +WIN_MenuStruct *MENU_Setting (WIN_WindowStruct *base,WIN_PicStruct *pic) { - WIN_MenuStruct *menu=WIN_CreatMenu (base,(void (*)(WIN_WindowStruct *,WIN_MsgStruct *))MENU_SettingMsgLoop, + WIN_MenuStruct *menu=WIN_CreatMenu (base,(void (*)(WIN_WindowStruct *,WIN_MsgStruct *))MENU_SettingMsgLoop, 0,0,base->x_size,base->y_size); ((WIN_WindowStruct *)menu)->intercept=1;//不发送按键消息到父窗口 - + WIN_SetBackPicPath ((WIN_WindowStruct *)menu,base->pic_path); MENU_SetTitle (menu,0,"设置"); - + MENU_SetMaxItem(menu,9); for (int i=0;i<9;i++) { MENU_AddItem (menu,ptr[i].img,(char *)ptr[i].txt); } - + WIN_ShowWindow((WIN_WindowStruct*)menu); return menu; } @@ -70,10 +70,10 @@ static void MENU_DoEnter (WIN_MenuStruct *menu) { //选择了一个设置项 if (MENU_GetIndex(menu)==0) MENU_ThemeSet((WIN_WindowStruct *)menu); - else if (MENU_GetIndex(menu)==1) TIMEBOX_TimeSet ((WIN_WindowStruct *)menu); - else if (MENU_GetIndex(menu)==2) MENU_LightSet((WIN_WindowStruct *)menu);//BACKLIGHTSETBOX_BackLightSet (); + else if (MENU_GetIndex(menu)==1) TIMEBOX_TimeSet ((WIN_WindowStruct *)menu); + else if (MENU_GetIndex(menu)==2) MENU_LightSet((WIN_WindowStruct *)menu);//BACKLIGHTSETBOX_BackLightSet (); else if (MENU_GetIndex(menu)==3) {MSGBOX_Inquiry ((WIN_WindowStruct *)menu,"重置","再按一次确定键重置","确定","返回");} - else if (MENU_GetIndex(menu)==4) + else if (MENU_GetIndex(menu)==4) { char *txt=mymalloc (512); if (APP_SOURCE) @@ -90,7 +90,7 @@ static void MENU_DoEnter (WIN_MenuStruct *menu) MSGBOX_TipsTime ((WIN_WindowStruct*)menu,"关于", txt,"确定",5000); myfree(txt); } - else if (MENU_GetIndex(menu)==5) SYSFILE_ChooseFile((WIN_WindowStruct *)menu); + else if (MENU_GetIndex(menu)==5) SYSFILE_ChooseFile((WIN_WindowStruct *)menu); else if (MENU_GetIndex(menu)==6) FILDER_ChooseFile ((WIN_WindowStruct *)menu,"0:"); else if(MENU_GetIndex(menu)==7) enter_sound((WIN_WindowStruct *)menu); else if(MENU_GetIndex(menu)==8) DEBUG_EnterPrint(); @@ -109,7 +109,7 @@ void MENU_SettingMsgLoop (WIN_MenuStruct *menu,WIN_MsgStruct *msg) WIN_TouchStruct *t=0; WIN_KeyStruct *k=0; switch (msg->msg) - { + { case WIN_MSG_KEY: k=msg->data.p; if (k->shortPress&KEY_VALUE_ENTER) @@ -191,7 +191,7 @@ static int cb_sound_fun(void *ptr) { DAC_FifolInit(); nrf_init(); - nrf_set_no_respond(1); + nrf_set_no_respond(1); g_work=1; uint16_t value=0; DAC_SetSetValuwFun(recv_value); diff --git a/Project/Src/MyWinApp/mywin_user_tool.c b/Project/Src/MyWinApp/mywin_user_tool.c index d3a4aa7..292e786 100644 --- a/Project/Src/MyWinApp/mywin_user_tool.c +++ b/Project/Src/MyWinApp/mywin_user_tool.c @@ -53,12 +53,9 @@ static void MENU_ToolEnter(WIN_MenuStruct *menu) { // 选择了一个 char *path = mymalloc(256); - char *tmp = mymalloc(256); - utf82gbk_str(MENU_GetSelectItem(menu), tmp); - sprintf(path, "%s/%s", TOOL_APP_PATH, tmp); + sprintf(path, "%s/%s", TOOL_APP_PATH, MENU_GetSelectItem(menu)); app_run_path(path); myfree(path); - myfree(tmp); } static void MENU_ToolDeleteFun(WIN_MenuStruct *menu) diff --git a/Project/make.py b/Project/make.py index 255c6d5..7227285 100644 --- a/Project/make.py +++ b/Project/make.py @@ -22,8 +22,8 @@ CFLAG=[ '-mfpu=fpv4-sp-d16', '-mfloat-abi=hard', '-Og', - '-Wall', - '-fdata-sections', + '-Wall', + '-fdata-sections', '-ffunction-sections', # debug '-g -gdwarf-2' @@ -237,7 +237,6 @@ def run_cmd_queue(cmd_queue:Queue,cpu_num:int=8): while not cmd_queue.empty(): cmd_queue.get() cmd_queue.cancel_join_thread() - return ret diff --git a/conv_code.py b/conv_code.py index a938642..bba50bb 100644 --- a/conv_code.py +++ b/conv_code.py @@ -25,10 +25,10 @@ def find_type(path:str,fix:str): def conv(file:str): s="" try: - with open(file,encoding="gb2312") as f: + with open(file,encoding="utf-8") as f: s=f.read() os.remove(file) - with open(file,mode="w+",encoding="utf-8") as f: + with open(file,mode="w+",encoding="gbk") as f: f.write(s) except Exception as e: print("conv failed",file)