Consistent static/value item macros

This commit is contained in:
Scott Lahteine
2020-08-23 00:12:03 -05:00
parent 34fb9c7071
commit bff0c68078
3 changed files with 45 additions and 35 deletions

View File

@@ -328,6 +328,20 @@ class MenuItem_bool : public MenuEditItemBase {
NEXT_ITEM(); \
}while(0)
// PSTRING_ITEM is like STATIC_ITEM but it takes
// two PSTRs with the style as the last parameter.
#define PSTRING_ITEM_P(PLABEL, PVAL, STYL) do{ \
constexpr int m = 20; \
char msg[m+1]; \
msg[0] = ':'; msg[1] = ' '; \
strncpy_P(msg+2, PSTR(PVAL), m-2); \
if (msg[m-1] & 0x80) msg[m-1] = '\0'; \
STATIC_ITEM_P(PLABEL, STYL, msg); \
}while(0)
#define PSTRING_ITEM(LABEL, V...) PSTRING_ITEM_P(GET_TEXT(LABEL), ##V)
#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P(GET_TEXT(LABEL), ##V)
#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_P(GET_TEXT(LABEL), ##V)