Po Ting
Well-known member
I think there might be some bug when using PROGMEM const array in functions?
some codes from POV guidance that you need to call pgm_read_type to work on PROGMEM arrays,
and codes in teensy just seemed to work well without calling any extra function
not sure if related or not
for example,
but after it changed to script below , i get like
sizeof(array) =4
sizeof(*array) =2
and the printed array = {0, 1}
no matter what the values the original array had,and PROGMEM/or not, i get the same result
not sure if this is bug, or anything i did wrong? it passes the compiler, but gives incorrect array
some codes from POV guidance that you need to call pgm_read_type to work on PROGMEM arrays,
and codes in teensy just seemed to work well without calling any extra function
not sure if related or not
for example,
the script above works well and i get the const array PROGMEM/or not, printed to my serial monitor correctly,const uint16_t gammaTable[] PROGMEM = {/* .... */}
void loop() {
consttoserial();
delay(4000);
}
void consttoserial(){
Serial.println(sizeof(gammaTable)/sizeof(*gammaTable));
for (int y=0;y<sizeof(gammaTable)/sizeof(*gammaTable);y++) {
Serial.print(gammaTable[y]);
Serial.print("\t");
if ((y+1)%16==0) {
Serial.println("");
}
}
}
but after it changed to script below , i get like
sizeof(array) =4
sizeof(*array) =2
and the printed array = {0, 1}
no matter what the values the original array had,and PROGMEM/or not, i get the same result
not sure if this is bug, or anything i did wrong? it passes the compiler, but gives incorrect array
const uint16_t gammaTable[] PROGMEM = {/* .... */}
void loop() {
consttoserial(gammaTable);
delay(4000);
}
void consttoserial(const uint16_t *array){
Serial.println(sizeof(array)/sizeof(*array));
for (int y=0;y<sizeof(array)/sizeof(*array);y++) {
Serial.print(array[y]);
Serial.print("\t");
if ((y+1)%16==0) {
Serial.println("");
}
}
}