Skip to content

Commit 56c88e2

Browse files
committed
Manual bed calibration working
1 parent cad0618 commit 56c88e2

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

main/reppanel_machine.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Copyright (c) 2020 Wolfgang Christl
33
// Licensed under Apache License, Version 2.0 - https://opensource.org/licenses/Apache-2.0
44

5+
#include "freertos/FreeRTOS.h"
6+
#include <freertos/task.h>
57
#include <lvgl/src/lv_objx/lv_page.h>
68
#include <lvgl/src/lv_objx/lv_ddlist.h>
79
#include <esp_log.h>
@@ -57,8 +59,12 @@ static void _home_z_event(lv_obj_t *obj, lv_event_t event) {
5759

5860
static void _next_height_adjust_event(lv_obj_t *obj, lv_event_t event) {
5961
if (event == LV_EVENT_CLICKED) {
60-
if (reprap_send_gcode("M292"))
61-
seq_num_msgbox = -1; // reset so we know msg GUI is not showing anymore - little dirty I know...
62+
if (reprap_send_gcode("M292")) {
63+
lv_obj_del(label_z_pos_cali);
64+
label_z_pos_cali = 0; // otherwise crash in update_ui
65+
lv_obj_del(cont_heigh_adj_diag);
66+
seq_num_msgbox = 0; // reset so we know msg GUI is not showing anymore - little dirty I know...
67+
}
6268
}
6369
}
6470

@@ -73,7 +79,7 @@ static void _height_adjust_event(lv_obj_t *obj, lv_event_t event) {
7379
}
7480
ESP_LOGI(TAG, "Moving %s%s", dir, amount);
7581
char command[64];
76-
sprintf(command, "M120%%0AG91%%0AG1%%20Z%s%s%%20F6000%%0AG90%%0AM121", dir, amount);
82+
sprintf(command, "M120\nG91\nG1 Z%s%s F6000\nG90\nM121", dir, amount);
7783
reprap_send_gcode(command);
7884
}
7985
}
@@ -175,8 +181,10 @@ static void _start_cali_event(lv_obj_t *obj, lv_event_t event) {
175181
}
176182

177183
void update_ui_machine() {
178-
if (label_z_pos_cali)
179-
lv_label_set_text_fmt(label_z_pos_cali, "%.02f mm", reprap_axes.z);
184+
portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
185+
portENTER_CRITICAL(&mutex); // not sure this really helps?!
186+
if (label_z_pos_cali) lv_label_set_text_fmt(label_z_pos_cali, "%.02f mm", reprap_axes.z);
187+
portEXIT_CRITICAL(&mutex);
180188
if (btn_home_x) {
181189
static lv_style_t homed_style;
182190
lv_style_copy(&homed_style, lv_btn_get_style(btn_home_x, LV_BTN_STYLE_REL));

main/reppanel_request.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static bool got_status_two = false;
3131
static bool got_duet_settings = false;
3232
static int status_request_err_cnt = 0; // request errors in a row
3333
bool job_paused = false;
34-
int seq_num_msgbox = -1;
34+
int seq_num_msgbox = 0;
3535

3636
const char *_decode_reprap_status(const char *valuestring) {
3737
job_paused = false;
@@ -165,6 +165,7 @@ void _process_reprap_status(char *buff, int type) {
165165
}
166166
}
167167

168+
168169
// Get tool heater state
169170
cJSON *duet_temps_state = cJSON_GetObjectItem(duet_temps, DUET_TEMPS_BED_STATE); // all other heater states
170171
int pos = 0;
@@ -891,7 +892,9 @@ bool reprap_send_gcode(char *gcode_command) {
891892
}
892893
} else if (reppanel_conn_status == REPPANEL_UART_CONNECTED) {
893894
ESP_LOGW(TAG, "Writing to UART not supported for now");
895+
return false;
894896
}
897+
return false;
895898
}
896899

897900
void request_filaments() {

0 commit comments

Comments
 (0)