|
@@ -49,6 +49,7 @@ static btn_t Button[BTN_NUM] = {
|
|
|
static volatile uint8_t DISP_WDT = 0;
|
|
|
static EEMEM uint8_t EEP_Bright;
|
|
|
static uint8_t Bright;
|
|
|
+static EEMEM uint8_t EEP_SunTime;
|
|
|
|
|
|
/* Constants */
|
|
|
/* Function prototypes */
|
|
@@ -58,6 +59,7 @@ static void btnProcess(void);
|
|
|
static void valIncrease(uint8_t * val, uint8_t max);
|
|
|
static void valDecrease(uint8_t * val, uint8_t max);
|
|
|
static void blink(void);
|
|
|
+static void setSunWinterTime(void);
|
|
|
|
|
|
void main(void) {
|
|
|
/**
|
|
@@ -72,6 +74,7 @@ void main(void) {
|
|
|
Flag.blink3 = 0;
|
|
|
Flag.blinkC = 0;
|
|
|
Flag.saveEEP = 0;
|
|
|
+
|
|
|
Bright = eeprom_read_byte(&EEP_Bright);
|
|
|
|
|
|
/**
|
|
@@ -102,6 +105,7 @@ void main(void) {
|
|
|
|
|
|
RTC_ReadTime(&RTC);
|
|
|
if (RTC.Sec == 0 && RTC.Min == 0) {
|
|
|
+ // begin of new hour
|
|
|
if (RTC.Hr == 0) {
|
|
|
RTC_ReadCalendar(&RTC);
|
|
|
ES_PlaceEvent(evRefreshCal);
|
|
@@ -111,7 +115,9 @@ void main(void) {
|
|
|
} else {
|
|
|
OCR2 = Bright;
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+ setSunWinterTime();
|
|
|
+ } // begin new hour
|
|
|
|
|
|
if (DISP_WDT != 0) {
|
|
|
DISP_WDT --;
|
|
@@ -176,6 +182,33 @@ static void Board_Init(void) {
|
|
|
sei();
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Correct current time for Sun or Winter
|
|
|
+ */
|
|
|
+static void setSunWinterTime(void) {
|
|
|
+ uint8_t sunTime = eeprom_read_byte(&EEP_SunTime);
|
|
|
+
|
|
|
+ /* Переход на летнее время */
|
|
|
+ if ((RTC.Mon == 3) && (RTC.WD == 7) && (RTC.Hr == 3) && (sunTime != 0)) {
|
|
|
+ if ((RTC.Day + 7) > 31) {
|
|
|
+ RTC.Hr = 4;
|
|
|
+ RTC_WriteHHMM(&RTC);
|
|
|
+ sunTime = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Переход на зимнее время */
|
|
|
+ if ((RTC.Mon == 10) && (RTC.WD == 7) && (RTC.Hr == 4) && (sunTime == 0)) {
|
|
|
+ if ((RTC.Day + 7) > 31) {
|
|
|
+ RTC.Hr = 3;
|
|
|
+ RTC_WriteHHMM(&RTC);
|
|
|
+ sunTime = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ eeprom_update_byte(&EEP_SunTime, sunTime);
|
|
|
+}
|
|
|
+
|
|
|
static void dotOn(void) {
|
|
|
PORTD |= DOT_PIN;
|
|
|
}
|