diff --git a/applications/ibutton/ibutton_app.h b/applications/ibutton/ibutton_app.h index ddaadfcda..5b529a1e2 100644 --- a/applications/ibutton/ibutton_app.h +++ b/applications/ibutton/ibutton_app.h @@ -9,7 +9,9 @@ #include "scene/ibutton_scene_read_crc_error.h" #include "scene/ibutton_scene_read_not_key_error.h" #include "scene/ibutton_scene_read_success.h" -#include "scene/ibutton_scene_readed_key_menu.h" +#include "scene/ibutton_scene_retry_confirm.h" +#include "scene/ibutton_scene_exit_confirm.h" +#include "scene/ibutton_scene_read_key_menu.h" #include "scene/ibutton_scene_write.h" #include "scene/ibutton_scene_write_success.h" #include "scene/ibutton_scene_saved_key_menu.h" @@ -42,7 +44,9 @@ public: SceneReadNotKeyError, SceneReadCRCError, SceneReadSuccess, - SceneReadedKeyMenu, + SceneRetryConfirm, + SceneExitConfirm, + SceneReadKeyMenu, SceneWrite, SceneWriteSuccess, SceneEmulate, @@ -105,7 +109,9 @@ private: {Scene::SceneReadCRCError, new iButtonSceneReadCRCError()}, {Scene::SceneReadNotKeyError, new iButtonSceneReadNotKeyError()}, {Scene::SceneReadSuccess, new iButtonSceneReadSuccess()}, - {Scene::SceneReadedKeyMenu, new iButtonSceneReadedKeyMenu()}, + {Scene::SceneRetryConfirm, new iButtonSceneRetryConfirm()}, + {Scene::SceneExitConfirm, new iButtonSceneExitConfirm()}, + {Scene::SceneReadKeyMenu, new iButtonSceneReadKeyMenu()}, {Scene::SceneWrite, new iButtonSceneWrite()}, {Scene::SceneWriteSuccess, new iButtonSceneWriteSuccess()}, {Scene::SceneEmulate, new iButtonSceneEmulate()}, diff --git a/applications/ibutton/scene/ibutton_scene_delete_success.cpp b/applications/ibutton/scene/ibutton_scene_delete_success.cpp index b2241141a..8c645a5f5 100644 --- a/applications/ibutton/scene/ibutton_scene_delete_success.cpp +++ b/applications/ibutton/scene/ibutton_scene_delete_success.cpp @@ -14,7 +14,7 @@ void iButtonSceneDeleteSuccess::on_enter(iButtonApp* app) { Popup* popup = view_manager->get_popup(); popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62); - popup_set_text(popup, "Deleted", 83, 19, AlignLeft, AlignBottom); + popup_set_header(popup, "Deleted", 83, 19, AlignLeft, AlignBottom); popup_set_callback(popup, popup_callback); popup_set_context(popup, app); diff --git a/applications/ibutton/scene/ibutton_scene_exit_confirm.cpp b/applications/ibutton/scene/ibutton_scene_exit_confirm.cpp new file mode 100644 index 000000000..2c9fe94cb --- /dev/null +++ b/applications/ibutton/scene/ibutton_scene_exit_confirm.cpp @@ -0,0 +1,51 @@ +#include "ibutton_scene_exit_confirm.h" +#include "../ibutton_app.h" + +static void widget_callback(GuiButtonType result, InputType type, void* context) { + furi_assert(context); + iButtonApp* app = static_cast(context); + iButtonEvent event; + + if(type == InputTypeShort) { + event.type = iButtonEvent::Type::EventTypeWidgetButtonResult; + event.payload.widget_button_result = result; + app->get_view_manager()->send_event(&event); + } +} + +void iButtonSceneExitConfirm::on_enter(iButtonApp* app) { + iButtonAppViewManager* view_manager = app->get_view_manager(); + Widget* widget = view_manager->get_widget(); + + widget_add_button_element(widget, GuiButtonTypeLeft, "Exit", widget_callback, app); + widget_add_button_element(widget, GuiButtonTypeRight, "Stay", widget_callback, app); + widget_add_string_element( + widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Exit to iButton menu"); + widget_add_string_element( + widget, 64, 29, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost"); + + view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget); +} + +bool iButtonSceneExitConfirm::on_event(iButtonApp* app, iButtonEvent* event) { + bool consumed = false; + + if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) { + if(event->payload.widget_button_result == GuiButtonTypeLeft) { + app->search_and_switch_to_previous_scene({iButtonApp::Scene::SceneStart}); + } else if(event->payload.widget_button_result == GuiButtonTypeRight) { + app->switch_to_previous_scene(); + } + consumed = true; + } else if(event->type == iButtonEvent::Type::EventTypeBack) { + consumed = true; + } + + return consumed; +} + +void iButtonSceneExitConfirm::on_exit(iButtonApp* app) { + iButtonAppViewManager* view_manager = app->get_view_manager(); + Widget* widget = view_manager->get_widget(); + widget_reset(widget); +} diff --git a/applications/ibutton/scene/ibutton_scene_exit_confirm.h b/applications/ibutton/scene/ibutton_scene_exit_confirm.h new file mode 100644 index 000000000..dc5981e13 --- /dev/null +++ b/applications/ibutton/scene/ibutton_scene_exit_confirm.h @@ -0,0 +1,9 @@ +#pragma once +#include "ibutton_scene_generic.h" + +class iButtonSceneExitConfirm : public iButtonScene { +public: + void on_enter(iButtonApp* app) final; + bool on_event(iButtonApp* app, iButtonEvent* event) final; + void on_exit(iButtonApp* app) final; +}; \ No newline at end of file diff --git a/applications/ibutton/scene/ibutton_scene_read.cpp b/applications/ibutton/scene/ibutton_scene_read.cpp index 1353ef96e..8a2abe617 100644 --- a/applications/ibutton/scene/ibutton_scene_read.cpp +++ b/applications/ibutton/scene/ibutton_scene_read.cpp @@ -34,15 +34,22 @@ bool iButtonSceneRead::on_event(iButtonApp* app, iButtonEvent* event) { consumed = true; iButtonKey* key = app->get_key(); + bool success = false; if(ibutton_key_get_type(key) == iButtonKeyDS1990) { if(!ibutton_key_dallas_crc_is_valid(key)) { app->switch_to_next_scene(iButtonApp::Scene::SceneReadCRCError); } else if(!ibutton_key_dallas_is_1990_key(key)) { app->switch_to_next_scene(iButtonApp::Scene::SceneReadNotKeyError); } else { - app->switch_to_next_scene(iButtonApp::Scene::SceneReadSuccess); + success = true; } } else { + success = true; + } + if(success) { + app->notify_success(); + app->notify_green_on(); + DOLPHIN_DEED(DolphinDeedIbuttonReadSuccess); app->switch_to_next_scene(iButtonApp::Scene::SceneReadSuccess); } } else if(event->type == iButtonEvent::Type::EventTypeTick) { diff --git a/applications/ibutton/scene/ibutton_scene_read_crc_error.cpp b/applications/ibutton/scene/ibutton_scene_read_crc_error.cpp index 1371334b0..213266cbb 100644 --- a/applications/ibutton/scene/ibutton_scene_read_crc_error.cpp +++ b/applications/ibutton/scene/ibutton_scene_read_crc_error.cpp @@ -47,7 +47,7 @@ bool iButtonSceneReadCRCError::on_event(iButtonApp* app, iButtonEvent* event) { if(event->type == iButtonEvent::Type::EventTypeDialogResult) { if(event->payload.dialog_result == DialogExResultRight) { - app->switch_to_next_scene(iButtonApp::Scene::SceneReadedKeyMenu); + app->switch_to_next_scene(iButtonApp::Scene::SceneReadKeyMenu); } else { app->switch_to_previous_scene(); } diff --git a/applications/ibutton/scene/ibutton_scene_readed_key_menu.cpp b/applications/ibutton/scene/ibutton_scene_read_key_menu.cpp similarity index 76% rename from applications/ibutton/scene/ibutton_scene_readed_key_menu.cpp rename to applications/ibutton/scene/ibutton_scene_read_key_menu.cpp index 02d540a24..b77572249 100644 --- a/applications/ibutton/scene/ibutton_scene_readed_key_menu.cpp +++ b/applications/ibutton/scene/ibutton_scene_read_key_menu.cpp @@ -1,11 +1,10 @@ -#include "ibutton_scene_readed_key_menu.h" +#include "ibutton_scene_read_key_menu.h" #include "../ibutton_app.h" typedef enum { SubmenuIndexWrite, SubmenuIndexEmulate, SubmenuIndexSave, - SubmenuIndexReadNewKey, } SubmenuIndex; static void submenu_callback(void* context, uint32_t index) { @@ -19,7 +18,7 @@ static void submenu_callback(void* context, uint32_t index) { app->get_view_manager()->send_event(&event); } -void iButtonSceneReadedKeyMenu::on_enter(iButtonApp* app) { +void iButtonSceneReadKeyMenu::on_enter(iButtonApp* app) { iButtonAppViewManager* view_manager = app->get_view_manager(); Submenu* submenu = view_manager->get_submenu(); @@ -28,13 +27,12 @@ void iButtonSceneReadedKeyMenu::on_enter(iButtonApp* app) { } submenu_add_item(submenu, "Save", SubmenuIndexSave, submenu_callback, app); submenu_add_item(submenu, "Emulate", SubmenuIndexEmulate, submenu_callback, app); - submenu_add_item(submenu, "Read new key", SubmenuIndexReadNewKey, submenu_callback, app); submenu_set_selected_item(submenu, submenu_item_selected); view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewSubmenu); } -bool iButtonSceneReadedKeyMenu::on_event(iButtonApp* app, iButtonEvent* event) { +bool iButtonSceneReadKeyMenu::on_event(iButtonApp* app, iButtonEvent* event) { bool consumed = false; if(event->type == iButtonEvent::Type::EventTypeMenuSelected) { @@ -49,20 +47,17 @@ bool iButtonSceneReadedKeyMenu::on_event(iButtonApp* app, iButtonEvent* event) { case SubmenuIndexSave: app->switch_to_next_scene(iButtonApp::Scene::SceneSaveName); break; - case SubmenuIndexReadNewKey: - app->search_and_switch_to_previous_scene({iButtonApp::Scene::SceneRead}); - break; } consumed = true; } else if(event->type == iButtonEvent::Type::EventTypeBack) { - app->search_and_switch_to_previous_scene({iButtonApp::Scene::SceneStart}); + app->switch_to_previous_scene(); consumed = true; } return consumed; } -void iButtonSceneReadedKeyMenu::on_exit(iButtonApp* app) { +void iButtonSceneReadKeyMenu::on_exit(iButtonApp* app) { iButtonAppViewManager* view = app->get_view_manager(); Submenu* submenu = view->get_submenu(); diff --git a/applications/ibutton/scene/ibutton_scene_readed_key_menu.h b/applications/ibutton/scene/ibutton_scene_read_key_menu.h similarity index 81% rename from applications/ibutton/scene/ibutton_scene_readed_key_menu.h rename to applications/ibutton/scene/ibutton_scene_read_key_menu.h index caa9ad431..e85ad815d 100644 --- a/applications/ibutton/scene/ibutton_scene_readed_key_menu.h +++ b/applications/ibutton/scene/ibutton_scene_read_key_menu.h @@ -1,7 +1,7 @@ #pragma once #include "ibutton_scene_generic.h" -class iButtonSceneReadedKeyMenu : public iButtonScene { +class iButtonSceneReadKeyMenu : public iButtonScene { public: void on_enter(iButtonApp* app) final; bool on_event(iButtonApp* app, iButtonEvent* event) final; diff --git a/applications/ibutton/scene/ibutton_scene_read_not_key_error.cpp b/applications/ibutton/scene/ibutton_scene_read_not_key_error.cpp index b88f4655d..7d0a235f1 100644 --- a/applications/ibutton/scene/ibutton_scene_read_not_key_error.cpp +++ b/applications/ibutton/scene/ibutton_scene_read_not_key_error.cpp @@ -47,7 +47,7 @@ bool iButtonSceneReadNotKeyError::on_event(iButtonApp* app, iButtonEvent* event) if(event->type == iButtonEvent::Type::EventTypeDialogResult) { if(event->payload.dialog_result == DialogExResultRight) { - app->switch_to_next_scene(iButtonApp::Scene::SceneReadedKeyMenu); + app->switch_to_next_scene(iButtonApp::Scene::SceneReadKeyMenu); } else { app->switch_to_previous_scene(); } diff --git a/applications/ibutton/scene/ibutton_scene_read_success.cpp b/applications/ibutton/scene/ibutton_scene_read_success.cpp index 6eb95721a..edf7d914e 100644 --- a/applications/ibutton/scene/ibutton_scene_read_success.cpp +++ b/applications/ibutton/scene/ibutton_scene_read_success.cpp @@ -18,7 +18,6 @@ void iButtonSceneReadSuccess::on_enter(iButtonApp* app) { DialogEx* dialog_ex = view_manager->get_dialog_ex(); iButtonKey* key = app->get_key(); const uint8_t* key_data = ibutton_key_get_data_p(key); - DOLPHIN_DEED(DolphinDeedIbuttonReadSuccess); switch(ibutton_key_get_type(key)) { case iButtonKeyDS1990: @@ -50,9 +49,6 @@ void iButtonSceneReadSuccess::on_enter(iButtonApp* app) { dialog_ex_set_context(dialog_ex, app); view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx); - - app->notify_success(); - app->notify_green_on(); } bool iButtonSceneReadSuccess::on_event(iButtonApp* app, iButtonEvent* event) { @@ -60,11 +56,13 @@ bool iButtonSceneReadSuccess::on_event(iButtonApp* app, iButtonEvent* event) { if(event->type == iButtonEvent::Type::EventTypeDialogResult) { if(event->payload.dialog_result == DialogExResultRight) { - app->switch_to_next_scene(iButtonApp::Scene::SceneReadedKeyMenu); + app->switch_to_next_scene(iButtonApp::Scene::SceneReadKeyMenu); } else { - app->switch_to_previous_scene(); + app->switch_to_next_scene(iButtonApp::Scene::SceneRetryConfirm); } - + consumed = true; + } else if(event->type == iButtonEvent::Type::EventTypeBack) { + app->switch_to_next_scene(iButtonApp::Scene::SceneExitConfirm); consumed = true; } diff --git a/applications/ibutton/scene/ibutton_scene_retry_confirm.cpp b/applications/ibutton/scene/ibutton_scene_retry_confirm.cpp new file mode 100644 index 000000000..aa3483b3d --- /dev/null +++ b/applications/ibutton/scene/ibutton_scene_retry_confirm.cpp @@ -0,0 +1,51 @@ +#include "ibutton_scene_retry_confirm.h" +#include "../ibutton_app.h" + +static void widget_callback(GuiButtonType result, InputType type, void* context) { + furi_assert(context); + iButtonApp* app = static_cast(context); + iButtonEvent event; + + if(type == InputTypeShort) { + event.type = iButtonEvent::Type::EventTypeWidgetButtonResult; + event.payload.widget_button_result = result; + app->get_view_manager()->send_event(&event); + } +} + +void iButtonSceneRetryConfirm::on_enter(iButtonApp* app) { + iButtonAppViewManager* view_manager = app->get_view_manager(); + Widget* widget = view_manager->get_widget(); + + widget_add_button_element(widget, GuiButtonTypeLeft, "Exit", widget_callback, app); + widget_add_button_element(widget, GuiButtonTypeRight, "Stay", widget_callback, app); + widget_add_string_element( + widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Return to reading?"); + widget_add_string_element( + widget, 64, 29, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost"); + + view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget); +} + +bool iButtonSceneRetryConfirm::on_event(iButtonApp* app, iButtonEvent* event) { + bool consumed = false; + + if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) { + if(event->payload.widget_button_result == GuiButtonTypeLeft) { + app->search_and_switch_to_previous_scene({iButtonApp::Scene::SceneRead}); + } else if(event->payload.widget_button_result == GuiButtonTypeRight) { + app->switch_to_previous_scene(); + } + consumed = true; + } else if(event->type == iButtonEvent::Type::EventTypeBack) { + consumed = true; + } + + return consumed; +} + +void iButtonSceneRetryConfirm::on_exit(iButtonApp* app) { + iButtonAppViewManager* view_manager = app->get_view_manager(); + Widget* widget = view_manager->get_widget(); + widget_reset(widget); +} diff --git a/applications/ibutton/scene/ibutton_scene_retry_confirm.h b/applications/ibutton/scene/ibutton_scene_retry_confirm.h new file mode 100644 index 000000000..2f96e13f1 --- /dev/null +++ b/applications/ibutton/scene/ibutton_scene_retry_confirm.h @@ -0,0 +1,9 @@ +#pragma once +#include "ibutton_scene_generic.h" + +class iButtonSceneRetryConfirm : public iButtonScene { +public: + void on_enter(iButtonApp* app) final; + bool on_event(iButtonApp* app, iButtonEvent* event) final; + void on_exit(iButtonApp* app) final; +}; \ No newline at end of file diff --git a/applications/ibutton/scene/ibutton_scene_save_name.cpp b/applications/ibutton/scene/ibutton_scene_save_name.cpp index 9a7ab8460..71eee148b 100644 --- a/applications/ibutton/scene/ibutton_scene_save_name.cpp +++ b/applications/ibutton/scene/ibutton_scene_save_name.cpp @@ -49,7 +49,7 @@ bool iButtonSceneSaveName::on_event(iButtonApp* app, iButtonEvent* event) { app->switch_to_next_scene(iButtonApp::Scene::SceneSaveSuccess); } else { app->search_and_switch_to_previous_scene( - {iButtonApp::Scene::SceneReadedKeyMenu, + {iButtonApp::Scene::SceneReadKeyMenu, iButtonApp::Scene::SceneSavedKeyMenu, iButtonApp::Scene::SceneAddType}); } diff --git a/applications/ibutton/scene/ibutton_scene_save_success.cpp b/applications/ibutton/scene/ibutton_scene_save_success.cpp index 0a1fc153a..13e173d2d 100644 --- a/applications/ibutton/scene/ibutton_scene_save_success.cpp +++ b/applications/ibutton/scene/ibutton_scene_save_success.cpp @@ -16,7 +16,7 @@ void iButtonSceneSaveSuccess::on_enter(iButtonApp* app) { DOLPHIN_DEED(DolphinDeedIbuttonSave); popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59); - popup_set_text(popup, "Saved!", 13, 22, AlignLeft, AlignBottom); + popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop); popup_set_callback(popup, popup_callback); popup_set_context(popup, app); @@ -31,7 +31,7 @@ bool iButtonSceneSaveSuccess::on_event(iButtonApp* app, iButtonEvent* event) { if(event->type == iButtonEvent::Type::EventTypeBack) { app->search_and_switch_to_previous_scene( - {iButtonApp::Scene::SceneReadedKeyMenu, + {iButtonApp::Scene::SceneReadKeyMenu, iButtonApp::Scene::SceneSavedKeyMenu, iButtonApp::Scene::SceneAddType}); consumed = true; diff --git a/applications/ibutton/scene/ibutton_scene_write_success.cpp b/applications/ibutton/scene/ibutton_scene_write_success.cpp index dbeb595d0..397347046 100644 --- a/applications/ibutton/scene/ibutton_scene_write_success.cpp +++ b/applications/ibutton/scene/ibutton_scene_write_success.cpp @@ -33,7 +33,7 @@ bool iButtonSceneWriteSuccess::on_event(iButtonApp* app, iButtonEvent* event) { if(event->type == iButtonEvent::Type::EventTypeBack) { app->search_and_switch_to_previous_scene( - {iButtonApp::Scene::SceneReadedKeyMenu, iButtonApp::Scene::SceneStart}); + {iButtonApp::Scene::SceneReadKeyMenu, iButtonApp::Scene::SceneStart}); consumed = true; } diff --git a/applications/infrared/scene/infrared_app_scene_edit_rename_done.cpp b/applications/infrared/scene/infrared_app_scene_edit_rename_done.cpp index 47ef343b5..2b6afafd6 100644 --- a/applications/infrared/scene/infrared_app_scene_edit_rename_done.cpp +++ b/applications/infrared/scene/infrared_app_scene_edit_rename_done.cpp @@ -5,7 +5,6 @@ void InfraredAppSceneEditRenameDone::on_enter(InfraredApp* app) { Popup* popup = view_manager->get_popup(); popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59); - popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop); popup_set_callback(popup, InfraredApp::popup_callback); diff --git a/applications/lfrfid/helpers/decoder_emmarin.cpp b/applications/lfrfid/helpers/decoder_emmarin.cpp index d80fc1d59..daa8e238c 100644 --- a/applications/lfrfid/helpers/decoder_emmarin.cpp +++ b/applications/lfrfid/helpers/decoder_emmarin.cpp @@ -15,7 +15,7 @@ constexpr uint32_t long_time_high = long_time + jitter_time; void DecoderEMMarin::reset_state() { ready = false; - readed_data = 0; + read_data = 0; manchester_advance( manchester_saved_state, ManchesterEventReset, &manchester_saved_state, nullptr); } @@ -26,7 +26,7 @@ bool DecoderEMMarin::read(uint8_t* data, uint8_t data_size) { if(ready) { result = true; em_marin.decode( - reinterpret_cast(&readed_data), sizeof(uint64_t), data, data_size); + reinterpret_cast(&read_data), sizeof(uint64_t), data, data_size); ready = false; } @@ -59,10 +59,10 @@ void DecoderEMMarin::process_front(bool polarity, uint32_t time) { manchester_advance(manchester_saved_state, event, &manchester_saved_state, &data); if(data_ok) { - readed_data = (readed_data << 1) | data; + read_data = (read_data << 1) | data; ready = em_marin.can_be_decoded( - reinterpret_cast(&readed_data), sizeof(uint64_t)); + reinterpret_cast(&read_data), sizeof(uint64_t)); } } } diff --git a/applications/lfrfid/helpers/decoder_emmarin.h b/applications/lfrfid/helpers/decoder_emmarin.h index c2bd64e33..a3b48d71c 100644 --- a/applications/lfrfid/helpers/decoder_emmarin.h +++ b/applications/lfrfid/helpers/decoder_emmarin.h @@ -13,7 +13,7 @@ public: private: void reset_state(); - uint64_t readed_data = 0; + uint64_t read_data = 0; std::atomic ready; ManchesterState manchester_saved_state; diff --git a/applications/lfrfid/helpers/rfid_reader.cpp b/applications/lfrfid/helpers/rfid_reader.cpp index e9be694ee..1a6ed5f70 100644 --- a/applications/lfrfid/helpers/rfid_reader.cpp +++ b/applications/lfrfid/helpers/rfid_reader.cpp @@ -78,7 +78,7 @@ void RfidReader::start() { start_comparator(); switch_timer_reset(); - last_readed_count = 0; + last_read_count = 0; } void RfidReader::start_forced(RfidReader::Type _type) { @@ -97,45 +97,45 @@ void RfidReader::stop() { bool RfidReader::read(LfrfidKeyType* _type, uint8_t* data, uint8_t data_size, bool switch_enable) { bool result = false; - bool something_readed = false; + bool something_read = false; // reading if(decoder_em.read(data, data_size)) { *_type = LfrfidKeyType::KeyEM4100; - something_readed = true; + something_read = true; } if(decoder_hid26.read(data, data_size)) { *_type = LfrfidKeyType::KeyH10301; - something_readed = true; + something_read = true; } if(decoder_indala.read(data, data_size)) { *_type = LfrfidKeyType::KeyI40134; - something_readed = true; + something_read = true; } // validation - if(something_readed) { + if(something_read) { switch_timer_reset(); - if(last_readed_type == *_type && memcmp(last_readed_data, data, data_size) == 0) { - last_readed_count = last_readed_count + 1; + if(last_read_type == *_type && memcmp(last_read_data, data, data_size) == 0) { + last_read_count = last_read_count + 1; - if(last_readed_count > 2) { + if(last_read_count > 2) { result = true; } } else { - last_readed_type = *_type; - memcpy(last_readed_data, data, data_size); - last_readed_count = 0; + last_read_type = *_type; + memcpy(last_read_data, data, data_size); + last_read_count = 0; } } // mode switching if(switch_enable && switch_timer_elapsed()) { switch_mode(); - last_readed_count = 0; + last_read_count = 0; } return result; @@ -152,7 +152,7 @@ bool RfidReader::detect() { } bool RfidReader::any_read() { - return last_readed_count > 0; + return last_read_count > 0; } void RfidReader::start_comparator(void) { diff --git a/applications/lfrfid/helpers/rfid_reader.h b/applications/lfrfid/helpers/rfid_reader.h index 9ed6e5897..b3a93b89c 100644 --- a/applications/lfrfid/helpers/rfid_reader.h +++ b/applications/lfrfid/helpers/rfid_reader.h @@ -49,9 +49,9 @@ private: void switch_timer_reset(); void switch_mode(); - LfrfidKeyType last_readed_type; - uint8_t last_readed_data[LFRFID_KEY_SIZE]; - uint8_t last_readed_count; + LfrfidKeyType last_read_type; + uint8_t last_read_data[LFRFID_KEY_SIZE]; + uint8_t last_read_count; Type type = Type::Normal; }; diff --git a/applications/lfrfid/lfrfid_app.cpp b/applications/lfrfid/lfrfid_app.cpp index fecf15a7e..4653eb2d5 100644 --- a/applications/lfrfid/lfrfid_app.cpp +++ b/applications/lfrfid/lfrfid_app.cpp @@ -2,7 +2,9 @@ #include "scene/lfrfid_app_scene_start.h" #include "scene/lfrfid_app_scene_read.h" #include "scene/lfrfid_app_scene_read_success.h" -#include "scene/lfrfid_app_scene_readed_menu.h" +#include "scene/lfrfid_app_scene_retry_confirm.h" +#include "scene/lfrfid_app_scene_exit_confirm.h" +#include "scene/lfrfid_app_scene_read_menu.h" #include "scene/lfrfid_app_scene_write.h" #include "scene/lfrfid_app_scene_write_success.h" #include "scene/lfrfid_app_scene_emulate.h" @@ -48,8 +50,10 @@ void LfRfidApp::run(void* _args) { } else { scene_controller.add_scene(SceneType::Start, new LfRfidAppSceneStart()); scene_controller.add_scene(SceneType::Read, new LfRfidAppSceneRead()); + scene_controller.add_scene(SceneType::RetryConfirm, new LfRfidAppSceneRetryConfirm()); + scene_controller.add_scene(SceneType::ExitConfirm, new LfRfidAppSceneExitConfirm()); scene_controller.add_scene(SceneType::ReadSuccess, new LfRfidAppSceneReadSuccess()); - scene_controller.add_scene(SceneType::ReadedMenu, new LfRfidAppSceneReadedMenu()); + scene_controller.add_scene(SceneType::ReadKeyMenu, new LfRfidAppSceneReadKeyMenu()); scene_controller.add_scene(SceneType::Write, new LfRfidAppSceneWrite()); scene_controller.add_scene(SceneType::WriteSuccess, new LfRfidAppSceneWriteSuccess()); scene_controller.add_scene(SceneType::Emulate, new LfRfidAppSceneEmulate()); diff --git a/applications/lfrfid/lfrfid_app.h b/applications/lfrfid/lfrfid_app.h index a73fccea1..dddfb753a 100644 --- a/applications/lfrfid/lfrfid_app.h +++ b/applications/lfrfid/lfrfid_app.h @@ -27,13 +27,17 @@ public: GENERIC_EVENT_ENUM_VALUES, Next, MenuSelected, + Stay, + Retry, }; enum class SceneType : uint8_t { GENERIC_SCENE_ENUM_VALUES, Read, ReadSuccess, - ReadedMenu, + RetryConfirm, + ExitConfirm, + ReadKeyMenu, Write, WriteSuccess, Emulate, diff --git a/applications/lfrfid/scene/lfrfid_app_scene_delete_confirm.cpp b/applications/lfrfid/scene/lfrfid_app_scene_delete_confirm.cpp index 8f8fe9af0..5b7ac0f95 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_delete_confirm.cpp +++ b/applications/lfrfid/scene/lfrfid_app_scene_delete_confirm.cpp @@ -73,6 +73,11 @@ bool LfRfidAppSceneDeleteConfirm::on_event(LfRfidApp* app, LfRfidApp::Event* eve app->delete_key(&app->worker.key); app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::DeleteSuccess); consumed = true; + } else if(event->type == LfRfidApp::EventType::Stay) { + app->scene_controller.switch_to_previous_scene(); + consumed = true; + } else if(event->type == LfRfidApp::EventType::Back) { + consumed = true; } return consumed; @@ -88,7 +93,7 @@ void LfRfidAppSceneDeleteConfirm::on_exit(LfRfidApp* app) { void LfRfidAppSceneDeleteConfirm::back_callback(void* context) { LfRfidApp* app = static_cast(context); LfRfidApp::Event event; - event.type = LfRfidApp::EventType::Back; + event.type = LfRfidApp::EventType::Stay; app->view_controller.send_event(&event); } diff --git a/applications/lfrfid/scene/lfrfid_app_scene_delete_success.cpp b/applications/lfrfid/scene/lfrfid_app_scene_delete_success.cpp index cb0d6eb79..a4f2bf38d 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_delete_success.cpp +++ b/applications/lfrfid/scene/lfrfid_app_scene_delete_success.cpp @@ -4,7 +4,7 @@ void LfRfidAppSceneDeleteSuccess::on_enter(LfRfidApp* app, bool need_restore) { auto popup = app->view_controller.get(); popup->set_icon(0, 2, &I_DolphinMafia_115x62); - popup->set_text("Deleted", 83, 19, AlignLeft, AlignBottom); + popup->set_header("Deleted", 83, 19, AlignLeft, AlignBottom); popup->set_context(app); popup->set_callback(LfRfidAppSceneDeleteSuccess::timeout_callback); popup->set_timeout(1500); diff --git a/applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.cpp b/applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.cpp new file mode 100644 index 000000000..262dfca1c --- /dev/null +++ b/applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.cpp @@ -0,0 +1,59 @@ +#include "lfrfid_app_scene_exit_confirm.h" +#include "../view/elements/button_element.h" +#include "../view/elements/icon_element.h" +#include "../view/elements/string_element.h" + +void LfRfidAppSceneExitConfirm::on_enter(LfRfidApp* app, bool need_restore) { + auto container = app->view_controller.get(); + + auto button = container->add(); + button->set_type(ButtonElement::Type::Left, "Exit"); + button->set_callback(app, LfRfidAppSceneExitConfirm::exit_callback); + + button = container->add(); + button->set_type(ButtonElement::Type::Right, "Stay"); + button->set_callback(app, LfRfidAppSceneExitConfirm::stay_callback); + + auto line_1 = container->add(); + auto line_2 = container->add(); + + line_1->set_text("Exit to RFID menu?", 64, 19, 128 - 2, AlignCenter, AlignBottom, FontPrimary); + line_2->set_text( + "All unsaved data will be lost", 64, 29, 0, AlignCenter, AlignBottom, FontSecondary); + + app->view_controller.switch_to(); +} + +bool LfRfidAppSceneExitConfirm::on_event(LfRfidApp* app, LfRfidApp::Event* event) { + bool consumed = false; + + if(event->type == LfRfidApp::EventType::Next) { + app->scene_controller.search_and_switch_to_previous_scene({LfRfidApp::SceneType::Start}); + consumed = true; + } else if(event->type == LfRfidApp::EventType::Stay) { + app->scene_controller.switch_to_previous_scene(); + consumed = true; + } else if(event->type == LfRfidApp::EventType::Back) { + consumed = true; + } + + return consumed; +} + +void LfRfidAppSceneExitConfirm::on_exit(LfRfidApp* app) { + app->view_controller.get()->clean(); +} + +void LfRfidAppSceneExitConfirm::exit_callback(void* context) { + LfRfidApp* app = static_cast(context); + LfRfidApp::Event event; + event.type = LfRfidApp::EventType::Next; + app->view_controller.send_event(&event); +} + +void LfRfidAppSceneExitConfirm::stay_callback(void* context) { + LfRfidApp* app = static_cast(context); + LfRfidApp::Event event; + event.type = LfRfidApp::EventType::Stay; + app->view_controller.send_event(&event); +} diff --git a/applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.h b/applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.h new file mode 100644 index 000000000..4f960d22f --- /dev/null +++ b/applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.h @@ -0,0 +1,13 @@ +#pragma once +#include "../lfrfid_app.h" + +class LfRfidAppSceneExitConfirm : public GenericScene { +public: + void on_enter(LfRfidApp* app, bool need_restore) final; + bool on_event(LfRfidApp* app, LfRfidApp::Event* event) final; + void on_exit(LfRfidApp* app) final; + +private: + static void exit_callback(void* context); + static void stay_callback(void* context); +}; \ No newline at end of file diff --git a/applications/lfrfid/scene/lfrfid_app_scene_readed_menu.cpp b/applications/lfrfid/scene/lfrfid_app_scene_read_menu.cpp similarity index 77% rename from applications/lfrfid/scene/lfrfid_app_scene_readed_menu.cpp rename to applications/lfrfid/scene/lfrfid_app_scene_read_menu.cpp index 9b0a6d8a1..ce0461f92 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_readed_menu.cpp +++ b/applications/lfrfid/scene/lfrfid_app_scene_read_menu.cpp @@ -1,4 +1,4 @@ -#include "lfrfid_app_scene_readed_menu.h" +#include "lfrfid_app_scene_read_menu.h" typedef enum { SubmenuWrite, @@ -6,7 +6,7 @@ typedef enum { SubmenuEmulate, } SubmenuIndex; -void LfRfidAppSceneReadedMenu::on_enter(LfRfidApp* app, bool need_restore) { +void LfRfidAppSceneReadKeyMenu::on_enter(LfRfidApp* app, bool need_restore) { auto submenu = app->view_controller.get(); submenu->add_item("Write", SubmenuWrite, submenu_callback, app); @@ -20,7 +20,7 @@ void LfRfidAppSceneReadedMenu::on_enter(LfRfidApp* app, bool need_restore) { app->view_controller.switch_to(); } -bool LfRfidAppSceneReadedMenu::on_event(LfRfidApp* app, LfRfidApp::Event* event) { +bool LfRfidAppSceneReadKeyMenu::on_event(LfRfidApp* app, LfRfidApp::Event* event) { bool consumed = false; if(event->type == LfRfidApp::EventType::MenuSelected) { @@ -38,18 +38,18 @@ bool LfRfidAppSceneReadedMenu::on_event(LfRfidApp* app, LfRfidApp::Event* event) } consumed = true; } else if(event->type == LfRfidApp::EventType::Back) { - app->scene_controller.search_and_switch_to_previous_scene({LfRfidApp::SceneType::Start}); + app->scene_controller.switch_to_previous_scene(); consumed = true; } return consumed; } -void LfRfidAppSceneReadedMenu::on_exit(LfRfidApp* app) { +void LfRfidAppSceneReadKeyMenu::on_exit(LfRfidApp* app) { app->view_controller.get()->clean(); } -void LfRfidAppSceneReadedMenu::submenu_callback(void* context, uint32_t index) { +void LfRfidAppSceneReadKeyMenu::submenu_callback(void* context, uint32_t index) { LfRfidApp* app = static_cast(context); LfRfidApp::Event event; diff --git a/applications/lfrfid/scene/lfrfid_app_scene_readed_menu.h b/applications/lfrfid/scene/lfrfid_app_scene_read_menu.h similarity index 82% rename from applications/lfrfid/scene/lfrfid_app_scene_readed_menu.h rename to applications/lfrfid/scene/lfrfid_app_scene_read_menu.h index 7a91aa952..43d68a81a 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_readed_menu.h +++ b/applications/lfrfid/scene/lfrfid_app_scene_read_menu.h @@ -1,7 +1,7 @@ #pragma once #include "../lfrfid_app.h" -class LfRfidAppSceneReadedMenu : public GenericScene { +class LfRfidAppSceneReadKeyMenu : public GenericScene { public: void on_enter(LfRfidApp* app, bool need_restore) final; bool on_event(LfRfidApp* app, LfRfidApp::Event* event) final; diff --git a/applications/lfrfid/scene/lfrfid_app_scene_read_success.cpp b/applications/lfrfid/scene/lfrfid_app_scene_read_success.cpp index a86f77e61..8f6a0b57e 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_read_success.cpp +++ b/applications/lfrfid/scene/lfrfid_app_scene_read_success.cpp @@ -85,7 +85,13 @@ bool LfRfidAppSceneReadSuccess::on_event(LfRfidApp* app, LfRfidApp::Event* event bool consumed = false; if(event->type == LfRfidApp::EventType::Next) { - app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::ReadedMenu); + app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::ReadKeyMenu); + consumed = true; + } else if(event->type == LfRfidApp::EventType::Retry) { + app->scene_controller.switch_to_next_scene({LfRfidApp::SceneType::RetryConfirm}); + consumed = true; + } else if(event->type == LfRfidApp::EventType::Back) { + app->scene_controller.switch_to_next_scene({LfRfidApp::SceneType::ExitConfirm}); consumed = true; } @@ -103,7 +109,7 @@ void LfRfidAppSceneReadSuccess::on_exit(LfRfidApp* app) { void LfRfidAppSceneReadSuccess::back_callback(void* context) { LfRfidApp* app = static_cast(context); LfRfidApp::Event event; - event.type = LfRfidApp::EventType::Back; + event.type = LfRfidApp::EventType::Retry; app->view_controller.send_event(&event); } diff --git a/applications/lfrfid/scene/lfrfid_app_scene_retry_confirm.cpp b/applications/lfrfid/scene/lfrfid_app_scene_retry_confirm.cpp new file mode 100644 index 000000000..092a5f020 --- /dev/null +++ b/applications/lfrfid/scene/lfrfid_app_scene_retry_confirm.cpp @@ -0,0 +1,59 @@ +#include "lfrfid_app_scene_retry_confirm.h" +#include "../view/elements/button_element.h" +#include "../view/elements/icon_element.h" +#include "../view/elements/string_element.h" + +void LfRfidAppSceneRetryConfirm::on_enter(LfRfidApp* app, bool need_restore) { + auto container = app->view_controller.get(); + + auto button = container->add(); + button->set_type(ButtonElement::Type::Left, "Exit"); + button->set_callback(app, LfRfidAppSceneRetryConfirm::exit_callback); + + button = container->add(); + button->set_type(ButtonElement::Type::Right, "Stay"); + button->set_callback(app, LfRfidAppSceneRetryConfirm::stay_callback); + + auto line_1 = container->add(); + auto line_2 = container->add(); + + line_1->set_text("Return to reading?", 64, 19, 128 - 2, AlignCenter, AlignBottom, FontPrimary); + line_2->set_text( + "All unsaved data will be lost", 64, 29, 0, AlignCenter, AlignBottom, FontSecondary); + + app->view_controller.switch_to(); +} + +bool LfRfidAppSceneRetryConfirm::on_event(LfRfidApp* app, LfRfidApp::Event* event) { + bool consumed = false; + + if(event->type == LfRfidApp::EventType::Next) { + app->scene_controller.search_and_switch_to_previous_scene({LfRfidApp::SceneType::Read}); + consumed = true; + } else if(event->type == LfRfidApp::EventType::Stay) { + app->scene_controller.switch_to_previous_scene(); + consumed = true; + } else if(event->type == LfRfidApp::EventType::Back) { + consumed = true; + } + + return consumed; +} + +void LfRfidAppSceneRetryConfirm::on_exit(LfRfidApp* app) { + app->view_controller.get()->clean(); +} + +void LfRfidAppSceneRetryConfirm::exit_callback(void* context) { + LfRfidApp* app = static_cast(context); + LfRfidApp::Event event; + event.type = LfRfidApp::EventType::Next; + app->view_controller.send_event(&event); +} + +void LfRfidAppSceneRetryConfirm::stay_callback(void* context) { + LfRfidApp* app = static_cast(context); + LfRfidApp::Event event; + event.type = LfRfidApp::EventType::Stay; + app->view_controller.send_event(&event); +} diff --git a/applications/lfrfid/scene/lfrfid_app_scene_retry_confirm.h b/applications/lfrfid/scene/lfrfid_app_scene_retry_confirm.h new file mode 100644 index 000000000..af2373f03 --- /dev/null +++ b/applications/lfrfid/scene/lfrfid_app_scene_retry_confirm.h @@ -0,0 +1,13 @@ +#pragma once +#include "../lfrfid_app.h" + +class LfRfidAppSceneRetryConfirm : public GenericScene { +public: + void on_enter(LfRfidApp* app, bool need_restore) final; + bool on_event(LfRfidApp* app, LfRfidApp::Event* event) final; + void on_exit(LfRfidApp* app) final; + +private: + static void exit_callback(void* context); + static void stay_callback(void* context); +}; \ No newline at end of file diff --git a/applications/lfrfid/scene/lfrfid_app_scene_save_name.cpp b/applications/lfrfid/scene/lfrfid_app_scene_save_name.cpp index c2ad5dd19..f755f0e32 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_save_name.cpp +++ b/applications/lfrfid/scene/lfrfid_app_scene_save_name.cpp @@ -42,7 +42,7 @@ bool LfRfidAppSceneSaveName::on_event(LfRfidApp* app, LfRfidApp::Event* event) { app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::SaveSuccess); } else { app->scene_controller.search_and_switch_to_previous_scene( - {LfRfidApp::SceneType::ReadedMenu}); + {LfRfidApp::SceneType::ReadKeyMenu}); } } diff --git a/applications/lfrfid/scene/lfrfid_app_scene_save_success.cpp b/applications/lfrfid/scene/lfrfid_app_scene_save_success.cpp index 3a37da86b..184a445ad 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_save_success.cpp +++ b/applications/lfrfid/scene/lfrfid_app_scene_save_success.cpp @@ -8,7 +8,7 @@ void LfRfidAppSceneSaveSuccess::on_enter(LfRfidApp* app, bool need_restore) { DOLPHIN_DEED(DolphinDeedRfidSave); popup->set_icon(32, 5, &I_DolphinNice_96x59); - popup->set_text("Saved!", 13, 22, AlignLeft, AlignBottom); + popup->set_header("Saved!", 5, 7, AlignLeft, AlignTop); popup->set_context(app); popup->set_callback(LfRfidAppSceneSaveSuccess::timeout_callback); popup->set_timeout(1500); @@ -22,11 +22,11 @@ bool LfRfidAppSceneSaveSuccess::on_event(LfRfidApp* app, LfRfidApp::Event* event if(event->type == LfRfidApp::EventType::Back) { bool result = app->scene_controller.has_previous_scene( - {LfRfidApp::SceneType::ReadedMenu, LfRfidApp::SceneType::SelectKey}); + {LfRfidApp::SceneType::ReadKeyMenu, LfRfidApp::SceneType::SelectKey}); if(result) { app->scene_controller.search_and_switch_to_previous_scene( - {LfRfidApp::SceneType::ReadedMenu, LfRfidApp::SceneType::SelectKey}); + {LfRfidApp::SceneType::ReadKeyMenu, LfRfidApp::SceneType::SelectKey}); } else { app->scene_controller.search_and_switch_to_another_scene( {LfRfidApp::SceneType::SaveType}, LfRfidApp::SceneType::SelectKey); diff --git a/applications/lfrfid/scene/lfrfid_app_scene_write_success.cpp b/applications/lfrfid/scene/lfrfid_app_scene_write_success.cpp index 87c870e9d..0539e6235 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_write_success.cpp +++ b/applications/lfrfid/scene/lfrfid_app_scene_write_success.cpp @@ -18,7 +18,7 @@ bool LfRfidAppSceneWriteSuccess::on_event(LfRfidApp* app, LfRfidApp::Event* even if(event->type == LfRfidApp::EventType::Back) { app->scene_controller.search_and_switch_to_previous_scene( - {LfRfidApp::SceneType::ReadedMenu, LfRfidApp::SceneType::SelectKey}); + {LfRfidApp::SceneType::ReadKeyMenu, LfRfidApp::SceneType::SelectKey}); consumed = true; } diff --git a/applications/rpc/rpc_storage.c b/applications/rpc/rpc_storage.c index e9c13ca30..97d9ab62f 100644 --- a/applications/rpc/rpc_storage.c +++ b/applications/rpc/rpc_storage.c @@ -473,17 +473,17 @@ static void rpc_system_storage_md5sum_process(const PB_Main* request, void* cont File* file = storage_file_alloc(fs_api); if(storage_file_open(file, filename, FSAM_READ, FSOM_OPEN_EXISTING)) { - const uint16_t read_size = 512; + const uint16_t size_to_read = 512; const uint8_t hash_size = 16; - uint8_t* data = malloc(read_size); + uint8_t* data = malloc(size_to_read); uint8_t* hash = malloc(sizeof(uint8_t) * hash_size); md5_context* md5_ctx = malloc(sizeof(md5_context)); md5_starts(md5_ctx); while(true) { - uint16_t readed_size = storage_file_read(file, data, read_size); - if(readed_size == 0) break; - md5_update(md5_ctx, data, readed_size); + uint16_t read_size = storage_file_read(file, data, size_to_read); + if(read_size == 0) break; + md5_update(md5_ctx, data, read_size); } md5_finish(md5_ctx, hash); free(md5_ctx); diff --git a/applications/storage/filesystem_api_internal.h b/applications/storage/filesystem_api_internal.h index 29098e591..f0a3bb3fe 100644 --- a/applications/storage/filesystem_api_internal.h +++ b/applications/storage/filesystem_api_internal.h @@ -33,14 +33,14 @@ struct File { * @param file pointer to file object * @param buff pointer to buffer for reading * @param bytes_to_read how many bytes to read, must be smaller or equal to buffer size - * @return how many bytes actually has been readed + * @return how many bytes actually has been read * * @var FS_File_Api::write * @brief Write bytes from buffer to file * @param file pointer to file object * @param buff pointer to buffer for writing * @param bytes_to_read how many bytes to write, must be smaller or equal to buffer size - * @return how many bytes actually has been writed + * @return how many bytes actually has been written * * @var FS_File_Api::seek * @brief Move r/w pointer @@ -107,7 +107,7 @@ typedef struct { * @var FS_Dir_Api::read * @brief Read next object info in directory * @param file pointer to file object - * @param fileinfo pointer to readed FileInfo, can be NULL + * @param fileinfo pointer to read FileInfo, can be NULL * @param name pointer to name buffer, can be NULL * @param name_length name buffer length * @return success flag (if next object not exist also returns false and set error_id to FSE_NOT_EXIST) @@ -133,7 +133,7 @@ typedef struct { * @var FS_Common_Api::stat * @brief Open directory to get objects from * @param path path to file/directory - * @param fileinfo pointer to readed FileInfo, can be NULL + * @param fileinfo pointer to read FileInfo, can be NULL * @param name pointer to name buffer, can be NULL * @param name_length name buffer length * @return FS_Error error info diff --git a/applications/storage/storage.h b/applications/storage/storage.h index bb71447b2..eb51adefa 100644 --- a/applications/storage/storage.h +++ b/applications/storage/storage.h @@ -76,7 +76,7 @@ bool storage_file_is_dir(File* file); * @param file pointer to file object. * @param buff pointer to a buffer, for reading * @param bytes_to_read how many bytes to read. Must be less than or equal to the size of the buffer. - * @return uint16_t how many bytes were actually readed + * @return uint16_t how many bytes were actually read */ uint16_t storage_file_read(File* file, void* buff, uint16_t bytes_to_read); @@ -144,7 +144,7 @@ bool storage_dir_close(File* file); /** Reads the next object in the directory * @param file pointer to file object. - * @param fileinfo pointer to the readed FileInfo, may be NULL + * @param fileinfo pointer to the read FileInfo, may be NULL * @param name pointer to name buffer, may be NULL * @param name_length name buffer length * @return success flag (if the next object does not exist, it also returns false and sets the file error id to FSE_NOT_EXIST) @@ -162,7 +162,7 @@ bool storage_dir_rewind(File* file); /** Retrieves information about a file/directory * @param app pointer to the api * @param path path to file/directory - * @param fileinfo pointer to the readed FileInfo, may be NULL + * @param fileinfo pointer to the read FileInfo, may be NULL * @return FS_Error operation result */ FS_Error storage_common_stat(Storage* storage, const char* path, FileInfo* fileinfo); diff --git a/applications/storage/storage_cli.c b/applications/storage/storage_cli.c index 17bffa97a..3cb345bdf 100644 --- a/applications/storage/storage_cli.c +++ b/applications/storage/storage_cli.c @@ -112,10 +112,10 @@ static void storage_cli_list(Cli* cli, string_t path) { if(storage_dir_open(file, string_get_cstr(path))) { FileInfo fileinfo; char name[MAX_NAME_LENGTH]; - bool readed = false; + bool read_done = false; while(storage_dir_read(file, &fileinfo, name, MAX_NAME_LENGTH)) { - readed = true; + read_done = true; if(fileinfo.flags & FSF_DIRECTORY) { printf("\t[D] %s\r\n", name); } else { @@ -123,7 +123,7 @@ static void storage_cli_list(Cli* cli, string_t path) { } } - if(!readed) { + if(!read_done) { printf("\tEmpty\r\n"); } } else { @@ -141,18 +141,18 @@ static void storage_cli_read(Cli* cli, string_t path) { File* file = storage_file_alloc(api); if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { - const uint16_t read_size = 128; - uint16_t readed_size = 0; + const uint16_t size_to_read = 128; + uint16_t read_size = 0; uint8_t* data = malloc(read_size); printf("Size: %lu\r\n", (uint32_t)storage_file_size(file)); do { - readed_size = storage_file_read(file, data, read_size); - for(uint16_t i = 0; i < readed_size; i++) { + read_size = storage_file_read(file, data, size_to_read); + for(uint16_t i = 0; i < read_size; i++) { printf("%c", data[i]); } - } while(readed_size > 0); + } while(read_size > 0); printf("\r\n"); free(data); @@ -176,33 +176,33 @@ static void storage_cli_write(Cli* cli, string_t path) { if(storage_file_open(file, string_get_cstr(path), FSAM_WRITE, FSOM_OPEN_APPEND)) { printf("Just write your text data. New line by Ctrl+Enter, exit by Ctrl+C.\r\n"); - uint32_t readed_index = 0; + uint32_t read_index = 0; while(true) { uint8_t symbol = cli_getc(cli); if(symbol == CliSymbolAsciiETX) { - uint16_t write_size = readed_index % buffer_size; + uint16_t write_size = read_index % buffer_size; if(write_size > 0) { - uint16_t writed_size = storage_file_write(file, buffer, write_size); + uint16_t written_size = storage_file_write(file, buffer, write_size); - if(writed_size != write_size) { + if(written_size != write_size) { storage_cli_print_error(storage_file_get_error(file)); } break; } } - buffer[readed_index % buffer_size] = symbol; - printf("%c", buffer[readed_index % buffer_size]); + buffer[read_index % buffer_size] = symbol; + printf("%c", buffer[read_index % buffer_size]); fflush(stdout); - readed_index++; + read_index++; - if(((readed_index % buffer_size) == 0)) { - uint16_t writed_size = storage_file_write(file, buffer, buffer_size); + if(((read_index % buffer_size) == 0)) { + uint16_t written_size = storage_file_write(file, buffer, buffer_size); - if(writed_size != buffer_size) { + if(written_size != buffer_size) { storage_cli_print_error(storage_file_get_error(file)); break; } @@ -239,11 +239,11 @@ static void storage_cli_read_chunks(Cli* cli, string_t path, string_t args) { printf("\r\nReady?\r\n"); cli_getc(cli); - uint16_t readed_size = storage_file_read(file, data, buffer_size); - for(uint16_t i = 0; i < readed_size; i++) { + uint16_t read_size = storage_file_read(file, data, buffer_size); + for(uint16_t i = 0; i < read_size; i++) { putchar(data[i]); } - file_size -= readed_size; + file_size -= read_size; } printf("\r\n"); @@ -277,9 +277,9 @@ static void storage_cli_write_chunk(Cli* cli, string_t path, string_t args) { buffer[i] = cli_getc(cli); } - uint16_t writed_size = storage_file_write(file, buffer, buffer_size); + uint16_t written_size = storage_file_write(file, buffer, buffer_size); - if(writed_size != buffer_size) { + if(written_size != buffer_size) { storage_cli_print_error(storage_file_get_error(file)); } @@ -400,17 +400,17 @@ static void storage_cli_md5(Cli* cli, string_t path) { File* file = storage_file_alloc(api); if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { - const uint16_t read_size = 512; + const uint16_t size_to_read = 512; const uint8_t hash_size = 16; - uint8_t* data = malloc(read_size); + uint8_t* data = malloc(size_to_read); uint8_t* hash = malloc(sizeof(uint8_t) * hash_size); md5_context* md5_ctx = malloc(sizeof(md5_context)); md5_starts(md5_ctx); while(true) { - uint16_t readed_size = storage_file_read(file, data, read_size); - if(readed_size == 0) break; - md5_update(md5_ctx, data, readed_size); + uint16_t read_size = storage_file_read(file, data, size_to_read); + if(read_size == 0) break; + md5_update(md5_ctx, data, read_size); } md5_finish(md5_ctx, hash); free(md5_ctx); diff --git a/applications/storage/storages/storage_ext.c b/applications/storage/storages/storage_ext.c index 4ef9a8eae..bf201d565 100644 --- a/applications/storage/storages/storage_ext.c +++ b/applications/storage/storages/storage_ext.c @@ -340,10 +340,10 @@ static uint16_t storage_ext_file_read(void* ctx, File* file, void* buff, uint16_t const bytes_to_read) { StorageData* storage = ctx; SDFile* file_data = storage_get_storage_file_data(file, storage); - uint16_t bytes_readed = 0; - file->internal_error_id = f_read(file_data, buff, bytes_to_read, &bytes_readed); + uint16_t bytes_read = 0; + file->internal_error_id = f_read(file_data, buff, bytes_to_read, &bytes_read); file->error_id = storage_ext_parse_error(file->internal_error_id); - return bytes_readed; + return bytes_read; } static uint16_t diff --git a/applications/storage/storages/storage_int.c b/applications/storage/storages/storage_int.c index 2f6109293..7f7dd7705 100644 --- a/applications/storage/storages/storage_int.c +++ b/applications/storage/storages/storage_int.c @@ -349,7 +349,7 @@ static uint16_t lfs_t* lfs = lfs_get_from_storage(storage); LFSHandle* handle = storage_get_storage_file_data(file, storage); - uint16_t bytes_readed = 0; + uint16_t bytes_read = 0; if(lfs_handle_is_open(handle)) { file->internal_error_id = @@ -361,10 +361,10 @@ static uint16_t file->error_id = storage_int_parse_error(file->internal_error_id); if(file->error_id == FSE_OK) { - bytes_readed = file->internal_error_id; + bytes_read = file->internal_error_id; file->internal_error_id = 0; } - return bytes_readed; + return bytes_read; } static uint16_t diff --git a/lib/nfc_protocols/mifare_ultralight.c b/lib/nfc_protocols/mifare_ultralight.c index a2e64017c..c9311124e 100644 --- a/lib/nfc_protocols/mifare_ultralight.c +++ b/lib/nfc_protocols/mifare_ultralight.c @@ -56,12 +56,12 @@ uint16_t mf_ul_prepare_read(uint8_t* dest, uint8_t start_page) { void mf_ul_parse_read_response(uint8_t* buff, uint16_t page_addr, MifareUlDevice* mf_ul_read) { uint8_t pages_read = 4; - uint8_t page_read_count = mf_ul_read->pages_readed + pages_read; + uint8_t page_read_count = mf_ul_read->pages_read + pages_read; if(page_read_count > mf_ul_read->pages_to_read) { pages_read -= page_read_count - mf_ul_read->pages_to_read; } - mf_ul_read->pages_readed += pages_read; - mf_ul_read->data.data_size = mf_ul_read->pages_readed * 4; + mf_ul_read->pages_read += pages_read; + mf_ul_read->data.data_size = mf_ul_read->pages_read * 4; memcpy(&mf_ul_read->data.data[page_addr * 4], buff, pages_read * 4); } @@ -77,8 +77,8 @@ void mf_ul_parse_fast_read_response( uint8_t start_page, uint8_t end_page, MifareUlDevice* mf_ul_read) { - mf_ul_read->pages_readed = end_page - start_page + 1; - mf_ul_read->data.data_size = mf_ul_read->pages_readed * 4; + mf_ul_read->pages_read = end_page - start_page + 1; + mf_ul_read->data.data_size = mf_ul_read->pages_read * 4; memcpy(mf_ul_read->data.data, buff, mf_ul_read->data.data_size); } diff --git a/lib/nfc_protocols/mifare_ultralight.h b/lib/nfc_protocols/mifare_ultralight.h index 06bab2223..84447c5de 100644 --- a/lib/nfc_protocols/mifare_ultralight.h +++ b/lib/nfc_protocols/mifare_ultralight.h @@ -74,7 +74,7 @@ typedef struct { typedef struct { uint8_t pages_to_read; - uint8_t pages_readed; + uint8_t pages_read; bool support_fast_read; bool data_changed; MifareUlData data; diff --git a/lib/one_wire/ibutton/ibutton_writer.c b/lib/one_wire/ibutton/ibutton_writer.c index fc63e9516..fe19db711 100644 --- a/lib/one_wire/ibutton/ibutton_writer.c +++ b/lib/one_wire/ibutton/ibutton_writer.c @@ -71,10 +71,10 @@ static bool writer_write_TM2004(iButtonWriter* writer, iButtonKey* key) { furi_hal_delay_us(600); writer_write_one_bit(writer, 1, 50000); - // read writed key byte + // read written key byte answer = onewire_host_read(writer->host); - // check that writed and readed are same + // check that written and read are same if(ibutton_key_get_data_p(key)[i] != answer) { result = false; break; diff --git a/scripts/flipper/storage.py b/scripts/flipper/storage.py index 53c01d8c8..0768ca9e1 100644 --- a/scripts/flipper/storage.py +++ b/scripts/flipper/storage.py @@ -232,18 +232,18 @@ class FlipperStorage: self.read.until(self.CLI_PROMPT) return filedata size = int(answer.split(b": ")[1]) - readed_size = 0 + read_size = 0 - while readed_size < size: + while read_size < size: self.read.until("Ready?" + self.CLI_EOL) self.send("y") - read_size = min(size - readed_size, buffer_size) + read_size = min(size - read_size, buffer_size) filedata.extend(self.port.read(read_size)) - readed_size = readed_size + read_size + read_size = read_size + read_size - percent = str(math.ceil(readed_size / size * 100)) + percent = str(math.ceil(read_size / size * 100)) total_chunks = str(math.ceil(size / buffer_size)) - current_chunk = str(math.ceil(readed_size / buffer_size)) + current_chunk = str(math.ceil(read_size / buffer_size)) sys.stdout.write(f"\r{percent}%, chunk {current_chunk} of {total_chunks}") sys.stdout.flush() print()