Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:53:53+00:00 2026-06-14T06:53:53+00:00

I have three array, like this, that contains my bitmap images: static unsigned char

  • 0

I have three array, like this, that contains my bitmap images:

static unsigned char __attribute__ ((progmem)) impostazioni_logo[]={

0x00, 0x02, 0x7E, 0x02, 0x00, 0x00, 0x78, 0x10, 0x08, 0x08, 0x08, 0x70, 0x10, 0x08,    0x08, 0x08,
0x70, 0x00, 0x00, 0x78, 0x10, 0x08, 0x08, 0x08, 0x10, 0x60, 0x00, 0x00, 0x60, 0x10, 0x08, 0x08,
0x08, 0x10, 0x60, 0x00, 0x00, 0x30, 0x48, 0x48, 0x08, 0x08, 0x10, 0x00, 0x00, 0x08, 0x7E, 0x08,
0x08, 0x08, 0x00, 0x00, 0x50, 0x48, 0x48, 0x48, 0x70, 0x00, 0x00, 0x08, 0x08, 0x08, 0x48, 0x28,
0x18, 0x00, 0x00, 0x7A, 0x00, 0x00, 0x60, 0x10, 0x08, 0x08, 0x08, 0x10, 0x60, 0x00, 0x00, 0x78,
0x10, 0x08, 0x08, 0x08, 0x08, 0x70, 0x00, 0x00, 0x7A, 0x00, 0x00, 0x08, 0x0F, 0x08, 0x00, 0x00,
0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x7F, 0x08, 0x08,
0x08, 0x08, 0x04, 0x03, 0x00, 0x00, 0x03, 0x04, 0x08, 0x08, 0x08, 0x04, 0x03, 0x00, 0x00, 0x04,
0x08, 0x08, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00, 0x07, 0x08, 0x08, 0x08, 0x00, 0x07, 0x08, 0x08,
0x08, 0x04, 0x0F, 0x00, 0x00, 0x0C, 0x0A, 0x09, 0x08, 0x08, 0x08, 0x00, 0x00, 0x0F, 0x00, 0x00,
0x03, 0x04, 0x08, 0x08, 0x08, 0x04, 0x03, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F,
0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  };

Now i want a function return the correct array to display on lcd by passing the page parameter.

unsigned char logo(int page){
 char buffer[32];
  switch(page){
    case 1:
       for(int i=0;i<sizeof(impostazioni_logo);i++){
        strcpy_P(buffer,pgm_read_byte(&(impostazioni_logo[i]))); //<==pgm_read_byte comes from here:http://www.arduino.cc/en/Reference/PROGMEM
       }  
    break;
  }
   return buffer;

}
it doesn’t work. Compiler tell me something wrong about conversion.

EDIT:

caller is a simply function that draw the right image. Images can be different for different pages. Number of pages are near 20:

void drawLogo(){
 glcd.drawbitmap(15,1, logo(), 90,16); //display lcd library for ST7565

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:53:54+00:00Added an answer on June 14, 2026 at 6:53 am

    There are a few issues with this code:

    1. return type for logo is unsigned char while you are returning char *
    2. pgm_read_byte supposedly returns a byte, so you could simply do buffer[i]=pgm_read_byte(...)
    3. buffer that you are trying to return is allocated on the stack and will not exist after function returns.

    You should probably be using strlcpy_P instead.

    Update:
    1. Assuming you have a fixed number of pages. Try creating a bitmap per page, like:

    static unsigned char __attribute__ ((progmem)) impostazioni_logo_page1[]={..}
    

    2. return a pointer to each pages’ logo:

    unsigned char* logo(int page)
    {
      switch(page)
      {
        case 1:
           return impostazioni_logo_page1;
        break;
      }
      return NULL;
    }
    

    If you like to have all bitmaps in a single array, calculate an offset in the array and return that instead:

    int offset = page_num*page_size_in_chars;    
    return &impostazioni_logo_all_pages[offset];
    

    Update 2: Another option to manage pages:

    static unsigned char* pages[] = { impostazioni_logo_page1, impostazioni_logo_page2, ... }
    ...
    glcd.drawbitmap(15,1, pages[page_index], 90,16);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one array that contains some settings that looks like basically like this:
If (in zsh) I have an array that contains something like this: echo ${fsizes[@]}
If I have an array that contains multiple FLV files like so: my @src_files
I have this method to save a mutable array named myWallet that contains instances
I have an array of folders/files that looks like this: Array ( [Root Folder
I have a string that contains something like this: ##### abc 'foo' /path/to/filename:1 #####
I have two array and three button in segment control i want that when
I have a variable that contains an array. That array contains X number of
I have a custom class of type NSObject that contains a single NSMutableArray. This
I have an array like this (output from console.log): [122.42.123.1, 122.42.123.1, 122.42.123.1, awdawd, awdawd]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.