-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
generate_bulk_scans.py
57 lines (48 loc) · 1.71 KB
/
generate_bulk_scans.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from pprint import pprint
import klipper.gcode as g
from main import generate_pa_results_for_pattern, PRINT_START
from pa import *
from pa_result import PaResult
import pickle
def main():
patterns: list[PatternInfo] = []
for x in range(20, 286, 31):
for y in range(80, 190, 45):
patterns.append(
PatternInfo(
0, 0.06,
x, y,
10,
30, 4
))
# g.send_gcode(PRINT_START)
# g.send_gcode("M109 S255")
# g.send_gcode("CLEAN_NOZZLE")
# for pattern in patterns:
# g.send_gcode(generate_pa_tune_gcode(pattern, False))
# g.send_gcode("G90;")
# g.send_gcode(f"G1 X{FINISHED_X} Y{FINISHED_Y} F30000")
# g.wait_until_printer_at_location(FINISHED_X, FINISHED_Y)
# g.send_gcode("M104 S0; let the hotend cool")
pa_scans: list[PaResult] = []
for pattern in patterns:
pa_scans.extend(
zip(pattern.pa_values,
generate_pa_results_for_pattern(
pattern
))
)
with open("matte_white_ambient_light.pkl", "wb") as f:
pickle.dump(pa_scans, f)
# results = generate_pa_results_for_pattern(calibration_pattern)
# sorted_results = list(sorted(zip(results, calibration_pattern.pa_values), key=lambda x: x[0].score))
# sorted_results = list([(x.score, y) for x, y in sorted_results])
# best_pa_value = sorted_results[0][1]
# print()
# pprint(sorted_results)
# print()
# print(f"Recommended PA Value: {best_pa_value}, with a score of {sorted_results[0][0]}")
# print()
# g.send_gcode(f"SET_PRESSURE_ADVANCE ADVANCE={best_pa_value}")
if __name__=="__main__":
main()