Please help me, I met a strange question about PROGMEM

This is the code.

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

static const uint8_t lt_bmp[] PROGMEM = {0x00, 0x10, 0x30, 0x7f, 0xff, 0x7f, 0x30, 0x10};
static const uint8_t up_bmp[] PROGMEM = {0x10, 0x38, 0x7c, 0xfe, 0x38, 0x38, 0x38, 0x38};
static const uint8_t rt_bmp[] PROGMEM = {0x00, 0x08, 0x0c, 0xfe, 0xff, 0xfe, 0x0c, 0x08};
static const uint8_t dw_bmp[] PROGMEM = {0x38, 0x38, 0x38, 0x38, 0xfe, 0x7c, 0x38, 0x10};
static const uint8_t k1_bmp[] PROGMEM = {0x00, 0xfe, 0xfe, 0xc6, 0xd6, 0xc6, 0xfe, 0xfe};
static const uint8_t k2_bmp[] PROGMEM = {0x3c, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3c};
static const uint8_t* const bmp_table[] PROGMEM = {k1_bmp, k2_bmp, lt_bmp, up_bmp, rt_bmp, dw_bmp};

void setup(){}
void loop(){
if (digitalRead(KEY1) == HIGH) newKeyIn(0);
delay(1000);
}

void newKeyIn(uint8_t n) {
uint8_t c=2;
lcd.drawBitmap(40, 18, bmp_table[n] , 8, 8, 1); // incorrect to display
lcd.drawBitmap(40, 18, bmp_table

 , 8, 8, 1); //correct!
  lcd.drawBitmap(40, 18, bmp_table[1] , 8, 8, 1); //correct![/color]
  lcd.display();
}


The same variables, but different results, so I was confused.

Can someone tell me why?
Thanks!

"c" and "1" are compile-time constants, and the compiler optimizes the code to directly load the proper byte into memory (at some level, the compiler doesn't understand PROGMEM. It see constant index to a constant array and just loads a number. "bmp_table[1]" just becomes "k2dmp") "n" however, is a variable, so the program will actually need to access program memory at runtime, using the PROGMEM access routines, which you didn't use. You'd probably need something like:

    lcd.drawBitmap(40,18, pgm_read_ptr(&bmp_table[n]));

hi westfw
thank you for giving me ideas, i did some research and resolved the problem.

uint8_t bmp[8];
 memcpy_P(bmp, ((uint8_t*)pgm_read_byte(&(bmp_table[n]))), 8);
  1. must use pgm_read_byte function to read PROGMEM varibles
  2. use memcpy_P to copy to memories before use.

http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html