Library used during 1 day workshops presented by Skool and ARM Hungary in 2015.
Fork of Skool_wkshp_lib2015 by
Diff: rtc.cpp
- Revision:
- 1:68d1a8c4970b
- Parent:
- 0:3ad0af8abf43
--- a/rtc.cpp Fri Sep 25 13:48:39 2015 +0000 +++ b/rtc.cpp Thu Oct 01 19:17:25 2015 +0000 @@ -17,7 +17,7 @@ extern FSM_State Main_FSM_States; const char BCD2HEX[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; -const char DOW[7][3] = { {'H',' ',' '}, {'K',' ',' '}, {'S','z','e'}, {'C','s',' '}, {'P',' ',' '}, {'S','z','o'}, {'V',' ',' '} }; +const char DOW[8][3] = { {' ',' ',' '}, {'H',' ',' '}, {'K',' ',' '}, {'S','z','e'}, {'C','s',' '}, {'P',' ',' '}, {'S','z','o'}, {'V',' ',' '} }; const char Yes_No[16] = {'*',':','O','K',' ',' ',' ',' ',' ','#',':','M',0x82,'g','s','e'};//"*:OK #:Mégse"}; void RTC_AlarmAEventCallback(void) { @@ -61,9 +61,9 @@ tt[6] = BCD2HEX[((rtc_alarm.AlarmTime.Seconds & 0xF0) >> 4)]; tt[7] = BCD2HEX[(rtc_alarm.AlarmTime.Seconds & 0x0F)]; tt[8] = ' '; - tt[9] = DOW[rtc_alarm.AlarmDateWeekDay - 1][0]; - tt[10] = DOW[rtc_alarm.AlarmDateWeekDay - 1][1]; - tt[11] = DOW[rtc_alarm.AlarmDateWeekDay - 1][2]; + tt[9] = DOW[rtc_alarm.AlarmDateWeekDay][0]; + tt[10] = DOW[rtc_alarm.AlarmDateWeekDay][1]; + tt[11] = DOW[rtc_alarm.AlarmDateWeekDay][2]; write_ser_text(tt, 12); write_ser_lcd(0xC0, false); wait_us(30); @@ -109,9 +109,9 @@ tt[10] = '.'; tmp_date = rtc_date.Date; tt[11] = ' '; - tt[12] = DOW[rtc_date.WeekDay - 1][0]; - tt[13] = DOW[rtc_date.WeekDay - 1][1]; - tt[14] = DOW[rtc_date.WeekDay - 1][2]; + tt[12] = DOW[rtc_date.WeekDay][0]; + tt[13] = DOW[rtc_date.WeekDay][1]; + tt[14] = DOW[rtc_date.WeekDay][2]; write_ser_text(tt,15); } @@ -152,9 +152,9 @@ tt[6] = BCD2HEX[((rtc_alarm.AlarmTime.Seconds & 0xF0) >> 4)]; tt[7] = BCD2HEX[(rtc_alarm.AlarmTime.Seconds & 0x0F)]; tt[8] = ' '; - tt[9] = DOW[rtc_date.WeekDay - 1][0]; - tt[10] = DOW[rtc_date.WeekDay - 1][1]; - tt[11] = DOW[rtc_date.WeekDay - 1][2]; + tt[9] = DOW[rtc_date.WeekDay][0]; + tt[10] = DOW[rtc_date.WeekDay][1]; + tt[11] = DOW[rtc_date.WeekDay][2]; write_ser_text(tt, 8); write_ser_lcd(0x80, false); // set DDRAM addr to 0x00, beginning of 1st line } @@ -179,9 +179,9 @@ tt[9] = BCD2HEX[(rtc_date.Date & 0x0F)]; tt[10] = '.'; tt[11] = ' '; - tt[12] = DOW[rtc_date.WeekDay - 1][0]; - tt[13] = DOW[rtc_date.WeekDay - 1][1]; - tt[14] = DOW[rtc_date.WeekDay - 1][2]; + tt[12] = DOW[rtc_date.WeekDay][0]; + tt[13] = DOW[rtc_date.WeekDay][1]; + tt[14] = DOW[rtc_date.WeekDay][2]; write_ser_text(tt,15); write_ser_lcd(0x82, false); // set DDRAM addr to 0x00, beginning of 1st line } @@ -237,7 +237,7 @@ int keypress; HAL_RTC_GetAlarm(&rtch, &rtc_alarm, RTC_ALARM_A, FORMAT_BCD); - if (rtc_alarm.AlarmDateWeekDay == 0) { rtc_alarm.AlarmDateWeekDay = 1;} // There was no alarm set yet + //if (rtc_alarm.AlarmDateWeekDay == 0) { rtc_alarm.AlarmDateWeekDay = 1;} // There was no alarm set yet ShowAlarm(); keypress = Poll_keypad_yesno(); if (keypress == 0x0C) { @@ -347,7 +347,11 @@ rtc_alarm.AlarmTime.Minutes = ((TT[3] - 0x30) << 4) + (TT[4] - 0x30); rtc_alarm.AlarmTime.Seconds = ((TT[6] - 0x30) << 4) + (TT[7] - 0x30); rtc_alarm.AlarmDateWeekDay = DoW; - rtc_alarm.AlarmMask = RTC_ALARMMASK_NONE; // Alarm is triggered when everything match + if (DoW == 0x00) { + rtc_alarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY; // Alarm is triggered every day, no date or weekday match + } else { + rtc_alarm.AlarmMask = RTC_ALARMMASK_NONE; // Alarm is triggered when everything match + } HAL_RTC_DeactivateAlarm(&rtch, RTC_ALARM_A); HAL_RTC_SetAlarm_IT(&rtch, &rtc_alarm, FORMAT_BCD); NVIC_SetVector(RTC_Alarm_IRQn, (uint32_t)RTC_AlarmIRQHandler); @@ -397,7 +401,7 @@ } write_ser_lcd(0x80, false); wait_us(30); - write_ser_text(TT,8); + write_ser_text(TT,15); write_ser_lcd(0x80 + index, false); } rtc_date.Year = ((TT[2] - 0x30) << 4) + (TT[3] - 0x30);