|
|
@ -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
|
|
|
|
} |
|
|
|
} |
|
|
|