AnsweredAssumed Answered

stemWin GUI_BMP_DrawEx Hardfaults

Question asked by ericsson.ola on Dec 15, 2015
Latest reply on Dec 16, 2015 by ericsson.ola
Hi everyone,
I'm trying to display an image from SD card on a display 800x480px. My image have the same size.
I can read and write files from the SD card, so that part is no problem. I can also use stemWin to display strings and windows cursor etc, so there are nothing wrong with the display driver either.
But when I call GUI_BMP_DrawEx(_GetDataSD, &imageFile, 0, 0); I get an hardfault.

I open my file like this:
  if (f_open(&imageFile, "0:image.bmp" , FA_READ) == FR_OK)
    GUI_BMP_DrawEx(_GetDataSD, &imageFile, 0, 0);
  f_close(&imageFile);

I have a global buffer unsigned char _acBuffer[512]; declard

My _GetData looks like this:

int _GetDataSD(void * p, const u8 ** ppData, unsigned NumBytesReq, u32 Off) {
  FIL * phFile;
  UINT NumBytesRead;
  phFile = (FIL *)p;

  // Check buffer size
  if (NumBytesReq > sizeof(_acBuffer)) {
    NumBytesReq = sizeof(_acBuffer);
  }
  // Set file pointer to the required position
  f_lseek(phFile, Off);
  // Read data into buffer
  f_read(phFile, _acBuffer, NumBytesReq, (UINT *)&NumBytesRead);
  // Set data pointer to the beginning of the buffer
  *ppData = _acBuffer;
  // Return number of available bytes
  return NumBytesRead;
}

Have anyone experience using GUI_BMP_DrawEx, that may have an input of what I'm doing wrong?

Outcomes