Skip to content

Commit

Permalink
Rename defines
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Jan 27, 2024
1 parent 939a9f6 commit 8198729
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions CYD-Klipper/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ build_flags =

### Porting options ###
# Defines the screen height
-DCYD_SCREEN_HEIGHT=240
-DCYD_SCREEN_HEIGHT_PX=240
# Defines the screen width
-DCYD_SCREEN_WIDTH=320
-DCYD_SCREEN_WIDTH_PX=320
# Defines the pixel gap used for large gaps (like between buttons)
-DCYD_SCREEN_BIG_GAP_PX=8
# Defines the pixel gap used for small gaps (like between text and buttons)
-DCYD_SCREEN_SMALL_GAP_PX=4
# Defines the minimum pixel height of a button
-DCYD_SCREEN_MIN_BUTTON_HEIGHT=35
-DCYD_SCREEN_MIN_BUTTON_HEIGHT_PX=35
# Defines the minimum pixel width of a button
-DCYD_SCREEN_MIN_BUTTON_WIDTH=35
-DCYD_SCREEN_MIN_BUTTON_WIDTH_PX=35
# Defines the size of font used
-DCYD_SCREEN_FONT=&lv_font_montserrat_14
# Defines the size of font used for small text
Expand Down
4 changes: 2 additions & 2 deletions CYD-Klipper/src/ui/nav_buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void nav_buttons_setup(unsigned char active_panel){
lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE);

lv_obj_t * root_panel = lv_create_empty_panel(lv_scr_act());
lv_obj_set_size(root_panel, CYD_SCREEN_SIDEBAR_SIZE_PX, CYD_SCREEN_HEIGHT);
lv_obj_set_size(root_panel, CYD_SCREEN_SIDEBAR_SIZE_PX, CYD_SCREEN_HEIGHT_PX);
lv_obj_align(root_panel, LV_ALIGN_TOP_LEFT, 0, 0);
lv_obj_set_layout(root_panel, LV_LAYOUT_FLEX);
lv_obj_set_flex_flow(root_panel, LV_FLEX_FLOW_COLUMN);
Expand All @@ -122,7 +122,7 @@ void nav_buttons_setup(unsigned char active_panel){
create_button(LV_SYMBOL_GPS, "Macro", btn_click_macros, NULL, root_panel);

lv_obj_t * panel = lv_create_empty_panel(lv_scr_act());
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH, CYD_SCREEN_HEIGHT);
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH, CYD_SCREEN_HEIGHT_PX);
lv_obj_align(panel, LV_ALIGN_TOP_RIGHT, 0, 0);

switch (active_panel){
Expand Down
10 changes: 5 additions & 5 deletions CYD-Klipper/src/ui/panels/macros_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void btn_goto_settings(lv_event_t * e){
void macros_panel_init(lv_obj_t* panel) {
lv_obj_t * btn = lv_btn_create(panel);
lv_obj_add_event_cb(btn, btn_goto_settings, LV_EVENT_CLICKED, NULL);
lv_obj_set_size(btn, CYD_SCREEN_PANEL_WIDTH - CYD_SCREEN_BIG_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT);
lv_obj_set_size(btn, CYD_SCREEN_PANEL_WIDTH - CYD_SCREEN_BIG_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_BIG_GAP_PX);

lv_obj_t * label = lv_label_create(btn);
Expand All @@ -38,8 +38,8 @@ void macros_panel_init(lv_obj_t* panel) {
}

lv_obj_t * root_panel = lv_create_empty_panel(panel);
lv_obj_set_size(root_panel, CYD_SCREEN_PANEL_WIDTH, CYD_SCREEN_HEIGHT - CYD_SCREEN_MIN_BUTTON_HEIGHT - CYD_SCREEN_BIG_GAP_PX);
lv_obj_align(root_panel, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_MIN_BUTTON_HEIGHT + CYD_SCREEN_BIG_GAP_PX);
lv_obj_set_size(root_panel, CYD_SCREEN_PANEL_WIDTH, CYD_SCREEN_HEIGHT_PX - CYD_SCREEN_MIN_BUTTON_HEIGHT_PX - CYD_SCREEN_BIG_GAP_PX);
lv_obj_align(root_panel, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX + CYD_SCREEN_BIG_GAP_PX);
lv_obj_set_layout(root_panel, LV_LAYOUT_FLEX);
lv_obj_set_flex_flow(root_panel, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(root_panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
Expand All @@ -51,7 +51,7 @@ void macros_panel_init(lv_obj_t* panel) {
const char* macro = query.macros[i];

lv_obj_t * panel = lv_create_empty_panel(root_panel);
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH - CYD_SCREEN_BIG_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT + CYD_SCREEN_BIG_GAP_PX * 2);
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH - CYD_SCREEN_BIG_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX + CYD_SCREEN_BIG_GAP_PX * 2);

lv_obj_t * line = lv_line_create(panel);
lv_line_set_points(line, line_points, 2);
Expand All @@ -67,7 +67,7 @@ void macros_panel_init(lv_obj_t* panel) {
lv_obj_set_width(label, CYD_SCREEN_PANEL_WIDTH * 0.75f);

lv_obj_t * btn = lv_btn_create(panel);
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT);
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
lv_obj_align(btn, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_add_event_cb(btn, btn_press, LV_EVENT_CLICKED, (void*)macro);

Expand Down
4 changes: 2 additions & 2 deletions CYD-Klipper/src/ui/panels/settings_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ static void on_during_print_switch(lv_event_t* e){
const static lv_point_t line_points[] = { {0, 0}, {(short int)((CYD_SCREEN_PANEL_WIDTH - CYD_SCREEN_BIG_GAP_PX * 2) * 0.85f), 0} };

void create_settings_widget(const char* label_text, lv_obj_t* object, lv_obj_t* root_panel){
lv_obj_set_height(object, CYD_SCREEN_MIN_BUTTON_HEIGHT);
lv_obj_set_height(object, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);

lv_obj_t * panel = lv_obj_create(root_panel);
lv_obj_set_style_border_width(panel, 0, 0);
lv_obj_set_style_bg_opa(panel, LV_OPA_TRANSP, 0);
lv_obj_set_style_pad_all(panel, 0, 0);
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH - CYD_SCREEN_BIG_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT + CYD_SCREEN_BIG_GAP_PX * 2);
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH - CYD_SCREEN_BIG_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX + CYD_SCREEN_BIG_GAP_PX * 2);

lv_obj_t * line = lv_line_create(panel);
lv_line_set_points(line, line_points, 2);
Expand Down
2 changes: 1 addition & 1 deletion CYD-Klipper/src/ui/ui_utils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define CYD_SCREEN_PANEL_WIDTH \
(CYD_SCREEN_WIDTH - CYD_SCREEN_SIDEBAR_SIZE_PX)
(CYD_SCREEN_WIDTH_PX - CYD_SCREEN_SIDEBAR_SIZE_PX)

lv_obj_t* lv_create_empty_panel(lv_obj_t* root);

0 comments on commit 8198729

Please sign in to comment.