mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
add sec+ 1.0/2.0 433mhz in add manually, and run fbt fmt
This commit is contained in:
@@ -24,9 +24,11 @@ typedef enum {
|
|||||||
SubmenuIndexLinear_300_00,
|
SubmenuIndexLinear_300_00,
|
||||||
SubmenuIndexLiftMaster_315_00,
|
SubmenuIndexLiftMaster_315_00,
|
||||||
SubmenuIndexLiftMaster_390_00,
|
SubmenuIndexLiftMaster_390_00,
|
||||||
|
SubmenuIndexLiftMaster_433_00,
|
||||||
SubmenuIndexSecPlus_v2_310_00,
|
SubmenuIndexSecPlus_v2_310_00,
|
||||||
SubmenuIndexSecPlus_v2_315_00,
|
SubmenuIndexSecPlus_v2_315_00,
|
||||||
SubmenuIndexSecPlus_v2_390_00,
|
SubmenuIndexSecPlus_v2_390_00,
|
||||||
|
SubmenuIndexSecPlus_v2_433_00,
|
||||||
|
|
||||||
//SubGhzCustomEvent
|
//SubGhzCustomEvent
|
||||||
SubGhzCustomEventSceneDeleteSuccess = 100,
|
SubGhzCustomEventSceneDeleteSuccess = 100,
|
||||||
|
|||||||
@@ -167,6 +167,12 @@ void subghz_scene_set_type_on_enter(void* context) {
|
|||||||
SubmenuIndexLiftMaster_390_00,
|
SubmenuIndexLiftMaster_390_00,
|
||||||
subghz_scene_set_type_submenu_callback,
|
subghz_scene_set_type_submenu_callback,
|
||||||
subghz);
|
subghz);
|
||||||
|
submenu_add_item(
|
||||||
|
subghz->submenu,
|
||||||
|
"Security+1.0 433MHz",
|
||||||
|
SubmenuIndexLiftMaster_433_00,
|
||||||
|
subghz_scene_set_type_submenu_callback,
|
||||||
|
subghz);
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
subghz->submenu,
|
subghz->submenu,
|
||||||
"Security+2.0 310MHz",
|
"Security+2.0 310MHz",
|
||||||
@@ -185,6 +191,12 @@ void subghz_scene_set_type_on_enter(void* context) {
|
|||||||
SubmenuIndexSecPlus_v2_390_00,
|
SubmenuIndexSecPlus_v2_390_00,
|
||||||
subghz_scene_set_type_submenu_callback,
|
subghz_scene_set_type_submenu_callback,
|
||||||
subghz);
|
subghz);
|
||||||
|
submenu_add_item(
|
||||||
|
subghz->submenu,
|
||||||
|
"Security+2.0 433MHz",
|
||||||
|
SubmenuIndexSecPlus_v2_433_00,
|
||||||
|
subghz_scene_set_type_submenu_callback,
|
||||||
|
subghz);
|
||||||
|
|
||||||
submenu_set_selected_item(
|
submenu_set_selected_item(
|
||||||
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType));
|
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType));
|
||||||
@@ -359,6 +371,20 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
|||||||
generated_protocol = true;
|
generated_protocol = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SubmenuIndexLiftMaster_433_00:
|
||||||
|
while(!subghz_protocol_secplus_v1_check_fixed(key)) {
|
||||||
|
key = subghz_random_serial();
|
||||||
|
}
|
||||||
|
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||||
|
subghz,
|
||||||
|
SUBGHZ_PROTOCOL_SECPLUS_V1_NAME,
|
||||||
|
(uint64_t)key << 32 | 0xE6000000,
|
||||||
|
42,
|
||||||
|
433920000,
|
||||||
|
"AM650")) {
|
||||||
|
generated_protocol = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SubmenuIndexSecPlus_v2_310_00:
|
case SubmenuIndexSecPlus_v2_310_00:
|
||||||
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||||
subghz->txrx->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
subghz->txrx->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
||||||
@@ -413,6 +439,24 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
|||||||
}
|
}
|
||||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||||
break;
|
break;
|
||||||
|
case SubmenuIndexSecPlus_v2_433_00:
|
||||||
|
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||||
|
subghz->txrx->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
||||||
|
subghz_preset_init(subghz, "AM650", 433920000, NULL, 0);
|
||||||
|
if(subghz->txrx->transmitter) {
|
||||||
|
subghz_protocol_secplus_v2_create_data(
|
||||||
|
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||||
|
subghz->txrx->fff_data,
|
||||||
|
key,
|
||||||
|
0x68,
|
||||||
|
0xE500000,
|
||||||
|
subghz->txrx->preset);
|
||||||
|
generated_protocol = true;
|
||||||
|
} else {
|
||||||
|
generated_protocol = false;
|
||||||
|
}
|
||||||
|
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,48 +1,144 @@
|
|||||||
#define tile_0_width 8
|
#define tile_0_width 8
|
||||||
#define tile_0_height 8
|
#define tile_0_height 8
|
||||||
static uint8_t tile_0_bits[] = {
|
static uint8_t tile_0_bits[] = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_1_width 8
|
#define tile_1_width 8
|
||||||
#define tile_1_height 8
|
#define tile_1_height 8
|
||||||
static uint8_t tile_1_bits[] = {
|
static uint8_t tile_1_bits[] = {
|
||||||
0x00, 0x10, 0x18, 0x10, 0x10, 0x10, 0x10, 0x00, };
|
0x00,
|
||||||
|
0x10,
|
||||||
|
0x18,
|
||||||
|
0x10,
|
||||||
|
0x10,
|
||||||
|
0x10,
|
||||||
|
0x10,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_2_width 8
|
#define tile_2_width 8
|
||||||
#define tile_2_height 8
|
#define tile_2_height 8
|
||||||
static uint8_t tile_2_bits[] = {
|
static uint8_t tile_2_bits[] = {
|
||||||
0x00, 0x1C, 0x20, 0x20, 0x18, 0x04, 0x3C, 0x00, };
|
0x00,
|
||||||
|
0x1C,
|
||||||
|
0x20,
|
||||||
|
0x20,
|
||||||
|
0x18,
|
||||||
|
0x04,
|
||||||
|
0x3C,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_3_width 8
|
#define tile_3_width 8
|
||||||
#define tile_3_height 8
|
#define tile_3_height 8
|
||||||
static uint8_t tile_3_bits[] = {
|
static uint8_t tile_3_bits[] = {
|
||||||
0x00, 0x1C, 0x20, 0x20, 0x18, 0x20, 0x1C, 0x00, };
|
0x00,
|
||||||
|
0x1C,
|
||||||
|
0x20,
|
||||||
|
0x20,
|
||||||
|
0x18,
|
||||||
|
0x20,
|
||||||
|
0x1C,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_4_width 8
|
#define tile_4_width 8
|
||||||
#define tile_4_height 8
|
#define tile_4_height 8
|
||||||
static uint8_t tile_4_bits[] = {
|
static uint8_t tile_4_bits[] = {
|
||||||
0x00, 0x04, 0x14, 0x14, 0x3C, 0x10, 0x10, 0x00, };
|
0x00,
|
||||||
|
0x04,
|
||||||
|
0x14,
|
||||||
|
0x14,
|
||||||
|
0x3C,
|
||||||
|
0x10,
|
||||||
|
0x10,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_5_width 8
|
#define tile_5_width 8
|
||||||
#define tile_5_height 8
|
#define tile_5_height 8
|
||||||
static uint8_t tile_5_bits[] = {
|
static uint8_t tile_5_bits[] = {
|
||||||
0x00, 0x3C, 0x04, 0x1C, 0x20, 0x20, 0x1C, 0x00, };
|
0x00,
|
||||||
|
0x3C,
|
||||||
|
0x04,
|
||||||
|
0x1C,
|
||||||
|
0x20,
|
||||||
|
0x20,
|
||||||
|
0x1C,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_6_width 8
|
#define tile_6_width 8
|
||||||
#define tile_6_height 8
|
#define tile_6_height 8
|
||||||
static uint8_t tile_6_bits[] = {
|
static uint8_t tile_6_bits[] = {
|
||||||
0x00, 0x18, 0x24, 0x04, 0x1C, 0x24, 0x18, 0x00, };
|
0x00,
|
||||||
|
0x18,
|
||||||
|
0x24,
|
||||||
|
0x04,
|
||||||
|
0x1C,
|
||||||
|
0x24,
|
||||||
|
0x18,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_7_width 8
|
#define tile_7_width 8
|
||||||
#define tile_7_height 8
|
#define tile_7_height 8
|
||||||
static uint8_t tile_7_bits[] = {
|
static uint8_t tile_7_bits[] = {
|
||||||
0x00, 0x3C, 0x20, 0x20, 0x10, 0x08, 0x08, 0x00, };
|
0x00,
|
||||||
|
0x3C,
|
||||||
|
0x20,
|
||||||
|
0x20,
|
||||||
|
0x10,
|
||||||
|
0x08,
|
||||||
|
0x08,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_8_width 8
|
#define tile_8_width 8
|
||||||
#define tile_8_height 8
|
#define tile_8_height 8
|
||||||
static uint8_t tile_8_bits[] = {
|
static uint8_t tile_8_bits[] = {
|
||||||
0x00, 0x18, 0x24, 0x18, 0x24, 0x24, 0x18, 0x00, };
|
0x00,
|
||||||
|
0x18,
|
||||||
|
0x24,
|
||||||
|
0x18,
|
||||||
|
0x24,
|
||||||
|
0x24,
|
||||||
|
0x18,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
#define tile_flag_width 8
|
#define tile_flag_width 8
|
||||||
#define tile_flag_height 8
|
#define tile_flag_height 8
|
||||||
static uint8_t tile_flag_bits[] = {
|
static uint8_t tile_flag_bits[] = {
|
||||||
0xFF, 0x81, 0xB9, 0x89, 0x89, 0x9D, 0x81, 0xFF, };
|
0xFF,
|
||||||
|
0x81,
|
||||||
|
0xB9,
|
||||||
|
0x89,
|
||||||
|
0x89,
|
||||||
|
0x9D,
|
||||||
|
0x81,
|
||||||
|
0xFF,
|
||||||
|
};
|
||||||
#define tile_mine_width 8
|
#define tile_mine_width 8
|
||||||
#define tile_mine_height 8
|
#define tile_mine_height 8
|
||||||
static uint8_t tile_mine_bits[] = {
|
static uint8_t tile_mine_bits[] = {
|
||||||
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, };
|
0x55,
|
||||||
|
0xAA,
|
||||||
|
0x55,
|
||||||
|
0xAA,
|
||||||
|
0x55,
|
||||||
|
0xAA,
|
||||||
|
0x55,
|
||||||
|
0xAA,
|
||||||
|
};
|
||||||
#define tile_uncleared_width 8
|
#define tile_uncleared_width 8
|
||||||
#define tile_uncleared_height 8
|
#define tile_uncleared_height 8
|
||||||
static uint8_t tile_uncleared_bits[] = {
|
static uint8_t tile_uncleared_bits[] = {
|
||||||
0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, };
|
0xFF,
|
||||||
|
0x81,
|
||||||
|
0x81,
|
||||||
|
0x81,
|
||||||
|
0x81,
|
||||||
|
0x81,
|
||||||
|
0x81,
|
||||||
|
0xFF,
|
||||||
|
};
|
||||||
|
|||||||
@@ -251,11 +251,16 @@ static void setup_playfield(Minesweeper* minesweeper_state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void place_flag(Minesweeper* minesweeper_state) {
|
static void place_flag(Minesweeper* minesweeper_state) {
|
||||||
if (minesweeper_state->playfield[minesweeper_state->cursor_x][minesweeper_state->cursor_y] == TileTypeUncleared) {
|
if(minesweeper_state->playfield[minesweeper_state->cursor_x][minesweeper_state->cursor_y] ==
|
||||||
minesweeper_state->playfield[minesweeper_state->cursor_x][minesweeper_state->cursor_y] = TileTypeFlag;
|
TileTypeUncleared) {
|
||||||
|
minesweeper_state->playfield[minesweeper_state->cursor_x][minesweeper_state->cursor_y] =
|
||||||
|
TileTypeFlag;
|
||||||
minesweeper_state->flags_set++;
|
minesweeper_state->flags_set++;
|
||||||
} else if (minesweeper_state->playfield[minesweeper_state->cursor_x][minesweeper_state->cursor_y] == TileTypeFlag) {
|
} else if(
|
||||||
minesweeper_state->playfield[minesweeper_state->cursor_x][minesweeper_state->cursor_y] = TileTypeUncleared;
|
minesweeper_state->playfield[minesweeper_state->cursor_x][minesweeper_state->cursor_y] ==
|
||||||
|
TileTypeFlag) {
|
||||||
|
minesweeper_state->playfield[minesweeper_state->cursor_x][minesweeper_state->cursor_y] =
|
||||||
|
TileTypeUncleared;
|
||||||
minesweeper_state->flags_set--;
|
minesweeper_state->flags_set--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,7 +308,8 @@ static bool game_won(Minesweeper* minesweeper_state) {
|
|||||||
const char* header_text = "Game won!";
|
const char* header_text = "Game won!";
|
||||||
furi_string_cat_printf(tempStr, "Minefield cleared in %01d:%02d", minutes, seconds);
|
furi_string_cat_printf(tempStr, "Minefield cleared in %01d:%02d", minutes, seconds);
|
||||||
dialog_message_set_header(message, header_text, 64, 3, AlignCenter, AlignTop);
|
dialog_message_set_header(message, header_text, 64, 3, AlignCenter, AlignTop);
|
||||||
dialog_message_set_text(message, furi_string_get_cstr(tempStr), 64, 32, AlignCenter, AlignCenter);
|
dialog_message_set_text(
|
||||||
|
message, furi_string_get_cstr(tempStr), 64, 32, AlignCenter, AlignCenter);
|
||||||
dialog_message_set_buttons(message, NULL, "Play again", NULL);
|
dialog_message_set_buttons(message, NULL, "Play again", NULL);
|
||||||
dialog_message_set_icon(message, NULL, 72, 17);
|
dialog_message_set_icon(message, NULL, 72, 17);
|
||||||
|
|
||||||
@@ -326,7 +332,8 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minesweeper_state->playfield[cursor_x][cursor_y] >= TileType1 && minesweeper_state->playfield[cursor_x][cursor_y] <= TileType8) {
|
if(minesweeper_state->playfield[cursor_x][cursor_y] >= TileType1 &&
|
||||||
|
minesweeper_state->playfield[cursor_x][cursor_y] <= TileType8) {
|
||||||
// click on a cleared cell with a number
|
// click on a cleared cell with a number
|
||||||
// count the flags around
|
// count the flags around
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
@@ -352,7 +359,8 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
|
|||||||
if(auto_x == cursor_x && auto_y == cursor_y) {
|
if(auto_x == cursor_x && auto_y == cursor_y) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( auto_x >= 0 && auto_x < PLAYFIELD_WIDTH && auto_y >= 0 && auto_y < PLAYFIELD_HEIGHT) {
|
if(auto_x >= 0 && auto_x < PLAYFIELD_WIDTH && auto_y >= 0 &&
|
||||||
|
auto_y < PLAYFIELD_HEIGHT) {
|
||||||
if(minesweeper_state->playfield[auto_x][auto_y] == TileTypeUncleared) {
|
if(minesweeper_state->playfield[auto_x][auto_y] == TileTypeUncleared) {
|
||||||
if(!play_move(minesweeper_state, auto_x, auto_y)) {
|
if(!play_move(minesweeper_state, auto_x, auto_y)) {
|
||||||
// flags were wrong, we got a mine!
|
// flags were wrong, we got a mine!
|
||||||
@@ -395,7 +403,8 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
|
|||||||
if(auto_x == cursor_x && auto_y == cursor_y) {
|
if(auto_x == cursor_x && auto_y == cursor_y) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( auto_x >= 0 && auto_x < PLAYFIELD_WIDTH && auto_y >= 0 && auto_y < PLAYFIELD_HEIGHT) {
|
if(auto_x >= 0 && auto_x < PLAYFIELD_WIDTH && auto_y >= 0 &&
|
||||||
|
auto_y < PLAYFIELD_HEIGHT) {
|
||||||
if(minesweeper_state->playfield[auto_x][auto_y] == TileTypeUncleared) {
|
if(minesweeper_state->playfield[auto_x][auto_y] == TileTypeUncleared) {
|
||||||
play_move(minesweeper_state, auto_x, auto_y);
|
play_move(minesweeper_state, auto_x, auto_y);
|
||||||
}
|
}
|
||||||
@@ -496,7 +505,10 @@ int32_t minesweeper_app(void* p) {
|
|||||||
setup_playfield(minesweeper_state);
|
setup_playfield(minesweeper_state);
|
||||||
minesweeper_state->game_started = true;
|
minesweeper_state->game_started = true;
|
||||||
}
|
}
|
||||||
if (!play_move(minesweeper_state, minesweeper_state->cursor_x, minesweeper_state->cursor_y)) {
|
if(!play_move(
|
||||||
|
minesweeper_state,
|
||||||
|
minesweeper_state->cursor_x,
|
||||||
|
minesweeper_state->cursor_y)) {
|
||||||
// ooops. looks like we hit a mine!
|
// ooops. looks like we hit a mine!
|
||||||
if(game_lost(minesweeper_state)) {
|
if(game_lost(minesweeper_state)) {
|
||||||
// player wants to restart.
|
// player wants to restart.
|
||||||
@@ -507,7 +519,8 @@ int32_t minesweeper_app(void* p) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// check win condition.
|
// check win condition.
|
||||||
if (minesweeper_state->fields_cleared == (PLAYFIELD_HEIGHT*PLAYFIELD_WIDTH) - MINECOUNT){
|
if(minesweeper_state->fields_cleared ==
|
||||||
|
(PLAYFIELD_HEIGHT * PLAYFIELD_WIDTH) - MINECOUNT) {
|
||||||
if(game_won(minesweeper_state)) {
|
if(game_won(minesweeper_state)) {
|
||||||
//player wants to restart
|
//player wants to restart
|
||||||
setup_playfield(minesweeper_state);
|
setup_playfield(minesweeper_state);
|
||||||
|
|||||||
Reference in New Issue
Block a user