Hello, gentlemen.
I using function 'IMAGE_SetBMPEx' to show image from SD card.
My '_GetData' function looks like:
static char _acBuffer[BYTES_IN_LINE];
int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Offset){
unsigned int NumBytesRead;
if (NumBytesReq > sizeof(_acBuffer)) {// Check buffer size
NumBytesReq = sizeof(_acBuffer);
}
f_lseek((FIL *) p, Offset); //Set file pointer to the required position
f_read((FIL *) p, (void *) _acBuffer, NumBytesReq, &NumBytesRead); //Read data into buffer
*ppData = (const U8*) _acBuffer; //set pointer to the buffer
return NumBytesRead;
}
I successfully loaded images from SD card whith and without window manager:
FATFS fileSystem;
FIL ImgFile;
FRESULT res;
/*Register the file system object to the FatFs module*/
/*
* param 1 Pointer to the file system object (NULL:unmount)
* param 2 Logical drive number to be mounted/unmounted
* param 3 0:Do not mount (delayed mount), 1:Mount immediately
*/
if (f_mount(&fileSystem, (TCHAR const*) SD_Path, 0) == FR_OK) {
/*Open file image with read access*/
/*
* param 1 Pointer to the blank file object
* param 2 Pointer to the file name
* param 3 Access mode and file open mode flags
*/
res = f_open(&ImgFile, "IMG1.bmp", FA_OPEN_EXISTING | FA_READ);
if (res == FR_OK) {
GUI_BMP_DrawEx(_GetData, &ImgFile, 0, 0);
}
}
and in dialog with windows manager:
#define ID_IMAGE (GUI_ID_USER + 0x70)
static const GUI_WIDGET_CREATE_INFO Main_Window_DialogCreate[] =
{
...
{ IMAGE_CreateIndirect, "Image", ID_IMAGE,
0, 0,
IMAGE_WIDTH, IMAGE_HEIGHT, 0, 0, 0 }
...
};
IMAGE_Handle image;
void WIDGETS_Callback(WM_MESSAGE * pMsg){ //Custom callback function
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
....
image = WM_GetDialogItem(pMsg->hWin, ID_IMAGE);
if (f_mount(&fileSystem, (TCHAR const*) SD_Path, 0) == FR_OK) {
/*Open file image with read access*/
/*
* param 1 Pointer to the blank file object
* param 2 Pointer to the file name
* param 3 Access mode and file open mode flags
*/
res = f_open(&ImgFile, "IMG1.bmp", FA_OPEN_EXISTING | FA_READ);
if (res == FR_OK) {
IMAGE_SetBMPEx(image, _GetData, &ImgFile);
}
}
break;
...
default:
WM_DefaultProc(pMsg); //Default message handler. p.407
}
}
WM_HWIN Create_GUI(void){
...
WM_HWIN EM_dialog;
EM_dialog = GUI_CreateDialogBox(Main_Window_DialogCreate, GUI_COUNTOF(Main_Window_DialogCreate), WIDGETS_Callback, WM_HBKWIN, 0, 0);return EM_dialog;}
And everything works fine - pictures in attachments.
BUT!
When I use FreeRTOS, function 'IMAGE_SetBMPEx' doesn't work properly.
It takes 9 or 10 lines from file and then stops. But GUI works fine, touch data updates without any problem, all button callbacks responses at touches, cursor displays properly, everything fine except BMP image.
In my example I use BMP 16 bit per pixel image that has size 560x320. In one loop through function '_GetData', it takes 1124 bytes.
On 9 or 10 (every time it different) loop cycle, it takes less than 1124 and after that goes to GUI thread and execute 'GUI_Exec();'
I tried different approaches, I used semaphores, play with preemption and Suspend-Resume functions, but all the same.
Cause library is completely closed I can't see in debug mode the cause of the problem.
My platform:
MCU: STM32F103ZET6 (without any external SRAM or SDRAM)
LCD: 7" 800 x 480 with Solomon's SSD1963 controller (1215kB VRAM).
SD connected through SDIO SD 1 bit protocol. (yes, it loads pretty slowly - nearly 1 second)
System configuration:
for emWin:
#define GUI_NUMBYTES (20*1024)
for RTOS:
#define configTOTAL_HEAP_SIZE ((size_t)30 * 1024)
F103ZET6 has 64kB of RAM and 512kB of ROM.
Whole project you can take from my yandex disk:
https://yadi.sk/d/sNU3ivowug4j9
B.R. Constantine Laskov.
Some details about this project you can also find at my site:
http://microelk.azurewebsites.net/
I using function 'IMAGE_SetBMPEx' to show image from SD card.
My '_GetData' function looks like:
static char _acBuffer[BYTES_IN_LINE];
int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Offset){
unsigned int NumBytesRead;
if (NumBytesReq > sizeof(_acBuffer)) {// Check buffer size
NumBytesReq = sizeof(_acBuffer);
}
f_lseek((FIL *) p, Offset); //Set file pointer to the required position
f_read((FIL *) p, (void *) _acBuffer, NumBytesReq, &NumBytesRead); //Read data into buffer
*ppData = (const U8*) _acBuffer; //set pointer to the buffer
return NumBytesRead;
}
I successfully loaded images from SD card whith and without window manager:
FATFS fileSystem;
FIL ImgFile;
FRESULT res;
/*Register the file system object to the FatFs module*/
/*
* param 1 Pointer to the file system object (NULL:unmount)
* param 2 Logical drive number to be mounted/unmounted
* param 3 0:Do not mount (delayed mount), 1:Mount immediately
*/
if (f_mount(&fileSystem, (TCHAR const*) SD_Path, 0) == FR_OK) {
/*Open file image with read access*/
/*
* param 1 Pointer to the blank file object
* param 2 Pointer to the file name
* param 3 Access mode and file open mode flags
*/
res = f_open(&ImgFile, "IMG1.bmp", FA_OPEN_EXISTING | FA_READ);
if (res == FR_OK) {
GUI_BMP_DrawEx(_GetData, &ImgFile, 0, 0);
}
}
and in dialog with windows manager:
#define ID_IMAGE (GUI_ID_USER + 0x70)
static const GUI_WIDGET_CREATE_INFO Main_Window_DialogCreate[] =
{
...
{ IMAGE_CreateIndirect, "Image", ID_IMAGE,
0, 0,
IMAGE_WIDTH, IMAGE_HEIGHT, 0, 0, 0 }
...
};
IMAGE_Handle image;
void WIDGETS_Callback(WM_MESSAGE * pMsg){ //Custom callback function
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
....
image = WM_GetDialogItem(pMsg->hWin, ID_IMAGE);
if (f_mount(&fileSystem, (TCHAR const*) SD_Path, 0) == FR_OK) {
/*Open file image with read access*/
/*
* param 1 Pointer to the blank file object
* param 2 Pointer to the file name
* param 3 Access mode and file open mode flags
*/
res = f_open(&ImgFile, "IMG1.bmp", FA_OPEN_EXISTING | FA_READ);
if (res == FR_OK) {
IMAGE_SetBMPEx(image, _GetData, &ImgFile);
}
}
break;
...
default:
WM_DefaultProc(pMsg); //Default message handler. p.407
}
}
WM_HWIN Create_GUI(void){
...
WM_HWIN EM_dialog;
EM_dialog = GUI_CreateDialogBox(Main_Window_DialogCreate, GUI_COUNTOF(Main_Window_DialogCreate), WIDGETS_Callback, WM_HBKWIN, 0, 0);return EM_dialog;}
And everything works fine - pictures in attachments.
BUT!
When I use FreeRTOS, function 'IMAGE_SetBMPEx' doesn't work properly.
It takes 9 or 10 lines from file and then stops. But GUI works fine, touch data updates without any problem, all button callbacks responses at touches, cursor displays properly, everything fine except BMP image.
In my example I use BMP 16 bit per pixel image that has size 560x320. In one loop through function '_GetData', it takes 1124 bytes.
On 9 or 10 (every time it different) loop cycle, it takes less than 1124 and after that goes to GUI thread and execute 'GUI_Exec();'
I tried different approaches, I used semaphores, play with preemption and Suspend-Resume functions, but all the same.
Cause library is completely closed I can't see in debug mode the cause of the problem.
My platform:
MCU: STM32F103ZET6 (without any external SRAM or SDRAM)
LCD: 7" 800 x 480 with Solomon's SSD1963 controller (1215kB VRAM).
SD connected through SDIO SD 1 bit protocol. (yes, it loads pretty slowly - nearly 1 second)
System configuration:
for emWin:
#define GUI_NUMBYTES (20*1024)
for RTOS:
#define configTOTAL_HEAP_SIZE ((size_t)30 * 1024)
F103ZET6 has 64kB of RAM and 512kB of ROM.
Whole project you can take from my yandex disk:
https://yadi.sk/d/sNU3ivowug4j9
B.R. Constantine Laskov.
Some details about this project you can also find at my site:
http://microelk.azurewebsites.net/