mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Refaktor model option reading
This commit is contained in:
parent
5c211d7e34
commit
0db6bdea6f
@ -78,13 +78,13 @@
|
|||||||
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Sugar Valley Modbus Register (* register are currently used)
|
* Sugar Valley Modbus Register (addresses marked with * are queried with each polling cycle)
|
||||||
* (see https://downloads.vodnici.net/uploads/wpforo/attachments/69/171-Modbus-registers.pdf)
|
* (see https://downloads.vodnici.net/uploads/wpforo/attachments/69/171-Modbus-registers.pdf)
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
enum NeoPoolRegister {
|
enum NeoPoolRegister {
|
||||||
// addr Unit Description
|
// addr Unit Description
|
||||||
// ------ ------ ------------------------------------------------------------
|
// ------ ------ ------------------------------------------------------------
|
||||||
// MODBUS page (0x0000 - 0x002E - unknown - for internal use only)
|
// MODBUS page (0x00xx) - undocumented - for internal use
|
||||||
MBF_POWER_MODULE_VERSION = 0x0002, // 0x0002 undocumented - power module version (MSB=Major, LSB=Minor)
|
MBF_POWER_MODULE_VERSION = 0x0002, // 0x0002 undocumented - power module version (MSB=Major, LSB=Minor)
|
||||||
MBF_POWER_MODULE_NODEID = 0x0004, // 0x0004 undocumented - power module Node ID (6 register 0x0004 - 0x0009)
|
MBF_POWER_MODULE_NODEID = 0x0004, // 0x0004 undocumented - power module Node ID (6 register 0x0004 - 0x0009)
|
||||||
MBF_POWER_MODULE_REGISTER = 0x000C, // 0x000C undocumented - Writing an address in this register causes the power module register address to be read out into MBF_POWER_MODULE_DATA, see MBF_POWER_MODULE_REG_*
|
MBF_POWER_MODULE_REGISTER = 0x000C, // 0x000C undocumented - Writing an address in this register causes the power module register address to be read out into MBF_POWER_MODULE_DATA, see MBF_POWER_MODULE_REG_*
|
||||||
@ -595,6 +595,7 @@ bool neopool_first_read = true;
|
|||||||
#endif // NEOPOOL_OPTIMIZE_READINGS
|
#endif // NEOPOOL_OPTIMIZE_READINGS
|
||||||
bool neopool_error = true;
|
bool neopool_error = true;
|
||||||
|
|
||||||
|
uint16_t neopool_model_option;
|
||||||
uint16_t neopool_power_module_version;
|
uint16_t neopool_power_module_version;
|
||||||
uint16_t neopool_power_module_nodeid[6];
|
uint16_t neopool_power_module_nodeid[6];
|
||||||
|
|
||||||
@ -613,10 +614,9 @@ struct {
|
|||||||
const uint16_t cnt;
|
const uint16_t cnt;
|
||||||
uint16_t *data;
|
uint16_t *data;
|
||||||
} NeoPoolReg[] = {
|
} NeoPoolReg[] = {
|
||||||
// 8 entries each poll needs 2 sec for complete register set
|
// complete poll cycle needs 7x250 ms to read complete register set
|
||||||
{MBF_ION_CURRENT, MBF_NOTIFICATION - MBF_ION_CURRENT + 1, nullptr},
|
{MBF_ION_CURRENT, MBF_NOTIFICATION - MBF_ION_CURRENT + 1, nullptr},
|
||||||
{MBF_CELL_RUNTIME_LOW, MBF_CELL_RUNTIME_POL_CHANGES_HIGH - MBF_CELL_RUNTIME_LOW + 1, nullptr},
|
{MBF_CELL_RUNTIME_LOW, MBF_CELL_RUNTIME_POL_CHANGES_HIGH - MBF_CELL_RUNTIME_LOW + 1, nullptr},
|
||||||
{MBF_PAR_VERSION, MBF_PAR_MODEL - MBF_PAR_VERSION + 1, nullptr},
|
|
||||||
{MBF_PAR_TIME_LOW, MBF_PAR_FILT_GPIO - MBF_PAR_TIME_LOW + 1, nullptr},
|
{MBF_PAR_TIME_LOW, MBF_PAR_FILT_GPIO - MBF_PAR_TIME_LOW + 1, nullptr},
|
||||||
{MBF_PAR_ION, MBF_PAR_FILTRATION_CONF - MBF_PAR_ION + 1, nullptr},
|
{MBF_PAR_ION, MBF_PAR_FILTRATION_CONF - MBF_PAR_ION + 1, nullptr},
|
||||||
{MBF_PAR_UICFG_MACHINE, MBF_PAR_UICFG_MACH_VISUAL_STYLE - MBF_PAR_UICFG_MACHINE + 1, nullptr},
|
{MBF_PAR_UICFG_MACHINE, MBF_PAR_UICFG_MACH_VISUAL_STYLE - MBF_PAR_UICFG_MACHINE + 1, nullptr},
|
||||||
@ -981,7 +981,7 @@ void (* const NPCommand[])(void) PROGMEM = {
|
|||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
|
||||||
void NeoPool250ms(void) // Every 250 mSec
|
void NeoPoolPoll(void) // Every 250 mSec
|
||||||
{
|
{
|
||||||
if (!neopool_poll) {
|
if (!neopool_poll) {
|
||||||
return;
|
return;
|
||||||
@ -1098,6 +1098,7 @@ bool NeoPoolInitData(void)
|
|||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
neopool_error = true;
|
neopool_error = true;
|
||||||
|
neopool_model_option = 0xFFFF;
|
||||||
neopool_power_module_version = 0;
|
neopool_power_module_version = 0;
|
||||||
memset(neopool_power_module_nodeid, 0, sizeof(neopool_power_module_nodeid));
|
memset(neopool_power_module_nodeid, 0, sizeof(neopool_power_module_nodeid));
|
||||||
for (uint32_t i = 0; i < nitems(NeoPoolReg); i++) {
|
for (uint32_t i = 0; i < nitems(NeoPoolReg); i++) {
|
||||||
@ -1346,9 +1347,18 @@ uint32_t NeoPoolGetSpeedIndex(uint16_t speedvalue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t NeoPoolModelOption(void)
|
||||||
|
{
|
||||||
|
if (0xFFFF == neopool_model_option) {
|
||||||
|
neopool_model_option = NeoPoolGetData(MBF_PAR_MODEL);
|
||||||
|
}
|
||||||
|
return neopool_model_option;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NeoPoolIsHydrolysis(void)
|
bool NeoPoolIsHydrolysis(void)
|
||||||
{
|
{
|
||||||
return (((NeoPoolGetData(MBF_PAR_MODEL) & MBMSK_MODEL_HIDRO)) ||
|
return (((NeoPoolModelOption() & MBMSK_MODEL_HIDRO)) ||
|
||||||
(NeoPoolGetData(MBF_HIDRO_STATUS) & (MBMSK_HIDRO_STATUS_CTRL_ACTIVE | MBMSK_HIDRO_STATUS_CTRL_ACTIVE)));
|
(NeoPoolGetData(MBF_HIDRO_STATUS) & (MBMSK_HIDRO_STATUS_CTRL_ACTIVE | MBMSK_HIDRO_STATUS_CTRL_ACTIVE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1379,7 +1389,7 @@ bool NeoPoolIsConductivity(void)
|
|||||||
|
|
||||||
bool NeoPoolIsIonization(void)
|
bool NeoPoolIsIonization(void)
|
||||||
{
|
{
|
||||||
return (NeoPoolGetData(MBF_PAR_MODEL) & MBMSK_MODEL_ION);
|
return (NeoPoolModelOption() & MBMSK_MODEL_ION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2466,7 +2476,7 @@ bool Xsns83(uint8_t function)
|
|||||||
} else if (neopool_active) {
|
} else if (neopool_active) {
|
||||||
switch (function) {
|
switch (function) {
|
||||||
case FUNC_EVERY_250_MSECOND:
|
case FUNC_EVERY_250_MSECOND:
|
||||||
NeoPool250ms();
|
NeoPoolPoll();
|
||||||
break;
|
break;
|
||||||
case FUNC_COMMAND:
|
case FUNC_COMMAND:
|
||||||
result = DecodeCommand(kNPCommands, NPCommand);
|
result = DecodeCommand(kNPCommands, NPCommand);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user