完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
跟着大家的教程移植完emwin以后,对官方的xbf字库又有点兴趣,感觉官方的功能很全很方便,但是根据例程改编的时候碰到了麻烦
#include "GUI.h"#include "ff.h"GUI_FONT XBFFont;GUI_XBF_DATA XBF_Data;static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) { DWORD NumBytesRead; FIL hFile;FIL fsrc; // ?¨????????×÷?àFRESULT res; // ?¨????×÷?á??±???UINT br;char string[30]; hFile = *(FIL *)pVoid; /* Set file pointer to the requested position */res = f_open(&fsrc, "0:/sys/Font18.xbf", FA_OPEN_EXISTING | FA_READ); if (res != FR_OK) { return 1; /* Error */ }res = f_lseek(&fsrc,Off); //?????×???· if (res != FR_OK) { return 1; /* Error */ }res=f_read(&fsrc,string,NumBytes,&br);//pBuffer=string;//res=f_read(&fsrc,pBuffer,NumBytes,&br);//pBuffer=&string;if (res != FR_OK) { return 1; /* Error */ }res = f_lseek(&fsrc,Off); //?????×???· if (res != FR_OK) { return 1; /* Error */ }res=f_read(&fsrc,pBuffer,NumBytes,&br);//pBuffer=string;//res=f_read(&fsrc,pBuffer,NumBytes,&br);//pBuffer=&string;if (res != FR_OK) { return 1; /* Error */ }// /* Read font data */// if (!ReadFile(hFile, pBuffer, NumBytes, &NumBytesRead, 0)) {// return 1; /* Error */// } if (br != NumBytes) { return 1; /* Error */ } return 0; /* Ok */} void readFontfromXBFSD(void){FIL fsrc; // ?¨????????×÷?àFRESULT res; // ?¨????×÷?á??±???res = f_open(&fsrc, "0:/sys/Font18.xbf", FA_OPEN_EXISTING | FA_READ); GUI_XBF_CreateFont(&XBFFont, /* Pointer to GUI_FONT structure in RAM */ &XBF_Data, /* Pointer to GUI_XBF_DATA structure in RAM */ GUI_XBF_TYPE_PROP, /* Font type to be created */ _cbGetData, /* Pointer to callback function */ &fsrc); /* Pointer to be passed to GetData function *///res = f_close(&fsrc); //??±?×???//GUI_SetFont(&XBFFont);GUI_DispStringAt("Hello world!", 160, 80);} 这是我的代码,程序跑到GUI_DispStringAT的时候,跑了2遍_cbGetData然后竟然开始从头跑程序,然后又开始跑到readFontfromXBFSD函数,继续循环 不是很明白为什么会开始重新跑程序,希望有人能帮一下 |
|
相关推荐
1个回答
|
|
|
还没搞过,帮顶。
|
|
|
|
|
只有小组成员才能发言,加入小组>>
1018 浏览 1 评论
1849 浏览 0 评论
1830 浏览 1 评论
3254 浏览 5 评论
3581 浏览 9 评论
1021浏览 1评论
1850浏览 1评论
如何知道嵌入式电子控制单元 (ECU) 中的RAM使用情况?
1360浏览 1评论
1852浏览 0评论
1178浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 03:39 , Processed in 0.609201 second(s), Total 74, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2785