Skip to content

Commit

Permalink
Add type to MMU errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lukash committed Oct 10, 2023
1 parent 208b066 commit e9e5670
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions 04_MMU/error-codes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Errors:
action: [Retry]
id: "FINDA_DIDNT_TRIGGER"
approved: true
type: WARNING

- code: "04102"
title: "FINDA FILAM. STUCK"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -349,6 +351,7 @@ Errors:
action: [Continue]
id: "FILAMENT_EJECTED"
approved: true
type: USER_ACTION

- code: "04900"
title: "UNKNOWN ERROR"
Expand Down
20 changes: 16 additions & 4 deletions generate_buddy_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -43,6 +49,7 @@
// 16 bit
ErrCode err_code;
std::array<ButtonOperations, 3> buttons;
ErrType type;
}};
}} // namespace MMU2
Expand Down Expand Up @@ -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)
Expand All @@ -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])
Expand Down

0 comments on commit e9e5670

Please sign in to comment.