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  a picture smaller than 320*240
  • 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 4 replies
  • Answers 1 answer
  • Subscribers 7 subscribers
  • Views 989 views
  • Users 0 members are here
  • stm32f407vgt6
Related

STM32F4 Loading  a picture smaller than 320*240

philip-1992
philip-1992 over 11 years ago

Hi everyone after a long time missing as I was designing a PCB I am back on programming. I need to load images on a 320*240 screen. So far I managed to load pictures 320*240 big and any other pictures with 320*x size where x can be any number between 1 to 240. But if I change the width of the picture (ie the 320) becomes sort of torsion (look on images below, the background is red in order to highlight where the picture starts and where it ends the size of this picture is 120*240). I have been trying to understand why this is happening but with no success :/. Below is the functions used to paint the picture, any help would be greatly appreciated thanks.

 

LCD_BMP((uint8_t*) ImageBuffer); // Calling the paint function from main

 

void LCD_BMP(uint8_t *bitmap) // painting the picture

{

  uint32_t size = 100 * 240;      // 100 = width, 240 = length

  uint16_t *bitmap_ptr = (u16 *)bitmap;

  LCD_SetCursor(0x00, 0x00);

  LCD_SetDisplayWindow(0, 0, 100, 240); // Setting the position to start painting the picture from 0,0 and the size of the picture to be painted is 100*240

 

  LCD_WriteRAM_Prepare(); // Prepare to write GRAM

 

  volatile uint32_t dlycnt;

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

      {

        LCD_Data = *bitmap_ptr++;

      }

}

 

void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t width, uint16_t Height) // Setting up the painting area

{

  uint32_t value = 0;

 

  LCD_WriteReg(SSD2119_H_RAM_START_REG, Xpos);

 

  if ((Xpos+width) >= LCD_PIXEL_WIDTH) {

    LCD_WriteReg(SSD2119_H_RAM_END_REG, LCD_PIXEL_WIDTH-1);

  } else {

    LCD_WriteReg(SSD2119_H_RAM_END_REG, Xpos+width);

  }

 

  if ((Ypos+Height) >= LCD_PIXEL_HEIGHT) {

    value = (LCD_PIXEL_HEIGHT-1) << 8;

  } else {

    value = (Ypos+Height) << 8;

  }

  value |= Xpos;

  LCD_WriteReg(SSD2119_V_RAM_POS_REG, value);

  LCD_SetCursor(Xpos, Ypos);

}

 

 

If you require any additional code in order to detect the problem write it in the comment section, I pasted the parts of the code where I guess the trouble is. Thank you once again .

 

These images are photos taken of the LCD screen in operation.

Image 1: 100*240 resolution picture

image

Image 2: 320*144 resolution picture:

image

Image 3: 320*240 resolution picture (full screen):

Fullscreen 4456.contentimage_29823.html Download
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

  • Sign in to reply
  • Cancel
Parents
  • shabaz
    0 shabaz over 11 years ago

    Just a guess, but perhaps

    LCD_SetDisplayWindow(0, 0, 100, 240);

    should be

    LCD_SetDisplayWindow(0, 0, 99, 239);

    (i.e. maybe the range is inclusive of the upper limit value).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • philip-1992
    0 philip-1992 over 11 years ago in reply to shabaz

    It seems that the width had to be 1 pixel less as you have told me!! Thank you for this, I have been stuck on this problem for 2 days!! What is troubling me is why do I need to subtract 1 pixel??

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

    Hi Philip,

     

    It's just a guess, I could be very wrong. Maybe the function expects pixel position, and not width.

    It should be in the SSD2119 documentation, to see what  SSD2119_H_RAM_START_REG and

    SSD2119_H_RAM_END_REG means.

    Maybe the person who wrote LCD_SetDisplayWindow misunderstood, and specified a width as a parameter when it was really the end pixel position : ( not sure. I don't have this board or display unfortunately, so I could be talking nonsense : (

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to philip-1992

    FWI, 0 is the first location, 239 is the last. Your math teacher wont agree but the computer understands. ;-)

    Bryan

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 11 years ago in reply to philip-1992

    FWI, 0 is the first location, 239 is the last. Your math teacher wont agree but the computer understands. ;-)

    Bryan

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
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