Minor refactor

This commit is contained in:
Theo Arends 2019-10-18 12:03:01 +02:00
parent f8104cacdd
commit 531c38b231

View File

@ -410,10 +410,9 @@ void solaxX1SnsInit(void)
protocolStatus.status = 0b00100000; // hasAddress protocolStatus.status = 0b00100000; // hasAddress
solaxX1Serial = new TasmotaSerial(pin[GPIO_SOLAXX1_RX], pin[GPIO_SOLAXX1_TX], 1); 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(); } if (solaxX1Serial->hardwareSerial()) { ClaimSerial(); }
}else { } else {
energy_flg = ENERGY_NONE; energy_flg = ENERGY_NONE;
} }
} }
@ -503,26 +502,25 @@ bool Xnrg12(uint8_t function)
{ {
bool result = false; bool result = false;
switch (function) switch (function) {
{ case FUNC_EVERY_250_MSECOND:
case FUNC_EVERY_250_MSECOND: if (uptime > 4) { solaxX1250MSecond(); }
if (uptime > 4) { solaxX1250MSecond(); } break;
break; case FUNC_JSON_APPEND:
case FUNC_INIT: solaxX1Show(1);
solaxX1SnsInit(); break;
break;
case FUNC_PRE_INIT:
solaxX1DrvInit();
break;
case FUNC_JSON_APPEND:
solaxX1Show(1);
break;
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR: case FUNC_WEB_SENSOR:
solaxX1Show(0); solaxX1Show(0);
break; break;
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
} case FUNC_INIT:
solaxX1SnsInit();
break;
case FUNC_PRE_INIT:
solaxX1DrvInit();
break;
}
return result; return result;
} }