Improved logical switches
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <debug.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "switches.h"
|
||||
|
||||
namespace yaml_conv_220 {
|
||||
|
||||
#include "yaml_datastructs_funcs.cpp"
|
||||
|
||||
@@ -823,3 +823,66 @@ bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#define r_logicSw nullptr
|
||||
|
||||
static const struct YamlNode _ls_node_v1 = YAML_PADDING(10);
|
||||
static const struct YamlNode _ls_node_v2 = YAML_PADDING(16);
|
||||
|
||||
bool w_logicSw(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
yaml_writer_func wf, void* opaque)
|
||||
{
|
||||
data += bitoffs >> 3UL;
|
||||
data -= sizeof(LogicalSwitchData::func);
|
||||
|
||||
const char* str = nullptr;
|
||||
auto ls = reinterpret_cast<LogicalSwitchData*>(data);
|
||||
switch(lswFamily(ls->func)) {
|
||||
|
||||
case LS_FAMILY_BOOL:
|
||||
case LS_FAMILY_STICKY:
|
||||
if (!w_swtchSrc(&_ls_node_v1, ls->v1, wf, opaque)) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
if (!w_swtchSrc(&_ls_node_v2, ls->v2, wf, opaque)) return false;
|
||||
break;
|
||||
|
||||
case LS_FAMILY_EDGE:
|
||||
if (!w_swtchSrc(&_ls_node_v1, ls->v1, wf, opaque)) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
str = yaml_unsigned2str(lswTimerValue(ls->v2));
|
||||
if (!wf(opaque,str,strlen(str))) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
if (ls->v3 < 0) {
|
||||
if (!wf(opaque,"<",1)) return false;
|
||||
} else if(ls->v3 == 0) {
|
||||
if (!wf(opaque,"-",1)) return false;
|
||||
} else {
|
||||
str = yaml_unsigned2str(lswTimerValue(ls->v2 + ls->v3));
|
||||
}
|
||||
break;
|
||||
|
||||
case LS_FAMILY_COMP:
|
||||
if (!w_mixSrcRaw(nullptr, ls->v1, wf, opaque)) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
if (!w_mixSrcRaw(nullptr, ls->v2, wf, opaque)) return false;
|
||||
break;
|
||||
|
||||
case LS_FAMILY_TIMER:
|
||||
str = yaml_unsigned2str(lswTimerValue(ls->v1));
|
||||
if (!wf(opaque,str,strlen(str))) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
str = yaml_unsigned2str(lswTimerValue(ls->v2));
|
||||
if (!wf(opaque,str,strlen(str))) return false;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!w_mixSrcRaw(nullptr, ls->v1, wf, opaque)) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
// TODO?: ls->v1 <= MIXSRC_LAST_CH ? calc100toRESX(ls->v2) : ls->v2
|
||||
str = yaml_signed2str(ls->v2);
|
||||
if (!wf(opaque,str,strlen(str))) return false;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -522,12 +522,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -491,12 +491,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -491,12 +491,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -491,12 +491,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -491,12 +491,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -539,12 +539,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -66,6 +66,7 @@ const struct YamlIdStr enum_Functions[] = {
|
||||
{ FUNC_BACKLIGHT, "BACKLIGHT" },
|
||||
{ FUNC_SCREENSHOT, "SCREENSHOT" },
|
||||
{ FUNC_RACING_MODE, "RACING_MODE" },
|
||||
{ FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
const struct YamlIdStr enum_UartModes[] = {
|
||||
@@ -538,12 +539,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -491,12 +491,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -499,12 +499,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -538,12 +538,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -476,12 +476,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -486,12 +486,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -483,12 +483,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
@@ -487,12 +487,13 @@ static const struct YamlNode struct_signed_8[] = {
|
||||
static const struct YamlNode struct_LogicalSwitchData[] = {
|
||||
YAML_IDX,
|
||||
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
|
||||
YAML_SIGNED( "v1", 10 ),
|
||||
YAML_SIGNED( "v3", 10 ),
|
||||
YAML_CUSTOM("def",r_logicSw,w_logicSw),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_PADDING( 10 ),
|
||||
YAML_SIGNED_CUST( "andsw", 9, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_PADDING( 1 ),
|
||||
YAML_PADDING( 2 ),
|
||||
YAML_SIGNED( "v2", 16 ),
|
||||
YAML_PADDING( 16 ),
|
||||
YAML_UNSIGNED( "delay", 8 ),
|
||||
YAML_UNSIGNED( "duration", 8 ),
|
||||
YAML_END
|
||||
|
||||
Reference in New Issue
Block a user