Skip to content

Commit

Permalink
Add color fix for dual-usb 2432S028R
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Mar 28, 2024
1 parent f110fee commit 1238b7e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CYD-Klipper/src/conf/global_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ typedef struct _GLOBAL_CONFIG {
bool auto_ota_update : 1;
bool multi_printer_mode : 1;
bool on_during_print : 1;
bool display_mode : 1; // Driver specifc usage. Currently only used on ESP32-2432S028R to fix the screen on the usb-c model
};
};

Expand Down
9 changes: 9 additions & 0 deletions CYD-Klipper/src/core/device/ESP32-2432S028R.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ void screen_setup()

tft.init();

if (global_config.display_mode) {
// <3 https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/blob/main/cyd.md#the-display-doesnt-look-as-good
tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected
tft.writedata(2);
delay(120);
tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected
tft.writedata(1);
}

ledcSetup(0, 5000, 12);
ledcAttachPin(21, 0);

Expand Down
11 changes: 11 additions & 0 deletions CYD-Klipper/src/ui/panels/settings_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ static void wake_timeout_dropdown(lv_event_t * e){
write_global_config();
}

static void dualusb_screen_fix_switch(lv_event_t* e){
auto state = lv_obj_get_state(lv_event_get_target(e));
bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED);
global_config.display_mode = checked;
write_global_config();
ESP.restart();
}

static void rotate_screen_switch(lv_event_t* e){
auto state = lv_obj_get_state(lv_event_get_target(e));
bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED);
Expand Down Expand Up @@ -186,6 +194,9 @@ void settings_panel_init(lv_obj_t* panel){
lv_create_custom_menu_dropdown("Wake Timeout", panel, wake_timeout_dropdown, wake_timeout_options, wake_timeout_settings_index);
#endif

#ifdef CYD_SCREEN_DRIVER_ESP32_2432S028R
lv_create_custom_menu_switch("Dual USB Screen Color Fix", panel, dualusb_screen_fix_switch, global_config.display_mode);
#endif
lv_create_custom_menu_switch("Rotate Screen", panel, rotate_screen_switch, global_config.rotate_screen);
lv_create_custom_menu_switch("Multi Printer Mode", panel, multi_printer_switch, global_config.multi_printer_mode);
lv_create_custom_menu_switch("Auto Update", panel, auto_ota_update_switch, global_config.auto_ota_update);
Expand Down

0 comments on commit 1238b7e

Please sign in to comment.