-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmacros.h
executable file
·43 lines (37 loc) · 1.53 KB
/
macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef MENU__TEXT_FIELD_MACROS_H
#define MENU__TEXT_FIELD_MACROS_H
#include "../_base/forEachMacros.h"
#include "../_base/helpersMacros.h"
#include "../_base/BaseChild.h"
#include "./TextField.h"
/////////////////////////////////////////////////////////////////////////////////////////////////
// MENU macros
// Will define TextField variables at PROGMEM
// Use as nested function at MENU macros
/////////////////////////////////////////////////////////////////////////////////////////////////
// Usage example:
// MENU(..., TEXT_FIELD(message, "Text: '", messageValue, "'"))
// ... - omited for example args for MENU macros (see MENU macros for details)
// Will define at PROGMEM:
// char messageTextBefore[] = "Text: '";
// char messageTextAfter[] = "'";
// Menu::BaseChild* messageBaseData = ...;
// Menu::TextFieldData messageTextFieldData = ...;
// Menu::TextField messageTextField = ...;
#define VAR_NAME_FOR_LIST__TEXT_FIELD(id, ...) &id##TextField,
#define CHILD_MACRO__TEXT_FIELD(id, textBefore, value, textAfter)\
const char id##TextBefore[] PROGMEM = textBefore;\
const char id##TextAfter[] PROGMEM = textAfter;\
\
const PROGMEM Menu::BaseData id##BaseData = {\
Menu::TYPE::TEXT_FIELD,\
id##TextBefore\
};\
const PROGMEM Menu::TextFieldData id##TextFieldData = {\
sizeof(value)/sizeof(char) - 1,\
value,\
id##TextAfter\
};\
Menu::TextField id##TextField(&id##BaseData, &id##TextFieldData);\
/////////////////////////////////////////////////////////////////////////////////////////////////
#endif