Pages: [1]   Go Down
Author Topic: How do I use Progmem and is this the right solution.  (Read 310 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good day
I am looking for a solution to store about 55 - 99 raw ir codes is progmem the right place to store them.
I don't know if EEprom will be large enough.
And I think I ma running out of SDRAM as I still have plenty of flash memory left.
My project stops responding as soon as I reach about 40,000bytes out of 258,048bytes of flash memory.The serial monitor remains blank and the mega don't respond.

How do I use progmem to store these codes, ore are the flash library a better proposition.
I tried to figure out how to index and call the code once in progmem

Code:
/*
 * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <avr/pgmspace.h>
#include <IRremote.h>

IRsend irsend;
// original code /* unsigned int raw1[100] = {550,1750,600,1700,600,1700,600,500,550,550,550,500,600,1700,600,500,550,550,550,1750,550,500,600,500,600,1700,600,1700,600,500,550,550,550,22800,600,1700,600,1750,550,1750,550,500,600,500,550,550,550,1750,550,500,600,500,600,1700,600,500,550,550,550,1750,550,1750,550,500,600,500,600,22900,600,1700,600,1700,600,1700,600,500,600,500,550,550,550,1750,550,500,600,500,550,1750,600,500,550,500,600,1700,600,1750,550,500,600,};*/
// one int for every ir code need about 50 - 99 of these codes.
unsigned int raw1[] PROGMEM = {550,1750,600,1700,600,1700,600,500,550,550,550,500,600,1700,600,500,550,550,550,1750,550,500,600,500,600,1700,600,1700,600,500,550,550,550,22800,600,1700,600,1750,550,1750,550,500,600,500,550,550,550,1750,550,500,600,500,600,1700,600,500,550,550,550,1750,550,1750,550,500,600,500,600,22900,600,1700,600,1700,600,1700,600,500,600,500,550,550,550,1750,550,500,600,500,550,1750,600,500,550,500,600,1700,600,1750,550,500,600,};
// store code into flash = this codes compiles
unsigned int raw2[] PROGMEM = {550,1750,600,1700,600,1700,600,500,550,550,550,500,600,1700,600,500,550,550,550,1750,550,500,600,500,600,1700,600,1700,600,500,550,550,550,22800,600,1700,600,1750,550,1750,550,500,600,500,550,550,550,1750,550,500,600,500,600,1700,600,500,550,550,550,1750,550,1750,550,500,600,500,600,22900,600,1700,600,1700,600,1700,600,500,600,500,550,550,550,1750,550,500,600,500,550,1750,600,500,550,500,600,1700,600,1750,550,500,600,};
// or
// store code into flash = code don't compile
//PROGMEM prog_int16_t raw[] = {550,1750,600,1700,600,1700,600,500,550,550,550,500,600,1700,600,500,550,550,550,1750,550,500,600,500,600,1700,600,1700,600,500,550,550,550,22800,600,1700,600,1750,550,1750,550,500,600,500,550,550,550,1750,550,500,600,500,600,1700,600,500,550,550,550,1750,550,1750,550,500,600,500,600,22900,600,1700,600,1700,600,1700,600,500,600,500,550,550,550,1750,550,500,600,500,550,1750,600,500,550,500,600,1700,600,1750,550,500,600,};

void setup()
{
  Serial.begin(9600);
}

void loop() {
  //if (Serial.read() != -1) {
    //for (int i = 0; i < 2; i++) {
     //irsend.sendRaw(raw,100,38);
      //delay(20);
   // }
  //}
}

void IRc1(){cli();for (int i = 0; i < 1; i++) {irsend.sendRaw(raw1,100,38);delay(20);}sei();}// one for every ir code more than 55 of these functions
void IRc2(){cli();for (int i = 0; i < 1; i++) {irsend.sendRaw(raw2,100,38);delay(20);}sei();}// one for every ir code more than 55 of these functions
                                               // the (raw2,100,38)changes depending on the IR code as well as the number of repeats.     
// 1 function for every ir code to be able to call the code from anywhere in the sketch.


I need to use the functions to call the code from diffident locations throughout the sketch ie. from udp call / ir call / voice call / or serial call.
Unless there is a better way (Always open to suggestions)


Many Thanks I would appreciate any information.
Riaan
Logged

Pages: [1]   Go Up
Jump to: