Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to upload to my nano the code attached. It is giving me an error saying variable must be const about something I am trying to put in progrem. I learned that installing a older version of the compiler worked. However I was wondering is there a way to just edit the code to make it work. I tried putting const before it but it didn't work. It is on line 78 and 79 of the first file.

const extern PGM_P *NApowerCodes[] PROGMEM;

const extern PGM_P *EUpowerCodes[] PROGMEM;

share|improve this question
    
Could you please post the concerning lines of code. You can't expect us to go to a webpage, find and download a zip, open it, just to see the code. – Gerben Apr 14 '15 at 16:33
    
Which version of the IDE are you using? I was able to compile to code on 1.0.5 – rslite Apr 16 '15 at 2:41
    
I am using the latest version, I believe 1.0.06. I was able to compile it with your version but would like to know how to fix it. – NULL Apr 16 '15 at 11:05
up vote 0 down vote accepted

Using the source from this link I got it to compile following these steps.


  • Before opening the sketch in the Arduino:
    • Rename TVB.pde to TVB.ino
    • Rename WORLDcodes.cpp to WORLDcodes.h

  • Open the sketch (TVB.ino) in the Arduino IDE

  • Edit main.h and change:

    // The structure of compressed code entries
    struct IrCode {
      uint8_t timer_val;
      uint8_t numpairs;
      uint8_t bitcompression;
      uint16_t const *times;
      uint8_t const*codes;
    };
    

    to:

    // The structure of compressed code entries
    struct IrCode {
      uint8_t timer_val;
      uint8_t numpairs;
      uint8_t bitcompression;
      uint16_t const *times;
      uint8_t const*codes PROGMEM;
    };
    

    That is, add PROGMEM to the codes line.


  • Edit TVB.ino and change:

    extern PGM_P *NApowerCodes[] PROGMEM;
    extern PGM_P *EUpowerCodes[] PROGMEM;
    extern uint8_t num_NAcodes, num_EUcodes;
    

    to:

    #include "WORLDcodes.h"
    

    This avoids some linker problems in the original code.


  • Edit WORLDcodes.h and delete the line:

     #include "main.h"
    

  • Continue editing WORLDcodes.h and change:

    const struct IrCode *NApowerCodes[] PROGMEM = {
    

    to:

    const struct IrCode * const NApowerCodes[] PROGMEM = {
    

    And also change:

    const struct IrCode *EUpowerCodes[] PROGMEM = {
    

    to:

    const struct IrCode * const EUpowerCodes[] PROGMEM = {
    

It should now compile OK.

share|improve this answer
    
Thanks so much! – NULL Aug 22 '15 at 22:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.