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
5860static 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
177183void 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 ));
0 commit comments