Fixes after testing.
This commit is contained in:
parent
47822bbdec
commit
cd33c35974
4 changed files with 92 additions and 16 deletions
|
@ -60,6 +60,7 @@ static void Playing__Interacting_Entry(StateMachineContext_T * context)
|
|||
Playing_Entry(context);
|
||||
srand(xTaskGetTickCount());
|
||||
}
|
||||
BLE_UpdateStatusPacket(STATE_PLAYING__INTERACTING);
|
||||
LOG("Entering the Interacting substate of the Playing state.");
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ static void Configuring_Entry(StateMachineContext_T *context)
|
|||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BEEP, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
}
|
||||
|
||||
|
||||
BLE_UpdateHelloPacket();
|
||||
|
||||
if (BLE_ScanAndAdvertise() != SYSTEMK_RESULT_SUCCESS)
|
||||
|
@ -81,7 +81,7 @@ static void Configuring_Entry(StateMachineContext_T *context)
|
|||
BLEConfigurationResponseTimer = xTimerCreateStatic(
|
||||
"BLEConfigResponse",
|
||||
xBLEConfigurationResponseTimerPeriod,
|
||||
pdTRUE,
|
||||
pdFALSE,
|
||||
(void *)0,
|
||||
BLEConfigurationResponseTimerCallback,
|
||||
&xBLEConfigurationResponseTimerBuffer);
|
||||
|
@ -105,6 +105,13 @@ static void Configuring_Do(StateMachineContext_T *context)
|
|||
{
|
||||
portBASE_TYPE xStatus;
|
||||
static KEvent_T Event;
|
||||
|
||||
// For the first hunderd milliseconds, keep updating the Hello packet, since on some platforms (PSoC6), one call is not enough.
|
||||
// TODO: Fix the Hello packet hack on PSoC6.
|
||||
if ((xTaskGetTickCount() - context->Time_At_State_Entry_In_Ticks) < (100 / portTICK_PERIOD_MS))
|
||||
{
|
||||
BLE_UpdateHelloPacket();
|
||||
}
|
||||
|
||||
xStatus = Receive_KEvent(&Event);
|
||||
|
||||
|
@ -278,11 +285,87 @@ static SystemKResult_T HandleParameterChangeRequest(BLE_ParameterKey_T key, uint
|
|||
{
|
||||
result = Set_Team_With_Audio_Feedback(team_ID);
|
||||
}
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
KLOG_INFO(KLOG_TAG, "Team set to %u over BLE.", team_ID);
|
||||
}
|
||||
}
|
||||
else if (key == BLE_PARAMETER_KEY_PLAYER_ID)
|
||||
{
|
||||
uint8_t player_ID = (uint8_t)value;
|
||||
result = Set_Player_With_Audio_Feedback(player_ID);
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
KLOG_INFO(KLOG_TAG, "Player set to %u over BLE.", player_ID);
|
||||
}
|
||||
}
|
||||
else if (key == BLE_PARAMETER_KEY_GAME_LENGTH)
|
||||
{
|
||||
result = SETTINGS_set_uint32_t(SYSTEMK_SETTING_T_GAME_LENGTH_in_ms, value);
|
||||
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BEEP, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
KLOG_INFO(KLOG_TAG, "Game length set to %lu ms over BLE.", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BONK, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
}
|
||||
}
|
||||
else if (key == BLE_PARAMETER_KEY_MAX_HEALTH)
|
||||
{
|
||||
uint8_t max_health = (uint8_t)value;
|
||||
Set_Max_Health(max_health);
|
||||
result = SETTINGS_set_uint8_t(SYSTEMK_SETTING_MAX_HEALTH, max_health);
|
||||
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BEEP, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
KLOG_INFO(KLOG_TAG, "Max health set to %u over BLE.", max_health);
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BONK, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
}
|
||||
}
|
||||
else if (key == BLE_PARAMETER_KEY_SECONDARY_COLOR)
|
||||
{
|
||||
result = SETTINGS_set_uint32_t(SYSTEMK_SETTING_SECONDARY_COLOR, value);
|
||||
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BEEP, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
KLOG_INFO(KLOG_TAG, "Secondary color set to %lu over BLE.", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BONK, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
}
|
||||
}
|
||||
else if (key == BLE_PARAMETER_KEY_SPECIAL_WEAPONS_ON_REENTRY)
|
||||
{
|
||||
uint8_t n_weapons_on_reentry = (uint8_t)value;
|
||||
Set_Available_Bombs(n_weapons_on_reentry);
|
||||
result = SETTINGS_set_uint8_t(SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY, n_weapons_on_reentry);
|
||||
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BEEP, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
KLOG_INFO(KLOG_TAG, "Number of special weapons granted on reentry set to %u over BLE.", n_weapons_on_reentry);
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_BONK, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -114,14 +114,4 @@ static void Initializing_Exit(StateMachineContext_T * context)
|
|||
uint8_t weapon_ID = NERF_LASER_STRIKE_BLASTER_ID;
|
||||
(void) SETTINGS_set_uint8_t(SYSTEMK_SETTING_WEAPONID, weapon_ID);
|
||||
(void) SETTINGS_Save();
|
||||
|
||||
//! \todo TEAM_PURPLE is always one-hit kill.
|
||||
uint8_t team_ID;
|
||||
(void) SETTINGS_get_uint8_t(SYSTEMK_SETTING_TEAMID, &team_ID);
|
||||
TeamID_t my_common_team_ID = Resolve_Common_Team_ID(team_ID);
|
||||
|
||||
if (my_common_team_ID == TEAM_PURPLE)
|
||||
{
|
||||
Set_Health(10);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue