element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
STM32F4DISCOVERY Expansion Boards
  • Products
  • Dev Tools
  • STM32F4DISCOVERY Expansion Boards
  • More
  • Cancel
STM32F4DISCOVERY Expansion Boards
Forum Stm32f4 loading image
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join STM32F4DISCOVERY Expansion Boards to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 18 replies
  • Subscribers 8 subscribers
  • Views 3334 views
  • Users 0 members are here
Related

Stm32f4 loading image

philip-1992
philip-1992 over 12 years ago

Hi all,

 

I am still on the experimenting phase of the stm32f4 Discovery. I am trying to load an image on the touch screen (DM-LCD35RT) but I cannot find any examples in order to guide me. Is there anyone that has an available example in which I can understand the process and thus write my own program? Any help would be greatly appreciated. Thank you

  • Sign in to reply
  • Cancel
  • Kilohercas
    0 Kilohercas over 12 years ago

    First download Embedded Resource Editor GUI from www.st.com, it will allow you to convert BMP, jpg and other to char array, and it will generate code.image

     

    Next you have to have paint bmp function, (you must know converted picture dimensions, like 320x240,  (you must resize jpg or any other file so it can fit inside screen !!!!)
    After that, copy generated file to bmp.h, include that to main.c, and call paint function from LCD library

    as example, i have SSD1289 with void LCD_WriteBMP(uint8_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width, uint8_t *bitmap) function
    so in main.c, i call:

    LCD_WriteBMP(0,0,320,240,(u8) * Name_of_Char_array_generated_by_gui_aka_ImageBuffer);

     

    Questions ?

    (mark helpful or correct answer if it helped)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • philip-1992
    0 philip-1992 over 12 years ago in reply to Kilohercas

    My screen is SSD2119 so does this line: void LCD_WriteBMP(uint8_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width, uint8_t *bitmap)  still works? Or that is from a ready made h file? Also:Name_of_Char_array_generated_by_gui_aka_ImageBuffer does that mean the file name generated by that program?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Kilohercas
    0 Kilohercas over 12 years ago in reply to philip-1992

    Yes, it should work.
    in GUI it will create array called const unsigned char ImageBuffer[], you can use default, or rename to mach your picture name.

    1) Copy all code generated by program to file picture.h

    2) #include <picture.h>  inside your main.c file

    3) Make sure you init your screen, so it can display something, test it with LCD_Clear(0xFF00);

    4) paint picture by calling : LCD_WriteBMP(0, 0, X, Y, (uint8_t*) ImageBuffer); // note that X and Y must be same, or lower than resollution of your screen, so max_x is 320, max_y 240 if i remember resolution corecly , test first with 200x200 pixels picture, so crop it, resize it, convert it to char array and so on.

    5) enjoy

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • philip-1992
    0 philip-1992 over 12 years ago in reply to Kilohercas

    I will try this hopefully by today will get back to you with the results image Thanks for your time

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • philip-1992
    0 philip-1992 over 12 years ago in reply to Kilohercas

    So I did what you told me and converted an image and included it in main and wrote the following code:

    int main(void)

    {

                

      /* Initializes LCD */

      STM32f4_Discovery_LCD_Init();

             

      /* Clear the LCD */

      LCD_Clear(LCD_COLOR_WHITE);

     

      while (1) {

      LCD_WriteBMP(0, 0, 320, 240, (uint8_t*) ImageBuffer);

      delay(500);

      }

     

    there are no errors but the image is not visible on screen

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Kilohercas
    0 Kilohercas over 12 years ago in reply to philip-1992

    for first time use 100x100 picture, convert it to char array

    Image buffer should be generated as ImageBuffer[20000]

     

    LCD_WriteBMP(20, 20, 100, 100, (uint8_t*) ImageBuffer);

     

    Also, make colour for LCD_Clear(GREEN) or other non stock collor

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • philip-1992
    0 philip-1992 over 12 years ago in reply to Kilohercas

    I am very sorry for all these questions but now an error has occured :Error[Pe140]: too many arguments in function call 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Kilohercas
    0 Kilohercas over 12 years ago in reply to philip-1992

    Hrr, i know the problem.

    You must rewrite this code for your lcd driver

     

    void Lcd_SetCursor(u16 x,u16 y)

    {

        if(DeviceCode==0x8989)

        {

             Lcd_WriteReg(0x004e,y);        //Å Å

            Lcd_WriteReg(0x004f,0x13f-x);  //ÄRegisteredÅ

        }

        else if(DeviceCode==0x9919)

        {

            Lcd_WriteReg(0x004e,x); // Å Å

              Lcd_WriteReg(0x004f,y); // ÄRegisteredÅ    

        }

        else

        {

              Lcd_WriteReg(0x0020,y); // Å Å

              Lcd_WriteReg(0x0021,0x13f-x); // ÄRegisteredÅ

        }

    }

     

    void Lcd_SetWindows(u16 StartX,u16 StartY,u16 EndX,u16 EndY)

    {

      Lcd_SetCursor(StartX,StartY);

      Lcd_WriteReg(0x0050, StartX);

      Lcd_WriteReg(0x0052, StartY);

      Lcd_WriteReg(0x0051, EndX);

      Lcd_WriteReg(0x0053, EndY);

    }

     

    void Lcd_DrawPicture(u16 StartX,u16 StartY,u16 EndX,u16 EndY,u8 *pic)

    {

      u16  i;

      Lcd_SetWindows(StartX,StartY,EndX,EndY);

      Lcd_SetCursor(StartX,StartY);

      u16 *bitmap_ptr = (u16 *)pic;

      Clr_Cs;

     

      Lcd_WriteIndex(0x0022);

      Set_Rs;

      for (i=0;i<(EndX*EndY);i++)

      {

          Lcd_WriteData(*bitmap_ptr++);

          Clr_nWr;Set_nWr;

      }

         

      Set_Cs;

    }

    note that Set_Cs, and other functions is already done by FSMC controller, so you just need to change some bits to get it working, and my old original main function will work for you as it should. And you will learn stuff by doing that

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Kilohercas
    0 Kilohercas over 12 years ago in reply to Kilohercas

    or, try this one, it is for SSD1289, but maybe that will work for you too:

     

    void LCD_SetCursor(uint16_t Xpos, uint16_t Ypos)

    {

      LCD_WriteReg(LCD_REG_78, Xpos);

      LCD_WriteReg(LCD_REG_79, Ypos);

    }

     

    void LCD_SetDisplayWindow(uint8_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width)

    {

      if(Xpos >= Height)

      {

        LCD_WriteReg(0x0044, (Xpos - Height +1));

      }

      else

      {

        LCD_WriteReg(0x0044, 0x0000);

      }

      if(Ypos >= Width)

      {

        LCD_WriteReg(0x0045, (Ypos - Width +1));

      } 

      else

      {

        LCD_WriteReg(0x0045, 0x0000);

      }

      LCD_WriteReg(0x0046, Ypos);

      LCD_SetCursor(Xpos, Ypos);

     

    }

     

    void LCD_WriteBMP(uint8_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width, uint8_t *bitmap)

    {

      volatile uint32_t index;

      uint16_t *bitmap_ptr = (uint16_t *)bitmap;

      uint32_t size;

      size=(Height * Width);

      LCD_SetDisplayWindow(Xpos, Ypos,Height, Width);

     

      LCD_WriteReg(LCD_REG_17, 0x6048);

     

      LCD_WriteRAM_Prepare();

     

      for(index = 0; index < size ; index++)

      {

        LCD_WriteRAM(*bitmap_ptr++);

      }

      LCD_WriteReg(LCD_REG_17, 0x6028);

      LCD_SetDisplayWindow(0, 0, 239, 319);

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • philip-1992
    0 philip-1992 over 12 years ago in reply to Kilohercas

    I will try that tomorrow thank you very much. I believe that i have to change the name of the functions since they are already defined by another function right?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube