LifeCycle.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: Beerware
2 /**
3  * @file LifeCycle.c
4  * @brief Life cycle handler
5  * @author Michael Fitzmayer
6  * @copyright "THE BEER-WARE LICENCE" (Revision 42)
7  */
8 
9 #include <stdbool.h>
10 #include "LifeCycle.h"
11 
12 static void _LifeCycleThread(void* pArg);
13 
14 /**
15  * @struct LifeCycleData
16  * @brief Life cycle handler data
17  */
18 typedef struct
19 {
20  Stats stStats; ///< Statistics
21 
23 
24 /**
25  * @var _stLifeCycle
26  * @brief Life cycle handler private data
27  */
28 static LifeCycleData _stLifeCycle = { 0 };
29 
30 /**
31  * @brief Initialise life cycle
32  */
33 void LifeCycle_Init(void)
34 {
36 }
37 
38 /**
39  * @brief Get pet statistics
40  * @return Pointer to stats
41  */
43 {
44  return &_stLifeCycle.stStats;
45 }
46 
47 /**
48  * @brief Check if status flag is set
49  * @param eFlag
50  * Status flag
51  * @return Flag state
52  * @retval true: Status flag is set
53  * @retval false: Status flag is not set
54  */
56 {
57  if ((_stLifeCycle.stStats.u16Flags >> eFlag) & 1)
58  {
59  return true;
60  }
61  else
62  {
63  return false;
64  }
65 }
66 
67 /**
68  * @brief Clear status flag
69  * @param eFlag
70  * Status flag
71  */
73 {
74  _stLifeCycle.stStats.u16Flags &= ~(1 << eFlag);
75 }
76 
77 /**
78  * @brief Set status flag
79  * @param eFlag
80  * Status flag
81  */
83 {
84  _stLifeCycle.stStats.u16Flags |= 1 << eFlag;
85 }
Life cycle handler data.
Definition: LifeCycle.c:18
Tamago life cycle handler.
Stats stStats
Statistics.
Definition: LifeCycle.c:20
void LifeCycle_SetFlag(StatusFlag eFlag)
Set status flag.
Definition: LifeCycle.c:82
bool LifeCycle_IsFlagSet(StatusFlag eFlag)
Check if status flag is set.
Definition: LifeCycle.c:55
void LifeCycle_ClearFlat(StatusFlag eFlag)
Clear status flag.
Definition: LifeCycle.c:72
uint16_t u16Flags
Status flags (bit-field)
Definition: LifeCycle.h:50
static LifeCycleData _stLifeCycle
Life cycle handler private data.
Definition: LifeCycle.c:28
StatusFlag
Status flags.
Definition: LifeCycle.h:35
Stats * LifeCycle_GetStats(void)
Get pet statistics.
Definition: LifeCycle.c:42
@ EGG
Egg.
Definition: LifeCycle.h:16
Pet statistics.
Definition: LifeCycle.h:48
void LifeCycle_Init(void)
Initialise life cycle.
Definition: LifeCycle.c:33
Evolution eEvolution
Current evolution.
Definition: LifeCycle.h:52