Просмотр исходного кода

Merge laser_tag from https://github.com/RocketGod-git/Flipper-Zero-Laser-Tag

Willy-JL 1 год назад
Родитель
Сommit
e18609080c

+ 9 - 6
laser_tag/README.md

@@ -1,8 +1,7 @@
 # Flipper-Zero-Laser-Tag
 # Flipper-Zero-Laser-Tag
 
 
-## 🚀 Flipper Zero Laser Tag - Team based
-
-Flipper Zero Laser Tag brings your favorite laser tag experience to your Flipper Zero device! Whether you’re battling friends or just practicing your aim, this open-source project lets you dominate the laser tag arena with just your Flipper Zero.
+## 🚀 Real World Team based Laser Tag game
+Use Flipper Zero as your laser blaster, RFID scan for power-ups, and automatic detection of add-on weapons to GPIO such as the Rabbit Labs Masta-Blasta for arena style play.
 
 
 ### ⚡ Key Features:
 ### ⚡ Key Features:
 
 
@@ -11,6 +10,8 @@ Flipper Zero Laser Tag brings your favorite laser tag experience to your Flipper
 - **Immersive Sound**: Laser firing and game-over sounds to enhance your battlefield experience.
 - **Immersive Sound**: Laser firing and game-over sounds to enhance your battlefield experience.
 - **Dynamic Health and Ammo Bars**: Keep track of your health and ammo with clean, dynamic UI elements.
 - **Dynamic Health and Ammo Bars**: Keep track of your health and ammo with clean, dynamic UI elements.
 - **Vibration Feedback**: Feel every hit with integrated vibration feedback.
 - **Vibration Feedback**: Feel every hit with integrated vibration feedback.
+- **RFID Powerups**: Specific tags can be written to any T5577 or EM4100 for adding ammo.
+- **External IR Boards**: Add or remove an external infrared blaster anytime during gameplay to switch between internal/external IR gun or swap weapons.
 
 
 ## 📸 Screenshots
 ## 📸 Screenshots
 
 
@@ -26,9 +27,11 @@ Flipper Zero Laser Tag brings your favorite laser tag experience to your Flipper
 3. **Reload**: When your ammo runs out, press 'Down' to reload and get back into action.
 3. **Reload**: When your ammo runs out, press 'Down' to reload and get back into action.
 4. **Survive**: Track your health, and make sure to avoid getting hit by your opponents' lasers. If your health reaches zero, it's game over!
 4. **Survive**: Track your health, and make sure to avoid getting hit by your opponents' lasers. If your health reaches zero, it's game over!
 
 
-## 🤔 ToDo: 
+## 🏅 Current Powerups for RFID Tags (T5577/EM4100):
+- **Universal Ammo Refill**: `13 37 00 FD 0A` – Increases ammo by `0x0A` for any player.
+- **Red Team Ammo Refill**: `13 37 A1 FD 0A` – Increases ammo by `0x0A` for the Red player.
+- **Blue Team Ammo Refill**: `13 37 B2 FD 0A` – Increases ammo by `0x0A` for the Blue player.
 
 
-- Allow RFID tags to be scanned with Flipper to add health or other powerups so they can be placed around the play field. 
-- Possibly tap teammates Flipper to increase their health.
+*Tip*: You can modify the last byte (e.g., `0A`) to change the amount of ammo refilled. Stay tuned for future updates and new powerups!
 
 
 ![rocketgod_logo](https://github.com/RocketGod-git/shodanbot/assets/57732082/7929b554-0fba-4c2b-b22d-6772d23c4a18)
 ![rocketgod_logo](https://github.com/RocketGod-git/shodanbot/assets/57732082/7929b554-0fba-4c2b-b22d-6772d23c4a18)

+ 1 - 1
laser_tag/application.fam

@@ -6,7 +6,7 @@ App(
     cdefines=["APP_LASER_TAG"],
     cdefines=["APP_LASER_TAG"],
     fap_category="Games",
     fap_category="Games",
     fap_author="@RocketGod-git & @jamisonderek",
     fap_author="@RocketGod-git & @jamisonderek",
-    fap_version="1.1",
+    fap_version="2.0",
     fap_description="Laser Tag game for Flipper Zero",
     fap_description="Laser Tag game for Flipper Zero",
     fap_icon="icons/laser_tag_10px.png",
     fap_icon="icons/laser_tag_10px.png",
     fap_libs=["assets"],
     fap_libs=["assets"],

+ 5 - 0
laser_tag/docs/CHANGELOG.md

@@ -1,3 +1,8 @@
+## v2.0
+
+- Add RFID support for ammo reload by @jamisonderek
+- Add external infrared board support by @RocketGod-git
+
 ## v1.1
 ## v1.1
 
 
 - Update app icon
 - Update app icon

+ 16 - 9
laser_tag/docs/README.md

@@ -1,25 +1,32 @@
-# Flipper-Zero-Laser-Tag
+# Laser Tag
+**Turn your Flipper Zero into a Laser Tag Device!**
 
 
-## Laser Tag for Flipper Zero - Team Based!
-
-Flipper Zero Laser Tag brings your favorite laser tag experience to your Flipper Zero device! Whether you’re battling friends or just practicing your aim, this open-source project lets you dominate the laser tag arena with just your Flipper Zero.
+## Real World - Team based Laser Tag game
+Use Flipper Zero as your laser blaster, RFID scan for power-ups, and automatic detection of add-on weapons to GPIO such as the Rabbit Labs Masta-Blasta for arena style play.
 
 
 ## Key Features:
 ## Key Features:
-
 - **Team Battles**: Choose your team and face off in epic Red vs. Blue laser battles.
 - **Team Battles**: Choose your team and face off in epic Red vs. Blue laser battles.
 - **Real-Time Gameplay**: Smooth and responsive laser firing and hit detection.
 - **Real-Time Gameplay**: Smooth and responsive laser firing and hit detection.
 - **Immersive Sound**: Laser firing and game-over sounds to enhance your battlefield experience.
 - **Immersive Sound**: Laser firing and game-over sounds to enhance your battlefield experience.
 - **Dynamic Health and Ammo Bars**: Keep track of your health and ammo with clean, dynamic UI elements.
 - **Dynamic Health and Ammo Bars**: Keep track of your health and ammo with clean, dynamic UI elements.
 - **Vibration Feedback**: Feel every hit with integrated vibration feedback.
 - **Vibration Feedback**: Feel every hit with integrated vibration feedback.
+- **RFID Powerups**: Specific tags can be written to any T5577 or EM4100 for adding ammo.
+- **External IR Boards**: Add or remove an external infrared blaster anytime during gameplay to switch between internal/external IR gun or swap weapons.
 
 
 ## How to Play
 ## How to Play
-
 1. **Select Your Team**: Use the Left or Right button to choose between Red or Blue team.
 1. **Select Your Team**: Use the Left or Right button to choose between Red or Blue team.
 2. **Fire Your Laser**: Press the OK button to shoot your laser at your opponents.
 2. **Fire Your Laser**: Press the OK button to shoot your laser at your opponents.
 3. **Reload**: When your ammo runs out, press 'Down' to reload and get back into action.
 3. **Reload**: When your ammo runs out, press 'Down' to reload and get back into action.
 4. **Survive**: Track your health, and make sure to avoid getting hit by your opponents' lasers. If your health reaches zero, it's game over!
 4. **Survive**: Track your health, and make sure to avoid getting hit by your opponents' lasers. If your health reaches zero, it's game over!
+5. **RFID Powerups**: Press the UP button during gameplay to scan a Powerup Tag.
+
+## Current Powerups for RFID Tags (T5577/EM4100):
+- **Universal Ammo Refill**: `13 37 00 FD 0A` – Increases ammo by `0x0A` for any player.
+- **Red Team Ammo Refill**: `13 37 A1 FD 0A` – Increases ammo by `0x0A` for the Red player.
+- **Blue Team Ammo Refill**: `13 37 B2 FD 0A` – Increases ammo by `0x0A` for the Blue player.
 
 
-## ToDo: 
+*Tip*: You can modify the last byte (e.g., `0A`) to change the amount of ammo refilled. Stay tuned for future updates and new powerups!
 
 
-- Allow RFID tags to be scanned with Flipper to add health or other powerups so they can be placed around the play field. 
-- Possibly tap teammates Flipper to increase their health.
+## Developers:
+- **RocketGod** (@RocketGod-git)
+- **codeallnight** (@jamisonderek)

+ 42 - 8
laser_tag/infrared_controller.c

@@ -3,6 +3,9 @@
 #include <infrared_worker.h>
 #include <infrared_worker.h>
 #include <infrared_signal.h>
 #include <infrared_signal.h>
 #include <notification/notification_messages.h>
 #include <notification/notification_messages.h>
+#include <furi_hal_gpio.h>
+#include <furi_hal_power.h>
+#include <furi_hal_infrared.h>
 
 
 #define TAG "InfraredController"
 #define TAG "InfraredController"
 
 
@@ -15,16 +18,47 @@ const NotificationSequence sequence_hit = {
     NULL,
     NULL,
 };
 };
 
 
-struct InfraredController {
-    LaserTagTeam team;
-    InfraredWorker* worker;
-    bool worker_rx_active;
-    InfraredSignal* signal;
-    NotificationApp* notification;
-    bool hit_received;
-    bool processing_signal;
+const NotificationSequence sequence_bloop = {
+    &message_note_g3,
+    &message_delay_50,
+    &message_sound_off,
+    NULL,
 };
 };
 
 
+extern const NotificationSequence sequence_short_beep;
+
+static bool external_board_connected = false;
+
+static void infrared_setup_external_board(bool enable) {
+    if(enable) {
+        furi_hal_gpio_init(&gpio_ext_pa7, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
+        furi_hal_power_enable_otg();
+        furi_hal_infrared_set_tx_output(FuriHalInfraredTxPinExtPA7);
+    } else {
+        furi_hal_gpio_init(&gpio_ext_pa7, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
+        furi_hal_power_disable_otg();
+        furi_hal_infrared_set_tx_output(FuriHalInfraredTxPinInternal);
+    }
+}
+
+void update_infrared_board_status(InfraredController* controller) {
+    if(!controller || !controller->notification) return;
+
+    FuriHalInfraredTxPin detected_pin = furi_hal_infrared_detect_tx_output();
+
+    if(detected_pin == FuriHalInfraredTxPinExtPA7 && !external_board_connected) {
+        external_board_connected = true;
+        infrared_setup_external_board(true);
+        notification_message(controller->notification, &sequence_short_beep);
+        FURI_LOG_I(TAG, "External infrared board connected and powered.");
+    } else if(detected_pin == FuriHalInfraredTxPinInternal && external_board_connected) {
+        external_board_connected = false;
+        infrared_setup_external_board(false);
+        notification_message(controller->notification, &sequence_bloop);
+        FURI_LOG_I(TAG, "External infrared board disconnected and power disabled.");
+    }
+}
+
 static void infrared_rx_callback(void* context, InfraredWorkerSignal* received_signal) {
 static void infrared_rx_callback(void* context, InfraredWorkerSignal* received_signal) {
     FURI_LOG_I(TAG, "RX callback triggered");
     FURI_LOG_I(TAG, "RX callback triggered");
 
 

+ 13 - 1
laser_tag/infrared_controller.h

@@ -1,15 +1,27 @@
 #pragma once
 #pragma once
 
 
 #include <stdbool.h>
 #include <stdbool.h>
+#include <notification/notification.h>
+#include <infrared_worker.h>
+#include <infrared_signal.h>
 #include "game_state.h"
 #include "game_state.h"
 
 
-typedef struct InfraredController InfraredController;
+typedef struct InfraredController {
+    LaserTagTeam team;
+    InfraredWorker* worker;
+    bool worker_rx_active;
+    InfraredSignal* signal;
+    NotificationApp* notification;
+    bool hit_received;
+    bool processing_signal;
+} InfraredController;
 
 
 InfraredController* infrared_controller_alloc();
 InfraredController* infrared_controller_alloc();
 void infrared_controller_free(InfraredController* controller);
 void infrared_controller_free(InfraredController* controller);
 void infrared_controller_set_team(InfraredController* controller, LaserTagTeam team);
 void infrared_controller_set_team(InfraredController* controller, LaserTagTeam team);
 void infrared_controller_send(InfraredController* controller);
 void infrared_controller_send(InfraredController* controller);
 bool infrared_controller_receive(InfraredController* controller);
 bool infrared_controller_receive(InfraredController* controller);
+void update_infrared_board_status(InfraredController* controller);
 void infrared_controller_pause(InfraredController* controller);
 void infrared_controller_pause(InfraredController* controller);
 void infrared_controller_resume(InfraredController* controller);
 void infrared_controller_resume(InfraredController* controller);
 
 

+ 2 - 0
laser_tag/laser_tag_app.c

@@ -361,6 +361,8 @@ int32_t laser_tag_app(void* p) {
     while(running) {
     while(running) {
         FURI_LOG_D(TAG, "Start of main loop iteration");
         FURI_LOG_D(TAG, "Start of main loop iteration");
 
 
+        update_infrared_board_status(app->ir_controller);
+
         FuriStatus status = furi_message_queue_get(app->event_queue, &event, 100);
         FuriStatus status = furi_message_queue_get(app->event_queue, &event, 100);
         if(status == FuriStatusOk) {
         if(status == FuriStatusOk) {
             FURI_LOG_D(TAG, "Received input event: type=%d, key=%d", event.type, event.key);
             FURI_LOG_D(TAG, "Received input event: type=%d, key=%d", event.type, event.key);

+ 0 - 178
laser_tag/laser_tag_icons.c

@@ -1,178 +0,0 @@
-
-#include "laser_tag_icons.h"
-#include <gui/icon_i.h>
-
-const uint8_t laser_gun_icon_data[] = {
-    0,
-    0b00000000,
-    0b00000000,
-    0b00000001,
-    0b10000000,
-    0b00000011,
-    0b11000000,
-    0b00000111,
-    0b11100000,
-    0b00001111,
-    0b11110000,
-    0b00011111,
-    0b11111000,
-    0b11111111,
-    0b11111110,
-    0b11111111,
-    0b11111111,
-};
-
-const uint8_t health_icon_data[] = {
-    0,
-    0b00001100,
-    0b00110000,
-    0b00011110,
-    0b01111000,
-    0b00111111,
-    0b11111100,
-    0b01111111,
-    0b11111110,
-    0b01111111,
-    0b11111110,
-    0b00111111,
-    0b11111100,
-    0b00011111,
-    0b11111000,
-    0b00000111,
-    0b11100000,
-};
-
-const uint8_t ammo_icon_data[] = {
-    0,
-    0b00011000,
-    0b00011000,
-    0b00111100,
-    0b00111100,
-    0b01111110,
-    0b01111110,
-    0b11111111,
-    0b11111111,
-    0b11111111,
-    0b11111111,
-    0b01111110,
-    0b01111110,
-    0b00111100,
-    0b00111100,
-    0b00011000,
-    0b00011000,
-};
-
-const uint8_t team_red_icon_data[] = {
-    0,
-    0b00011000,
-    0b00011000,
-    0b00111100,
-    0b00111100,
-    0b01111110,
-    0b01111110,
-    0b11111111,
-    0b11111111,
-    0b11111111,
-    0b11111111,
-    0b01111110,
-    0b01111110,
-    0b00111100,
-    0b00111100,
-    0b00011000,
-    0b00011000,
-};
-
-const uint8_t team_blue_icon_data[] = {
-    0,
-    0b11100111,
-    0b11100111,
-    0b11000011,
-    0b11000011,
-    0b10000001,
-    0b10000001,
-    0b00000000,
-    0b00000000,
-    0b00000000,
-    0b00000000,
-    0b10000001,
-    0b10000001,
-    0b11000011,
-    0b11000011,
-    0b11100111,
-    0b11100111,
-};
-
-const uint8_t game_over_icon_data[] = {
-    0,
-    0b11111111,
-    0b11111111,
-    0b10000000,
-    0b00000001,
-    0b10111101,
-    0b10111101,
-    0b10100001,
-    0b10100001,
-    0b10100001,
-    0b10100001,
-    0b10111101,
-    0b10111101,
-    0b10000000,
-    0b00000001,
-    0b11111111,
-    0b11111111,
-};
-
-const uint8_t* const laser_gun_icon_frames[] = {laser_gun_icon_data};
-const uint8_t* const health_icon_frames[] = {health_icon_data};
-const uint8_t* const ammo_icon_frames[] = {ammo_icon_data};
-const uint8_t* const team_red_icon_frames[] = {team_red_icon_data};
-const uint8_t* const team_blue_icon_frames[] = {team_blue_icon_data};
-const uint8_t* const game_over_icon_frames[] = {game_over_icon_data};
-
-const Icon I_laser_gun_icon = {
-    .width = 16,
-    .height = 8,
-    .frame_count = 1,
-    .frame_rate = 0,
-    .frames = laser_gun_icon_frames,
-};
-
-const Icon I_health_icon = {
-    .width = 16,
-    .height = 8,
-    .frame_count = 1,
-    .frame_rate = 0,
-    .frames = health_icon_frames,
-};
-
-const Icon I_ammo_icon = {
-    .width = 16,
-    .height = 8,
-    .frame_count = 1,
-    .frame_rate = 0,
-    .frames = ammo_icon_frames,
-};
-
-const Icon I_team_red_icon = {
-    .width = 16,
-    .height = 8,
-    .frame_count = 1,
-    .frame_rate = 0,
-    .frames = team_red_icon_frames,
-};
-
-const Icon I_team_blue_icon = {
-    .width = 16,
-    .height = 8,
-    .frame_count = 1,
-    .frame_rate = 0,
-    .frames = team_blue_icon_frames,
-};
-
-const Icon I_game_over_icon = {
-    .width = 16,
-    .height = 8,
-    .frame_count = 1,
-    .frame_rate = 0,
-    .frames = game_over_icon_frames,
-};

+ 0 - 18
laser_tag/laser_tag_icons.h

@@ -1,18 +0,0 @@
-
-#pragma once
-
-#include <gui/icon.h>
-
-extern const Icon I_laser_gun_icon;
-extern const Icon I_health_icon;
-extern const Icon I_ammo_icon;
-extern const Icon I_team_red_icon;
-extern const Icon I_team_blue_icon;
-extern const Icon I_game_over_icon;
-
-#define LASER_GUN_ICON (&I_laser_gun_icon)
-#define HEALTH_ICON    (&I_health_icon)
-#define AMMO_ICON      (&I_ammo_icon)
-#define TEAM_RED_ICON  (&I_team_red_icon)
-#define TEAM_BLUE_ICON (&I_team_blue_icon)
-#define GAME_OVER_ICON (&I_game_over_icon)

+ 2 - 2
laser_tag/manifest.yml

@@ -13,8 +13,8 @@ screenshots:
 short_description: 'Laser Tag game for Flipper Zero'
 short_description: 'Laser Tag game for Flipper Zero'
 sourcecode:
 sourcecode:
   location:
   location:
-    commit_sha: f9b4be203cb2e47636477dbbd6971c0b8ce9f7b6
+    commit_sha: f4ffc246367430547f649fc5a493bb939c9f6e7d3
     origin: https://github.com/RocketGod-git/Flipper-Zero-Laser-Tag.git
     origin: https://github.com/RocketGod-git/Flipper-Zero-Laser-Tag.git
     subdir:
     subdir:
   type: git
   type: git
-version: 1.0
+version: 2.0