You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
13 years ago
|
#!/usr/bin/env python
|
||
|
|
||
6 years ago
|
from __future__ import print_function
|
||
|
from __future__ import division
|
||
|
|
||
13 years ago
|
""" 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
|
||
|
|
||
6 years ago
|
print("#ifndef SPEED_LOOKUPTABLE_H")
|
||
|
print("#define SPEED_LOOKUPTABLE_H")
|
||
|
print()
|
||
5 years ago
|
print('#include "MarlinCore.h"')
|
||
6 years ago
|
print()
|
||
13 years ago
|
|
||
6 years ago
|
print("const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {")
|
||
13 years ago
|
a = [ timer_freq / ((i*256)+(args.cpu_freq*2)) for i in range(256) ]
|
||
13 years ago
|
b = [ a[i] - a[i+1] for i in range(255) ]
|
||
|
b.append(b[-1])
|
||
|
for i in range(32):
|
||
6 years ago
|
print(" ", end=' ')
|
||
13 years ago
|
for j in range(8):
|
||
6 years ago
|
print("{%d, %d}," % (a[8*i+j], b[8*i+j]), end=' ')
|
||
|
print()
|
||
|
print("};")
|
||
|
print()
|
||
13 years ago
|
|
||
6 years ago
|
print("const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {")
|
||
13 years ago
|
a = [ timer_freq / ((i*8)+(args.cpu_freq*2)) for i in range(256) ]
|
||
13 years ago
|
b = [ a[i] - a[i+1] for i in range(255) ]
|
||
|
b.append(b[-1])
|
||
|
for i in range(32):
|
||
6 years ago
|
print(" ", end=' ')
|
||
13 years ago
|
for j in range(8):
|
||
6 years ago
|
print("{%d, %d}," % (a[8*i+j], b[8*i+j]), end=' ')
|
||
|
print()
|
||
|
print("};")
|
||
|
print()
|
||
13 years ago
|
|
||
6 years ago
|
print("#endif")
|
||
13 years ago
|
|