From e9e5670d89657729d14537c6266ac40b83827ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= Date: Thu, 5 Oct 2023 17:04:22 +0200 Subject: [PATCH] Add type to MMU errors The type is meant to distinguish actual errors from warnings regular workflow dialogs. The three types added to the MMU yaml are meant to serve as examples. --- 04_MMU/error-codes.yaml | 3 +++ generate_buddy_headers.py | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/04_MMU/error-codes.yaml b/04_MMU/error-codes.yaml index 614628f..55db491 100644 --- a/04_MMU/error-codes.yaml +++ b/04_MMU/error-codes.yaml @@ -28,6 +28,7 @@ Errors: action: [Retry] id: "FINDA_DIDNT_TRIGGER" approved: true + type: WARNING - code: "04102" title: "FINDA FILAM. STUCK" @@ -114,6 +115,7 @@ Errors: action: [Continue,ResetMMU] id: "WARNING_TMC_PULLEY_TOO_HOT" approved: true + type: ERROR - code: "04211" title: "WARNING TMC TOO HOT" @@ -349,6 +351,7 @@ Errors: action: [Continue] id: "FILAMENT_EJECTED" approved: true + type: USER_ACTION - code: "04900" title: "UNKNOWN ERROR" diff --git a/generate_buddy_headers.py b/generate_buddy_headers.py index fa01d89..2fa642a 100644 --- a/generate_buddy_headers.py +++ b/generate_buddy_headers.py @@ -31,6 +31,12 @@ inline constexpr uint8_t ERR_MMU_CODE = {printer_code}; +enum class ErrType : uint8_t {{ + ERROR = 0, + WARNING, + USER_ACTION +}}; + enum class ErrCode : uint16_t {{ ERR_UNDEF = 0, {enum_items} @@ -43,6 +49,7 @@ // 16 bit ErrCode err_code; std::array buttons; + ErrType type; }}; }} // namespace MMU2 @@ -137,16 +144,21 @@ def generate_header_file(yaml_file_name, header_file_name, mmu, list, includes): if len(btns) == 2: btns.append("ButtonOperations::NoOperation") - btns_text = f",\n {{{', '.join(btns)}}}" + mmu_extra_text = f",\n {{{', '.join(btns)}}}" + + if "type" not in err: + err["type"] = "ERROR" + + mmu_extra_text += f",\n ErrType::{err['type']}" else: - btns_text = "" + mmu_extra_text = "" err_dict[err_code] = { "id": err_id, "code": err_code, "title": err["title"], "text": err["text"].replace("\n", "\\n"), - "btns": btns_text + "mmu_extra_text": mmu_extra_text } os.makedirs(header_file_name.parent, exist_ok=True) @@ -157,7 +169,7 @@ def generate_header_file(yaml_file_name, header_file_name, mmu, list, includes): {{ N_("{err['title']}"), N_("{err['text']}"), - ErrCode::{err['id']}{err['btns']} + ErrCode::{err['id']}{err['mmu_extra_text']} }}""" for err in err_dict.values()) include_items = "\n".join([f"#include <{item}>" for item in includes])