Skip to content

Commit

Permalink
Make all colors somewhat worth using
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Jan 6, 2024
1 parent 91920a6 commit 595331a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
14 changes: 7 additions & 7 deletions CYD-Klipper/src/conf/global_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
GLOBAL_CONFIG global_config = {0};

COLOR_DEF color_defs[] = {
{LV_PALETTE_BLUE, LV_PALETTE_RED},
{LV_PALETTE_GREEN, LV_PALETTE_PURPLE},
{LV_PALETTE_GREY, LV_PALETTE_CYAN},
{LV_PALETTE_YELLOW, LV_PALETTE_PINK},
{LV_PALETTE_ORANGE, LV_PALETTE_BLUE},
{LV_PALETTE_RED, LV_PALETTE_GREEN},
{LV_PALETTE_PURPLE, LV_PALETTE_GREY},
{LV_PALETTE_BLUE, 0, LV_PALETTE_RED},
{LV_PALETTE_LIME, -2, LV_PALETTE_PURPLE},
{LV_PALETTE_BLUE, 0, LV_PALETTE_CYAN},
{LV_PALETTE_YELLOW, -2, LV_PALETTE_PINK},
{LV_PALETTE_ORANGE, -2, LV_PALETTE_BLUE},
{LV_PALETTE_RED, 0, LV_PALETTE_GREEN},
{LV_PALETTE_PURPLE, 0, LV_PALETTE_GREY},
};

void WriteGlobalConfig() {
Expand Down
4 changes: 4 additions & 0 deletions CYD-Klipper/src/conf/global_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ typedef struct _GLOBAL_CONFIG {
union {
unsigned char raw;
struct {
// Internal
bool screenCalibrated : 1;
bool wifiConfigured : 1;
bool ipConfigured : 1;

// External
bool lightMode : 1;
bool invertColors : 1;
bool rotateScreen : 1;
Expand Down Expand Up @@ -40,6 +43,7 @@ typedef struct _GLOBAL_CONFIG {

typedef struct _COLOR_DEF {
lv_palette_t primary_color;
short primary_color_light;
lv_palette_t secondary_color;
} COLOR_DEF;

Expand Down
15 changes: 14 additions & 1 deletion CYD-Klipper/src/core/screen_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,20 @@ void screen_lv_touchRead(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)

void set_color_scheme(){
lv_disp_t *dispp = lv_disp_get_default();
lv_theme_t *theme = lv_theme_default_init(dispp, lv_palette_main(color_defs[global_config.color_scheme].primary_color), lv_palette_main(color_defs[global_config.color_scheme].secondary_color), !global_config.lightMode, LV_FONT_DEFAULT);
lv_color_t main_color = {0};
COLOR_DEF color_def = color_defs[global_config.color_scheme];

if (color_defs[global_config.color_scheme].primary_color_light > 0){
main_color = lv_palette_lighten(color_def.primary_color, color_def.primary_color_light);
}
else if (color_defs[global_config.color_scheme].primary_color_light < 0) {
main_color = lv_palette_darken(color_def.primary_color, color_def.primary_color_light * -1);
}
else {
main_color = lv_palette_main(color_defs[global_config.color_scheme].primary_color);
}

lv_theme_t *theme = lv_theme_default_init(dispp, main_color, lv_palette_main(color_def.secondary_color), !global_config.lightMode, LV_FONT_DEFAULT);
lv_disp_set_theme(dispp, theme);
}

Expand Down

0 comments on commit 595331a

Please sign in to comment.