Correct early requests

This commit is contained in:
destroyedlolo 2018-03-28 00:40:51 +02:00
parent f0ff69d8d1
commit 273fb764e8

View File

@ -47,15 +47,21 @@ void owRcv( OneWireSlave::ReceiveEvent evt, byte cmd ){
switch( evt ){
case OneWireSlave::RE_Reset:
state = DeviceState::WAIT4COMMAND;
#ifdef DEBUG
Serial.println(F("Reset"));
#endif
break;
case OneWireSlave::RE_Error:
state = DeviceState::WAIT4RESET;
#ifdef DEBUG
Serial.println(F("Error"));
#endif
break;
case OneWireSlave::RE_Byte:
switch( cmd ){
case OW_Cmd::START_CONVERSION:
// Do a new request only if enough time passed
if( millis() < conversionStartTime || millis() > conversionStartTime + 2000 ){
if( !millis() || millis() < conversionStartTime || millis() > conversionStartTime + 2000 ){
state = DeviceState::CONVERTING;
OWSlave.beginWriteBit(0, true); // send zeros as long as the conversion is not finished
}