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:
@@ -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 字节连续写入)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user