Add printer switch to ip setup screen

This commit is contained in:
suchmememanyskill
2024-03-18 18:05:08 +01:00
parent 44e57995fb
commit 6cde9cb887
3 changed files with 14 additions and 5 deletions

View File

@@ -271,6 +271,13 @@ void ip_init_inner(){
lv_obj_add_event_cb(portEntry, ta_event_cb, LV_EVENT_ALL, keyboard); lv_obj_add_event_cb(portEntry, ta_event_cb, LV_EVENT_ALL, keyboard);
lv_keyboard_set_mode(keyboard, LV_KEYBOARD_MODE_USER_1); lv_keyboard_set_mode(keyboard, LV_KEYBOARD_MODE_USER_1);
lv_keyboard_set_textarea(keyboard, hostEntry); lv_keyboard_set_textarea(keyboard, hostEntry);
if (global_config.multi_printer_mode)
{
lv_obj_t * btn = draw_switch_printer_button();
lv_obj_set_parent(btn, textbow_row);
lv_obj_align(btn, LV_ALIGN_DEFAULT, 0, 0);
}
} }
long last_data_update_ip = -10000; long last_data_update_ip = -10000;

View File

@@ -1,5 +1,4 @@
#include "switch_printer.h" #include "switch_printer.h"
#include "lvgl.h"
#include "../conf/global_config.h" #include "../conf/global_config.h"
#include "ui_utils.h" #include "ui_utils.h"
#include "../core/http_client.h" #include "../core/http_client.h"
@@ -47,7 +46,7 @@ void switch_printer_init() {
PRINTER_CONFIG * config = &global_config.printer_config[i]; PRINTER_CONFIG * config = &global_config.printer_config[i];
const char* printer_name = (config->printer_name[0] == 0) ? config->klipper_host : config->printer_name; const char* printer_name = (config->printer_name[0] == 0) ? config->klipper_host : config->printer_name;
if (config == get_current_printer_config()) if (config == get_current_printer_config() && config->ip_configured)
{ {
lv_create_custom_menu_label(printer_name, parent, "Active"); lv_create_custom_menu_label(printer_name, parent, "Active");
continue; continue;
@@ -75,11 +74,11 @@ static void show_switch_printer_screen(lv_event_t * e){
switch_printer_init(); switch_printer_init();
} }
void draw_switch_printer_button() lv_obj_t * draw_switch_printer_button()
{ {
if (!global_config.multi_printer_mode) if (!global_config.multi_printer_mode)
{ {
return; return NULL;
} }
lv_obj_t * btn = lv_btn_create(lv_scr_act()); lv_obj_t * btn = lv_btn_create(lv_scr_act());
@@ -90,4 +89,6 @@ void draw_switch_printer_button()
lv_obj_t * label = lv_label_create(btn); lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, LV_SYMBOL_HOME); lv_label_set_text(label, LV_SYMBOL_HOME);
lv_obj_center(label); lv_obj_center(label);
return btn;
} }

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "lvgl.h"
void switch_printer(int index); void switch_printer(int index);
void switch_printer_init(); void switch_printer_init();
void draw_switch_printer_button(); lv_obj_t * draw_switch_printer_button();