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 ){ switch( evt ){
case OneWireSlave::RE_Reset: case OneWireSlave::RE_Reset:
state = DeviceState::WAIT4COMMAND; state = DeviceState::WAIT4COMMAND;
#ifdef DEBUG
Serial.println(F("Reset"));
#endif
break; break;
case OneWireSlave::RE_Error: case OneWireSlave::RE_Error:
state = DeviceState::WAIT4RESET; state = DeviceState::WAIT4RESET;
#ifdef DEBUG
Serial.println(F("Error"));
#endif
break; break;
case OneWireSlave::RE_Byte: case OneWireSlave::RE_Byte:
switch( cmd ){ switch( cmd ){
case OW_Cmd::START_CONVERSION: case OW_Cmd::START_CONVERSION:
// Do a new request only if enough time passed // 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; state = DeviceState::CONVERTING;
OWSlave.beginWriteBit(0, true); // send zeros as long as the conversion is not finished OWSlave.beginWriteBit(0, true); // send zeros as long as the conversion is not finished
} }