SissiFeng commited on
Commit
d98b776
·
1 Parent(s): a0f3c4e
Files changed (1) hide show
  1. app.py +22 -21
app.py CHANGED
@@ -145,6 +145,28 @@ def get_data():
145
  latest_data["update_time"]
146
  )
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  # Gradio interface
149
  with gr.Blocks(title="Bambu A1 Mini Print Analysis") as demo:
150
  gr.Markdown("# Bambu A1 Mini Print Quality Analysis")
@@ -300,27 +322,6 @@ def analyze_print(image, nozzle_temp, bed_temp, print_speed, fan_speed):
300
  float(results['objectives']['total'])
301
  )
302
 
303
- def send_print_parameters(nozzle_temp, bed_temp, print_speed, fan_speed):
304
- """Send new print parameters to printer"""
305
- try:
306
- params = {
307
- 'nozzle_temp': nozzle_temp,
308
- 'bed_temp': bed_temp,
309
- 'print_speed': print_speed,
310
- 'fan_speed': fan_speed
311
- }
312
-
313
- request_topic = f"bambu_a1_mini/request/{PRINTER_SERIAL}"
314
- if client:
315
- client.publish(request_topic, json.dumps({
316
- 'command': 'set_parameters',
317
- 'parameters': params
318
- }))
319
- return "Parameters sent successfully"
320
- return "MQTT not connected"
321
- except Exception as e:
322
- return f"Error sending parameters: {e}"
323
-
324
  # Launch the app
325
  if __name__ == "__main__":
326
  demo.launch()
 
145
  latest_data["update_time"]
146
  )
147
 
148
+ def send_print_parameters(nozzle_temp, bed_temp, print_speed, fan_speed):
149
+ """Send new print parameters to printer"""
150
+ try:
151
+ params = {
152
+ 'nozzle_temp': nozzle_temp,
153
+ 'bed_temp': bed_temp,
154
+ 'print_speed': print_speed,
155
+ 'fan_speed': fan_speed
156
+ }
157
+
158
+ serial = PRINTER_SERIAL
159
+ request_topic = f"bambu_a1_mini/request/{serial}"
160
+ if client:
161
+ client.publish(request_topic, json.dumps({
162
+ 'command': 'set_parameters',
163
+ 'parameters': params
164
+ }))
165
+ return "Parameters sent successfully"
166
+ return "MQTT not connected"
167
+ except Exception as e:
168
+ return f"Error sending parameters: {e}"
169
+
170
  # Gradio interface
171
  with gr.Blocks(title="Bambu A1 Mini Print Analysis") as demo:
172
  gr.Markdown("# Bambu A1 Mini Print Quality Analysis")
 
322
  float(results['objectives']['total'])
323
  )
324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  # Launch the app
326
  if __name__ == "__main__":
327
  demo.launch()