src/HapTouch.cpp
// enterGameState()
// See section 8.3 of BoosterPack User Guide (slaa616)
// Note that enterGameState returns 2 bytes instead of the usual 1 byte
enterGameState()
See section 8.3 of BoosterPack User Guide (slaa616)
Note that enterGameState returns 2 bytes instead of the usual 1 byte
enterGameState () See section 8 . 3 of BoosterPack User Guide ( slaa616 ) Note that enterGameState returns 2 bytes instead of the usual 1 byte
uint16_t HapTouch::enterGameState()
{
  uint8_t rc[2];
  int i = 0;
  char c;
  Wire.beginTransmission(_i2c_addr);
  Wire.write(CMD_ENTER_GAME_STATE);  
  Wire.requestFrom((uint8_t) _i2c_addr, (uint8_t) 2);  
  while (Wire.available() && (i < 2)) {
    c = Wire.read();
    if (c != 0x0c) { 
      rc[i] = c;
      i++;
    }
  }
  return (rc[1] << 8) | rc[0];
}
uint16_t HapTouch :: enterGameState ( ) { uint8_t rc [ 2 ] ; int i = 0 ; char c ; Wire . beginTransmission ( _i2c_addr ) ; Wire . write ( CMD_ENTER_GAME_STATE ) ; Wire . requestFrom ( ( uint8_t ) _i2c_addr , ( uint8_t ) 2 ) ; while ( Wire . available ( ) && ( i < 2 ) ) { c = Wire . read ( ) ; if ( c != 0x0c ) { rc [ i ] = c ; i ++ ; } } return ( rc [ 1 ] << 8 ) | rc [ 0 ] ; }
enterGameState()
See section 8.3 of BoosterPack User Guide (slaa616)
Note that enterGameState returns 2 bytes instead of the usual 1 byte
enterGameState () See section 8 . 3 of BoosterPack User Guide ( slaa616 ) Note that enterGameState returns 2 bytes instead of the usual 1 byte
// Command opcode // Get the Response Code // If we get WAIT_FOR_RESPONSE, then try again // Return code: // MSB is PlayerOneOrTwo // LSB is Response code