Browse Source

:sparkles: 添加模组电压和温度

Mizore 1 year ago
parent
commit
225dbe8c3a
1 changed files with 12 additions and 0 deletions
  1. 12 0
      script/util_notify.lua

+ 12 - 0
script/util_notify.lua

@@ -317,6 +317,18 @@ local function append()
     local band = util_mobile.getBand()
     if band >= 0 then msg = msg .. "\n频段: B" .. band end
 
+    -- 电压, 读取 VBAT 供电电压, 单位为 mV
+    adc.open(adc.CH_VBAT)
+    local vbat = adc.get(adc.CH_VBAT)
+    adc.close(adc.CH_VBAT)
+    if vbat >= 0 then msg = msg .. "\n电压: " .. string.format("%.1f", vbat / 1000) .. "V" end
+
+    -- 温度
+    adc.open(adc.CH_CPU)
+    local temp = adc.get(adc.CH_CPU)
+    adc.close(adc.CH_CPU)
+    if temp >= 0 then msg = msg .. "\n温度: " .. string.format("%.1f", temp / 1000) .. "°C" end
+
     -- 流量统计
     -- local uplinkGB, uplinkB, downlinkGB, downlinkB = mobile.dataTraffic()
     -- uplinkB = uplinkGB * 1024 * 1024 * 1024 + uplinkB