fixed the subghz part of the tanks game
13
applications/external/tanksgame/application.fam
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
App(
|
||||
appid="tanks",
|
||||
name="Tanks",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
entry_point="tanks_game_app",
|
||||
cdefines=["APP_TANKS_GAME"],
|
||||
requires=["gui", "subghz"],
|
||||
stack_size=4 * 1024,
|
||||
order=730,
|
||||
fap_icon="tanksIcon.png",
|
||||
fap_category="Games",
|
||||
fap_icon_assets="images",
|
||||
)
|
||||
19
applications/external/tanksgame/constants.h
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef FLIPPERZERO_FIRMWARE_CONSTANTS_H
|
||||
#define FLIPPERZERO_FIRMWARE_CONSTANTS_H
|
||||
|
||||
const uint8_t SCREEN_WIDTH_TANKS = 128;
|
||||
const uint8_t SCREEN_HEIGHT_TANKS = 64;
|
||||
|
||||
const uint8_t FIELD_WIDTH = 16;
|
||||
const uint8_t FIELD_HEIGHT = 11;
|
||||
|
||||
const uint16_t TURN_LENGTH = 300;
|
||||
const uint16_t LONG_PRESS_LENGTH = 10;
|
||||
|
||||
const uint8_t SHOT_COOLDOWN = 5;
|
||||
const uint8_t RESPAWN_COOLDOWN = 8;
|
||||
const uint8_t PLAYER_RESPAWN_COOLDOWN = 1;
|
||||
|
||||
const uint8_t CELL_LENGTH_PIXELS = 6;
|
||||
|
||||
#endif
|
||||
64
applications/external/tanksgame/helpers/radio_device_loader.c
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "radio_device_loader.h"
|
||||
|
||||
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
|
||||
#include <lib/subghz/devices/cc1101_int/cc1101_int_interconnect.h>
|
||||
|
||||
static void radio_device_loader_power_on() {
|
||||
uint8_t attempts = 0;
|
||||
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
|
||||
furi_hal_power_enable_otg();
|
||||
//CC1101 power-up time
|
||||
furi_delay_ms(10);
|
||||
}
|
||||
}
|
||||
|
||||
static void radio_device_loader_power_off() {
|
||||
if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg();
|
||||
}
|
||||
|
||||
bool radio_device_loader_is_connect_external(const char* name) {
|
||||
bool is_connect = false;
|
||||
bool is_otg_enabled = furi_hal_power_is_otg_enabled();
|
||||
|
||||
if(!is_otg_enabled) {
|
||||
radio_device_loader_power_on();
|
||||
}
|
||||
|
||||
const SubGhzDevice* device = subghz_devices_get_by_name(name);
|
||||
if(device) {
|
||||
is_connect = subghz_devices_is_connect(device);
|
||||
}
|
||||
|
||||
if(!is_otg_enabled) {
|
||||
radio_device_loader_power_off();
|
||||
}
|
||||
return is_connect;
|
||||
}
|
||||
|
||||
const SubGhzDevice* radio_device_loader_set(
|
||||
const SubGhzDevice* current_radio_device,
|
||||
SubGhzRadioDeviceType radio_device_type) {
|
||||
const SubGhzDevice* radio_device;
|
||||
|
||||
if(radio_device_type == SubGhzRadioDeviceTypeExternalCC1101 &&
|
||||
radio_device_loader_is_connect_external(SUBGHZ_DEVICE_CC1101_EXT_NAME)) {
|
||||
radio_device_loader_power_on();
|
||||
radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_EXT_NAME);
|
||||
subghz_devices_begin(radio_device);
|
||||
} else if(current_radio_device == NULL) {
|
||||
radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME);
|
||||
} else {
|
||||
radio_device_loader_end(current_radio_device);
|
||||
radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME);
|
||||
}
|
||||
|
||||
return radio_device;
|
||||
}
|
||||
|
||||
void radio_device_loader_end(const SubGhzDevice* radio_device) {
|
||||
furi_assert(radio_device);
|
||||
radio_device_loader_power_off();
|
||||
if(radio_device != subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME)) {
|
||||
subghz_devices_end(radio_device);
|
||||
}
|
||||
}
|
||||
15
applications/external/tanksgame/helpers/radio_device_loader.h
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <lib/subghz/devices/devices.h>
|
||||
|
||||
/** SubGhzRadioDeviceType */
|
||||
typedef enum {
|
||||
SubGhzRadioDeviceTypeInternal,
|
||||
SubGhzRadioDeviceTypeExternalCC1101,
|
||||
} SubGhzRadioDeviceType;
|
||||
|
||||
const SubGhzDevice* radio_device_loader_set(
|
||||
const SubGhzDevice* current_radio_device,
|
||||
SubGhzRadioDeviceType radio_device_type);
|
||||
|
||||
void radio_device_loader_end(const SubGhzDevice* radio_device);
|
||||
BIN
applications/external/tanksgame/images/HappyFlipper_128x64.png
vendored
Normal file
|
After Width: | Height: | Size: 633 B |
BIN
applications/external/tanksgame/images/TanksSplashScreen_128x64.png
vendored
Normal file
|
After Width: | Height: | Size: 649 B |
BIN
applications/external/tanksgame/images/enemy_down.png
vendored
Normal file
|
After Width: | Height: | Size: 157 B |
BIN
applications/external/tanksgame/images/enemy_left.png
vendored
Normal file
|
After Width: | Height: | Size: 159 B |
BIN
applications/external/tanksgame/images/enemy_right.png
vendored
Normal file
|
After Width: | Height: | Size: 159 B |
BIN
applications/external/tanksgame/images/enemy_up.png
vendored
Normal file
|
After Width: | Height: | Size: 160 B |
BIN
applications/external/tanksgame/images/projectile_down.png
vendored
Normal file
|
After Width: | Height: | Size: 104 B |
BIN
applications/external/tanksgame/images/projectile_left.png
vendored
Normal file
|
After Width: | Height: | Size: 106 B |
BIN
applications/external/tanksgame/images/projectile_right.png
vendored
Normal file
|
After Width: | Height: | Size: 108 B |
BIN
applications/external/tanksgame/images/projectile_up.png
vendored
Normal file
|
After Width: | Height: | Size: 102 B |
BIN
applications/external/tanksgame/images/tank_base.png
vendored
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
applications/external/tanksgame/images/tank_down.png
vendored
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
applications/external/tanksgame/images/tank_explosion.png
vendored
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
applications/external/tanksgame/images/tank_hedgehog.png
vendored
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
applications/external/tanksgame/images/tank_left.png
vendored
Normal file
|
After Width: | Height: | Size: 159 B |
BIN
applications/external/tanksgame/images/tank_right.png
vendored
Normal file
|
After Width: | Height: | Size: 155 B |
BIN
applications/external/tanksgame/images/tank_stone.png
vendored
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
applications/external/tanksgame/images/tank_up.png
vendored
Normal file
|
After Width: | Height: | Size: 157 B |
BIN
applications/external/tanksgame/images/tank_wall.png
vendored
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
applications/external/tanksgame/tanksIcon.png
vendored
Normal file
|
After Width: | Height: | Size: 1.9 KiB |