Minor refactor

This commit is contained in:
Theo Arends 2019-10-18 12:03:01 +02:00
parent f8104cacdd
commit 531c38b231
1 changed files with 26 additions and 28 deletions

View File

@ -410,10 +410,9 @@ void solaxX1SnsInit(void)
protocolStatus.status = 0b00100000; // hasAddress
solaxX1Serial = new TasmotaSerial(pin[GPIO_SOLAXX1_RX], pin[GPIO_SOLAXX1_TX], 1);
if (solaxX1Serial->begin(SOLAXX1_SPEED))
{
if (solaxX1Serial->begin(SOLAXX1_SPEED)) {
if (solaxX1Serial->hardwareSerial()) { ClaimSerial(); }
}else {
} else {
energy_flg = ENERGY_NONE;
}
}
@ -503,17 +502,10 @@ bool Xnrg12(uint8_t function)
{
bool result = false;
switch (function)
{
switch (function) {
case FUNC_EVERY_250_MSECOND:
if (uptime > 4) { solaxX1250MSecond(); }
break;
case FUNC_INIT:
solaxX1SnsInit();
break;
case FUNC_PRE_INIT:
solaxX1DrvInit();
break;
case FUNC_JSON_APPEND:
solaxX1Show(1);
break;
@ -522,6 +514,12 @@ bool Xnrg12(uint8_t function)
solaxX1Show(0);
break;
#endif // USE_WEBSERVER
case FUNC_INIT:
solaxX1SnsInit();
break;
case FUNC_PRE_INIT:
solaxX1DrvInit();
break;
}
return result;
}