Reworked BLE according to v0.11 of the KTag Beacon Specification (#2)
This was done to support the new KTag Konfigurator app, which Jack created for his Senior Design project. Co-authored-by: Joe Kearney <joe@clubk.club> Reviewed-on: #2
This commit is contained in:
parent
4fe072f2d3
commit
bfcdf4c354
26 changed files with 917 additions and 128 deletions
|
@ -23,7 +23,8 @@
|
|||
|
||||
KTag_Game_Data_T KTAG_Game_Data =
|
||||
{
|
||||
.My_Health = MAX_HEALTH,
|
||||
.My_Health = 0,
|
||||
.Max_Health = 0,
|
||||
.My_Weapon = TEST_PATTERN_ID,
|
||||
.My_Shield_Strength = 100,
|
||||
.Time_Remaining_in_Game_in_ms = UINT32_MAX,
|
||||
|
|
66
Game/Game.h
66
Game/Game.h
|
@ -24,8 +24,6 @@
|
|||
|
||||
#include "Weapons.h"
|
||||
|
||||
#define MAX_HEALTH 10
|
||||
|
||||
//! Implemented according to the 2024-07-20 "KTag Teams Compatibility Matrix".
|
||||
typedef enum
|
||||
{
|
||||
|
@ -44,6 +42,18 @@ typedef enum
|
|||
MAXIMUM_TEAM_ID = 7
|
||||
} TeamID_t;
|
||||
|
||||
inline bool Is_Valid_Team_ID(uint8_t team_ID)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (team_ID <= MAXIMUM_TEAM_ID)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline SystemKResult_T Set_Team_With_Audio_Feedback(uint8_t team_ID)
|
||||
{
|
||||
static uint8_t Team_ID = 0; // This is static because AUDIO_PRONOUNCE_NUMBER_0_TO_100 needs a *pointer*.
|
||||
|
@ -77,6 +87,27 @@ __attribute__((always_inline)) inline TeamID_t Resolve_Common_Team_ID(uint8_t te
|
|||
return (team_ID & COMMON_TEAM_ID_MASK);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline SystemKResult_T Set_Player_With_Audio_Feedback(uint8_t player_ID)
|
||||
{
|
||||
static uint8_t Player_ID = 0; // This is static because AUDIO_PRONOUNCE_NUMBER_0_TO_100 needs a *pointer*.
|
||||
SystemKResult_T result = SYSTEMK_RESULT_SUCCESS;
|
||||
|
||||
Player_ID = player_ID;
|
||||
|
||||
result = SETTINGS_set_uint8_t(SYSTEMK_SETTING_PLAYERID, Player_ID);
|
||||
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
AudioAction_T audio_action = {.ID = AUDIO_PLAY_PLAYER_ID_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
|
||||
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&Player_ID};
|
||||
Perform_Audio_Action(&volume_action);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) inline bool Team_Can_Tag_Me(uint8_t tagging_team_ID)
|
||||
{
|
||||
bool can_tag = false;
|
||||
|
@ -104,6 +135,7 @@ typedef struct
|
|||
uint8_t My_Health;
|
||||
WeaponID_t My_Weapon;
|
||||
uint8_t My_Shield_Strength;
|
||||
uint8_t Max_Health;
|
||||
uint32_t Time_Remaining_in_Game_in_ms;
|
||||
uint32_t Time_Remaining_Until_Countdown_in_ms;
|
||||
uint16_t Shots_Fired;
|
||||
|
@ -130,6 +162,36 @@ __attribute__((always_inline)) inline void Set_Health(uint8_t health)
|
|||
}
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) inline uint8_t Get_Max_Health()
|
||||
{
|
||||
if (KTAG_Game_Data.Max_Health == 0)
|
||||
{
|
||||
// Initialize from settings.
|
||||
uint8_t max_health;
|
||||
if (SETTINGS_get_uint8_t(SYSTEMK_SETTING_MAX_HEALTH, &max_health) == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
KTAG_Game_Data.Max_Health = max_health;
|
||||
}
|
||||
else
|
||||
{
|
||||
KTAG_Game_Data.Max_Health = 100;
|
||||
}
|
||||
}
|
||||
|
||||
return KTAG_Game_Data.Max_Health;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) inline void Set_Max_Health(uint8_t health)
|
||||
{
|
||||
KTAG_Game_Data.Max_Health = health;
|
||||
|
||||
// Limit current health to max health.
|
||||
if (KTAG_Game_Data.My_Health > health)
|
||||
{
|
||||
KTAG_Game_Data.My_Health = health;
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) inline void Reduce_Health(uint8_t reduction)
|
||||
{
|
||||
if (reduction < KTAG_Game_Data.My_Health)
|
||||
|
|
|
@ -158,7 +158,7 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
|||
|
||||
// The Dubuque Protocol
|
||||
{
|
||||
.ID = LASER_X_ID,
|
||||
.ID = DUBUQUE_PROTOCOL_ID,
|
||||
.Type = ENERGY,
|
||||
.Protocol = DUBUQUE_PROTOCOL,
|
||||
.Damage_Per_Shot = 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue