mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 05:33:24 +00:00
Allow running wifi-less
This commit is contained in:
@@ -71,6 +71,7 @@ typedef struct {
|
|||||||
// Internal
|
// Internal
|
||||||
bool screen_calibrated : 1;
|
bool screen_calibrated : 1;
|
||||||
bool wifi_configured : 1;
|
bool wifi_configured : 1;
|
||||||
|
bool wifi_configuration_skipped : 1;
|
||||||
|
|
||||||
// External
|
// External
|
||||||
bool rotate_screen : 1;
|
bool rotate_screen : 1;
|
||||||
|
|||||||
@@ -394,8 +394,16 @@ static void printer_type_serial_klipper(lv_event_t * e)
|
|||||||
show_ip_entry();
|
show_ip_entry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void return_to_wifi_configuration(lv_event_t * e)
|
||||||
|
{
|
||||||
|
global_config.wifi_configuration_skipped = false;
|
||||||
|
write_global_config();
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
|
||||||
void choose_printer_type()
|
void choose_printer_type()
|
||||||
{
|
{
|
||||||
|
lv_obj_t * btn;
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
global_config.printer_config[global_config.printer_index].ip_configured = false;
|
global_config.printer_config[global_config.printer_index].ip_configured = false;
|
||||||
global_config.printer_config[global_config.printer_index].auth_configured = false;
|
global_config.printer_config[global_config.printer_index].auth_configured = false;
|
||||||
@@ -410,13 +418,16 @@ void choose_printer_type()
|
|||||||
lv_obj_t * label = lv_label_create(root);
|
lv_obj_t * label = lv_label_create(root);
|
||||||
lv_label_set_text(label, "Choose printer type");
|
lv_label_set_text(label, "Choose printer type");
|
||||||
|
|
||||||
lv_obj_t * btn = lv_btn_create(root);
|
if (global_config.wifi_configured)
|
||||||
|
{
|
||||||
|
btn = lv_btn_create(root);
|
||||||
lv_obj_set_size(btn, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
lv_obj_set_size(btn, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
lv_obj_add_event_cb(btn, printer_type_klipper, LV_EVENT_CLICKED, NULL);
|
lv_obj_add_event_cb(btn, printer_type_klipper, LV_EVENT_CLICKED, NULL);
|
||||||
|
|
||||||
label = lv_label_create(btn);
|
label = lv_label_create(btn);
|
||||||
lv_label_set_text(label, "Klipper");
|
lv_label_set_text(label, "Klipper");
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
|
}
|
||||||
|
|
||||||
btn = lv_btn_create(root);
|
btn = lv_btn_create(root);
|
||||||
lv_obj_set_size(btn, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
lv_obj_set_size(btn, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
@@ -426,6 +437,8 @@ void choose_printer_type()
|
|||||||
lv_label_set_text(label, "Klipper (Serial)");
|
lv_label_set_text(label, "Klipper (Serial)");
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
|
|
||||||
|
if (global_config.wifi_configured)
|
||||||
|
{
|
||||||
btn = lv_btn_create(root);
|
btn = lv_btn_create(root);
|
||||||
lv_obj_set_size(btn, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
lv_obj_set_size(btn, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
lv_obj_add_event_cb(btn, printer_type_bambu_local, LV_EVENT_CLICKED, NULL);
|
lv_obj_add_event_cb(btn, printer_type_bambu_local, LV_EVENT_CLICKED, NULL);
|
||||||
@@ -435,6 +448,18 @@ void choose_printer_type()
|
|||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (global_config.wifi_configuration_skipped)
|
||||||
|
{
|
||||||
|
btn = lv_btn_create(root);
|
||||||
|
lv_obj_set_size(btn, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
|
lv_obj_add_event_cb(btn, return_to_wifi_configuration, LV_EVENT_CLICKED, NULL);
|
||||||
|
|
||||||
|
label = lv_label_create(btn);
|
||||||
|
lv_label_set_text(label, "Return to WiFi configuration");
|
||||||
|
lv_obj_center(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ip_init(){
|
void ip_init(){
|
||||||
if (!global_config.printer_config[global_config.printer_index].setup_complete)
|
if (!global_config.printer_config[global_config.printer_index].setup_complete)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ static void reset_click(lv_event_t * e){
|
|||||||
|
|
||||||
static void reset_wifi_click(lv_event_t * e){
|
static void reset_wifi_click(lv_event_t * e){
|
||||||
global_config.wifi_configured = false;
|
global_config.wifi_configured = false;
|
||||||
|
global_config.wifi_configuration_skipped = false;
|
||||||
write_global_config();
|
write_global_config();
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ static void wifi_btn_manual_ssid(lv_event_t * e){
|
|||||||
lv_create_keyboard_text_entry(wifi_keyboard_cb_manual_ssid, "Enter SSID Manually", LV_KEYBOARD_MODE_TEXT_LOWER, CYD_SCREEN_WIDTH_PX * 0.75, 31, "", false);
|
lv_create_keyboard_text_entry(wifi_keyboard_cb_manual_ssid, "Enter SSID Manually", LV_KEYBOARD_MODE_TEXT_LOWER, CYD_SCREEN_WIDTH_PX * 0.75, 31, "", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void wifi_btn_skip_setup(lv_event_t * e){
|
||||||
|
global_config.wifi_configuration_skipped = true;
|
||||||
|
}
|
||||||
|
|
||||||
void wifi_init_inner(){
|
void wifi_init_inner(){
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
@@ -162,6 +166,14 @@ void wifi_init_inner(){
|
|||||||
lv_obj_set_flex_grow(label, 1);
|
lv_obj_set_flex_grow(label, 1);
|
||||||
|
|
||||||
lv_obj_t * btn = lv_btn_create(top_row);
|
lv_obj_t * btn = lv_btn_create(top_row);
|
||||||
|
lv_obj_add_event_cb(btn, wifi_btn_skip_setup, LV_EVENT_CLICKED, NULL);
|
||||||
|
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
|
|
||||||
|
label = lv_label_create(btn);
|
||||||
|
lv_label_set_text(label, "Skip");
|
||||||
|
lv_obj_center(label);
|
||||||
|
|
||||||
|
btn = lv_btn_create(top_row);
|
||||||
lv_obj_add_event_cb(btn, wifi_btn_manual_ssid, LV_EVENT_CLICKED, NULL);
|
lv_obj_add_event_cb(btn, wifi_btn_manual_ssid, LV_EVENT_CLICKED, NULL);
|
||||||
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
|
|
||||||
@@ -216,10 +228,15 @@ const int print_freq = 1000;
|
|||||||
int print_timer = 0;
|
int print_timer = 0;
|
||||||
|
|
||||||
void wifi_init(){
|
void wifi_init(){
|
||||||
|
if (global_config.wifi_configuration_skipped)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
wifi_init_inner();
|
wifi_init_inner();
|
||||||
|
|
||||||
while (!global_config.wifi_configured || WiFi.status() != WL_CONNECTED){
|
while (!global_config.wifi_configuration_skipped && (!global_config.wifi_configured || WiFi.status() != WL_CONNECTED)){
|
||||||
if (millis() - print_timer > print_freq){
|
if (millis() - print_timer > print_freq){
|
||||||
print_timer = millis();
|
print_timer = millis();
|
||||||
LOG_F(("WiFi Status: %s\n", errs[WiFi.status()]))
|
LOG_F(("WiFi Status: %s\n", errs[WiFi.status()]))
|
||||||
@@ -227,14 +244,13 @@ void wifi_init(){
|
|||||||
|
|
||||||
lv_handler();
|
lv_handler();
|
||||||
serial_console::run();
|
serial_console::run();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong start_time_recovery = 0;
|
ulong start_time_recovery = 0;
|
||||||
|
|
||||||
void wifi_ok(){
|
void wifi_ok(){
|
||||||
if (WiFi.status() != WL_CONNECTED){
|
if (global_config.wifi_configured && WiFi.status() != WL_CONNECTED){
|
||||||
LOG_LN("WiFi Connection Lost. Reconnecting...");
|
LOG_LN("WiFi Connection Lost. Reconnecting...");
|
||||||
freeze_request_thread();
|
freeze_request_thread();
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
|
|||||||
Reference in New Issue
Block a user