Several examples run on only mbed-os5.13.0 (not 5.14.0)
Dependencies: BD_SD_DISCO_F769NI BSP_DISCO_F769NI LCD_DISCO_F769NI TS_DISCO_F769NI USBHost_F769NI
Diff: zz_common/drawImage_copy2.cpp
- Revision:
- 4:0f4affc00183
- Parent:
- 3:35ac9ee7d2d6
--- a/zz_common/drawImage_copy2.cpp Wed Aug 07 05:39:01 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* - * Mbed function - * - * Created: July 30th, 2019 - * Revised: August 4th, 2019 - */ - -/* - https://os.mbed.com/users/Lightsource/code/DISCO-F746NG_BMP_FROM_SDCARD/ - https://www.gimp.org/downloads/ - https://os.mbed.com/questions/69098/how-can-I-load-an-image-to-screen/#answer14107 - */ - -//#include "select_program.h" -#if defined(NIOI_SENSOR) || defined(EXAMPLE_10_BITMAP) - -// Include -------------------------------------------------------------------- -#include "mbed.h" -#include "FATFileSystem.h" -#include "LCD_DISCO_F769NI.h" -#include "stm32f769i_discovery_lcd.h" - -// Definition ----------------------------------------------------------------- -#define DEBUG 1 - -#if DEBUG -#define DBG(...) pc.printf(__VA_ARGS__) -#else -#define DBG(...) {;} -#endif - -// Constructor ---------------------------------------------------------------- -extern Serial pc; -extern FATFileSystem fs; -extern LCD_DISCO_F769NI lcd; - -// RAM ------------------------------------------------------------------------ - -// ROM / Constant data -------------------------------------------------------- - -// Function prototypes -------------------------------------------------------- -extern void drawImage(const char * name, uint16_t x, uint16_t y); - -//------------------------------------------------------------------------------ -// Control Program -//------------------------------------------------------------------------------ -void drawImage(const char * name, uint16_t x, uint16_t y) -{ - uint32_t index = 0, width = 0, height = 0, bit_pixel = 0; - int fileSize; - char * buffer; - char * buf; - - FILE *image = fopen(name, "rb"); // open the bmp file - if (image == 0) { - pc.printf("%s is not found in the disk\r\n", name); - return; - } - //obtain file size: - fseek(image, 0, SEEK_END); - fileSize = ftell(image); - DBG("fileSize=%d\r\n", fileSize); - fclose(image); - //rewind(image); - - // allocate memory to contain the whole file: - buffer = (char*) malloc (sizeof(char)*fileSize); -#if 0 - buf = buffer; - for (int i = 0; i < fileSize; i += 4) { - *(__IO uint32_t *) buf = 0xff; - buf += 4; - } -#endif -#if 0 - // copy the file into the buffer: - fseek(image, 0, SEEK_SET); - //wait_ms(10); - // set SD file data start position - fread(buffer, 1, fileSize, image); - wait_ms(10); - // copy the file into the buffer: - fseek(image, 0, SEEK_SET); - //wait_ms(10); - // set SD file data start position - fread(buffer, 1, fileSize, image); - wait_ms(10); -#else - image = fopen(name, "rb"); // open the bmp file - if (image == 0) { - pc.printf("%s is not found in the disk\r\n", name); - return; - } - fread(buffer, 1, fileSize, image); -#endif - fclose(image); - - //Draw image - lcd.DrawBitmap(x,y,(uint8_t *)buffer); - //Free allocated memory - free(buffer); -} - -#endif