mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 13:43:25 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a2fff27d6 | ||
|
|
082d66ca10 |
@@ -4,6 +4,7 @@
|
||||
#include "../conf/global_config.h"
|
||||
#include <HTTPClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <esp_task_wdt.h>
|
||||
#include "macros_query.h"
|
||||
|
||||
const char *printer_state_messages[] = {
|
||||
@@ -64,7 +65,6 @@ void send_gcode(bool wait, const char *gcode)
|
||||
|
||||
void fetch_printer_data()
|
||||
{
|
||||
bool frozen = true;
|
||||
freeze_request_thread();
|
||||
char buff[256] = {};
|
||||
sprintf(buff, "http://%s:%d/printer/objects/query?extruder&heater_bed&toolhead&gcode_move&virtual_sdcard&print_stats&webhooks", global_config.klipperHost, global_config.klipperPort);
|
||||
@@ -83,7 +83,6 @@ void fetch_printer_data()
|
||||
int printer_state = printer.state;
|
||||
delay(10);
|
||||
unfreeze_request_thread();
|
||||
frozen = false;
|
||||
freeze_render_thread();
|
||||
|
||||
if (status.containsKey("webhooks"))
|
||||
@@ -196,10 +195,8 @@ void fetch_printer_data()
|
||||
{
|
||||
klipper_request_consecutive_fail_count++;
|
||||
Serial.printf("Failed to fetch printer data: %d\n", httpCode);
|
||||
}
|
||||
|
||||
if (frozen)
|
||||
unfreeze_request_thread();
|
||||
}
|
||||
}
|
||||
|
||||
void data_loop()
|
||||
@@ -211,6 +208,7 @@ void data_loop()
|
||||
}
|
||||
|
||||
void data_loop_background(void * param){
|
||||
esp_task_wdt_init(10, true);
|
||||
while (true){
|
||||
delay(data_update_interval);
|
||||
fetch_printer_data();
|
||||
|
||||
@@ -84,7 +84,11 @@ void touchscreen_calibrate(bool force)
|
||||
|
||||
void screen_setBrightness(byte brightness)
|
||||
{
|
||||
analogWrite(TFT_BL, brightness);
|
||||
// calculate duty, 4095 from 2 ^ 12 - 1
|
||||
uint32_t duty = (4095 / 255) * brightness;
|
||||
|
||||
// write duty to LEDC
|
||||
ledcWrite(0, duty);
|
||||
}
|
||||
|
||||
void set_screen_brightness()
|
||||
@@ -213,6 +217,10 @@ void screen_setup()
|
||||
lv_init();
|
||||
|
||||
tft.init();
|
||||
|
||||
ledcSetup(0, 5000, 12);
|
||||
ledcAttachPin(21, 0);
|
||||
|
||||
tft.setRotation(global_config.rotateScreen ? 3 : 1);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
set_screen_brightness();
|
||||
|
||||
Reference in New Issue
Block a user