Hello,
I have a boat load of static arrays. They are raw IR codes. There are so many of them, I am unable to compile because of memory consumption, so I need to store them in PROGMEM.
The problem is, I cannot seem to get them out of flash and use them.
For example, if I don't store them in flash, and use the function to send the code out the IR LED, it works (in this case, it will mute the TV)
const unsigned int TvMute[67] = {4450,4350,600,1550,650,1550,650,1550,600,500,650,450,650,500,600,500,600,500,600,1600,600,1550,650,1550,650,450,650,500,600,500,600,500,600,500,600,1600,600,1600,600,1550,650,1550,600,500,650,450,650,500,600,500,600,500,600,500,600,500,600,500,650,1550,600,1600,600,1600,600,1550,6500};
void sendRaw (const unsigned int buf[], unsigned int len, unsigned int hz)
{
// Set IR carrier frequency
enableIROut(hz);
for (unsigned int i = 0; i < len; i++) {
if (i & 1) space(buf[i]) ;
else mark (buf[i]) ;
}
space(0); // Always end with the LED off
}
void sendCommand() {
sendRaw(TvMute, sizeof(TvMute)-1, hz);
}
Doing it this way, produces no results ... now the IRLED does blink (I look at it using a cell phone camera) ... but it doesn't send anything that the television understands, so I'm not sure what's happening, but I am sure that the array is not being represented as it was defined.
const unsigned int TvMute[67] PROGMEM = {4450,4350,600,1550,650,1550,650,1550,600,500,650,450,650,500,600,500,600,500,600,1600,600,1550,650,1550,650,450,650,500,600,500,600,500,600,500,600,1600,600,1600,600,1550,650,1550,600,500,650,450,650,500,600,500,600,500,600,500,600,500,600,500,650,1550,600,1600,600,1600,600,1550,6500};
void sendRaw (const unsigned int buf[] PROGMEM, unsigned int len, unsigned int hz)
{
// Set IR carrier frequency
enableIROut(hz);
int max = sizeof(buf);
for (unsigned int i = 0; i < max; i++) {
if (i & 1) space(pgm_read_word_near(buf[i]));
else mark (pgm_read_word_near(buf[i]));
}
space(0); // Always end with the LED off
}
void sendCommand() {
sendRaw(TvMute, sizeof(TvMute)-1, hz);
}
What is the right way to accomplish what I'm trying to accomplish?