mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 21:53:24 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48520f652a | ||
|
|
c5d08253a7 | ||
|
|
5224e34f8c |
@@ -97,15 +97,15 @@ void fetch_printer_data()
|
|||||||
|
|
||||||
if (status.containsKey("toolhead"))
|
if (status.containsKey("toolhead"))
|
||||||
{
|
{
|
||||||
printer.position[0] = status["toolhead"]["position"][0];
|
|
||||||
printer.position[1] = status["toolhead"]["position"][1];
|
|
||||||
printer.position[2] = status["toolhead"]["position"][2];
|
|
||||||
const char *homed_axis = status["toolhead"]["homed_axes"];
|
const char *homed_axis = status["toolhead"]["homed_axes"];
|
||||||
printer.homed_axis = strcmp(homed_axis, "xyz") == 0;
|
printer.homed_axis = strcmp(homed_axis, "xyz") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.containsKey("gcode_move"))
|
if (status.containsKey("gcode_move"))
|
||||||
{
|
{
|
||||||
|
printer.position[0] = status["gcode_move"]["gcode_position"][0];
|
||||||
|
printer.position[1] = status["gcode_move"]["gcode_position"][1];
|
||||||
|
printer.position[2] = status["gcode_move"]["gcode_position"][2];
|
||||||
bool absolute_coords = status["gcode_move"]["absolute_coordinates"];
|
bool absolute_coords = status["gcode_move"]["absolute_coordinates"];
|
||||||
printer.absolute_coords = absolute_coords == true;
|
printer.absolute_coords = absolute_coords == true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,17 @@ bool verify_ip(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool retry_ip_verify(){
|
||||||
|
for (int i = 0; i < 5; i++){
|
||||||
|
if (verify_ip()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void ta_event_cb(lv_event_t * e) {
|
static void ta_event_cb(lv_event_t * e) {
|
||||||
lv_event_code_t code = lv_event_get_code(e);
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
lv_obj_t * ta = lv_event_get_target(e);
|
lv_obj_t * ta = lv_event_get_target(e);
|
||||||
@@ -87,7 +98,7 @@ void ip_setup_inner(){
|
|||||||
void ip_setup(){
|
void ip_setup(){
|
||||||
connect_ok = false;
|
connect_ok = false;
|
||||||
|
|
||||||
if (global_config.ipConfigured && verify_ip()){
|
if (global_config.ipConfigured && retry_ip_verify()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,8 +108,6 @@ void wifi_init_inner(){
|
|||||||
lv_task_handler();
|
lv_task_handler();
|
||||||
lv_refr_now(NULL);
|
lv_refr_now(NULL);
|
||||||
|
|
||||||
int n = WiFi.scanNetworks();
|
|
||||||
|
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
|
|
||||||
lv_obj_t * refreshBtn = lv_btn_create(lv_scr_act());
|
lv_obj_t * refreshBtn = lv_btn_create(lv_scr_act());
|
||||||
@@ -128,25 +126,50 @@ void wifi_init_inner(){
|
|||||||
lv_obj_align(list, LV_ALIGN_TOP_LEFT, 10, 40);
|
lv_obj_align(list, LV_ALIGN_TOP_LEFT, 10, 40);
|
||||||
lv_obj_set_size(list, TFT_HEIGHT - 20, TFT_WIDTH - 40 - 5);
|
lv_obj_set_size(list, TFT_HEIGHT - 20, TFT_WIDTH - 40 - 5);
|
||||||
|
|
||||||
for (int i = 0; i < n; ++i) {
|
int n = WiFi.scanNetworks();
|
||||||
const char* ssid = WiFi.SSID(i).c_str();
|
|
||||||
int len = strlen(ssid);
|
|
||||||
|
|
||||||
if (len == 0)
|
for (int i = 0; i < n; ++i) {
|
||||||
|
String ssid = WiFi.SSID(i);
|
||||||
|
char* ssid_copy = (char*)malloc(ssid.length() + 1);
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
for (; j < ssid.length(); ++j){
|
||||||
|
if (ssid[j] == '\0')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char* ssid_copy = (const char*)malloc(len + 1);
|
ssid_copy[j] = ssid[j];
|
||||||
strcpy((char*)ssid_copy, ssid);
|
}
|
||||||
|
|
||||||
|
ssid_copy[j] = '\0';
|
||||||
|
|
||||||
lv_obj_t * btn = lv_list_add_btn(list, LV_SYMBOL_WIFI, ssid_copy);
|
lv_obj_t * btn = lv_list_add_btn(list, LV_SYMBOL_WIFI, ssid_copy);
|
||||||
lv_obj_add_event_cb(btn, wifi_btn_event_handler, LV_EVENT_ALL, (void*)ssid_copy);
|
lv_obj_add_event_cb(btn, wifi_btn_event_handler, LV_EVENT_ALL, (void*)ssid_copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* errs[] = {
|
||||||
|
"Idle",
|
||||||
|
"No SSID Available",
|
||||||
|
"Scan Completed",
|
||||||
|
"Connected",
|
||||||
|
"Connection Failed",
|
||||||
|
"Connection Lost",
|
||||||
|
"Disconnected"
|
||||||
|
};
|
||||||
|
|
||||||
|
const int print_freq = 1000;
|
||||||
|
int print_timer = 0;
|
||||||
|
|
||||||
void wifi_init(){
|
void wifi_init(){
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
wifi_init_inner();
|
wifi_init_inner();
|
||||||
|
|
||||||
while (!global_config.wifiConfigured || WiFi.status() != WL_CONNECTED){
|
while (!global_config.wifiConfigured || WiFi.status() != WL_CONNECTED){
|
||||||
|
if (millis() - print_timer > print_freq){
|
||||||
|
print_timer = millis();
|
||||||
|
Serial.printf("WiFi Status: %s\n", errs[WiFi.status()]);
|
||||||
|
}
|
||||||
|
|
||||||
lv_timer_handler();
|
lv_timer_handler();
|
||||||
lv_task_handler();
|
lv_task_handler();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user