Update app.py
Browse files
app.py
CHANGED
|
@@ -411,6 +411,21 @@ with demo:
|
|
| 411 |
fn=lambda: gr.update(interactive=True), outputs=capture_btn
|
| 412 |
)
|
| 413 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
send_params_btn.click(
|
| 415 |
fn=api_send_print_parameters,
|
| 416 |
inputs=[nozzle_temp, bed_temp, print_speed, fan_speed],
|
|
@@ -549,20 +564,6 @@ with demo:
|
|
| 549 |
logger.error(f"Error in lambda: {e}")
|
| 550 |
return {"error": str(e)}
|
| 551 |
|
| 552 |
-
def api_send_print_parameters(
|
| 553 |
-
nozzle_temp=200, bed_temp=60, print_speed=60, fan_speed=100
|
| 554 |
-
):
|
| 555 |
-
"""API endpoint to send print parameters to the Bambu printer via RPI MQTT"""
|
| 556 |
-
global is_first_load
|
| 557 |
-
|
| 558 |
-
# if the application just started, skip the actual operation
|
| 559 |
-
if is_first_load:
|
| 560 |
-
logger.info("First load detected, skipping automatic parameter sending")
|
| 561 |
-
is_first_load = False
|
| 562 |
-
return "Ready to send parameters. Click 'Submit' to send."
|
| 563 |
-
|
| 564 |
-
# the original function, only execute when the user explicitly requests it
|
| 565 |
-
return send_print_parameters(nozzle_temp, bed_temp, print_speed, fan_speed)
|
| 566 |
|
| 567 |
api_json_output = gr.JSON()
|
| 568 |
api_text_output = gr.Textbox()
|
|
|
|
| 411 |
fn=lambda: gr.update(interactive=True), outputs=capture_btn
|
| 412 |
)
|
| 413 |
|
| 414 |
+
def api_send_print_parameters(
|
| 415 |
+
nozzle_temp=200, bed_temp=60, print_speed=60, fan_speed=100
|
| 416 |
+
):
|
| 417 |
+
"""API endpoint to send print parameters to the Bambu printer via RPI MQTT"""
|
| 418 |
+
global is_first_load
|
| 419 |
+
|
| 420 |
+
# if the application just started, skip the actual operation
|
| 421 |
+
if is_first_load:
|
| 422 |
+
logger.info("First load detected, skipping automatic parameter sending")
|
| 423 |
+
is_first_load = False
|
| 424 |
+
return "Ready to send parameters. Click 'Submit' to send."
|
| 425 |
+
|
| 426 |
+
# the original function, only execute when the user explicitly requests it
|
| 427 |
+
return send_print_parameters(nozzle_temp, bed_temp, print_speed, fan_speed)
|
| 428 |
+
|
| 429 |
send_params_btn.click(
|
| 430 |
fn=api_send_print_parameters,
|
| 431 |
inputs=[nozzle_temp, bed_temp, print_speed, fan_speed],
|
|
|
|
| 564 |
logger.error(f"Error in lambda: {e}")
|
| 565 |
return {"error": str(e)}
|
| 566 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
|
| 568 |
api_json_output = gr.JSON()
|
| 569 |
api_text_output = gr.Textbox()
|