summaryrefslogtreecommitdiff
path: root/helper/convert-stm32.py
diff options
context:
space:
mode:
Diffstat (limited to 'helper/convert-stm32.py')
-rw-r--r--helper/convert-stm32.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/helper/convert-stm32.py b/helper/convert-stm32.py
new file mode 100644
index 0000000..73c4a2e
--- /dev/null
+++ b/helper/convert-stm32.py
@@ -0,0 +1,64 @@
+print('DEF STM32F429BIT6_1 IC 0 40 Y Y 4 F N')
+print('F1 "" 0 0 60 H V C CNN')
+print('F2 "" 0 0 60 H V C CNN')
+print('F3 "" 0 0 60 H V C CNN')
+print('DRAW')
+
+def print_rec(r):
+ for i in range(len(r)):
+ ri = r[i]
+ if i > 0: print(' ', end='')
+ print(ri, end='')
+
+ print("\n", end='')
+
+SKIP_REC_TYPES = ['#', 'F0', 'F1', 'F2', 'F3', 'DRAW', 'ENDDRAW', 'ENDDEF']
+
+with open('stm32.old', 'r') as f_rd:
+ f_rd_lines = f_rd.readlines()
+
+ for f_rd_line in f_rd_lines:
+ rd_line = f_rd_line.strip()
+
+ rec = rd_line.split(' ')
+ rec_type = rec[0]
+
+ #
+ # DEF
+ #
+ if rec_type == "DEF":
+ unit = rec[1].split('_')[1]
+ continue
+
+ #
+ # T
+ #
+ if rec_type == "T":
+ rec[6] = unit
+ print_rec(rec)
+ continue
+
+ #
+ # P
+ #
+ if rec_type == "P":
+ rec[2] = unit
+ print_rec(rec)
+ continue
+
+ #
+ # X
+ #
+ if rec_type == "X":
+ rec[-3] = unit
+ print_rec(rec)
+ continue
+
+ if rec_type in SKIP_REC_TYPES: continue
+ else: raise RuntimeError("rec_type == '%s'" % rec_type)
+
+ print(rd_line)
+
+
+print('ENDDRAW')
+print('ENDDEF')