Skip to content

Commit

Permalink
Add printer switch to ip setup screen
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Mar 18, 2024
1 parent 44e5799 commit 6cde9cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CYD-Klipper/src/ui/ip_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ void ip_init_inner(){
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_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;
Expand Down
9 changes: 5 additions & 4 deletions CYD-Klipper/src/ui/switch_printer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "switch_printer.h"
#include "lvgl.h"
#include "../conf/global_config.h"
#include "ui_utils.h"
#include "../core/http_client.h"
Expand Down Expand Up @@ -47,7 +46,7 @@ void switch_printer_init() {
PRINTER_CONFIG * config = &global_config.printer_config[i];
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");
continue;
Expand Down Expand Up @@ -75,11 +74,11 @@ static void show_switch_printer_screen(lv_event_t * e){
switch_printer_init();
}

void draw_switch_printer_button()
lv_obj_t * draw_switch_printer_button()
{
if (!global_config.multi_printer_mode)
{
return;
return NULL;
}

lv_obj_t * btn = lv_btn_create(lv_scr_act());
Expand All @@ -90,4 +89,6 @@ void draw_switch_printer_button()
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, LV_SYMBOL_HOME);
lv_obj_center(label);

return btn;
}
3 changes: 2 additions & 1 deletion CYD-Klipper/src/ui/switch_printer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "lvgl.h"

void switch_printer(int index);
void switch_printer_init();
void draw_switch_printer_button();
lv_obj_t * draw_switch_printer_button();

0 comments on commit 6cde9cb

Please sign in to comment.