feat(ui): extend set_clock_app to edit day/month/year, not just time

time_edit_field now cycles through 5 fields (hour/min/day/month/year)
via long-press CONFIRM. Up/down adjusts whichever field is focused,
with day clamped to Days_In_Month() when month/year changes, and
Clock_RecalcWeekday() called after every date edit so the weekday
label stays in sync. UI_UpdateSetTimeDigit() now also refreshes the
weekday abbreviation when editing day/month/year, since the computed
weekday can change independently of which digit was actually touched.
Save writes the full date+weekday via PCF8563_WriteDateTime(). Also
removes PCF8563_ReadTime()/WriteTime(), now unused since every caller
was updated to the DateTime variants directly.
This commit is contained in:
edisondeng
2026-07-31 19:53:56 +08:00
parent 6baf93c550
commit 6022f0a409
5 changed files with 73 additions and 88 deletions

View File

@@ -310,45 +310,6 @@ bit PCF8563_ReadDateTime(u8 *hour, u8 *min, u8 *sec, u8 *day, u8 *month, u8 *yea
return 1;
}
/**
* @brief 从 PCF8563 读取当前时间 (兼容旧接口,只取时分秒,丢弃日期部分)
*/
bit PCF8563_ReadTime(u8 *hour, u8 *min, u8 *sec)
{
u8 day, month, year;
return PCF8563_ReadDateTime(hour, min, sec, &day, &month, &year);
}
/**
* @brief 将时间精准写入 PCF8563 RTC 芯片 (只写时分秒三个寄存器,不触碰日期寄存器)
*/
bit PCF8563_WriteTime(u8 hour, u8 min, u8 sec)
{
I2C_Start();
I2C_SendByte(PCF8563_ADDR_WRITE);
if (!I2C_WaitAck()) return 0;
// 定位写入起始寄存器 0x02
I2C_SendByte(REG_VL_SECONDS);
if (!I2C_WaitAck()) return 0;
// 写入秒
I2C_SendByte(DEC2BCD(sec & 0x7F));
if (!I2C_WaitAck()) return 0;
// 写入分
I2C_SendByte(DEC2BCD(min & 0x7F));
if (!I2C_WaitAck()) return 0;
// 写入时
I2C_SendByte(DEC2BCD(hour & 0x3F));
if (!I2C_WaitAck()) return 0;
I2C_Stop();
return 1;
}
/**
* @brief 将时间与日期一次性连续写入 PCF8563 RTC 芯片 (寄存器 0x02~0x08 共 7 字节连续写入)
*/

View File

@@ -24,24 +24,6 @@
*/
bit PCF8563_Init(void);
/**
* @brief 从 PCF8563 芯片读取当前时间 (时、分、秒)
* @param hour 小时指针 (0~23)
* @param min 分钟指针 (0~59)
* @param sec 秒钟指针 (0~59)
* @return bit 1: 读取成功, 0: 通讯失败
*/
bit PCF8563_ReadTime(u8 *hour, u8 *min, u8 *sec);
/**
* @brief 将指定的时间 (时、分、秒) 写入 PCF8563 芯片
* @param hour 小时 (0~23)
* @param min 分钟 (0~59)
* @param sec 秒钟 (0~59)
* @return bit 1: 写入成功, 0: 通讯失败
*/
bit PCF8563_WriteTime(u8 hour, u8 min, u8 sec);
/**
* @brief 从 PCF8563 芯片连续读取时间与日期 (时/分/秒/日/月/年)
* @param hour 小时指针 (0~23)