scripts: Update ntc-thermistor table generator

Update the script to work with the current version of the
ntc-thermistor driver.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
This commit is contained in:
Paweł Anikiel 2023-08-04 10:36:35 +00:00 committed by Maureen Helm
commit 4b33f4fe19

View file

@ -7,8 +7,8 @@
Zephyr's NTC Thermistor DTS Table generator Zephyr's NTC Thermistor DTS Table generator
########################################### ###########################################
This script can be used to generate a "zephyr,ntc-thermistor-rt-table" compatible This script can be used to generate an NTC thermistor DTS node with a
Device Tree node for NTC thermistors. This uses the Beta Parameter Equation "zephyr,compensation-table" property. This uses the Beta Parameter Equation
https://devxplained.eu/en/blog/temperature-measurement-with-ntcs#beta-parameter-equation https://devxplained.eu/en/blog/temperature-measurement-with-ntcs#beta-parameter-equation
@ -47,22 +47,17 @@ def main(
temps_range = range(temp_init, temp_final + interval - 1, interval) temps_range = range(temp_init, temp_final + interval - 1, interval)
print(f"/* NTC Thermistor Table Generated with {os.path.basename(__file__)} */\n") print(f"/* NTC Thermistor Table Generated with {os.path.basename(__file__)} */\n")
print(f"/ {{")
print( print(
f"\tthermistor_R25_{int(r25)}_B_{int(beta)}: thermistor-R25-{int(r25)}-B-{int(beta)} {{" f"thermistor_R25_{int(r25)}_B_{int(beta)}: thermistor-R25-{int(r25)}-B-{int(beta)} {{"
) )
print(f'\t\tstatus = "disabled";')
print(f'\t\tcompatible = "zephyr,ntc-thermistor-rt-table";\n')
table = [] table = []
for temp in temps_range: for temp in temps_range:
resistance = beta_equation_calc_resistance(r25, beta, temp) resistance = beta_equation_calc_resistance(r25, beta, temp)
table.append(f"<({int(temp)}) {int(resistance)}>") table.append(f"<({int(temp)}) {int(resistance)}>")
tbl_string = ',\n\t\t\t'.join(table) tbl_string = ',\n\t\t'.join(table)
print(f"\t\t/* TR Table Format <temp resistance> */") print(f"\tzephyr,compensation-table = {tbl_string};")
print(f"\t\ttr-table = {tbl_string};")
print(f"\t}};")
print(f"}};") print(f"}};")