Skip to content

Commit 4249244

Browse files
committed
Time variables fixed
1 parent b59fb4b commit 4249244

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

src/include/System.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void System::rtcSetTime(uint8_t rtcHour, uint8_t rtcMinute, uint8_t rtcSecond)
224224
*/
225225
void System::rtcSetDate(uint8_t rtcWeekday, uint8_t rtcDay, uint8_t rtcMonth, uint16_t yr)
226226
{
227-
rtc_time.rtcYear = yr - 1970; // convert to RTC rtcYear format 0-99
227+
rtcYear = yr - 1970; // convert to RTC rtcYear format 0-99
228228

229229
Wire.beginTransmission(I2C_ADDR);
230230
Wire.write(RTC_RAM_by);
@@ -236,7 +236,7 @@ void System::rtcSetDate(uint8_t rtcWeekday, uint8_t rtcDay, uint8_t rtcMonth, ui
236236
Wire.write(rtcDecToBcd(rtcDay));
237237
Wire.write(rtcDecToBcd(rtcWeekday));
238238
Wire.write(rtcDecToBcd(rtcMonth));
239-
Wire.write(rtcDecToBcd(rtc_time.rtcYear));
239+
Wire.write(rtcDecToBcd(rtcYear));
240240
Wire.endTransmission();
241241
}
242242

@@ -303,13 +303,13 @@ void System::rtcGetRtcData()
303303

304304
while (Wire.available())
305305
{
306-
rtc_time.rtcSecond = rtcBcdToDec(Wire.read() & 0x7F); // ignore bit 7
307-
rtc_time.rtcMinute = rtcBcdToDec(Wire.read() & 0x7F);
308-
rtc_time.rtcHour = rtcBcdToDec(Wire.read() & 0x3F); // ignore bits 7 & 6
309-
rtc_time.rtcDay = rtcBcdToDec(Wire.read() & 0x3F);
310-
rtc_time.rtcWeekday = rtcBcdToDec(Wire.read() & 0x07); // ignore bits 7,6,5,4 & 3
311-
rtc_time.rtcMonth = rtcBcdToDec(Wire.read() & 0x1F); // ignore bits 7,6 & 5
312-
rtc_time.rtcYear = rtcBcdToDec(Wire.read()) + 1970;
306+
rtcSecond = rtcBcdToDec(Wire.read() & 0x7F); // ignore bit 7
307+
rtcMinute = rtcBcdToDec(Wire.read() & 0x7F);
308+
rtcHour = rtcBcdToDec(Wire.read() & 0x3F); // ignore bits 7 & 6
309+
rtcDay = rtcBcdToDec(Wire.read() & 0x3F);
310+
rtcWeekday = rtcBcdToDec(Wire.read() & 0x07); // ignore bits 7,6,5,4 & 3
311+
rtcMonth = rtcBcdToDec(Wire.read() & 0x1F); // ignore bits 7,6 & 5
312+
rtcYear = rtcBcdToDec(Wire.read()) + 1970;
313313
}
314314
}
315315

@@ -320,7 +320,7 @@ void System::rtcGetRtcData()
320320
*/
321321
uint8_t System::rtcGetSecond()
322322
{
323-
return rtc_time.rtcSecond;
323+
return rtcSecond;
324324
}
325325

326326
/**
@@ -330,7 +330,7 @@ uint8_t System::rtcGetSecond()
330330
*/
331331
uint8_t System::rtcGetMinute()
332332
{
333-
return rtc_time.rtcMinute;
333+
return rtcMinute;
334334
}
335335

336336
/**
@@ -340,7 +340,7 @@ uint8_t System::rtcGetMinute()
340340
*/
341341
uint8_t System::rtcGetHour()
342342
{
343-
return rtc_time.rtcHour;
343+
return rtcHour;
344344
}
345345

346346
/**
@@ -350,7 +350,7 @@ uint8_t System::rtcGetHour()
350350
*/
351351
uint8_t System::rtcGetDay()
352352
{
353-
return rtc_time.rtcDay;
353+
return rtcDay;
354354
}
355355

356356
/**
@@ -360,7 +360,7 @@ uint8_t System::rtcGetDay()
360360
*/
361361
uint8_t System::rtcGetWeekday()
362362
{
363-
return rtc_time.rtcWeekday;
363+
return rtcWeekday;
364364
}
365365

366366
/**
@@ -370,7 +370,7 @@ uint8_t System::rtcGetWeekday()
370370
*/
371371
uint8_t System::rtcGetMonth()
372372
{
373-
return rtc_time.rtcMonth;
373+
return rtcMonth;
374374
}
375375

376376
/**
@@ -380,7 +380,7 @@ uint8_t System::rtcGetMonth()
380380
*/
381381
uint16_t System::rtcGetYear()
382382
{
383-
return rtc_time.rtcYear;
383+
return rtcYear;
384384
}
385385

386386
/**

src/include/System.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,16 @@ class System : public Esp,
173173
uint8_t rtcControl2;
174174
uint8_t _panelOn = 0;
175175
int16_t _sdCardOk = 0;
176-
/* time variables structure */
177-
struct date_time
178-
{
179-
uint8_t rtcHour;
180-
uint8_t rtcMinute;
181-
uint8_t rtcSecond;
182-
uint8_t rtcDay;
183-
uint8_t rtcWeekday;
184-
uint8_t rtcMonth;
185-
uint16_t rtcYear;
186-
} rtc_time;
176+
/* time variables*/
177+
178+
uint8_t rtcHour;
179+
uint8_t rtcMinute;
180+
uint8_t rtcSecond;
181+
uint8_t rtcDay;
182+
uint8_t rtcWeekday;
183+
uint8_t rtcMonth;
184+
uint16_t rtcYear;
185+
187186
};
188187

189188
#endif

0 commit comments

Comments
 (0)