diff --git a/.github/workflows/compile.yaml b/.github/workflows/compile.yaml index 5cd4644..ab781aa 100644 --- a/.github/workflows/compile.yaml +++ b/.github/workflows/compile.yaml @@ -4,7 +4,7 @@ permissions: pages: write id-token: write -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: build: @@ -45,7 +45,7 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest needs: build - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' steps: - name: Print GitHub event name run: | diff --git a/CYD-Klipper/extract_commit.py b/CYD-Klipper/extract_commit.py new file mode 100644 index 0000000..106d4bb --- /dev/null +++ b/CYD-Klipper/extract_commit.py @@ -0,0 +1,23 @@ +import subprocess + +def extract_commit() -> tuple[str, str]: # Version, Commit + git_describe_output = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True, check=True).stdout.strip() + split_output = git_describe_output.split("-") + return split_output[0], split_output[2][1:] + +try: + data = extract_commit() + version = f"{data[0]}\\ ({data[1]})" +except: + version = "Unknown" + + +flag = "-D REPO_VERSION=\\\"" + version + "\\\"" +print(f"Version: {version}") +print(f"Flag: {flag}") + +Import("env") + +env.Append( + BUILD_FLAGS=[flag] +) \ No newline at end of file diff --git a/CYD-Klipper/platformio.ini b/CYD-Klipper/platformio.ini index e006454..5a6c0ed 100644 --- a/CYD-Klipper/platformio.ini +++ b/CYD-Klipper/platformio.ini @@ -20,6 +20,8 @@ lib_deps = monitor_filters = esp32_exception_decoder build_flags = -DLV_CONF_PATH="../../../../src/conf/lv_conf.h" +extra_scripts = + pre:extract_commit.py [env:esp32-2432S028R] board = esp32-2432S028R diff --git a/CYD-Klipper/src/ui/panels/settings_panel.cpp b/CYD-Klipper/src/ui/panels/settings_panel.cpp index acace5c..1486ff1 100644 --- a/CYD-Klipper/src/ui/panels/settings_panel.cpp +++ b/CYD-Klipper/src/ui/panels/settings_panel.cpp @@ -7,6 +7,10 @@ #include #include "../../core/lv_setup.h" +#ifndef REPO_VERSION + #define REPO_VERSION "Unknown" +#endif // REPO_VERSION + static void invert_color_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); @@ -85,9 +89,7 @@ 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_PX - CYD_SCREEN_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_PX); - +void create_settings_widget(const char* label_text, lv_obj_t* object, lv_obj_t* root_panel, bool set_height = true){ lv_obj_t * panel = lv_create_empty_panel(root_panel); lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX); @@ -98,6 +100,9 @@ void create_settings_widget(const char* label_text, lv_obj_t* object, lv_obj_t* lv_obj_set_parent(object, panel); lv_obj_align(object, LV_ALIGN_RIGHT_MID, 0, 0); + if (set_height) + lv_obj_set_height(object, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX); + lv_obj_t * line = lv_line_create(root_panel); lv_line_set_points(line, line_points, 2); lv_obj_set_style_line_width(line, 1, 0); @@ -204,4 +209,9 @@ void settings_panel_init(lv_obj_t* panel){ create_settings_widget("Screen On During Print", toggle, panel); #endif + + label = lv_label_create_ex(panel); + lv_label_set_text(label, REPO_VERSION " "); + + create_settings_widget("Version", label, panel, false); } \ No newline at end of file