mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 05:33:24 +00:00
Display M117 message on screen
This commit is contained in:
@@ -17,6 +17,7 @@ lib_deps =
|
|||||||
https://github.com/suchmememanyskill/esp32-smartdisplay
|
https://github.com/suchmememanyskill/esp32-smartdisplay
|
||||||
bblanchon/ArduinoJson@^7.0.0
|
bblanchon/ArduinoJson@^7.0.0
|
||||||
plageoj/UrlEncode@^1.0.1
|
plageoj/UrlEncode@^1.0.1
|
||||||
|
erriez/ErriezCRC32 @ ^1.0.1
|
||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
build_flags =
|
build_flags =
|
||||||
-DLV_CONF_PATH="../../../../src/conf/lv_conf.h"
|
-DLV_CONF_PATH="../../../../src/conf/lv_conf.h"
|
||||||
@@ -32,6 +33,7 @@ lib_deps =
|
|||||||
https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
|
https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
|
||||||
bblanchon/ArduinoJson@^7.0.0
|
bblanchon/ArduinoJson@^7.0.0
|
||||||
plageoj/UrlEncode@^1.0.1
|
plageoj/UrlEncode@^1.0.1
|
||||||
|
erriez/ErriezCRC32 @ ^1.0.1
|
||||||
|
|
||||||
[env:esp32-3248S035C]
|
[env:esp32-3248S035C]
|
||||||
board = esp32-3248S035C
|
board = esp32-3248S035C
|
||||||
@@ -42,6 +44,7 @@ lib_deps =
|
|||||||
https://github.com/OperatorB/gt911-arduino-fixed-reset.git
|
https://github.com/OperatorB/gt911-arduino-fixed-reset.git
|
||||||
bblanchon/ArduinoJson@^7.0.0
|
bblanchon/ArduinoJson@^7.0.0
|
||||||
plageoj/UrlEncode@^1.0.1
|
plageoj/UrlEncode@^1.0.1
|
||||||
|
erriez/ErriezCRC32 @ ^1.0.1
|
||||||
|
|
||||||
[env:esp32-2432S028Rv1-SD]
|
[env:esp32-2432S028Rv1-SD]
|
||||||
board = esp32-2432S028RV1-smartdisplay
|
board = esp32-2432S028RV1-smartdisplay
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "macros_query.h"
|
#include "macros_query.h"
|
||||||
#include <UrlEncode.h>
|
#include <UrlEncode.h>
|
||||||
#include "http_client.h"
|
#include "http_client.h"
|
||||||
|
#include "../ui/ui_utils.h"
|
||||||
|
|
||||||
const char *printer_state_messages[] = {
|
const char *printer_state_messages[] = {
|
||||||
"Error",
|
"Error",
|
||||||
@@ -112,7 +113,7 @@ void fetch_printer_data()
|
|||||||
{
|
{
|
||||||
freeze_request_thread();
|
freeze_request_thread();
|
||||||
PRINTER_CONFIG *config = get_current_printer_config();
|
PRINTER_CONFIG *config = get_current_printer_config();
|
||||||
SETUP_HTTP_CLIENT("/printer/objects/query?extruder&heater_bed&toolhead&gcode_move&virtual_sdcard&print_stats&webhooks&fan")
|
SETUP_HTTP_CLIENT("/printer/objects/query?extruder&heater_bed&toolhead&gcode_move&virtual_sdcard&print_stats&webhooks&fan&display_status")
|
||||||
|
|
||||||
int httpCode = client.GET();
|
int httpCode = client.GET();
|
||||||
delay(10);
|
delay(10);
|
||||||
@@ -235,8 +236,11 @@ void fetch_printer_data()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make a call to /server/files/metadata to get more accurate time estimates
|
if (status.containsKey("display_status"))
|
||||||
// https://moonraker.readthedocs.io/en/latest/web_api/#server-administration
|
{
|
||||||
|
const char* message = status["display_status"]["message"];
|
||||||
|
lv_create_popup_message(message, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
if (printer.state == PRINTER_STATE_PRINTING && printer.print_progress > 0)
|
if (printer.state == PRINTER_STATE_PRINTING && printer.print_progress > 0)
|
||||||
{
|
{
|
||||||
@@ -418,5 +422,5 @@ void data_setup()
|
|||||||
|
|
||||||
macros_query_setup();
|
macros_query_setup();
|
||||||
freeze_render_thread();
|
freeze_render_thread();
|
||||||
xTaskCreatePinnedToCore(data_loop_background, "data_loop_background", 5000, NULL, 0, &background_loop, 0);
|
xTaskCreatePinnedToCore(data_loop_background, "data_loop_background", 5000, NULL, 2, &background_loop, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "ui_utils.h"
|
#include "ui_utils.h"
|
||||||
#include "../core/data_setup.h"
|
#include "../core/data_setup.h"
|
||||||
#include "../core/lv_setup.h"
|
#include "../core/lv_setup.h"
|
||||||
|
#include <ErriezCRC32.h>
|
||||||
|
|
||||||
lv_obj_t* lv_create_empty_panel(lv_obj_t* root) {
|
lv_obj_t* lv_create_empty_panel(lv_obj_t* root) {
|
||||||
lv_obj_t* panel = lv_obj_create(root);
|
lv_obj_t* panel = lv_obj_create(root);
|
||||||
@@ -200,3 +201,53 @@ void lv_create_custom_menu_label(const char *label_text, lv_obj_t* root_panel, c
|
|||||||
lv_label_set_text(label, text);
|
lv_label_set_text(label, text);
|
||||||
lv_create_custom_menu_entry(label_text, label, root_panel, false);
|
lv_create_custom_menu_entry(label_text, label, root_panel, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t message_hash = 0;
|
||||||
|
lv_timer_t* timer = NULL;
|
||||||
|
|
||||||
|
void on_timer_destroy(lv_event_t * e)
|
||||||
|
{
|
||||||
|
lv_timer_del(timer);
|
||||||
|
timer = NULL;
|
||||||
|
Serial.println("Timer destroy");
|
||||||
|
}
|
||||||
|
|
||||||
|
void timer_callback(lv_timer_t *timer)
|
||||||
|
{
|
||||||
|
lv_obj_t * panel = (lv_obj_t *)timer->user_data;
|
||||||
|
lv_obj_del(panel);
|
||||||
|
Serial.println("Timer callback");
|
||||||
|
}
|
||||||
|
|
||||||
|
void lv_create_popup_message(const char* message, uint16_t timeout_ms)
|
||||||
|
{
|
||||||
|
Serial.println("Hello");
|
||||||
|
if (message == nullptr || timer != NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t new_hash = crc32String(message);
|
||||||
|
|
||||||
|
if (new_hash == message_hash)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
message_hash = new_hash;
|
||||||
|
|
||||||
|
lv_obj_t* panel = lv_obj_create(lv_scr_act());
|
||||||
|
lv_obj_set_style_pad_all(panel, CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX);
|
||||||
|
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, LV_SIZE_CONTENT);
|
||||||
|
lv_layout_flex_column(panel, LV_FLEX_ALIGN_CENTER);
|
||||||
|
lv_obj_align(panel, LV_ALIGN_TOP_RIGHT, -CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX);
|
||||||
|
lv_obj_add_event_cb(panel, on_timer_destroy, LV_EVENT_DELETE, NULL);
|
||||||
|
lv_obj_set_style_border_color(panel, lv_color_hex(0xFF0000), 0);
|
||||||
|
|
||||||
|
lv_obj_t* label = lv_label_create(panel);
|
||||||
|
lv_label_set_text_fmt(label, "%s", message);
|
||||||
|
lv_obj_set_size(label, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 6, LV_SIZE_CONTENT);
|
||||||
|
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
|
||||||
|
|
||||||
|
timer = lv_timer_create(timer_callback, timeout_ms, panel);
|
||||||
|
}
|
||||||
@@ -44,3 +44,4 @@ void lv_create_custom_menu_button(const char *label_text, lv_obj_t* root_panel,
|
|||||||
void lv_create_custom_menu_switch(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_toggle, bool state, void * user_data = NULL);
|
void lv_create_custom_menu_switch(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_toggle, bool state, void * user_data = NULL);
|
||||||
void lv_create_custom_menu_dropdown(const char *label_text, lv_obj_t *root_panel, lv_event_cb_t on_change, const char *options, int index, void * user_data = NULL);
|
void lv_create_custom_menu_dropdown(const char *label_text, lv_obj_t *root_panel, lv_event_cb_t on_change, const char *options, int index, void * user_data = NULL);
|
||||||
void lv_create_custom_menu_label(const char *label_text, lv_obj_t* root_panel, const char *text);
|
void lv_create_custom_menu_label(const char *label_text, lv_obj_t* root_panel, const char *text);
|
||||||
|
void lv_create_popup_message(const char* message, uint16_t timeout_ms);
|
||||||
Reference in New Issue
Block a user