Timer question

I want to be able to call a function during the "setup" part of my program for about 3 seconds. I want to pass a value from an EEPROM address to this function. Then continue with setup.

I then want to call this same function during loop but let it do its job with out the value from the EEPROM.

Does this sound feasible?

I have just been thinking about this and it won’t work. I will need to create a second function as the first one won’t use the EEPROM value as I want, it will overwrite it with its own values.

Another question.

Do I put the timer in the setup area then call a function I want to run for 3S then return Or do I call the function and have the 3 second timer in the function.

windoze_killa:
I want to be able to call a function during the “setup” part of my program for about 3 seconds. I want to pass a value from an EEPROM address to this function. Then continue with setup.

I then want to call this same function during loop but let it do its job with out the value from the EEPROM.

Does this sound feasible?

I’m not sure what you mean by “I want to be able to call a function during the “setup” part of my program for about 3 seconds”. In terms of calling the function with or without an EEPROM address you can do one of two things:

  1. Declare the function with a default argument:
void foo(int address=0) 
{ 
    // do something
}
  1. Overload the function:
void foo(int address) 
{ 
    // do something
}

void foo() 
{ 
    // do something else
}

windoze_killa:
I want to be able to call a function during the "setup" part of my program for about 3 seconds. I want to pass a value from an EEPROM address to this function. Then continue with setup.

I then want to call this same function during loop but let it do its job with out the value from the EEPROM.

Does this sound feasible?

Yes, it is possible. You just need to use a global variable or static variable to store the value from EEPROM in the first call (from setup() function ).

For example

void foo(int address = 0)
{
  static bool isReadFromEEPROM = false;
  static int valueReadFromEEPROM;

  if (isReadFromEEPROM == false)
  {
    valueReadFromEEPROM = ;// read from eeprom code
    isReadFromEEPROM = true;
  }
}

Thanks. I will have a play when I get home tonight.

As I expected it didn't work. The function gets data from another variable when running so it ignores the EEPROM data. I will just right a second function that doesn't and call that one during setup.