/** * Check if the settings are valid and if not initialize them */ void WidgetSettingsClass::Init() { int magic_number = ReadInt(MAGIC_NUMBER_OFFSET); if (magic_number != MAGIC_NUMBER) { // init the settings WriteInt(MAGIC_NUMBER_OFFSET, MAGIC_NUMBER); SetStartAddress(1); SetEstaId(0x7a70); SetSerialNumber(DEFAULT_SERIAL_NUMBER); SetDeviceLabel(DEFAULT_LABEL, sizeof(DEFAULT_LABEL)); SetDevicePowerCycles(0); SaveSensorValue(0); SetPersonality(1); } else { m_start_address = ReadInt(START_ADDRESS_OFFSET); m_personality = EEPROM.read(DMX_PERSONALITY_VALUE); } IncrementDevicePowerCycles(); }
VOID CPokemonCodec::SetSexByte(BYTE bSexByte) { if(m_pPokemon == NULL || m_bEncoded) return; BYTE bShiny = GetIsShiny(); BYTE bPersonality = GetPersonality(); // the code is a bit slow, but it is easy to write SetChar((m_pPokemon->Header.dwChar & 0xFFFFFF00) + bSexByte); // the least significant byte indicates sex SetPersonality(bPersonality); if(bShiny) { SetID(GenShinyID()); } else { while(GetIsShiny()) { SetID(m_pPokemon->Header.dwID + 0x00010000); } } }