mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
Refactor template
This commit is contained in:
parent
dbc9f16ffc
commit
e5a44e6326
@ -397,7 +397,8 @@ struct SYSCFG {
|
||||
uint16_t mcp230xx_int_timer; // 718
|
||||
uint8_t rgbwwTable[5]; // 71A
|
||||
uint8_t user_template_base; // 71F
|
||||
mytmplt user_template; // 720 29 bytes
|
||||
char user_template_name[15]; // 720 15 bytes
|
||||
mytmplt user_template; // 72F 14 bytes
|
||||
uint8_t novasds_startingoffset; // 73D
|
||||
uint8_t web_color[18][3]; // 73E
|
||||
uint16_t display_width; // 774
|
||||
|
@ -1098,9 +1098,10 @@ bool ValidModule(uint32_t index)
|
||||
String AnyModuleName(uint32_t index)
|
||||
{
|
||||
if (USER_MODULE == index) {
|
||||
return String(Settings.user_template.name);
|
||||
return String(Settings.user_template_name);
|
||||
} else {
|
||||
return FPSTR(kModules[index].name);
|
||||
char name[15];
|
||||
return String(GetTextIndexed(name, sizeof(name), index, kModuleNames));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1153,6 +1154,7 @@ void ModuleDefault(uint32_t module)
|
||||
{
|
||||
if (USER_MODULE == module) { module = WEMOS; } // Generic
|
||||
Settings.user_template_base = module;
|
||||
GetTextIndexed(Settings.user_template_name, sizeof(Settings.user_template_name), module, kModuleNames);
|
||||
memcpy_P(&Settings.user_template, &kModules[module], sizeof(mytmplt));
|
||||
}
|
||||
|
||||
@ -1268,7 +1270,7 @@ bool JsonTemplate(const char* dataBuf)
|
||||
// All parameters are optional allowing for partial changes
|
||||
const char* name = obj[D_JSON_NAME];
|
||||
if (name != nullptr) {
|
||||
strlcpy(Settings.user_template.name, name, sizeof(Settings.user_template.name));
|
||||
strlcpy(Settings.user_template_name, name, sizeof(Settings.user_template_name));
|
||||
}
|
||||
if (obj[D_JSON_GPIO].success()) {
|
||||
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
|
||||
@ -1289,7 +1291,7 @@ bool JsonTemplate(const char* dataBuf)
|
||||
|
||||
void TemplateJson(void)
|
||||
{
|
||||
Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), Settings.user_template.name);
|
||||
Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), Settings.user_template_name);
|
||||
for (uint32_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
|
||||
ResponseAppend_P(PSTR("%s%d"), (i>0)?",":"", Settings.user_template.gp.io[i]);
|
||||
}
|
||||
|
@ -1064,7 +1064,7 @@ void CmndTemplate(void)
|
||||
if (Settings.module != USER_MODULE) {
|
||||
ModuleDefault(Settings.module);
|
||||
}
|
||||
snprintf_P(Settings.user_template.name, sizeof(Settings.user_template.name), PSTR("Merged"));
|
||||
snprintf_P(Settings.user_template_name, sizeof(Settings.user_template_name), PSTR("Merged"));
|
||||
uint32_t j = 0;
|
||||
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
|
||||
if (6 == i) { j = 9; }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1494,7 +1494,7 @@ void HandleTemplateConfiguration(void)
|
||||
|
||||
void TemplateSaveSettings(void)
|
||||
{
|
||||
char tmp[sizeof(Settings.user_template.name)]; // WebGetArg NAME and GPIO/BASE/FLAG byte value
|
||||
char tmp[sizeof(Settings.user_template_name)]; // WebGetArg NAME and GPIO/BASE/FLAG byte value
|
||||
char webindex[5]; // WebGetArg name
|
||||
char svalue[128]; // Template command string
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user