SystemK v1.00 #9
82 changed files with 300 additions and 132 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
@ -511,4 +510,3 @@ bool BLE_IsBLEPacketForMe(const uint8_t BD_ADDR[6])
|
|||
|
||||
return for_me;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@
|
|||
extern const uint8_t BLE_BROADCAST_ADDRESS[6];
|
||||
|
||||
const char* BLE_ADDR_To_Str(const uint8_t bd_addr[6]);
|
||||
SystemKResult_T BLE_HandleCommonEvents(KEvent_T *event);
|
||||
SystemKResult_T BLE_HandleCommonEvents(KEvent_T *event);
|
||||
|
|
|
|||
1
Colors.h
Executable file → Normal file
1
Colors.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Events/Command_Mapping.h
Executable file → Normal file
1
Events/Command_Mapping.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Events/KEvents.c
Executable file → Normal file
1
Events/KEvents.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
83
Events/KEvents.h
Executable file → Normal file
83
Events/KEvents.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
@ -32,55 +31,57 @@
|
|||
typedef enum
|
||||
{
|
||||
KEVENT_NO_EVENT = 0,
|
||||
KEVENT_AUTOMATIC_TRANSITION = 1,
|
||||
KEVENT_CAPSENSE_ONE_PRESSED = 2,
|
||||
KEVENT_CAPSENSE_ONE_RELEASED = 3,
|
||||
KEVENT_CAPSENSE_TWO_PRESSED = 4,
|
||||
KEVENT_CAPSENSE_TWO_RELEASED = 5,
|
||||
KEVENT_TRIGGER_SWITCH_PRESSED = 6,
|
||||
//! For #KEVENT_UNSUCCESSFUL_SYSTEMK_RESULT, #KEvent_T::Data contains a #SystemKResult_T indicating the nature of the failure.
|
||||
KEVENT_UNSUCCESSFUL_SYSTEMK_RESULT = 1,
|
||||
KEVENT_AUTOMATIC_TRANSITION = 2,
|
||||
KEVENT_CAPSENSE_ONE_PRESSED = 3,
|
||||
KEVENT_CAPSENSE_ONE_RELEASED = 4,
|
||||
KEVENT_CAPSENSE_TWO_PRESSED = 5,
|
||||
KEVENT_CAPSENSE_TWO_RELEASED = 6,
|
||||
KEVENT_TRIGGER_SWITCH_PRESSED = 7,
|
||||
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.
|
||||
KEVENT_CENTER_SWITCH_RELEASED = KEVENT_TRIGGER_SWITCH_RELEASED,
|
||||
KEVENT_UP_SWITCH_PRESSED = 8,
|
||||
KEVENT_UP_SWITCH_LONG_PRESSED = 9,
|
||||
KEVENT_UP_SWITCH_RELEASED = 10,
|
||||
KEVENT_DOWN_SWITCH_PRESSED = 11,
|
||||
KEVENT_DOWN_SWITCH_LONG_PRESSED = 12,
|
||||
KEVENT_DOWN_SWITCH_RELEASED = 13,
|
||||
KEVENT_FORWARD_SWITCH_PRESSED = 14,
|
||||
KEVENT_FORWARD_SWITCH_LONG_PRESSED = 15,
|
||||
KEVENT_FORWARD_SWITCH_RELEASED = 16,
|
||||
KEVENT_BACKWARD_SWITCH_PRESSED = 17,
|
||||
KEVENT_BACKWARD_SWITCH_LONG_PRESSED = 18,
|
||||
KEVENT_BACKWARD_SWITCH_RELEASED = 19,
|
||||
KEVENT_TAG_SENT = 20,
|
||||
KEVENT_UP_SWITCH_PRESSED = 9,
|
||||
KEVENT_UP_SWITCH_LONG_PRESSED = 10,
|
||||
KEVENT_UP_SWITCH_RELEASED = 11,
|
||||
KEVENT_DOWN_SWITCH_PRESSED = 12,
|
||||
KEVENT_DOWN_SWITCH_LONG_PRESSED = 13,
|
||||
KEVENT_DOWN_SWITCH_RELEASED = 14,
|
||||
KEVENT_FORWARD_SWITCH_PRESSED = 15,
|
||||
KEVENT_FORWARD_SWITCH_LONG_PRESSED = 16,
|
||||
KEVENT_FORWARD_SWITCH_RELEASED = 17,
|
||||
KEVENT_BACKWARD_SWITCH_PRESSED = 18,
|
||||
KEVENT_BACKWARD_SWITCH_LONG_PRESSED = 19,
|
||||
KEVENT_BACKWARD_SWITCH_RELEASED = 20,
|
||||
KEVENT_TAG_SENT = 21,
|
||||
//! For #KEVENT_TAG_RECEIVED, #KEvent_T::Data points to #TagPacket_T.
|
||||
KEVENT_TAG_RECEIVED = 21,
|
||||
KEVENT_TAGGED_OUT = 22,
|
||||
KEVENT_MISFIRE = 23,
|
||||
KEVENT_NEAR_MISS = 24,
|
||||
KEVENT_TAG_RECEIVED = 22,
|
||||
KEVENT_TAGGED_OUT = 23,
|
||||
KEVENT_MISFIRE = 24,
|
||||
KEVENT_NEAR_MISS = 25,
|
||||
//! 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.
|
||||
KEVENT_COMMAND_RECEIVED = 26,
|
||||
KEVENT_MENU_ENTER = 27,
|
||||
KEVENT_MENU_SELECT = 28,
|
||||
KEVENT_MENU_BACK = 29,
|
||||
KEVENT_MENU_UP = 30,
|
||||
KEVENT_MENU_DOWN = 31,
|
||||
KEVENT_MENU_EXIT = 32,
|
||||
KEVENT_REPROGRAM = 33,
|
||||
KEVENT_COMMAND_RECEIVED = 27,
|
||||
KEVENT_MENU_ENTER = 28,
|
||||
KEVENT_MENU_SELECT = 29,
|
||||
KEVENT_MENU_BACK = 30,
|
||||
KEVENT_MENU_UP = 31,
|
||||
KEVENT_MENU_DOWN = 32,
|
||||
KEVENT_MENU_EXIT = 33,
|
||||
KEVENT_REPROGRAM = 34,
|
||||
//! 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.
|
||||
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.
|
||||
KEVENT_AUDIO_COMPLETED = 36,
|
||||
KEVENT_GAME_OVER = 37,
|
||||
KEVENT_PLAY_PRESSED_ON_REMOTE = 38,
|
||||
KEVENT_AUDIO_COMPLETED = 37,
|
||||
KEVENT_GAME_OVER = 38,
|
||||
KEVENT_PLAY_PRESSED_ON_REMOTE = 39,
|
||||
//! 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
|
||||
} KEvent_ID_T;
|
||||
|
|
@ -95,7 +96,7 @@ typedef struct
|
|||
void *Data;
|
||||
} 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.");
|
||||
|
||||
void Init_KEvents(void);
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
|||
.Time_To_Reload_in_ms = 0
|
||||
},
|
||||
|
||||
// Bayonette
|
||||
// Bayonet
|
||||
{
|
||||
.ID = BAYONETTE_ID,
|
||||
.ID = BAYONET_ID,
|
||||
.Type = EDGE,
|
||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
||||
.Protocol = DUBUQUE_PROTOCOL,
|
||||
.Damage_Per_Shot = 1,
|
||||
.Shots_Per_Reload = UINT16_MAX,
|
||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||
|
|
@ -52,7 +52,7 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
|||
{
|
||||
.ID = PISTOL_ID,
|
||||
.Type = PROJECTILE,
|
||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
||||
.Protocol = DUBUQUE_PROTOCOL,
|
||||
.Damage_Per_Shot = 10,
|
||||
.Shots_Per_Reload = 8,
|
||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||
|
|
@ -64,7 +64,7 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
|||
{
|
||||
.ID = SHOTGUN_ID,
|
||||
.Type = PROJECTILE,
|
||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
||||
.Protocol = DUBUQUE_PROTOCOL,
|
||||
.Damage_Per_Shot = 20,
|
||||
.Shots_Per_Reload = 2,
|
||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||
|
|
@ -76,7 +76,7 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
|||
{
|
||||
.ID = RIFLE_ID,
|
||||
.Type = PROJECTILE,
|
||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
||||
.Protocol = DUBUQUE_PROTOCOL,
|
||||
.Damage_Per_Shot = 10,
|
||||
.Shots_Per_Reload = 8,
|
||||
.Delay_Before_Sending_Shot_in_ms = 0,
|
||||
|
|
@ -88,11 +88,11 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
|||
{
|
||||
.ID = MACHINE_GUN_ID,
|
||||
.Type = PROJECTILE,
|
||||
.Protocol = MILES_TAG_II_PROTOCOL, // For now...
|
||||
.Protocol = DUBUQUE_PROTOCOL,
|
||||
.Damage_Per_Shot = 10,
|
||||
.Shots_Per_Reload = 250,
|
||||
.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
|
||||
},
|
||||
|
||||
|
|
@ -168,4 +168,3 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] =
|
|||
.Time_To_Reload_in_ms = 3000
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
typedef enum
|
||||
{
|
||||
TEST_PATTERN_ID = 0,
|
||||
BAYONETTE_ID = 1,
|
||||
BAYONET_ID = 1,
|
||||
PISTOL_ID = 2,
|
||||
SHOTGUN_ID = 3,
|
||||
RIFLE_ID = 4,
|
||||
|
|
@ -68,7 +68,7 @@ extern Weapon_t WeaponsByID[NUMBER_OF_WEAPONS];
|
|||
|
||||
__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)
|
||||
{
|
||||
|
|
@ -79,4 +79,3 @@ __attribute__((always_inline)) inline Weapon_t GetWeaponFromID(WeaponID_t id)
|
|||
}
|
||||
|
||||
#endif // WEAPON_H
|
||||
|
||||
|
|
|
|||
1
Logging/KLog.c
Executable file → Normal file
1
Logging/KLog.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Logging/KLog.h
Executable file → Normal file
1
Logging/KLog.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -101,4 +101,4 @@ static void OnDecrement()
|
|||
|
||||
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&Player_ID};
|
||||
Perform_Audio_Action(&volume_action);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,4 +99,4 @@ static void OnDecrement()
|
|||
{
|
||||
KLOG_WARN(KLOG_TAG, "Failed to decrement team!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,4 +101,4 @@ static void OnDecrement()
|
|||
{
|
||||
Submenus[SubmenuIndex]->OnFocus(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,4 +113,4 @@ static void OnDecrement()
|
|||
|
||||
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&Volume};
|
||||
Perform_Audio_Action(&volume_action);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,4 +104,4 @@ static void RootMenuOnDecrement()
|
|||
{
|
||||
Submenus[SubmenuIndex]->OnFocus(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Dynasty.c
Executable file → Normal file
1
Protocols/Dynasty.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Dynasty.h
Executable file → Normal file
1
Protocols/Dynasty.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Laser_X.c
Executable file → Normal file
1
Protocols/Laser_X.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Laser_X.h
Executable file → Normal file
1
Protocols/Laser_X.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Miles_Tag_II.c
Executable file → Normal file
1
Protocols/Miles_Tag_II.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Miles_Tag_II.h
Executable file → Normal file
1
Protocols/Miles_Tag_II.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/NEC.c
Executable file → Normal file
1
Protocols/NEC.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/NEC.h
Executable file → Normal file
1
Protocols/NEC.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Nerf_Laser_Ops_Pro.c
Executable file → Normal file
1
Protocols/Nerf_Laser_Ops_Pro.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Nerf_Laser_Ops_Pro.h
Executable file → Normal file
1
Protocols/Nerf_Laser_Ops_Pro.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Nerf_Laser_Strike.c
Executable file → Normal file
1
Protocols/Nerf_Laser_Strike.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Nerf_Laser_Strike.h
Executable file → Normal file
1
Protocols/Nerf_Laser_Strike.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Nerf_Phoenix_LTX.c
Executable file → Normal file
1
Protocols/Nerf_Phoenix_LTX.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Nerf_Phoenix_LTX.h
Executable file → Normal file
1
Protocols/Nerf_Phoenix_LTX.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Protocols.c
Executable file → Normal file
1
Protocols/Protocols.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Protocols.h
Executable file → Normal file
1
Protocols/Protocols.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Squad_Hero.c
Executable file → Normal file
1
Protocols/Squad_Hero.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Squad_Hero.h
Executable file → Normal file
1
Protocols/Squad_Hero.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Test.c
Executable file → Normal file
1
Protocols/Test.c
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
1
Protocols/Test.h
Executable file → Normal file
1
Protocols/Test.h
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ typedef enum
|
|||
SYSTEMK_RESULT_FAILED_TO_CREATE_RTOS_TASK,
|
||||
SYSTEMK_RESULT_FAILED_TO_CREATE_RTOS_TIMER,
|
||||
SYSTEMK_RESULT_FAILED_TO_START_RTOS_TIMER,
|
||||
SYSTEMK_RESULT_FILESYSTEM_NOT_PRESENT,
|
||||
SYSTEMK_RESULT_FILE_NOT_FOUND,
|
||||
SYSTEMK_RESULT_KEY_NOT_FOUND,
|
||||
SYSTEMK_RESULT_READ_FAILED,
|
||||
|
|
|
|||
11
Settings/Settings.csv
Normal file
11
Settings/Settings.csv
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Setting ID,Type,Key,Default Value,Description
|
||||
SYSTEMK_SETTING_IS_RIGHT_HANDED,uint8_t,"Is_Right_Handed",1,"1 if this device is configured for a right-handed player, 0 otherwise."
|
||||
SYSTEMK_SETTING_AUDIO_VOLUME,uint8_t,"Audio_Volume",CONFIG_KTAG_MAX_AUDIO_VOLUME,"Value from CONFIG_KTAG_MIN_AUDIO_VOLUME to CONFIG_KTAG_MAX_AUDIO_VOLUME representing the current volume."
|
||||
SYSTEMK_SETTING_TEAMID,uint8_t,"Team_ID",BASIC_TEAMS_MINIMUM,"Selected team."
|
||||
SYSTEMK_SETTING_PLAYERID,uint8_t,"Player_ID",0,"Unique-per-team identification of a player."
|
||||
SYSTEMK_SETTING_WEAPONID,uint8_t,"Weapon_ID",DUBUQUE_PROTOCOL_ID,"Selected weapon."
|
||||
SYSTEMK_SETTING_MAX_HEALTH,uint8_t,"Max_Health",100,"Maximum health for the game."
|
||||
SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY,uint8_t,"N_Special_Weapons_On_Reentry",1,"Number of special weapons (currently only bombs) obtained when reentering after being tagged out."
|
||||
SYSTEMK_SETTING_T_START_GAME_in_ms,uint32_t,"T_Start_Game_in_ms",30000,"Time (in milliseconds) after starting a game before the countdown begins."
|
||||
SYSTEMK_SETTING_T_GAME_LENGTH_in_ms,uint32_t,"T_Game_Length_in_ms",600000,"Duration of a game (in milliseconds). If this is zero or UINT32_MAX, the game is untimed."
|
||||
SYSTEMK_SETTING_SECONDARY_COLOR,uint32_t,"Secondary_Color",0xFE000000,"Color in addition to the team color used to identify a player's device. The format is Brightness-Red-Green-Blue, where a brightness of 0xFF indicates a false flag."
|
||||
|
220
Settings/generate_settings_code.py
Normal file
220
Settings/generate_settings_code.py
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
SystemK settings code generator.
|
||||
|
||||
This program source code file is part of SystemK, a library in the KTag project.
|
||||
|
||||
🛡️ https://ktag.clubk.club
|
||||
|
||||
Copyright © 2025 Joseph P. Kearney and the KTag developers.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Affero General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
details.
|
||||
|
||||
A copy of the GNU Affero General Public License should be available in the
|
||||
LICENSE file in the root of this repository. If not, see http://www.gnu.org/licenses/.
|
||||
"""
|
||||
|
||||
import csv
|
||||
from typing import List, Dict
|
||||
|
||||
|
||||
def parse_csv(filename: str) -> List[Dict[str, str]]:
|
||||
"""Parse the settings CSV file."""
|
||||
settings = []
|
||||
with open(filename, "r") as f:
|
||||
reader = csv.DictReader(f)
|
||||
for row in reader:
|
||||
settings.append(row)
|
||||
return settings
|
||||
|
||||
|
||||
def generate_get_function(settings: List[Dict[str, str]], datatype: str) -> str:
|
||||
"""Generate the SETTINGS_get function for a specific datatype."""
|
||||
func_name = f"SETTINGS_get_{datatype}"
|
||||
|
||||
code = f"""SystemKResult_T {func_name}(SystemKSettingID_T id, {datatype} *value)
|
||||
{{
|
||||
SystemKResult_T result = SYSTEMK_RESULT_UNSPECIFIED_FAILURE;
|
||||
|
||||
switch (id)
|
||||
{{
|
||||
"""
|
||||
|
||||
for setting in settings:
|
||||
if setting["Type"] != datatype:
|
||||
continue
|
||||
|
||||
setting_id = setting["Setting ID"]
|
||||
key = setting["Key"]
|
||||
cache_var = f"Cached_{key}"
|
||||
|
||||
code += f""" case {setting_id}:
|
||||
*value = {cache_var};
|
||||
result = SYSTEMK_RESULT_SUCCESS;
|
||||
break;
|
||||
|
||||
"""
|
||||
|
||||
code += """ default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
"""
|
||||
return code
|
||||
|
||||
|
||||
def generate_set_function(settings: List[Dict[str, str]], datatype: str) -> str:
|
||||
"""Generate the SETTINGS_set function for a specific datatype."""
|
||||
func_name = f"SETTINGS_set_{datatype}"
|
||||
kv_func = f"KV_Set_Value_{datatype.replace('_t', '')}"
|
||||
|
||||
code = f"""SystemKResult_T {func_name}(SystemKSettingID_T id, {datatype} value)
|
||||
{{
|
||||
SystemKResult_T result = SYSTEMK_RESULT_SUCCESS;
|
||||
|
||||
switch (id)
|
||||
{{
|
||||
"""
|
||||
|
||||
for setting in settings:
|
||||
if setting["Type"] != datatype:
|
||||
continue
|
||||
|
||||
setting_id = setting["Setting ID"]
|
||||
key = setting["Key"]
|
||||
|
||||
cache_var = f"Cached_{key}"
|
||||
code += f""" case {setting_id}:
|
||||
{cache_var} = value;
|
||||
result = {kv_func}(CONFIG_FILE, "{key}", &value);
|
||||
break;
|
||||
|
||||
"""
|
||||
|
||||
code += """ default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
"""
|
||||
return code
|
||||
|
||||
|
||||
def generate_initialize_function(settings: List[Dict[str, str]]) -> str:
|
||||
"""Generate the Initialize_Settings function."""
|
||||
code = """SystemKResult_T Initialize_Settings(void)
|
||||
{
|
||||
SystemKResult_T result = SYSTEMK_RESULT_SUCCESS;
|
||||
SystemKResult_T temp_result;
|
||||
"""
|
||||
|
||||
# Group settings by datatype.
|
||||
datatypes = set(s["Type"] for s in settings)
|
||||
|
||||
for datatype in sorted(datatypes):
|
||||
code += f" {datatype} value_{datatype};\n"
|
||||
|
||||
code += """
|
||||
KLOG_INFO(TAG, "Initializing settings...");
|
||||
|
||||
"""
|
||||
|
||||
# Generate initialization code for each setting.
|
||||
for setting in settings:
|
||||
setting_id = setting["Setting ID"]
|
||||
datatype = setting["Type"]
|
||||
key = setting["Key"]
|
||||
default_value = setting["Default Value"]
|
||||
|
||||
code += f""" // Initialize {key}
|
||||
temp_result = KV_Get_Value_{datatype.replace('_t', '')}(CONFIG_FILE, "{key}", &value_{datatype});
|
||||
if (temp_result != SYSTEMK_RESULT_SUCCESS)
|
||||
{{
|
||||
// Try to get from default config
|
||||
temp_result = KV_Get_Value_{datatype.replace('_t', '')}(DEFAULT_CONFIG_FILE, "{key}", &value_{datatype});
|
||||
if (temp_result != SYSTEMK_RESULT_SUCCESS)
|
||||
{{
|
||||
// Use hardcoded default
|
||||
value_{datatype} = {default_value};
|
||||
KLOG_WARN(TAG, "{key} not found in config files; using default value of {default_value}.");
|
||||
}}
|
||||
// Save to config file
|
||||
temp_result = KV_Set_Value_{datatype.replace('_t', '')}(CONFIG_FILE, "{key}", &value_{datatype});
|
||||
if (temp_result != SYSTEMK_RESULT_SUCCESS)
|
||||
{{
|
||||
result = temp_result;
|
||||
KLOG_ERROR(TAG, "Failed to set {key} in config file.");
|
||||
}}
|
||||
}}
|
||||
"""
|
||||
|
||||
# Initialize the cache variable
|
||||
cache_var = f"Cached_{key}"
|
||||
code += f" {cache_var} = value_{datatype};\n"
|
||||
|
||||
code += "\n"
|
||||
|
||||
code += """ xEventGroupSetBits(Get_System_Events(), SYS_SETTINGS_READY);
|
||||
KLOG_INFO(TAG, "Settings initialized.");
|
||||
|
||||
return result;
|
||||
}
|
||||
"""
|
||||
return code
|
||||
|
||||
|
||||
def generate_cache_declarations(settings: List[Dict[str, str]]) -> str:
|
||||
"""Generate static cache variable declarations initialized to defaults."""
|
||||
code = ""
|
||||
|
||||
# Generate cache variable declarations for all settings
|
||||
for setting in settings:
|
||||
datatype = setting["Type"]
|
||||
key = setting["Key"]
|
||||
description = setting["Description"]
|
||||
default_value = setting["Default Value"]
|
||||
cache_var = f"Cached_{key}"
|
||||
|
||||
code += f"// {description}\n"
|
||||
code += f"static {datatype} {cache_var} = {default_value};\n"
|
||||
|
||||
return code
|
||||
|
||||
|
||||
def main():
|
||||
"""Main function to generate all settings code."""
|
||||
settings = parse_csv("Settings.csv")
|
||||
|
||||
# Get unique datatypes
|
||||
datatypes = sorted(set(s["Type"] for s in settings))
|
||||
|
||||
print("// Cache variable declarations")
|
||||
print(generate_cache_declarations(settings))
|
||||
print()
|
||||
|
||||
# Generate get and set functions for each datatype
|
||||
for datatype in datatypes:
|
||||
print(generate_get_function(settings, datatype))
|
||||
print()
|
||||
print(generate_set_function(settings, datatype))
|
||||
print()
|
||||
|
||||
# Generate initialize function
|
||||
print(generate_initialize_function(settings))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -36,4 +36,4 @@ void Starting_Game_Entry(StateMachineContext_T * context)
|
|||
|
||||
void Starting_Game_Exit(StateMachineContext_T * context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ static void Initializing_Entry(StateMachineContext_T * context);
|
|||
static void Initializing_Do(StateMachineContext_T * context);
|
||||
static void Initializing_Exit(StateMachineContext_T * context);
|
||||
|
||||
#ifdef PSOC_PLATFORM
|
||||
static const char *KLOG_TAG = "STATE_INITIALIZING";
|
||||
#endif // PSOC_PLATFORM
|
||||
|
||||
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};
|
||||
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!");
|
||||
uint8_t weapon_ID = DUBUQUE_PROTOCOL_ID;
|
||||
(void) SETTINGS_set_uint8_t(SYSTEMK_SETTING_WEAPONID, weapon_ID);
|
||||
(void) SETTINGS_Save();
|
||||
#endif // PSOC_PLATFORM
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,4 +194,3 @@ void HandleBLEEventPacket(const BLE_EventPacket_T *const packet, StateMachineCon
|
|||
|
||||
BLE_FreePacketBuffer((BLE_GenericPacketType_T *)packet);
|
||||
}
|
||||
|
||||
|
|
|
|||
6
SystemK.h
Executable file → Normal file
6
SystemK.h
Executable file → Normal file
|
|
@ -70,9 +70,9 @@
|
|||
#ifndef SYSTEMK_H
|
||||
#define SYSTEMK_H
|
||||
|
||||
#define SYSTEMK_MAJOR_VERSION 0
|
||||
#define SYSTEMK_MINOR_VERSION 99
|
||||
#define SYSTEMK_VERSION_STRING "00.99"
|
||||
#define SYSTEMK_MAJOR_VERSION 1
|
||||
#define SYSTEMK_MINOR_VERSION 0
|
||||
#define SYSTEMK_VERSION_STRING "01.00"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue