#encoding:utf8
#电池厂提供excel电池曲线zcv到mtk电池曲线zcv转换
import pandas as pd
import openpyxl
import math
# 读取Excel文件
df = pd.read_excel("a55-zcv.xlsx")
for j in range(0,10):
if(j<3):
offset=0 #T0~T2
if(j==3):
offset=7 #T3
if(j==3):
offset=14 #T4~T9
print("/* T%s */"%(j))
print("struct fuelgauge_profile_struct fg_profile_t%s[TOTAL_BATTERY_NUMBER][100] = {"%(j))
for k in range(0,4):
print(r'{')
for i in range(0,100):
if(i>95):
i=95
mAh = df.iloc[i,3+offset]*10
mcV = df.iloc[i, 2+offset]*10
moM = int(df.iloc[i, 4+offset]*10000)
if(math.isnan(mcV)):
mcV=df.iloc[1, 2+offset]*10+8
if(math.isnan(mAh)):
mAh=0
if(math.isnan(moM)):
moM=0
print("{%s,%s,%s},"%(mAh,mcV,moM))
print(r'},')
print(r'};')
============================================================================
#dtsi
#encoding:utf8
#电池厂提供excel电池曲线zcv到mtk电池曲线zcv转换
import pandas as pd
import openpyxl
import math
# 读取Excel文件
df = pd.read_excel("a55-zcv.xlsx")
for j in range(0,6):
if(j<3):
offset=0 #T0~T2
if(j==3):
offset=7 #T3
if(j>3):
offset=14 #T4~T9
print("battery0_profile_t%s_num = <100>;"%(j))
print("battery0_profile_t%s_col = <3>;"%(j))
print("battery0_profile_t%s ="%(j))
print("<")
for k in range(0,1):
for i in range(0,100):
if(i>95):
i=95
mAh = df.iloc[i,3+offset]*10
mcV = df.iloc[i, 1+offset]*10
moM = int(df.iloc[i, 4+offset]*10000)
if(math.isnan(mcV)):
mcV=df.iloc[1, 1+offset]*10+8
if(math.isnan(mAh)):
mAh=0
if(math.isnan(moM)):
moM=0
print("%s %s %s "%(mAh,mcV,moM))
print(">;")
print(" ")