diff --git a/CHANGELOG.md b/CHANGELOG.md index 48d487185..75d414b30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,10 @@ ### New changes -* PR: Feature: lock device with pin by long pressing up button (by @an4tur0r | PR #107) -* Plugins: Updated TOTP (Authenticator) [(by akopachov)](https://github.com/akopachov/flipper-zero_authenticator) -* OFW PR: scripts: simpler tar format (OFW PR 1871 by hedger) -* OFW PR: Updated: MFC Improvements Part 2/2 (OFW PR 1868 by Astrrra) -* OFW: Dolphin: add L1_Painting animation -* OFW: fbt: more fixes & improvements -* OFW: Badusb: show script errors on screen +* Add 433Mhz Security+ 1.0/2.0 in add manually in subghz +* Update Minesweeper (https://github.com/panki27/minesweeper) +----- +* SubGHz: Fix DTM Neo (keeloq) encoder +* fbt: fix flash usb without resources +* OFW: DesktopSettings: reset submenu before running dialog #### [🎲 Download extra apps pack](https://download-directory.github.io/?url=https://github.com/UberGuidoZ/Flipper/tree/main/Applications/Unleashed) diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index 39acf5fd6..158ef623c 100644 --- a/applications/main/subghz/helpers/subghz_custom_event.h +++ b/applications/main/subghz/helpers/subghz_custom_event.h @@ -24,9 +24,11 @@ typedef enum { SubmenuIndexLinear_300_00, SubmenuIndexLiftMaster_315_00, SubmenuIndexLiftMaster_390_00, + SubmenuIndexLiftMaster_433_00, SubmenuIndexSecPlus_v2_310_00, SubmenuIndexSecPlus_v2_315_00, SubmenuIndexSecPlus_v2_390_00, + SubmenuIndexSecPlus_v2_433_00, //SubGhzCustomEvent SubGhzCustomEventSceneDeleteSuccess = 100, diff --git a/applications/main/subghz/scenes/subghz_scene_set_type.c b/applications/main/subghz/scenes/subghz_scene_set_type.c index 1771c984b..dd36ad08c 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_type.c +++ b/applications/main/subghz/scenes/subghz_scene_set_type.c @@ -167,6 +167,12 @@ void subghz_scene_set_type_on_enter(void* context) { SubmenuIndexLiftMaster_390_00, subghz_scene_set_type_submenu_callback, subghz); + submenu_add_item( + subghz->submenu, + "Security+1.0 433MHz", + SubmenuIndexLiftMaster_433_00, + subghz_scene_set_type_submenu_callback, + subghz); submenu_add_item( subghz->submenu, "Security+2.0 310MHz", @@ -185,6 +191,12 @@ void subghz_scene_set_type_on_enter(void* context) { SubmenuIndexSecPlus_v2_390_00, subghz_scene_set_type_submenu_callback, 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( 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; } 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: subghz->txrx->transmitter = subghz_transmitter_alloc_init( 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); 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: return false; break; diff --git a/applications/plugins/minesweeper/README.md b/applications/plugins/minesweeper/README.md index ab253a4a6..28176bd5e 100644 --- a/applications/plugins/minesweeper/README.md +++ b/applications/plugins/minesweeper/README.md @@ -11,6 +11,7 @@ This is a Minesweeper implementation for the Flipper Zero device. - Arrow buttons to move - Push center button to open field - Hold center button to toggle flag +- Push center button on an already open field that has the correct amount of flags surrounding it to auto-open the remaining ones (thanks @gelin!) ## Compiling diff --git a/applications/plugins/minesweeper/minesweeper.c b/applications/plugins/minesweeper/minesweeper.c index e825dfcdc..6d29bab2d 100644 --- a/applications/plugins/minesweeper/minesweeper.c +++ b/applications/plugins/minesweeper/minesweeper.c @@ -311,7 +311,6 @@ static bool game_won(Minesweeper* minesweeper_state) { dialog_message_set_text( message, furi_string_get_cstr(tempStr), 64, 32, AlignCenter, AlignCenter); dialog_message_set_buttons(message, NULL, "Play again", NULL); - // TODO: create icon dialog_message_set_icon(message, NULL, 72, 17); DialogMessageButton choice = dialog_message_show(dialogs, message); @@ -321,18 +320,23 @@ static bool game_won(Minesweeper* minesweeper_state) { return choice == DialogMessageButtonCenter; } +// returns false if the move loses the game - otherwise true static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y) { - if(minesweeper_state->playfield[cursor_x][cursor_y] != TileTypeUncleared) { - // we're on an already uncovered field + if(minesweeper_state->playfield[cursor_x][cursor_y] == TileTypeFlag) { + // we're on a flagged field, do nothing return true; } if(minesweeper_state->minefield[cursor_x][cursor_y] == FieldMine) { - // TODO: player loses! + // player loses - draw mine minesweeper_state->playfield[cursor_x][cursor_y] = TileTypeMine; return false; - } else { - // get number of surrounding mines. - int hint = 0; + } + + 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 + // count the flags around + int flags = 0; for(int y = cursor_y - 1; y <= cursor_y + 1; y++) { for(int x = cursor_x - 1; x <= cursor_x + 1; x++) { if(x == cursor_x && y == cursor_y) { @@ -341,18 +345,15 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y } // make sure we don't go OOB if(x >= 0 && x < PLAYFIELD_WIDTH && y >= 0 && y < PLAYFIELD_HEIGHT) { - if(minesweeper_state->minefield[x][y] == FieldMine) { - hint++; + if(minesweeper_state->playfield[x][y] == TileTypeFlag) { + flags++; } } } } - // 〜( ̄▽ ̄〜) don't judge me (〜 ̄▽ ̄)〜 - minesweeper_state->playfield[cursor_x][cursor_y] = hint; - minesweeper_state->fields_cleared++; - FURI_LOG_D("Minesweeper", "Setting %d,%d to %d", cursor_x, cursor_y, hint); - if(hint == 0) { - // auto open surrounding fields. + int mines = minesweeper_state->playfield[cursor_x][cursor_y]; // ¯\_(ツ)_/¯ + if(flags == mines) { + // auto uncover all non-flags around (to win faster ;) for(int auto_y = cursor_y - 1; auto_y <= cursor_y + 1; auto_y++) { for(int auto_x = cursor_x - 1; auto_x <= cursor_x + 1; auto_x++) { if(auto_x == cursor_x && auto_y == cursor_y) { @@ -361,14 +362,57 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y if(auto_x >= 0 && auto_x < PLAYFIELD_WIDTH && auto_y >= 0 && auto_y < PLAYFIELD_HEIGHT) { if(minesweeper_state->playfield[auto_x][auto_y] == TileTypeUncleared) { - play_move(minesweeper_state, auto_x, auto_y); + if(!play_move(minesweeper_state, auto_x, auto_y)) { + // flags were wrong, we got a mine! + return false; + } } } } } + // we're done without hitting a mine - so return + return true; } - return true; } + + // calculate number of surrounding mines. + int hint = 0; + for(int y = cursor_y - 1; y <= cursor_y + 1; y++) { + for(int x = cursor_x - 1; x <= cursor_x + 1; x++) { + if(x == cursor_x && y == cursor_y) { + // we're on the cell the user selected, so ignore. + continue; + } + // make sure we don't go OOB + if(x >= 0 && x < PLAYFIELD_WIDTH && y >= 0 && y < PLAYFIELD_HEIGHT) { + if(minesweeper_state->minefield[x][y] == FieldMine) { + hint++; + } + } + } + } + // 〜( ̄▽ ̄〜) don't judge me (〜 ̄▽ ̄)〜 + minesweeper_state->playfield[cursor_x][cursor_y] = hint; + minesweeper_state->fields_cleared++; + FURI_LOG_D("Minesweeper", "Setting %d,%d to %d", cursor_x, cursor_y, hint); + if(hint == 0) { + // the field is "empty" + // auto open surrounding fields. + for(int auto_y = cursor_y - 1; auto_y <= cursor_y + 1; auto_y++) { + for(int auto_x = cursor_x - 1; auto_x <= cursor_x + 1; auto_x++) { + if(auto_x == cursor_x && auto_y == cursor_y) { + continue; + } + if(auto_x >= 0 && auto_x < PLAYFIELD_WIDTH && auto_y >= 0 && + auto_y < PLAYFIELD_HEIGHT) { + if(minesweeper_state->playfield[auto_x][auto_y] == TileTypeUncleared) { + play_move(minesweeper_state, auto_x, auto_y); + } + } + } + } + } + return true; } static void minesweeper_state_init(Minesweeper* const minesweeper_state) { @@ -510,6 +554,9 @@ int32_t minesweeper_app(void* p) { } } } + } else { + // event timeout + ; } view_port_update(view_port); release_mutex(&state_mutex, minesweeper_state); diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 65927d7b1..4df10aff2 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -151,6 +151,11 @@ static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instanc instance->manufacture_name = ""; } + // DTM Neo uses 12bit, simple learning + if((strcmp(instance->manufacture_name, "DTM_Neo") == 0)) { + decrypt = btn << 28 | (instance->generic.serial & 0xFFF) << 16 | instance->generic.cnt; + } + // Nice Smilo, MHouse, JCM has 8bit serial - simple learning if((strcmp(instance->manufacture_name, "NICE_Smilo") == 0) || (strcmp(instance->manufacture_name, "NICE_MHOUSE") == 0) || diff --git a/scripts/update.py b/scripts/update.py index 6be1dce06..1ff818c46 100755 --- a/scripts/update.py +++ b/scripts/update.py @@ -80,6 +80,7 @@ class Main(App): stage_basename = "updater.bin" # used to be basename(self.args.stage) dfu_basename = "firmware.dfu" # used to be basename(self.args.dfu) radiobin_basename = "radio.bin" # used to be basename(self.args.radiobin) + radiobin_basename_arg = basename(self.args.radiobin) resources_basename = "" radio_version = 0 @@ -115,7 +116,7 @@ class Main(App): if self.args.dfu: dfu_size = os.stat(self.args.dfu).st_size shutil.copyfile(self.args.dfu, join(self.args.directory, dfu_basename)) - if radiobin_basename: + if radiobin_basename_arg: shutil.copyfile( self.args.radiobin, join(self.args.directory, radiobin_basename) ) @@ -155,10 +156,13 @@ class Main(App): file.writeComment("little-endian hex!") file.writeKey("Loader CRC", self.int2ffhex(self.crc(self.args.stage))) file.writeKey("Firmware", dfu_basename) - file.writeKey("Radio", radiobin_basename or "") + if radiobin_basename_arg: + file.writeKey("Radio", radiobin_basename) + else: + file.writeKey("Radio", "") file.writeKey("Radio address", self.int2ffhex(radio_addr)) file.writeKey("Radio version", self.int2ffhex(radio_version, 12)) - if radiobin_basename: + if radiobin_basename_arg: file.writeKey("Radio CRC", self.int2ffhex(self.crc(self.args.radiobin))) else: file.writeKey("Radio CRC", self.int2ffhex(0))