EEPROM.h

I'm an old BASIC programmer, and some of my programs were several hundred K of source code. But that was a long time ago. C and this variant are a different world to me. I'm running WIN 10.

I have a drapery controller that I wrote over a year ago, running perfectly on the Uno, and now I want to change functionality somewhat. Problem is, even compiling that original program shows errors, and nothing has been changed yet!

To handle power failures I save the drape position as one bit of EEPROM, so for that one bit I need to access the EEPROM library.

The errors I get refer to EEPROM.h. One is "43:30: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]" then "operator const uint8_t() const {return **this; }"

The other starts with "92:26" and then is the same through "operator const" followed by "int() const {return index; } "

Thank you for any help.

Dave

Please, you must show us your complete sketch. Attach your code using the </> icon on the left side of the posting menu.
Put your sketch between the code tags [code][/code]

See:

These are just warnings, not errors, and nothing to worry about.
I have already fixed these in my code and they should be available in a not to distant release of the IDE.

These warnings will not impact your code in any way.

As for the suggestion to look at the last thing I did, it is unchanged since I had successfully compiled it.

As for warnings? Should I ignore them?

I tried including the sketch, but I get the error here that it's over 9000 characters. I'll put the start of it here:

/* Drapery Controller v2 Dave Powell 7/15 - 8/7/15

 #include <EEPROM.h>
 
  const int Dark = 0;                     // Indicates light is below the set threshold level.
  const int Transition = 1;               // Indicates light is between Dark and Threshold + 25.
  const int Bright = 2;                   // Indicates light is bright day.
  const int Opened = 1;                   // For EEPROM to remember current drape position.
  const int Closed = 0;                   // For EEPROM to remember current drape position.
  
  int N;                                  // Utility temporary variable.
  int RunTimeSet;                         // Run time trim from pot.
  int RunTime;                            // Actual run time, nominally 11 seconds.
  int Timer = 0;                          // Timer, counts 1 second loops.  This timer
                                          //    is to ensure that either bright
                                          //    or dark exists continuously for five minutes 
                                          //    before drape movement.
  int Satisfied = HIGH;                   // Flag to indicate no action needed.         
  int LightLevel;                         // Light level from the photocell.
  int Threshold;                          // Threshold pot factored for correct range.
  int LightMode;                          // Dark, Transition, or Bright.
  int OldLightMode;                       // Last time through, detects change in light status.
  int CurrentPosition;                    // Saved in EEPROM, holds current drape position.
  int TimerRun = LOW;                     // Controls sense delay timer.
  unsigned long HoldStart = 0;            // Holds the drape closed for two hours.
    
void setup() {

digitalWrite(11, HIGH);                   //   Flash to start
delay(200);
digitalWrite(11,LOW);
delay(200);
digitalWrite(11, HIGH);      
delay(200);
digitalWrite(11,LOW);


  
  Serial.begin(9600);                     // Start serial output for testing.
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
    
  CurrentPosition = EEPROM.read(1000);    // Read the last drape position from the EEPROM.
  if (CurrentPosition > 1)  {             // Solves wrong initial value from EEPROM.
    CurrentPosition = 1;
  }
  }

void loop() {

//                                                                        MOTOR STOP
//                                                                        ==========                                
  digitalWrite(8, LOW);                   // Motor off,
  digitalWrite(9, LOW);                   //    both directions.

//                                                                        HALF SECOND DELAY
//                                                                        ================                                             
                                          // The following makes the loop nominally 0.5 second.
  digitalWrite(10, HIGH);                 // Trigger the watchdog timer high.
  if (TimerRun != 0) {                    // If in the 5 minute delay,
    if (HoldStart == 0){                   //    and not in hold closed,
    digitalWrite(11, HIGH);               //    turn the white LED on.
    }
  }  
  delay(250);                             // Wait 0.25 second.
  digitalWrite(10, LOW);                  // Now set the watchdog low.
  if (TimerRun != 0) {                    // If in the 5 minute delay,
    if (HoldStart == 0) {                 //    and not in hold closed,
      digitalWrite(11, LOW);              //    turn the white LED off, advance
      Timer = Timer + 1;                  //    the count on the 5 minute timer.
    }
  }
  delay(250);                             // Wait another 0.25 second.


//                                                                          READ THE INPUTS
//                                                                          ===============
  N = analogRead(1);                      // Get threshold setting.
  Threshold  = (N/4 + 10);                // Set the adjustment range.
  N = analogRead(2);                      // Get runtime adjustment value.
  RunTime = 8000 + (1000 * (N/170));      // Set time range to 8000 - 14000 milliseconds.
  LightLevel = analogRead(3);             // Get ambient light level.
     
  //                                                                        MEASURE THE LIGHT
  //                                                                        =================
  OldLightMode = LightMode;               // Note the existing mode.
  LightMode = Transition;                 // Start at the middle light range.                
  if (LightLevel > (Threshold + 25)) {    // If bright, reset to that.
    LightMode = Bright;
    digitalWrite(5, HIGH);                // Light the green LED.
    digitalWrite(6, LOW);                 // Extinguish the red LED.
    }
    
  if (LightLevel < Threshold) {           // If dark, reset to that.
    LightMode = Dark;
    digitalWrite(6, HIGH);                // light the red LED.
    digitalWrite(5, LOW);                 // Extinguish the green LED.
    }
//                                                                        "SATISFIED" DETERMINATION:
//                                                                      DOES DRAPE MATCH LIGHT LEVEL?
//                                                                      =============================                      
  Satisfied = HIGH;                       // Set true to start with.
  if (LightMode == Bright) {              // Is action needed?
    if (CurrentPosition == Closed){       // Is it closed and bright?
      Satisfied = LOW;                    // Action is needed.
        }}
  if (LightMode == Dark)  {
    if (CurrentPosition == Opened){       // Is it opened and dark?
      Satisfied = LOW;                    // Action is needed.
        }}

  if (Satisfied == HIGH) {                // If no action needed, stop the timer.
     Timer = 0;
     TimerRun = LOW;
     }
//                                                                              PROCESS CHANGE OF LIGHT MODE
//                                                                              ============================
  if (LightMode != OldLightMode) {        // Has the mode changed?
    if (Satisfied == LOW){
      Timer = 0;                          // Zero the counter.
      TimerRun = HIGH;                    // Start the 5 minute timer.
     }
    }
  if (LightMode == Transition) {          // If middle range, kill the LEDs.
    digitalWrite(5, LOW);                 // Extinguish the green LED.
    digitalWrite(6, LOW);                 // Extinguish the red LED.
    TimerRun = LOW;                       // Stop the timer.
    }  

 //                                                                                       MANUAL CLOSE     
 //                                                                                       ============
  N = digitalRead(3);                     // Is the switch down (close request)?
    if (N == HIGH) {                      // If so,
       if (CurrentPosition == Opened) {   //    are the drapes open?
            Timer = 0;                    // Reset the timer,
            TimerRun = HIGH;              //    and start it.
            digitalWrite(9, HIGH);        // If so, close the drapes.
            delay(RunTime);               // Run for about 11 seconds.
            digitalWrite(9, LOW);         // Stop the motor.
            CurrentPosition = Closed;     // Update the position memory.
            EEPROM.write(1000, Closed);   // Save in EEPROM in case of restart. 
            HoldStart = millis();         // Set the hold start time to hold 2 hours,
            digitalWrite(11, HIGH);       //    and light the white LED.
               
  and more...

I haven't tried loading because of the errors. If I have a bad load, the controller will be unusable, and that's what controls my drapes.

I always felt that I was safe by having the sketch in case anything happened to the controller, but since I can't use what I wrote now, I'm uncomfortable.

The rest of it follows.

    if (abs((millis() - HoldStart)) > 7200000) { // If drape has held closed 2 hours,
      HoldStart = 0;                      //    shut off the hold,
    }  
      
    if (HoldStart != 0) {                 // If in the 2 hour closed hold. 
      digitalWrite(11, HIGH);             // Light the white LED.
    }  
  
    if (HoldStart == 0)  {                // If not in the hold time,   
      digitalWrite(11, LOW);              //   shut off the white LED,      
      if (Timer > 600)  {                 //   if over five minutes, do the move. (600 half seconds)                                    //   and continue to automatic moves. 
  
  //                                                                                  AUTOMATIC CLOSE   
  //                                                                                  =============== 
        TimerRun = LOW;                   // Stop the timer,
        Timer = 0;                        //    and reset it.
        digitalWrite(11, LOW);            // White LED off.
          if (Satisfied == LOW)  {        // Drape needs to move.
            if (LightMode == Dark) {      // If darkness was sensed over 5 minutes.
              digitalWrite(9, HIGH);      // Close the drapes.
              delay(RunTime);             // Run for about 11 seconds.
              digitalWrite(9, LOW);       // Stop the motor.
              CurrentPosition = Closed;   // Update the position variable.
              EEPROM.write(1000, Closed); // Save in EEPROM in case of restart.   
              Satisfied = HIGH;           // Now drape position is correct.
            }
          }
    //                                                                                 AUTOMATIC OPEN                   
    //                                                                                 ==============   
        if (Satisfied == LOW) {           // Drape needs to move.   
          if (LightMode == Bright) {      // If brightness was sensed over 5 minutes.
            Timer = 0;                    // Reset the timer,
            TimerRun = LOW;               //    and stop it.
            digitalWrite(8, HIGH);        // Open the drapes.
            delay(RunTime);               // Run for about 11 seconds.
            CurrentPosition = Opened;     // Update the position variable.
            EEPROM.write(1000, Opened);   // Save in EEPROM in case of restart.   
          }
        }
      }
       
}}

DavidSPowell:
As for warnings? Should I ignore them?

Yes, the warnings are emitted because there are redundant 'const' applied to the functions. The warnings are telling you the extra 'const' are ignored.

DavidSPowell:
I tried including the sketch, but I get the error here that it's over 9000 characters. I'll put the start of it here:

For future reference, you can add such files as attachments.

Many thanks!

Now I can get back to work on it.

Dave