diff --git a/BLE/BLE_Packet_Tracker.h b/BLE/BLE_Packet_Tracker.h index 914c752..9059411 100644 --- a/BLE/BLE_Packet_Tracker.h +++ b/BLE/BLE_Packet_Tracker.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/BLE/BLE_Packets.c b/BLE/BLE_Packets.c index c44fc62..af332f1 100644 --- a/BLE/BLE_Packets.c +++ b/BLE/BLE_Packets.c @@ -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; } - diff --git a/BLE/BLE_Packets.h b/BLE/BLE_Packets.h index d1f3e36..36e439e 100644 --- a/BLE/BLE_Packets.h +++ b/BLE/BLE_Packets.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/BLE/BLE_Utils.h b/BLE/BLE_Utils.h index c52efc0..94b4866 100644 --- a/BLE/BLE_Utils.h +++ b/BLE/BLE_Utils.h @@ -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); \ No newline at end of file +SystemKResult_T BLE_HandleCommonEvents(KEvent_T *event); diff --git a/Colors.h b/Colors.h old mode 100755 new mode 100644 index b821e8a..ea7323d --- a/Colors.h +++ b/Colors.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Events/Command_Mapping.h b/Events/Command_Mapping.h old mode 100755 new mode 100644 index 80c28c8..e87b946 --- a/Events/Command_Mapping.h +++ b/Events/Command_Mapping.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Events/KEvents.c b/Events/KEvents.c old mode 100755 new mode 100644 index 8b1f052..0f9fae6 --- a/Events/KEvents.c +++ b/Events/KEvents.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Events/KEvents.h b/Events/KEvents.h old mode 100755 new mode 100644 index 027a733..119d35e --- a/Events/KEvents.h +++ b/Events/KEvents.h @@ -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); diff --git a/Game/Weapons.c b/Game/Weapons.c index 52da364..d254bef 100644 --- a/Game/Weapons.c +++ b/Game/Weapons.c @@ -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 } }; - diff --git a/Game/Weapons.h b/Game/Weapons.h index e711ae7..ed78f73 100644 --- a/Game/Weapons.h +++ b/Game/Weapons.h @@ -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 - diff --git a/Logging/KLog.c b/Logging/KLog.c old mode 100755 new mode 100644 index 4c63a6b..4e68b3e --- a/Logging/KLog.c +++ b/Logging/KLog.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Logging/KLog.h b/Logging/KLog.h old mode 100755 new mode 100644 index 6629594..afa4330 --- a/Logging/KLog.h +++ b/Logging/KLog.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Menu/GameSettings/PlayerIDMenuItem.c b/Menu/GameSettings/PlayerIDMenuItem.c index fb7bcfe..f3d860a 100644 --- a/Menu/GameSettings/PlayerIDMenuItem.c +++ b/Menu/GameSettings/PlayerIDMenuItem.c @@ -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); -} \ No newline at end of file +} diff --git a/Menu/GameSettings/TeamIDMenuItem.c b/Menu/GameSettings/TeamIDMenuItem.c index 7d363d2..55068f1 100644 --- a/Menu/GameSettings/TeamIDMenuItem.c +++ b/Menu/GameSettings/TeamIDMenuItem.c @@ -99,4 +99,4 @@ static void OnDecrement() { KLOG_WARN(KLOG_TAG, "Failed to decrement team!"); } -} \ No newline at end of file +} diff --git a/Menu/HardwareSettings/HardwareMenuItem.c b/Menu/HardwareSettings/HardwareMenuItem.c index 1f3204a..8333962 100644 --- a/Menu/HardwareSettings/HardwareMenuItem.c +++ b/Menu/HardwareSettings/HardwareMenuItem.c @@ -101,4 +101,4 @@ static void OnDecrement() { Submenus[SubmenuIndex]->OnFocus(false); } -} \ No newline at end of file +} diff --git a/Menu/HardwareSettings/VolumeMenuItem.c b/Menu/HardwareSettings/VolumeMenuItem.c index 330d4e8..307a384 100644 --- a/Menu/HardwareSettings/VolumeMenuItem.c +++ b/Menu/HardwareSettings/VolumeMenuItem.c @@ -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); -} \ No newline at end of file +} diff --git a/Menu/Menu.c b/Menu/Menu.c index 47ecfa0..ec15a34 100644 --- a/Menu/Menu.c +++ b/Menu/Menu.c @@ -104,4 +104,4 @@ static void RootMenuOnDecrement() { Submenus[SubmenuIndex]->OnFocus(false); } -} \ No newline at end of file +} diff --git a/NeoPixels/Animation.h b/NeoPixels/Animation.h index fb8b300..f7f06b9 100644 --- a/NeoPixels/Animation.h +++ b/NeoPixels/Animation.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/All_Off.c b/NeoPixels/Animations/All_Off.c index ee23d1a..1969b23 100644 --- a/NeoPixels/Animations/All_Off.c +++ b/NeoPixels/Animations/All_Off.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/All_Off.h b/NeoPixels/Animations/All_Off.h index 2e59d6e..67ee311 100644 --- a/NeoPixels/Animations/All_Off.h +++ b/NeoPixels/Animations/All_Off.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/BLE_Nearby.c b/NeoPixels/Animations/BLE_Nearby.c index 90a93f3..35e82eb 100644 --- a/NeoPixels/Animations/BLE_Nearby.c +++ b/NeoPixels/Animations/BLE_Nearby.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/BLE_Nearby.h b/NeoPixels/Animations/BLE_Nearby.h index ddee90b..3344e82 100644 --- a/NeoPixels/Animations/BLE_Nearby.h +++ b/NeoPixels/Animations/BLE_Nearby.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/BLE_RSSI.c b/NeoPixels/Animations/BLE_RSSI.c index faef9de..a80a71c 100644 --- a/NeoPixels/Animations/BLE_RSSI.c +++ b/NeoPixels/Animations/BLE_RSSI.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/BLE_RSSI.h b/NeoPixels/Animations/BLE_RSSI.h index 4220285..913bb99 100644 --- a/NeoPixels/Animations/BLE_RSSI.h +++ b/NeoPixels/Animations/BLE_RSSI.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Countdown.c b/NeoPixels/Animations/Countdown.c index 20cf434..2763a09 100644 --- a/NeoPixels/Animations/Countdown.c +++ b/NeoPixels/Animations/Countdown.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Countdown.h b/NeoPixels/Animations/Countdown.h index d965095..b12bbb1 100644 --- a/NeoPixels/Animations/Countdown.h +++ b/NeoPixels/Animations/Countdown.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Flamethrower.c b/NeoPixels/Animations/Flamethrower.c index a154189..00e8ef2 100644 --- a/NeoPixels/Animations/Flamethrower.c +++ b/NeoPixels/Animations/Flamethrower.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Flamethrower.h b/NeoPixels/Animations/Flamethrower.h index 04c134f..bc67b47 100644 --- a/NeoPixels/Animations/Flamethrower.h +++ b/NeoPixels/Animations/Flamethrower.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Flashlight.c b/NeoPixels/Animations/Flashlight.c index 8deb1c1..025f085 100644 --- a/NeoPixels/Animations/Flashlight.c +++ b/NeoPixels/Animations/Flashlight.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Flashlight.h b/NeoPixels/Animations/Flashlight.h index d608f88..0e9651d 100644 --- a/NeoPixels/Animations/Flashlight.h +++ b/NeoPixels/Animations/Flashlight.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Health_Report.c b/NeoPixels/Animations/Health_Report.c index 062bf3a..8bd2211 100644 --- a/NeoPixels/Animations/Health_Report.c +++ b/NeoPixels/Animations/Health_Report.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Health_Report.h b/NeoPixels/Animations/Health_Report.h index 96a647f..167b285 100644 --- a/NeoPixels/Animations/Health_Report.h +++ b/NeoPixels/Animations/Health_Report.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Idle_Animation.h b/NeoPixels/Animations/Idle_Animation.h index cecf242..1713b8f 100644 --- a/NeoPixels/Animations/Idle_Animation.h +++ b/NeoPixels/Animations/Idle_Animation.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Menu_Animation.c b/NeoPixels/Animations/Menu_Animation.c index 90a8acd..db1fa41 100644 --- a/NeoPixels/Animations/Menu_Animation.c +++ b/NeoPixels/Animations/Menu_Animation.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Menu_Animation.h b/NeoPixels/Animations/Menu_Animation.h index 66ee0e8..5390b1d 100644 --- a/NeoPixels/Animations/Menu_Animation.h +++ b/NeoPixels/Animations/Menu_Animation.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Shot_Fired.c b/NeoPixels/Animations/Shot_Fired.c index 484a7c4..6b8d47b 100644 --- a/NeoPixels/Animations/Shot_Fired.c +++ b/NeoPixels/Animations/Shot_Fired.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Shot_Fired.h b/NeoPixels/Animations/Shot_Fired.h index c80fd68..6978158 100644 --- a/NeoPixels/Animations/Shot_Fired.h +++ b/NeoPixels/Animations/Shot_Fired.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Tag_Received.c b/NeoPixels/Animations/Tag_Received.c index 51e63d8..5ce1d33 100644 --- a/NeoPixels/Animations/Tag_Received.c +++ b/NeoPixels/Animations/Tag_Received.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Tag_Received.h b/NeoPixels/Animations/Tag_Received.h index cd3c358..06f1873 100644 --- a/NeoPixels/Animations/Tag_Received.h +++ b/NeoPixels/Animations/Tag_Received.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Tagged_Out.c b/NeoPixels/Animations/Tagged_Out.c index d0e92f1..861a41a 100644 --- a/NeoPixels/Animations/Tagged_Out.c +++ b/NeoPixels/Animations/Tagged_Out.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Tagged_Out.h b/NeoPixels/Animations/Tagged_Out.h index 614df26..3004ddb 100644 --- a/NeoPixels/Animations/Tagged_Out.h +++ b/NeoPixels/Animations/Tagged_Out.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Team_Colors.c b/NeoPixels/Animations/Team_Colors.c index f7e1067..394620e 100644 --- a/NeoPixels/Animations/Team_Colors.c +++ b/NeoPixels/Animations/Team_Colors.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Team_Colors.h b/NeoPixels/Animations/Team_Colors.h index 4f56435..436ecce 100644 --- a/NeoPixels/Animations/Team_Colors.h +++ b/NeoPixels/Animations/Team_Colors.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Test_Pattern.c b/NeoPixels/Animations/Test_Pattern.c index e341888..8c43bf1 100644 --- a/NeoPixels/Animations/Test_Pattern.c +++ b/NeoPixels/Animations/Test_Pattern.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Test_Pattern.h b/NeoPixels/Animations/Test_Pattern.h index d7dcfe5..5f7d68b 100644 --- a/NeoPixels/Animations/Test_Pattern.h +++ b/NeoPixels/Animations/Test_Pattern.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Wrapping_Up_Animation.c b/NeoPixels/Animations/Wrapping_Up_Animation.c index 078ecaf..4648d38 100644 --- a/NeoPixels/Animations/Wrapping_Up_Animation.c +++ b/NeoPixels/Animations/Wrapping_Up_Animation.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Animations/Wrapping_Up_Animation.h b/NeoPixels/Animations/Wrapping_Up_Animation.h index 722726f..796dcaa 100644 --- a/NeoPixels/Animations/Wrapping_Up_Animation.h +++ b/NeoPixels/Animations/Wrapping_Up_Animation.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Displays.h b/NeoPixels/Displays.h index 8f05806..d4088d7 100644 --- a/NeoPixels/Displays.h +++ b/NeoPixels/Displays.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Four_Channel_Helpers.h b/NeoPixels/Four_Channel_Helpers.h index 83743c9..dedea28 100644 --- a/NeoPixels/Four_Channel_Helpers.h +++ b/NeoPixels/Four_Channel_Helpers.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Gamma.c b/NeoPixels/Gamma.c index 5d091f5..219dc90 100644 --- a/NeoPixels/Gamma.c +++ b/NeoPixels/Gamma.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Gamma.h b/NeoPixels/Gamma.h index f6243a7..7f0c94c 100644 --- a/NeoPixels/Gamma.h +++ b/NeoPixels/Gamma.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/NeoPixels.c b/NeoPixels/NeoPixels.c index a13e64f..b4c1231 100644 --- a/NeoPixels/NeoPixels.c +++ b/NeoPixels/NeoPixels.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Sine.c b/NeoPixels/Sine.c index a649a6a..9faad93 100644 --- a/NeoPixels/Sine.c +++ b/NeoPixels/Sine.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Sine.h b/NeoPixels/Sine.h index 2fad7f6..cef73f8 100644 --- a/NeoPixels/Sine.h +++ b/NeoPixels/Sine.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/NeoPixels/Single_Channel_Helpers.h b/NeoPixels/Single_Channel_Helpers.h index be8d44f..ca9c3cf 100644 --- a/NeoPixels/Single_Channel_Helpers.h +++ b/NeoPixels/Single_Channel_Helpers.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Dynasty.c b/Protocols/Dynasty.c old mode 100755 new mode 100644 index 269fa38..7e31560 --- a/Protocols/Dynasty.c +++ b/Protocols/Dynasty.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Dynasty.h b/Protocols/Dynasty.h old mode 100755 new mode 100644 index c2fcfc5..4ba7fdd --- a/Protocols/Dynasty.h +++ b/Protocols/Dynasty.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Laser_X.c b/Protocols/Laser_X.c old mode 100755 new mode 100644 index 4ff5087..1633162 --- a/Protocols/Laser_X.c +++ b/Protocols/Laser_X.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Laser_X.h b/Protocols/Laser_X.h old mode 100755 new mode 100644 index 57ec76f..1840e5b --- a/Protocols/Laser_X.h +++ b/Protocols/Laser_X.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Miles_Tag_II.c b/Protocols/Miles_Tag_II.c old mode 100755 new mode 100644 index 357cbd2..da4c3b9 --- a/Protocols/Miles_Tag_II.c +++ b/Protocols/Miles_Tag_II.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Miles_Tag_II.h b/Protocols/Miles_Tag_II.h old mode 100755 new mode 100644 index b2e2a66..ed06c08 --- a/Protocols/Miles_Tag_II.h +++ b/Protocols/Miles_Tag_II.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/NEC.c b/Protocols/NEC.c old mode 100755 new mode 100644 index 4e10e30..ef81515 --- a/Protocols/NEC.c +++ b/Protocols/NEC.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/NEC.h b/Protocols/NEC.h old mode 100755 new mode 100644 index b9626c3..5c52ca9 --- a/Protocols/NEC.h +++ b/Protocols/NEC.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Nerf_Laser_Ops_Pro.c b/Protocols/Nerf_Laser_Ops_Pro.c old mode 100755 new mode 100644 index d38490b..7b107ef --- a/Protocols/Nerf_Laser_Ops_Pro.c +++ b/Protocols/Nerf_Laser_Ops_Pro.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Nerf_Laser_Ops_Pro.h b/Protocols/Nerf_Laser_Ops_Pro.h old mode 100755 new mode 100644 index 77ecbdc..19d4b87 --- a/Protocols/Nerf_Laser_Ops_Pro.h +++ b/Protocols/Nerf_Laser_Ops_Pro.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Nerf_Laser_Strike.c b/Protocols/Nerf_Laser_Strike.c old mode 100755 new mode 100644 index 5b4ac93..3bff5b7 --- a/Protocols/Nerf_Laser_Strike.c +++ b/Protocols/Nerf_Laser_Strike.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Nerf_Laser_Strike.h b/Protocols/Nerf_Laser_Strike.h old mode 100755 new mode 100644 index 140e9ca..b27de19 --- a/Protocols/Nerf_Laser_Strike.h +++ b/Protocols/Nerf_Laser_Strike.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Nerf_Phoenix_LTX.c b/Protocols/Nerf_Phoenix_LTX.c old mode 100755 new mode 100644 index caedb11..bd8a982 --- a/Protocols/Nerf_Phoenix_LTX.c +++ b/Protocols/Nerf_Phoenix_LTX.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Nerf_Phoenix_LTX.h b/Protocols/Nerf_Phoenix_LTX.h old mode 100755 new mode 100644 index 3243a10..a2f40b8 --- a/Protocols/Nerf_Phoenix_LTX.h +++ b/Protocols/Nerf_Phoenix_LTX.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Protocols.c b/Protocols/Protocols.c old mode 100755 new mode 100644 index 4b0bf60..78bd200 --- a/Protocols/Protocols.c +++ b/Protocols/Protocols.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Protocols.h b/Protocols/Protocols.h old mode 100755 new mode 100644 index fef6e40..9f0e205 --- a/Protocols/Protocols.h +++ b/Protocols/Protocols.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Squad_Hero.c b/Protocols/Squad_Hero.c old mode 100755 new mode 100644 index 634e076..2aab448 --- a/Protocols/Squad_Hero.c +++ b/Protocols/Squad_Hero.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Squad_Hero.h b/Protocols/Squad_Hero.h old mode 100755 new mode 100644 index 5447783..3a5e115 --- a/Protocols/Squad_Hero.h +++ b/Protocols/Squad_Hero.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Test.c b/Protocols/Test.c old mode 100755 new mode 100644 index 91518b0..f9c1964 --- a/Protocols/Test.c +++ b/Protocols/Test.c @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Protocols/Test.h b/Protocols/Test.h old mode 100755 new mode 100644 index d02ded0..ba57bd0 --- a/Protocols/Test.h +++ b/Protocols/Test.h @@ -1,4 +1,3 @@ - /* * This program source code file is part of SystemK, a library in the KTag project. * diff --git a/Results.h b/Results.h index 3f651ee..8b3be7c 100644 --- a/Results.h +++ b/Results.h @@ -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, diff --git a/Settings/Settings.csv b/Settings/Settings.csv new file mode 100644 index 0000000..3fbf3a6 --- /dev/null +++ b/Settings/Settings.csv @@ -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." \ No newline at end of file diff --git a/Settings/generate_settings_code.py b/Settings/generate_settings_code.py new file mode 100644 index 0000000..f78e9a4 --- /dev/null +++ b/Settings/generate_settings_code.py @@ -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() diff --git a/States/Starting_Game/State_Starting_Game.c b/States/Starting_Game/State_Starting_Game.c index 8f75a90..e6159b9 100644 --- a/States/Starting_Game/State_Starting_Game.c +++ b/States/Starting_Game/State_Starting_Game.c @@ -36,4 +36,4 @@ void Starting_Game_Entry(StateMachineContext_T * context) void Starting_Game_Exit(StateMachineContext_T * context) { -} \ No newline at end of file +} diff --git a/States/State_Initializing.c b/States/State_Initializing.c index 55e2b9f..50fd91c 100644 --- a/States/State_Initializing.c +++ b/States/State_Initializing.c @@ -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 } diff --git a/States/State_Machine.c b/States/State_Machine.c index 7bb4151..3b4ad32 100644 --- a/States/State_Machine.c +++ b/States/State_Machine.c @@ -194,4 +194,3 @@ void HandleBLEEventPacket(const BLE_EventPacket_T *const packet, StateMachineCon BLE_FreePacketBuffer((BLE_GenericPacketType_T *)packet); } - diff --git a/SystemK.h b/SystemK.h old mode 100755 new mode 100644 index 2ff8590..4fd14f2 --- a/SystemK.h +++ b/SystemK.h @@ -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"