diff options
author | jaseg <git@jaseg.net> | 2018-05-20 15:54:03 +0200 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2018-05-20 15:54:03 +0200 |
commit | cba83e780a9350eb45eb1c2f09fc87f5d389e1ac (patch) | |
tree | 89232388812444e2f95242e2b49d68d0de510f1c /doc/calc_framerate.py | |
parent | f4d511afdb126de676914a74bf5143d913f62a4f (diff) | |
download | olsndot-cba83e780a9350eb45eb1c2f09fc87f5d389e1ac.tar.gz olsndot-cba83e780a9350eb45eb1c2f09fc87f5d389e1ac.tar.bz2 olsndot-cba83e780a9350eb45eb1c2f09fc87f5d389e1ac.zip |
Move documentation and simulation stuff to its own subdir
Diffstat (limited to 'doc/calc_framerate.py')
-rw-r--r-- | doc/calc_framerate.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/doc/calc_framerate.py b/doc/calc_framerate.py new file mode 100644 index 0000000..aaedc4d --- /dev/null +++ b/doc/calc_framerate.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +TIMER_FREQ = 30e6 # MHz + + +with open('main.c') as f: + lines = f.readlines() + +defs = {} +for line in lines: + if line.startswith('#define'): + _pragma, name, val, *_comment = line.split() + val = defs.get(val, val) + defs[name] = val + +print('Bit cycle timings:') +timings_total = 0 +in_array = False +for line in lines: + if not in_array: + if line.startswith('static uint16_t timer_period_lookup'): + in_array = True + else: + if '}' in line: + break + if ',' not in line: + continue + val, *_comment = line.split(',') + for name, defval in defs.items(): + val = val.replace(name, defval) + duration = eval(val) + print(duration) + timings_total += duration + int(defs['RESET_PERIOD_LENGTH']) + +total_len = timings_total/TIMER_FREQ +print('Total cycles:', timings_total) +print('Total cycle length: {:.3f}ms'.format(total_len*1e3)) +print('Frame rate: {:.3f}Hz'.format(1/total_len)) |