Browse Source

update script/libs/pcf8563t.lua.
最近测试PCF8563T芯片的时候使用本库时发现默认例程在走时几秒后就出现输出不正确的情况,如开始时间[2023-11-04 16:02:27.206] I/user.time 2023 11 2 13 14 15 week=2,走时5秒后输出[2023-11-04 16:02:32.211] I/user.time 2023 31 2 13 14 20 week=2,后面的走时更加错误,如[2023-11-04 16:02:52.293] I/user.time 2023 51 42 53 14 40 week=42。经查发现是pcf8563t.read()里在处理数据与时与到了不需要位,导致bcd_to_hex(data)时出现错误。按datasheet修改7个字节中每字节需要保留的位数,暂时测试正常。

Signed-off-by: 会溺水的鱼 <believeran@gmail.com>

会溺水的鱼 2 years ago
parent
commit
0f39264610
1 changed files with 7 additions and 7 deletions
  1. 7 7
      script/libs/pcf8563t.lua

+ 7 - 7
script/libs/pcf8563t.lua

@@ -93,13 +93,13 @@ function pcf8563t.read()
     if not data or #data ~= 7 then
         return time_data
     end
-    time_data.year  = bcd_to_hex(data:byte(7)) + baseyear
-    time_data.mon   = bcd_to_hex(bit.band(data:byte(6),0x7f))
-    time_data.wday  = bcd_to_hex(data:byte(5)) + 1
-    time_data.day   = bcd_to_hex(data:byte(4))
-    time_data.hour  = bcd_to_hex(data:byte(3))
-    time_data.min   = bcd_to_hex(data:byte(2))
-    time_data.sec   = bcd_to_hex(data:byte(1) & 0x7F)
+    time_data.year = bcd_to_hex(data:byte(7)) + baseyear
+    time_data.mon = bcd_to_hex(data:byte(6) & 0x9F)
+    time_data.wday = bcd_to_hex(data:byte(5) & 0x07) + 1
+    time_data.day = bcd_to_hex(data:byte(4) & 0x3F)
+    time_data.hour = bcd_to_hex(data:byte(3) & 0x3F)
+    time_data.min = bcd_to_hex(data:byte(2) & 0x7F)
+    time_data.sec = bcd_to_hex(data:byte(1) & 0x7F)
 	return time_data
 end