diff options
author | Georgiy Bondarenko <69736697+nehilo@users.noreply.github.com> | 2021-03-04 20:54:23 +0300 |
---|---|---|
committer | Georgiy Bondarenko <69736697+nehilo@users.noreply.github.com> | 2021-03-04 20:54:23 +0300 |
commit | e8701195e66f2d27ffe17fb514eae8173795aaf7 (patch) | |
tree | 9f519c4abf6556b9ae7190a6210d87ead1dfadde /buildroot/share/scripts/createSpeedLookupTable.py | |
download | kp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.tar.xz kp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.zip |
Initial commit
Diffstat (limited to 'buildroot/share/scripts/createSpeedLookupTable.py')
-rw-r--r-- | buildroot/share/scripts/createSpeedLookupTable.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/buildroot/share/scripts/createSpeedLookupTable.py b/buildroot/share/scripts/createSpeedLookupTable.py new file mode 100644 index 0000000..da24c7c --- /dev/null +++ b/buildroot/share/scripts/createSpeedLookupTable.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +from __future__ import print_function +from __future__ import division + +""" Generate the stepper delay lookup table for Marlin firmware. """ + +import argparse + +__author__ = "Ben Gamari <bgamari@gmail.com>" +__copyright__ = "Copyright 2012, Ben Gamari" +__license__ = "GPL" + +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument('-f', '--cpu-freq', type=int, default=16, help='CPU clockrate in MHz (default=16)') +parser.add_argument('-d', '--divider', type=int, default=8, help='Timer/counter pre-scale divider (default=8)') +args = parser.parse_args() + +cpu_freq = args.cpu_freq * 1000000 +timer_freq = cpu_freq / args.divider + +print("#ifndef SPEED_LOOKUPTABLE_H") +print("#define SPEED_LOOKUPTABLE_H") +print() +print('#include "MarlinCore.h"') +print() + +print("const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {") +a = [ timer_freq / ((i*256)+(args.cpu_freq*2)) for i in range(256) ] +b = [ a[i] - a[i+1] for i in range(255) ] +b.append(b[-1]) +for i in range(32): + print(" ", end=' ') + for j in range(8): + print("{%d, %d}," % (a[8*i+j], b[8*i+j]), end=' ') + print() +print("};") +print() + +print("const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {") +a = [ timer_freq / ((i*8)+(args.cpu_freq*2)) for i in range(256) ] +b = [ a[i] - a[i+1] for i in range(255) ] +b.append(b[-1]) +for i in range(32): + print(" ", end=' ') + for j in range(8): + print("{%d, %d}," % (a[8*i+j], b[8*i+j]), end=' ') + print() +print("};") +print() + +print("#endif") + |