Skip to content

Commit

Permalink
better scaling on main/fine tune/print status.
Browse files Browse the repository at this point in the history
  • Loading branch information
ballaswag committed Apr 20, 2024
1 parent 0b6f3d5 commit fa1eb65
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/image_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ ImageLabel::ImageLabel(lv_obj_t *parent,
lv_obj_set_size(cont, LV_PCT(width_pct), LV_PCT(height_pct));
lv_obj_set_style_border_width(cont, 2, 0);
lv_obj_set_style_radius(cont, 4, 0);
lv_obj_set_style_pad_left(cont, 5, 0);
lv_obj_set_style_pad_right(cont, 5, 0);

lv_img_set_src(image, img);
lv_label_set_text(label, value);

auto scale = (double)lv_disp_get_physical_hor_res(NULL) / 800.0;

lv_obj_align(image, LV_ALIGN_LEFT_MID, -30 * scale, 0);
lv_obj_align(image, LV_ALIGN_LEFT_MID, 0, 0);
lv_obj_align(label, LV_ALIGN_RIGHT_MID, 0, 0);
}

Expand All @@ -47,7 +49,9 @@ ImageLabel::ImageLabel(lv_obj_t *parent,
const char *v)
: ImageLabel(parent, img, width_pct, height_pct, v)
{
lv_img_set_zoom(image, img_scale);
auto wscale = lv_disp_get_physical_hor_res(NULL) / 800.0;
lv_img_set_size_mode(image, LV_IMG_SIZE_MODE_REAL);
lv_img_set_zoom(image, img_scale * wscale);
}

ImageLabel::ImageLabel(lv_obj_t *parent,
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static void hal_init(void) {

evdev_init();
static lv_indev_drv_t indev_drv_1;
lv_indev_drv_init(&indev_drv_1);
indev_drv_1.read_cb = evdev_read; // no calibration
indev_drv_1.type = LV_INDEV_TYPE_POINTER;

Expand Down
3 changes: 2 additions & 1 deletion src/main_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ void MainPanel::create_main(lv_obj_t * parent)

lv_obj_clear_flag(temp_cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_size(temp_cont, LV_PCT(50), LV_PCT(50));

lv_obj_set_style_pad_all(temp_cont, 0, 0);

lv_obj_set_flex_flow(temp_cont, LV_FLEX_FLOW_ROW_WRAP);
lv_obj_set_grid_cell(temp_cont, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 2);

Expand Down
7 changes: 5 additions & 2 deletions src/sensor_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ SensorContainer::SensorContainer(KWebSocketClient &c,
// cont_height = cont_height > 60 ? 60 : cont_height;

auto width_scale = (double)lv_disp_get_physical_hor_res(NULL) / 800.0;
lv_obj_set_size(sensor_cont, 330 * width_scale, 60 * width_scale);
auto height_scale = (double)lv_disp_get_physical_ver_res(NULL) / 480.0;
lv_obj_set_size(sensor_cont, 330 * width_scale, 60 * height_scale);
lv_obj_set_style_pad_all(sensor_cont, 0, 0);

lv_img_set_src(sensor_img, img);
lv_obj_align(sensor_img, LV_ALIGN_LEFT_MID, -25 * width_scale, 0);
lv_obj_align(sensor_img, LV_ALIGN_LEFT_MID, 0, 0);

lv_label_set_text(sensor_label, text);
lv_obj_align_to(sensor_label, sensor_img, LV_ALIGN_OUT_RIGHT_MID, -7 * width_scale, 0);
Expand Down

0 comments on commit fa1eb65

Please sign in to comment.