|
12 | 12 | halc = hal.component("lathe") |
13 | 13 | haluic = hal.component("halui") |
14 | 14 | c = linuxcnc.command() |
| 15 | +reset_z = 0 |
| 16 | +reset_x = 0 |
15 | 17 |
|
16 | 18 | hal_pin_machine_is_on = haluic.newpin("machine.is-on", hal.HAL_BIT, hal.HAL_OUT) |
17 | 19 |
|
|
41 | 43 | hal_pin_velocity_z_cmd = halc.newpin("velocity_z_cmd", hal.HAL_FLOAT, hal.HAL_OUT) |
42 | 44 | hal_pin_velocity_x_cmd = halc.newpin("velocity_x_cmd", hal.HAL_FLOAT, hal.HAL_OUT) |
43 | 45 |
|
44 | | -hal_pin_reset_z = halc.newpin("reset_z", hal.HAL_BIT, hal.HAL_OUT) |
45 | | -hal_pin_reset_x = halc.newpin("reset_x", hal.HAL_BIT, hal.HAL_OUT) |
| 46 | +hal_pin_reset_z = halc.newpin("reset_z", hal.HAL_U32, hal.HAL_OUT) |
| 47 | +hal_pin_reset_x = halc.newpin("reset_x", hal.HAL_U32, hal.HAL_OUT) |
46 | 48 |
|
47 | 49 | app = Flask(__name__) |
48 | 50 | CORS(app, resources={r"/*": {"origins": "*"}}) |
@@ -498,6 +500,7 @@ def execute_threading(): |
498 | 500 | return {"status": "Error", "message": error_msg}, 500 |
499 | 501 |
|
500 | 502 |
|
| 503 | + |
501 | 504 | @app.put("/hal/cleanup") |
502 | 505 | def cleanup_canned_cycle_files(): |
503 | 506 | """Clean up temporary canned cycle .ngc files""" |
@@ -531,14 +534,23 @@ def cleanup_canned_cycle_files(): |
531 | 534 |
|
532 | 535 | @app.put("/hal/hal_out") |
533 | 536 | def write_hal_out(): |
| 537 | + global reset_z, reset_x |
534 | 538 | json = request.json |
535 | 539 |
|
536 | 540 | if "control_stop_now" in json: |
537 | 541 | hal_pin_velocity_z_cmd.set(0) |
538 | 542 | hal_pin_velocity_x_cmd.set(0) |
539 | 543 | hal_pin_control_z_type.set(0) |
540 | 544 | hal_pin_control_x_type.set(0) |
541 | | - |
| 545 | + |
| 546 | + if "reset_position" in json: |
| 547 | + print(f"reset_position {reset_z} {reset_x}") |
| 548 | + reset_z = reset_z + 1 |
| 549 | + hal_pin_reset_z.set(reset_z) |
| 550 | + reset_x = reset_x + 1 |
| 551 | + hal_pin_reset_x.set(reset_x) |
| 552 | + c.reset_interpreter() |
| 553 | + |
542 | 554 | hal_pin_offset_z_encoder.set(-hal_pin_position_a.get()) |
543 | 555 | hal_pin_offset_z_stepper.set(+hal_pin_position_z_encoder.get()) |
544 | 556 | hal_pin_offset_x_encoder.set(-hal_pin_position_a.get()) |
@@ -573,12 +585,18 @@ def write_hal_out(): |
573 | 585 |
|
574 | 586 | return {"status": "OK"} |
575 | 587 |
|
576 | | - |
577 | 588 | halc.ready() |
578 | 589 | haluic.ready() |
579 | 590 |
|
580 | | -hal_pin_reset_z.set(1) |
581 | | -hal_pin_reset_x.set(1) |
| 591 | +hal_pin_reset_z.set(reset_z) |
| 592 | +hal_pin_reset_x.set(reset_x) |
| 593 | + |
| 594 | +time.sleep(0.500) |
| 595 | + |
| 596 | +reset_z = reset_z + 1 |
| 597 | +hal_pin_reset_z.set(reset_z) |
| 598 | +reset_x = reset_x + 1 |
| 599 | +hal_pin_reset_x.set(reset_x) |
582 | 600 |
|
583 | 601 | print("{REST_API_READY}") |
584 | 602 |
|
|
0 commit comments