Skip to content

Commit

Permalink
System Load settings from File: Provide Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bkerler committed Mar 5, 2024
1 parent b3ee47a commit a331bcc
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/gui/MItem_menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,32 @@ MI_LOAD_SETTINGS::MI_LOAD_SETTINGS()
: WI_LABEL_t(_(label), nullptr, is_enabled_t::yes, is_hidden_t::no) {
}

static void add_load_response(const char *name, bool flag, char *msg, int msglen) {
char tmp[strlen(name) + 5];
snprintf(tmp, sizeof(tmp), "%s: %s\n", name, flag ? "+" : "-");
strncat(msg, tmp, msglen);
}

void MI_LOAD_SETTINGS::click(IWindowMenu & /*window_menu*/) {
// FIXME: Some error handling/reporting
// TODO: Loading other things than just network
bool is_network = false;
bool is_connect = false;

if (netdev_load_ini_to_eeprom()) {
notify_reconfigure();
is_network = true;
}

// FIXME: Error handling
#if BUDDY_ENABLE_CONNECT()
connect_client::MarlinPrinter::load_cfg_from_ini();
if (connect_client::MarlinPrinter::load_cfg_from_ini()) {
is_connect = true;
}
#endif
char msg[MSG_MAX_LENGTH] = "\nLoading settings finished.\n\n";
add_load_response("Network", is_network, msg, MSG_MAX_LENGTH - strlen(msg));
#if BUDDY_ENABLE_CONNECT()
add_load_response("Connect", is_connect, msg, MSG_MAX_LENGTH - strlen(msg));
#endif
MsgBoxInfo(string_view_utf8::MakeCPUFLASH((const uint8_t *)msg), Responses_Ok);
}

/**********************************************************************************************/
Expand Down

0 comments on commit a331bcc

Please sign in to comment.