Skip to content

Commit

Permalink
minor refactoring for invert z icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
ballaswag committed Apr 15, 2024
1 parent c07d1c0 commit d6e93ee
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 36 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ ifdef EVDEV_CALIBRATE
DEFINES += -D EVDEV_CALIBRATE
endif

ifdef Z_PLUS_UPARROW
DEFINES += -D Z_PLUS_UPARROW
endif

# SIMULATION is enabled by default, need CROSS_COMPILE variable to do MIPS build
ifndef CROSS_COMPILE
DEFINES += -D LV_BUILD_TEST=0 -D SIMULATOR
Expand All @@ -107,7 +103,7 @@ libhv.a:

libspdlog.a:
@mkdir -p $(SPDLOG_DIR)/build
@cmake -B $(SPDLOG_DIR)/build -S $(SPDLOG_DIR)/
@cmake -B $(SPDLOG_DIR)/build -S $(SPDLOG_DIR)/ -DCMAKE_CXX_COMPILER=$(CXX)
$(MAKE) -C $(SPDLOG_DIR)/build -j$(nproc)

wpaclient:
Expand Down
3 changes: 0 additions & 3 deletions lv_touch_calibration/lv_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include "math.h"

#include <stdio.h>

#ifdef ESP_PLATFORM
#include "esp_log.h"
#endif
Expand Down Expand Up @@ -174,7 +172,6 @@ lv_point_t lv_tc_transform_point(lv_point_t point) {
}

if (disp->driver->rotated == LV_DISP_ROT_180) {
lv_coord_t tmp = transformedPoint.y;
transformedPoint.y = lv_disp_get_ver_res(NULL) - transformedPoint.y;
transformedPoint.x = lv_disp_get_hor_res(NULL) - transformedPoint.x;
}
Expand Down
12 changes: 4 additions & 8 deletions src/finetune_panel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "finetune_panel.h"
#include "state.h"
#include "spdlog/spdlog.h"
#include "config.h"

#include <algorithm>

Expand Down Expand Up @@ -88,8 +89,6 @@ FineTunePanel::FineTunePanel(KWebSocketClient &websocket_client, std::mutex &l)
lv_obj_set_grid_cell(back_btn.get_container(), LV_GRID_ALIGN_CENTER, 4, 1, LV_GRID_ALIGN_CENTER, 3, 1);

ws.register_notify_update(this);

conf = Config::get_instance();
}

FineTunePanel::~FineTunePanel() {
Expand Down Expand Up @@ -128,12 +127,9 @@ void FineTunePanel::foreground() {
}

//Set the Z axis buttons
v = conf->get_json("/z_plus_uparrow");
bool uparrow = false;
if (!v.is_null()) {
uparrow = v.template get<bool>();
}
if (uparrow) {
v = Config::get_instance()->get_json("/invert_z_icon");
bool inverted = !v.is_null() && v.template get<bool>();
if (inverted) {
// UP arrow
zup_btn.set_image(&z_farther);
zdown_btn.set_image(&z_closer);
Expand Down
2 changes: 0 additions & 2 deletions src/finetune_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "image_label.h"
#include "websocket_client.h"
#include "notify_consumer.h"
#include "config.h"

#include <mutex>

Expand Down Expand Up @@ -72,7 +71,6 @@ class FineTunePanel : public NotifyConsumer {
ImageLabel pa;
ImageLabel speed_factor;
ImageLabel flow_factor;
Config *conf;
};

#endif // __FINETINE_PANEL_H__
12 changes: 5 additions & 7 deletions src/homing_panel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "homing_panel.h"
#include "state.h"
#include "spdlog/spdlog.h"
#include "config.h"

static const float distances[] = {0.1, 0.5, 1, 5, 10, 25, 50};

Expand Down Expand Up @@ -143,13 +144,10 @@ void HomingPanel::foreground() {
}

//Set the Z axis buttons
conf = Config::get_instance();
v = conf->get_json("/z_plus_uparrow");
bool uparrow = false;
if (!v.is_null()) {
uparrow = v.template get<bool>();
}
if (uparrow) {

v = Config::get_instance()->get_json("/invert_z_icon");
bool inverted = !v.is_null() && v.template get<bool>();
if (inverted) {
// UP arrow
z_up_btn.set_image(&z_farther);
z_down_btn.set_image(&z_closer);
Expand Down
6 changes: 0 additions & 6 deletions src/homing_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "websocket_client.h"
#include "selector.h"
#include "notify_consumer.h"
#include "config.h"

#include <mutex>

Expand Down Expand Up @@ -46,11 +45,6 @@ class HomingPanel : public NotifyConsumer {
ButtonContainer motoroff_btn;
ButtonContainer back_btn;
Selector distance_selector;
Config *conf;

// lv_obj_t *selector_label;
// lv_obj_t *btnm;
// uint32_t selector_index;
};

#endif // __HOMING_PANEL_H__
10 changes: 5 additions & 5 deletions src/sysinfo_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ SysInfoPanel::SysInfoPanel()
// estop prompt
, estop_toggle_cont(lv_obj_create(left_cont))
, prompt_estop_toggle(lv_switch_create(estop_toggle_cont))
, back_btn(cont, &back, "Back", &SysInfoPanel::_handle_callback, this)

// Z axis icons
, z_icon_toggle_cont(lv_obj_create(left_cont))
, z_icon_toggle(lv_switch_create(z_icon_toggle_cont))

, back_btn(cont, &back, "Back", &SysInfoPanel::_handle_callback, this)
{
lv_obj_move_background(cont);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
Expand Down Expand Up @@ -152,11 +152,11 @@ SysInfoPanel::SysInfoPanel()
lv_obj_set_style_pad_all(z_icon_toggle_cont, 0, 0);

l = lv_label_create(z_icon_toggle_cont);
lv_label_set_text(l, "Z+ UP-arrow");
lv_label_set_text(l, "Invert Z Icon");
lv_obj_align(l, LV_ALIGN_LEFT_MID, 0, 0);
lv_obj_align(z_icon_toggle, LV_ALIGN_RIGHT_MID, 0, 0);

v = conf->get_json("/z_plus_uparrow");
v = conf->get_json("/invert_z_icon");
if (!v.is_null()) {
if (v.template get<bool>()) {
lv_obj_add_state(z_icon_toggle, LV_STATE_CHECKED);
Expand Down Expand Up @@ -241,8 +241,8 @@ void SysInfoPanel::handle_callback(lv_event_t *e)
}
}
else if (obj == z_icon_toggle) {
bool use_up = lv_obj_has_state(z_icon_toggle, LV_STATE_CHECKED);
conf->set<bool>("/z_plus_uparrow", use_up);
bool inverted = lv_obj_has_state(z_icon_toggle, LV_STATE_CHECKED);
conf->set<bool>("/invert_z_icon", inverted);
conf->save();
}
}
Expand Down

0 comments on commit d6e93ee

Please sign in to comment.