SystemK v1.00 #9
5 changed files with 59 additions and 51 deletions
|
|
@ -32,55 +32,57 @@
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
KEVENT_NO_EVENT = 0,
|
KEVENT_NO_EVENT = 0,
|
||||||
KEVENT_AUTOMATIC_TRANSITION = 1,
|
//! For #KEVENT_UNSUCCESSFUL_SYSTEMK_RESULT, #KEvent_T::Data contains a #SystemKResult_T indicating the nature of the failure.
|
||||||
KEVENT_CAPSENSE_ONE_PRESSED = 2,
|
KEVENT_UNSUCCESSFUL_SYSTEMK_RESULT = 1,
|
||||||
KEVENT_CAPSENSE_ONE_RELEASED = 3,
|
KEVENT_AUTOMATIC_TRANSITION = 2,
|
||||||
KEVENT_CAPSENSE_TWO_PRESSED = 4,
|
KEVENT_CAPSENSE_ONE_PRESSED = 3,
|
||||||
KEVENT_CAPSENSE_TWO_RELEASED = 5,
|
KEVENT_CAPSENSE_ONE_RELEASED = 4,
|
||||||
KEVENT_TRIGGER_SWITCH_PRESSED = 6,
|
KEVENT_CAPSENSE_TWO_PRESSED = 5,
|
||||||
|
KEVENT_CAPSENSE_TWO_RELEASED = 6,
|
||||||
|
KEVENT_TRIGGER_SWITCH_PRESSED = 7,
|
||||||
KEVENT_CENTER_SWITCH_PRESSED = KEVENT_TRIGGER_SWITCH_PRESSED,
|
KEVENT_CENTER_SWITCH_PRESSED = KEVENT_TRIGGER_SWITCH_PRESSED,
|
||||||
KEVENT_TRIGGER_SWITCH_RELEASED = 7,
|
KEVENT_TRIGGER_SWITCH_RELEASED = 8,
|
||||||
//! For #KEVENT_CENTER_SWITCH_RELEASED, #KEvent_T::Data contains the duration of the press in milliseconds.
|
//! For #KEVENT_CENTER_SWITCH_RELEASED, #KEvent_T::Data contains the duration of the press in milliseconds.
|
||||||
KEVENT_CENTER_SWITCH_RELEASED = KEVENT_TRIGGER_SWITCH_RELEASED,
|
KEVENT_CENTER_SWITCH_RELEASED = KEVENT_TRIGGER_SWITCH_RELEASED,
|
||||||
KEVENT_UP_SWITCH_PRESSED = 8,
|
KEVENT_UP_SWITCH_PRESSED = 9,
|
||||||
KEVENT_UP_SWITCH_LONG_PRESSED = 9,
|
KEVENT_UP_SWITCH_LONG_PRESSED = 10,
|
||||||
KEVENT_UP_SWITCH_RELEASED = 10,
|
KEVENT_UP_SWITCH_RELEASED = 11,
|
||||||
KEVENT_DOWN_SWITCH_PRESSED = 11,
|
KEVENT_DOWN_SWITCH_PRESSED = 12,
|
||||||
KEVENT_DOWN_SWITCH_LONG_PRESSED = 12,
|
KEVENT_DOWN_SWITCH_LONG_PRESSED = 13,
|
||||||
KEVENT_DOWN_SWITCH_RELEASED = 13,
|
KEVENT_DOWN_SWITCH_RELEASED = 14,
|
||||||
KEVENT_FORWARD_SWITCH_PRESSED = 14,
|
KEVENT_FORWARD_SWITCH_PRESSED = 15,
|
||||||
KEVENT_FORWARD_SWITCH_LONG_PRESSED = 15,
|
KEVENT_FORWARD_SWITCH_LONG_PRESSED = 16,
|
||||||
KEVENT_FORWARD_SWITCH_RELEASED = 16,
|
KEVENT_FORWARD_SWITCH_RELEASED = 17,
|
||||||
KEVENT_BACKWARD_SWITCH_PRESSED = 17,
|
KEVENT_BACKWARD_SWITCH_PRESSED = 18,
|
||||||
KEVENT_BACKWARD_SWITCH_LONG_PRESSED = 18,
|
KEVENT_BACKWARD_SWITCH_LONG_PRESSED = 19,
|
||||||
KEVENT_BACKWARD_SWITCH_RELEASED = 19,
|
KEVENT_BACKWARD_SWITCH_RELEASED = 20,
|
||||||
KEVENT_TAG_SENT = 20,
|
KEVENT_TAG_SENT = 21,
|
||||||
//! For #KEVENT_TAG_RECEIVED, #KEvent_T::Data points to #TagPacket_T.
|
//! For #KEVENT_TAG_RECEIVED, #KEvent_T::Data points to #TagPacket_T.
|
||||||
KEVENT_TAG_RECEIVED = 21,
|
KEVENT_TAG_RECEIVED = 22,
|
||||||
KEVENT_TAGGED_OUT = 22,
|
KEVENT_TAGGED_OUT = 23,
|
||||||
KEVENT_MISFIRE = 23,
|
KEVENT_MISFIRE = 24,
|
||||||
KEVENT_NEAR_MISS = 24,
|
KEVENT_NEAR_MISS = 25,
|
||||||
//! For #KEVENT_BLE_PACKET_RECEIVED, #KEvent_T::Data points to #COMM_BLE_Packet_T.
|
//! For #KEVENT_BLE_PACKET_RECEIVED, #KEvent_T::Data points to #COMM_BLE_Packet_T.
|
||||||
KEVENT_BLE_PACKET_RECEIVED = 25,
|
KEVENT_BLE_PACKET_RECEIVED = 26,
|
||||||
//! For #KEVENT_COMMAND_RECEIVED, #KEvent_T::Data points to #CommandPacket_T.
|
//! For #KEVENT_COMMAND_RECEIVED, #KEvent_T::Data points to #CommandPacket_T.
|
||||||
KEVENT_COMMAND_RECEIVED = 26,
|
KEVENT_COMMAND_RECEIVED = 27,
|
||||||
KEVENT_MENU_ENTER = 27,
|
KEVENT_MENU_ENTER = 28,
|
||||||
KEVENT_MENU_SELECT = 28,
|
KEVENT_MENU_SELECT = 29,
|
||||||
KEVENT_MENU_BACK = 29,
|
KEVENT_MENU_BACK = 30,
|
||||||
KEVENT_MENU_UP = 30,
|
KEVENT_MENU_UP = 31,
|
||||||
KEVENT_MENU_DOWN = 31,
|
KEVENT_MENU_DOWN = 32,
|
||||||
KEVENT_MENU_EXIT = 32,
|
KEVENT_MENU_EXIT = 33,
|
||||||
KEVENT_REPROGRAM = 33,
|
KEVENT_REPROGRAM = 34,
|
||||||
//! For #KEVENT_ACCESSORY_SWITCH_PRESSED, #KEvent_T::Data contains the duration the switch has not been pressed in milliseconds.
|
//! For #KEVENT_ACCESSORY_SWITCH_PRESSED, #KEvent_T::Data contains the duration the switch has not been pressed in milliseconds.
|
||||||
KEVENT_ACCESSORY_SWITCH_PRESSED = 34,
|
KEVENT_ACCESSORY_SWITCH_PRESSED = 35,
|
||||||
//! For #KEVENT_ACCESSORY_SWITCH_PRESSED, #KEvent_T::Data contains the duration of the press in milliseconds.
|
//! For #KEVENT_ACCESSORY_SWITCH_PRESSED, #KEvent_T::Data contains the duration of the press in milliseconds.
|
||||||
KEVENT_ACCESSORY_SWITCH_RELEASED = 35,
|
KEVENT_ACCESSORY_SWITCH_RELEASED = 36,
|
||||||
//! For #KEVENT_AUDIO_COMPLETED, #KEvent_T::Data contains the AudioActionID_T of the completed action.
|
//! For #KEVENT_AUDIO_COMPLETED, #KEvent_T::Data contains the AudioActionID_T of the completed action.
|
||||||
KEVENT_AUDIO_COMPLETED = 36,
|
KEVENT_AUDIO_COMPLETED = 37,
|
||||||
KEVENT_GAME_OVER = 37,
|
KEVENT_GAME_OVER = 38,
|
||||||
KEVENT_PLAY_PRESSED_ON_REMOTE = 38,
|
KEVENT_PLAY_PRESSED_ON_REMOTE = 39,
|
||||||
//! For #KEVENT_BLE_EVENT_RECEIVED, #KEvent_T::Data contains the BLE_EventID_T of the received event.
|
//! For #KEVENT_BLE_EVENT_RECEIVED, #KEvent_T::Data contains the BLE_EventID_T of the received event.
|
||||||
KEVENT_BLE_EVENT_RECEIVED = 39,
|
KEVENT_BLE_EVENT_RECEIVED = 40,
|
||||||
// KEVENT_IS_OUT_OF_RANGE is one more than the last valid event.
|
// KEVENT_IS_OUT_OF_RANGE is one more than the last valid event.
|
||||||
KEVENT_IS_OUT_OF_RANGE
|
KEVENT_IS_OUT_OF_RANGE
|
||||||
} KEvent_ID_T;
|
} KEvent_ID_T;
|
||||||
|
|
@ -95,7 +97,7 @@ typedef struct
|
||||||
void *Data;
|
void *Data;
|
||||||
} KEvent_T;
|
} KEvent_T;
|
||||||
|
|
||||||
// Verify the pointer size, since sometime we store uint32_t's in the KEvent_T::Data pointer.
|
// Verify the pointer size, since sometimes we store uint32_t's in the KEvent_T::Data pointer.
|
||||||
_Static_assert(sizeof(uintptr_t) >= sizeof(uint32_t), "Pointer size is less than 32 bits! KEvents will not work properly on this system.");
|
_Static_assert(sizeof(uintptr_t) >= sizeof(uint32_t), "Pointer size is less than 32 bits! KEvents will not work properly on this system.");
|
||||||
|
|
||||||
void Init_KEvents(void);
|
void Init_KEvents(void);
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,11 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
||||||
.Time_To_Reload_in_ms = 0
|
.Time_To_Reload_in_ms = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
// Bayonette
|
// Bayonet
|
||||||
{
|
{
|
||||||
.ID = BAYONETTE_ID,
|
.ID = BAYONET_ID,
|
||||||
.Type = EDGE,
|
.Type = EDGE,
|
||||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
.Protocol = DUBUQUE_PROTOCOL,
|
||||||
.Damage_Per_Shot = 1,
|
.Damage_Per_Shot = 1,
|
||||||
.Shots_Per_Reload = UINT16_MAX,
|
.Shots_Per_Reload = UINT16_MAX,
|
||||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||||
|
|
@ -52,7 +52,7 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
||||||
{
|
{
|
||||||
.ID = PISTOL_ID,
|
.ID = PISTOL_ID,
|
||||||
.Type = PROJECTILE,
|
.Type = PROJECTILE,
|
||||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
.Protocol = DUBUQUE_PROTOCOL,
|
||||||
.Damage_Per_Shot = 10,
|
.Damage_Per_Shot = 10,
|
||||||
.Shots_Per_Reload = 8,
|
.Shots_Per_Reload = 8,
|
||||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||||
|
|
@ -64,7 +64,7 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
||||||
{
|
{
|
||||||
.ID = SHOTGUN_ID,
|
.ID = SHOTGUN_ID,
|
||||||
.Type = PROJECTILE,
|
.Type = PROJECTILE,
|
||||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
.Protocol = DUBUQUE_PROTOCOL,
|
||||||
.Damage_Per_Shot = 20,
|
.Damage_Per_Shot = 20,
|
||||||
.Shots_Per_Reload = 2,
|
.Shots_Per_Reload = 2,
|
||||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||||
|
|
@ -76,7 +76,7 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
||||||
{
|
{
|
||||||
.ID = RIFLE_ID,
|
.ID = RIFLE_ID,
|
||||||
.Type = PROJECTILE,
|
.Type = PROJECTILE,
|
||||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
.Protocol = DUBUQUE_PROTOCOL,
|
||||||
.Damage_Per_Shot = 10,
|
.Damage_Per_Shot = 10,
|
||||||
.Shots_Per_Reload = 8,
|
.Shots_Per_Reload = 8,
|
||||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||||
|
|
@ -88,11 +88,11 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
||||||
{
|
{
|
||||||
.ID = MACHINE_GUN_ID,
|
.ID = MACHINE_GUN_ID,
|
||||||
.Type = PROJECTILE,
|
.Type = PROJECTILE,
|
||||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
.Protocol = DUBUQUE_PROTOCOL,
|
||||||
.Damage_Per_Shot = 10,
|
.Damage_Per_Shot = 10,
|
||||||
.Shots_Per_Reload = 250,
|
.Shots_Per_Reload = 250,
|
||||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||||
.Time_Between_Shots_in_ms = 0,
|
.Time_Between_Shots_in_ms = 100,
|
||||||
.Time_To_Reload_in_ms = 2*60*1000
|
.Time_To_Reload_in_ms = 2*60*1000
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
TEST_PATTERN_ID = 0,
|
TEST_PATTERN_ID = 0,
|
||||||
BAYONETTE_ID = 1,
|
BAYONET_ID = 1,
|
||||||
PISTOL_ID = 2,
|
PISTOL_ID = 2,
|
||||||
SHOTGUN_ID = 3,
|
SHOTGUN_ID = 3,
|
||||||
RIFLE_ID = 4,
|
RIFLE_ID = 4,
|
||||||
|
|
@ -68,7 +68,7 @@ extern Weapon_t WeaponsByID[NUMBER_OF_WEAPONS];
|
||||||
|
|
||||||
__attribute__((always_inline)) inline Weapon_t GetWeaponFromID(WeaponID_t id)
|
__attribute__((always_inline)) inline Weapon_t GetWeaponFromID(WeaponID_t id)
|
||||||
{
|
{
|
||||||
Weapon_t result = WeaponsByID[TEST_PATTERN_ID];
|
Weapon_t result = WeaponsByID[DUBUQUE_PROTOCOL_ID];
|
||||||
|
|
||||||
if (id < NUMBER_OF_WEAPONS)
|
if (id < NUMBER_OF_WEAPONS)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ typedef enum
|
||||||
SYSTEMK_RESULT_FAILED_TO_CREATE_RTOS_TASK,
|
SYSTEMK_RESULT_FAILED_TO_CREATE_RTOS_TASK,
|
||||||
SYSTEMK_RESULT_FAILED_TO_CREATE_RTOS_TIMER,
|
SYSTEMK_RESULT_FAILED_TO_CREATE_RTOS_TIMER,
|
||||||
SYSTEMK_RESULT_FAILED_TO_START_RTOS_TIMER,
|
SYSTEMK_RESULT_FAILED_TO_START_RTOS_TIMER,
|
||||||
|
SYSTEMK_RESULT_FILESYSTEM_NOT_PRESENT,
|
||||||
SYSTEMK_RESULT_FILE_NOT_FOUND,
|
SYSTEMK_RESULT_FILE_NOT_FOUND,
|
||||||
SYSTEMK_RESULT_KEY_NOT_FOUND,
|
SYSTEMK_RESULT_KEY_NOT_FOUND,
|
||||||
SYSTEMK_RESULT_READ_FAILED,
|
SYSTEMK_RESULT_READ_FAILED,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,9 @@ static void Initializing_Entry(StateMachineContext_T * context);
|
||||||
static void Initializing_Do(StateMachineContext_T * context);
|
static void Initializing_Do(StateMachineContext_T * context);
|
||||||
static void Initializing_Exit(StateMachineContext_T * context);
|
static void Initializing_Exit(StateMachineContext_T * context);
|
||||||
|
|
||||||
|
#ifdef PSOC_PLATFORM
|
||||||
static const char *KLOG_TAG = "STATE_INITIALIZING";
|
static const char *KLOG_TAG = "STATE_INITIALIZING";
|
||||||
|
#endif // PSOC_PLATFORM
|
||||||
|
|
||||||
static bool Startup_Sound_Complete = false;
|
static bool Startup_Sound_Complete = false;
|
||||||
|
|
||||||
|
|
@ -109,9 +111,12 @@ static void Initializing_Exit(StateMachineContext_T * context)
|
||||||
AudioAction_T audio_action = {.ID = AUDIO_SILENCE, .Data = (void *)0x00};
|
AudioAction_T audio_action = {.ID = AUDIO_SILENCE, .Data = (void *)0x00};
|
||||||
Perform_Audio_Action(&audio_action);
|
Perform_Audio_Action(&audio_action);
|
||||||
|
|
||||||
//! \todo Add a menu item to change the weapon.
|
#ifdef PSOC_PLATFORM
|
||||||
|
//! \todo Add a menu item to change the weapon on the 2020TPC.
|
||||||
|
// On the ESP32 platform, the weapon can be set via the USB stick.
|
||||||
KLOG_WARN(KLOG_TAG, "Weapon hardcoded to the Dubuque Protocol!");
|
KLOG_WARN(KLOG_TAG, "Weapon hardcoded to the Dubuque Protocol!");
|
||||||
uint8_t weapon_ID = DUBUQUE_PROTOCOL_ID;
|
uint8_t weapon_ID = DUBUQUE_PROTOCOL_ID;
|
||||||
(void) SETTINGS_set_uint8_t(SYSTEMK_SETTING_WEAPONID, weapon_ID);
|
(void) SETTINGS_set_uint8_t(SYSTEMK_SETTING_WEAPONID, weapon_ID);
|
||||||
(void) SETTINGS_Save();
|
(void) SETTINGS_Save();
|
||||||
|
#endif // PSOC_PLATFORM
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue