Skip to content

Commit

Permalink
conditional eeprom support
Browse files Browse the repository at this point in the history
When using the Arduino IDE to compile for some of the newer boards,
such as those based on the ESP8266, the library won’t compile as the
IDE knows EEPROM isn’t supported. My change adds conditional compiles
that take out the EEPROM-dependent code.
  • Loading branch information
roadfun authored and roadfun committed Mar 28, 2016
1 parent a0cdfb3 commit acfb4af
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Timezone.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
* San Francisco, California, 94105, USA. *
*----------------------------------------------------------------------*/

#include <avr/eeprom.h>
#include "Timezone.h"

#ifdef __AVR__
#include <avr/eeprom.h>
#endif

/*----------------------------------------------------------------------*
* Create a Timezone object from the given time change rules. *
*----------------------------------------------------------------------*/
Expand All @@ -21,6 +24,7 @@ Timezone::Timezone(TimeChangeRule dstStart, TimeChangeRule stdStart)
_std = stdStart;
}

#ifdef __AVR__
/*----------------------------------------------------------------------*
* Create a Timezone object from time change rules stored in EEPROM *
* at the given address. *
Expand All @@ -29,6 +33,7 @@ Timezone::Timezone(int address)
{
readRules(address);
}
#endif

/*----------------------------------------------------------------------*
* Convert the given UTC time to local time, standard or *
Expand Down Expand Up @@ -176,6 +181,7 @@ time_t Timezone::toTime_t(TimeChangeRule r, int yr)
return t;
}

#ifdef __AVR__
/*----------------------------------------------------------------------*
* Read the daylight and standard time rules from EEPROM at *
* the given address. *
Expand All @@ -197,3 +203,5 @@ void Timezone::writeRules(int address)
address += sizeof(_dst);
eeprom_write_block((void *) &_std, (void *) address, sizeof(_std));
}

#endif

0 comments on commit acfb4af

Please sign in to comment.