diff --git a/CYD-Klipper/boards/esp32-3248S035C-vertical.json b/CYD-Klipper/boards/esp32-3248S035C-vertical.json new file mode 100644 index 0000000..bfa0cb2 --- /dev/null +++ b/CYD-Klipper/boards/esp32-3248S035C-vertical.json @@ -0,0 +1,66 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DUSER_SETUP_LOADED=1", + "-DST7796_DRIVER=1", + "-DTFT_BL=27", + "-DTFT_BACKLIGHT_ON=HIGH", + "-DTFT_MISO=12", + "-DTFT_MOSI=13", + "-DTFT_SCLK=14", + "-DTFT_CS=15", + "-DTFT_DC=2", + "-DTFT_RST=-1", + "-DLOAD_GCLD=1", + "-DSPI_FREQUENCY=80000000", + "-DSPI_READ_FREQUENCY=20000000", + "-DSPI_TOUCH_FREQUENCY=2500000", + "-DTOUCH_CS=-1", + + "-DCYD_SCREEN_HEIGHT_PX=480", + "-DCYD_SCREEN_WIDTH_PX=320", + "-DCYD_SCREEN_GAP_PX=10", + "-DCYD_SCREEN_MIN_BUTTON_HEIGHT_PX=45", + "-DCYD_SCREEN_MIN_BUTTON_WIDTH_PX=45", + "-DCYD_SCREEN_FONT=lv_font_montserrat_16", + "-DCYD_SCREEN_FONT_SMALL=lv_font_montserrat_12", + "-DCYD_SCREEN_SIDEBAR_SIZE_PX=50", + "-DCYD_SCREEN_DRIVER_ESP32_3248S035C=1", + "-DCYD_SCREEN_DISABLE_TOUCH_CALIBRATION=1", + "-DCYD_SCREEN_VERTICAL=1", + "-DCYD_SCREEN_NO_TEMP_SCROLL=1" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "esp32" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_board": "esp-wroom-32.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "esp32-3248S035C-V", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.aliexpress.com/item/1005004632953455.html", + "vendor": "Sunton" + } \ No newline at end of file diff --git a/CYD-Klipper/platformio.ini b/CYD-Klipper/platformio.ini index e1771b0..fbfd7f4 100644 --- a/CYD-Klipper/platformio.ini +++ b/CYD-Klipper/platformio.ini @@ -46,6 +46,17 @@ lib_deps = plageoj/UrlEncode@^1.0.1 erriez/ErriezCRC32 @ ^1.0.1 +[env:esp32-3248S035C-V] +board = esp32-3248S035C-vertical +lib_deps = + SPI + https://github.com/suchmememanyskill/lvgl + https://github.com/Bodmer/TFT_eSPI.git + https://github.com/OperatorB/gt911-arduino-fixed-reset.git + bblanchon/ArduinoJson@^7.0.0 + plageoj/UrlEncode@^1.0.1 + erriez/ErriezCRC32 @ ^1.0.1 + [env:esp32-2432S024C-SD] board = esp32-2432S024C-smartdisplay diff --git a/CYD-Klipper/src/core/device/ESP32-3248S035C.cpp b/CYD-Klipper/src/core/device/ESP32-3248S035C.cpp index 22ea6d5..715b38f 100644 --- a/CYD-Klipper/src/core/device/ESP32-3248S035C.cpp +++ b/CYD-Klipper/src/core/device/ESP32-3248S035C.cpp @@ -1,10 +1,6 @@ #ifdef CYD_SCREEN_DRIVER_ESP32_3248S035C #include "../screen_driver.h" -#ifdef CYD_SCREEN_VERTICAL - #error "Vertical screen not supported with the ESP32_3248S035C driver" -#endif - #include "lvgl.h" #include #include @@ -107,14 +103,13 @@ void screen_setup() { // Initialize the touchscreen tp.begin(); - tp.setRotation(ROTATION_NORMAL); + // Initialize LVGL lv_init(); // Initialize the display tft.init(); ledcSetup(0, 5000, 12); ledcAttachPin(TFT_BL, 0); - tft.setRotation(global_config.rotate_screen ? 3 : 1); tft.fillScreen(TFT_BLACK); set_invert_display(); LED_init(); @@ -122,8 +117,22 @@ void screen_setup() lv_disp_draw_buf_init(&draw_buf, buf, NULL, TFT_WIDTH * TFT_HEIGHT / 10); static lv_disp_drv_t disp_drv; lv_disp_drv_init(&disp_drv); - disp_drv.hor_res = TFT_HEIGHT; - disp_drv.ver_res = TFT_WIDTH; + + + #ifdef CYD_SCREEN_VERTICAL + disp_drv.hor_res = TFT_WIDTH; + disp_drv.ver_res = TFT_HEIGHT; + tp.setRotation(2); + tft.setRotation(global_config.rotate_screen ? 2 : 0); + #else + disp_drv.hor_res = TFT_HEIGHT; + disp_drv.ver_res = TFT_WIDTH; + + tft.setRotation(global_config.rotate_screen ? 3 : 1); + tp.setRotation(ROTATION_NORMAL); + #endif + + disp_drv.flush_cb = screen_lv_flush; disp_drv.draw_buf = &draw_buf; lv_disp_drv_register(&disp_drv); diff --git a/CYD-Klipper/src/core/lv_setup.cpp b/CYD-Klipper/src/core/lv_setup.cpp index 6f446ca..0cbb26b 100644 --- a/CYD-Klipper/src/core/lv_setup.cpp +++ b/CYD-Klipper/src/core/lv_setup.cpp @@ -270,7 +270,7 @@ void lv_setup() #endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION display_driver->driver->read_cb = lv_touch_intercept; - + screen_timer_setup(); screen_timer_start(); lv_png_init(); diff --git a/CYD-Klipper/src/ui/panels/stats_panel.cpp b/CYD-Klipper/src/ui/panels/stats_panel.cpp index b55793b..e9d361b 100644 --- a/CYD-Klipper/src/ui/panels/stats_panel.cpp +++ b/CYD-Klipper/src/ui/panels/stats_panel.cpp @@ -225,13 +225,14 @@ void create_stat_text_block(lv_obj_t * root, const char* label, lv_event_cb_t va } void stats_panel_init(lv_obj_t* panel) { - auto panel_width = CYD_SCREEN_PANEL_WIDTH_PX / 2 - CYD_SCREEN_GAP_PX * 3; + auto panel_width = CYD_SCREEN_PANEL_WIDTH_PX / 2 - CYD_SCREEN_GAP_PX * 2; lv_obj_t * left_panel = lv_create_empty_panel(panel); lv_obj_set_size(left_panel, panel_width, CYD_SCREEN_PANEL_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2); lv_layout_flex_column(left_panel); lv_obj_set_flex_align(left_panel, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); lv_obj_align(left_panel, LV_ALIGN_TOP_LEFT, CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX); + lv_obj_clear_flag(left_panel, LV_OBJ_FLAG_SCROLLABLE); create_stat_text_block(left_panel, "Position:", label_pos); diff --git a/CYD-Klipper/src/ui/panels/temp_panel.cpp b/CYD-Klipper/src/ui/panels/temp_panel.cpp index d9e7890..6b5d70c 100644 --- a/CYD-Klipper/src/ui/panels/temp_panel.cpp +++ b/CYD-Klipper/src/ui/panels/temp_panel.cpp @@ -225,20 +225,10 @@ static void set_bed_target_temp_chart(lv_event_t * e){ lv_chart_set_next_value(chart, series, printer.bed_target_temp); } -void temp_panel_init(lv_obj_t * panel){ +void create_charts(lv_obj_t * root) +{ const auto element_width = CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2; - root_panel = panel; - edit_mode = false; - - lv_obj_t * root_temp_panel = lv_create_empty_panel(panel); - lv_obj_set_size(root_temp_panel, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_PANEL_HEIGHT_PX); - lv_obj_align(root_temp_panel, LV_ALIGN_TOP_RIGHT, 0, 0); - lv_obj_set_style_pad_all(root_temp_panel, CYD_SCREEN_GAP_PX, 0); - lv_layout_flex_column(root_temp_panel); - lv_obj_set_flex_align(root_temp_panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_CENTER); - lv_obj_set_scrollbar_mode(root_temp_panel, LV_SCROLLBAR_MODE_OFF); - - lv_obj_t * chart = lv_chart_create(root_temp_panel); + lv_obj_t * chart = lv_chart_create(root); lv_obj_set_size(chart, element_width - CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX * 3); lv_chart_set_type(chart, LV_CHART_TYPE_LINE); lv_chart_set_point_count(chart, 120); @@ -261,16 +251,16 @@ void temp_panel_init(lv_obj_t * panel){ lv_obj_add_event_cb(chart, set_bed_temp_chart, LV_EVENT_MSG_RECEIVED, ser4); lv_obj_add_event_cb(chart, set_chart_range, LV_EVENT_MSG_RECEIVED, NULL); lv_msg_subscribe_obj(DATA_PRINTER_DATA, chart, NULL); +} - lv_obj_t * single_screen_panel = lv_create_empty_panel(root_temp_panel); - lv_obj_set_size(single_screen_panel, element_width, CYD_SCREEN_PANEL_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2 - CYD_SCREEN_GAP_PX / 2); - lv_layout_flex_column(single_screen_panel); - +void create_temp_buttons(lv_obj_t * root, lv_obj_t * panel) +{ + const auto element_width = CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2; lv_obj_t * temp_rows[2] = {0}; lv_obj_t * button_temp_rows[2] = {0}; for (int tempIter = 0; tempIter < 2; tempIter++){ - temp_rows[tempIter] = lv_create_empty_panel(single_screen_panel); + temp_rows[tempIter] = lv_create_empty_panel(root); lv_layout_flex_column(temp_rows[tempIter]); lv_obj_set_size(temp_rows[tempIter], element_width, LV_SIZE_CONTENT); @@ -306,9 +296,40 @@ void temp_panel_init(lv_obj_t * panel){ lv_label_set_text(label, "Set"); lv_obj_center(label); } +} - lv_obj_t * gap = lv_create_empty_panel(single_screen_panel); - lv_obj_set_flex_grow(gap, 1); +void temp_panel_init(lv_obj_t * panel){ + const auto element_width = CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2; + root_panel = panel; + edit_mode = false; + + lv_obj_t * root_temp_panel = lv_create_empty_panel(panel); + lv_obj_set_size(root_temp_panel, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_PANEL_HEIGHT_PX); + lv_obj_align(root_temp_panel, LV_ALIGN_TOP_RIGHT, 0, 0); + lv_obj_set_style_pad_all(root_temp_panel, CYD_SCREEN_GAP_PX, 0); + lv_layout_flex_column(root_temp_panel); + lv_obj_set_flex_align(root_temp_panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_CENTER); + lv_obj_set_scrollbar_mode(root_temp_panel, LV_SCROLLBAR_MODE_OFF); + + #ifndef CYD_SCREEN_NO_TEMP_SCROLL + create_charts(root_temp_panel); + + lv_obj_t * single_screen_panel = lv_create_empty_panel(root_temp_panel); + lv_obj_set_size(single_screen_panel, element_width, CYD_SCREEN_PANEL_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2 - CYD_SCREEN_GAP_PX / 2); + lv_layout_flex_column(single_screen_panel); + #else + lv_obj_clear_flag(root_temp_panel, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_t * single_screen_panel = root_temp_panel; + #endif + + create_temp_buttons(single_screen_panel, panel); + + #ifdef CYD_SCREEN_NO_TEMP_SCROLL + create_charts(single_screen_panel); + #else + lv_obj_t * gap = lv_create_empty_panel(single_screen_panel); + lv_obj_set_flex_grow(gap, 1); + #endif lv_obj_t * one_above_bottom_panel = lv_create_empty_panel(single_screen_panel); lv_obj_set_size(one_above_bottom_panel, element_width, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX); diff --git a/_site/index.html b/_site/index.html index e262944..a82f39c 100644 --- a/_site/index.html +++ b/_site/index.html @@ -91,6 +91,7 @@ + diff --git a/ci.py b/ci.py index cf9b893..8ed1366 100644 --- a/ci.py +++ b/ci.py @@ -6,7 +6,8 @@ CYD_PORTS = [ "esp32-2432S032C-SD", "esp32-8048S043C-SD", "esp32-2432S024C-SD", - "esp32-4827S043C-SD" + "esp32-4827S043C-SD", + "esp32-3248S035C-V" ] BASE_DIR = os.getcwd()