diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bd8c243..2cd8238d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: env: TARGETS: f6 f7 - DEFAULT_TARGET: f6 + DEFAULT_TARGET: f7 jobs: build: diff --git a/.gitmodules b/.gitmodules index 02edf606..27f32c67 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,12 @@ [submodule "lib/littlefs"] path = lib/littlefs url = https://github.com/littlefs-project/littlefs.git +[submodule "lib/nanopb"] + path = lib/nanopb + url = https://github.com/nanopb/nanopb.git +[submodule "assets/protobuf"] + path = assets/protobuf + url = https://github.com/flipperdevices/flipperzero-protobuf.git +[submodule "lib/libusb_stm32"] + path = lib/libusb_stm32 + url = https://github.com/flipperdevices/libusb_stm32.git diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..ee72b67a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +hello@flipperdevices.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..7aeccb89 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,71 @@ +# Welcome to FlipperZero contributing guide + +Thank you for investing your time in contributing to our project! + +Read our [Code of Coduct](CODE_OF_CONDUCT.md) to keep our community approachable and respectable. + +In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, reviewing, and merging the PR. + +## New contributor guide + +See the [ReadMe](ReadMe.md) to get an overview of the project. Here are some helpful resources to get you comfortable with open source contribution: + +- [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github) +- [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git) +- [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow) +- [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests) + +## Getting started + +Before writing code and creating PR make sure that it aligns with our mission and guidlines: + +- All our devices are intended for research and education. +- PR that contains code intended to commit crimes is not going to be accepted. +- Your PR must contain code compatiable with project [LICENSE](LICENSE). +- PR will only be merged if it pass CI/CD. +- PR will only be merged if it pass review by code owner. + +Feel free to ask questions in issues if you're not sure. + +### Issues + +#### Create a new issue + +If you found a problem, [search if an issue already exists](https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments). If a related issue doesn't exist, you can open a new issue using a relevant [issue form](https://github.com/flipperdevices/flipperzero-firmware/issues/new/choose). + +#### Solve an issue + +Scan through our [existing issues](https://github.com/flipperdevices/flipperzero-firmware/issues) to find one that interests you. + +### Make Changes + +1. Fork the repository. +- Using GitHub Desktop: + - [Getting started with GitHub Desktop](https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/getting-started-with-github-desktop) will guide you through setting up Desktop. + - Once Desktop is set up, you can use it to [fork the repo](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/cloning-and-forking-repositories-from-github-desktop)! + +- Using the command line: + - [Fork the repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) so that you can make your changes without affecting the original project until you're ready to merge them. + +2. Install build requirements + +3. Create a working branch and start with your changes! + +### Commit your update + +Commit the changes once you are happy with them. Make sure that code compilation is not broken and passes tests. Check syntax and formatting. + +### Pull Request + +When you're done making the changes, open a pull request, often referred to as a PR. +- Fill out the "Ready for review" template so we can review your PR. This template helps reviewers understand your changes and the purpose of your pull request. +- Don't forget to [link PR to issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) if you are solving one. +- Enable the checkbox to [allow maintainer edits](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork) so the branch can be updated for a merge. +Once you submit your PR, a Docs team member will review your proposal. We may ask questions or request for additional information. +- We may ask for changes to be made before a PR can be merged, either using [suggested changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request) or pull request comments. You can apply suggested changes directly through the UI. You can make any other changes in your fork, then commit them to your branch. +- As you update your PR and apply changes, mark each conversation as [resolved](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations). +- If you run into any merge issues, checkout this [git tutorial](https://lab.github.com/githubtraining/managing-merge-conflicts) to help you resolve merge conflicts and other issues. + +### Your PR is merged! + +Congratulations :tada::tada: The FlipperDevices team thanks you :sparkles:. diff --git a/ReadMe.md b/ReadMe.md index 9fd85687..073b23de 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -162,6 +162,7 @@ Finally, you will have **`firmware/.obj/f6/full.dfu`** file that can be distribu - core - core libraries: home for furi - debug - debug helpers, plugins and tools - docker - docker image sources (used for automated firmware build) +- documentation - documentation generation system configs and input files - firmware - firmware for flipper * targets - targets' hal and implementation - lib - different libraries and drivers that apps and firmware uses diff --git a/applications/applications.c b/applications/applications.c old mode 100755 new mode 100644 index 9c014450..edb6f466 --- a/applications/applications.c +++ b/applications/applications.c @@ -2,6 +2,7 @@ #include // Services +extern int32_t rpc_srv(void* p); extern int32_t bt_srv(void* p); extern int32_t cli_srv(void* p); extern int32_t dialogs_srv(void* p); @@ -19,8 +20,8 @@ extern int32_t desktop_srv(void* p); extern int32_t accessor_app(void* p); extern int32_t archive_app(void* p); extern int32_t blink_test_app(void* p); -extern int32_t flipper_test_app(void* p); -extern int32_t gpio_test_app(void* p); +extern int32_t delay_test_app(void* p); +extern int32_t gpio_app(void* p); extern int32_t ibutton_app(void* p); extern int32_t irda_app(void* p); extern int32_t irda_monitor_app(void* p); @@ -33,6 +34,9 @@ extern int32_t storage_test_app(void* p); extern int32_t subghz_app(void* p); extern int32_t vibro_test_app(void* p); extern int32_t bt_debug_app(void* p); +extern int32_t usb_test_app(void* p); +extern int32_t usb_mouse_app(void* p); +extern int32_t bad_usb_app(void* p); // Plugins extern int32_t music_player_app(void* p); @@ -47,6 +51,7 @@ extern void nfc_cli_init(); extern void storage_cli_init(); extern void subghz_cli_init(); extern void power_cli_init(); +extern void unit_tests_cli_init(); // Settings extern int32_t notification_settings_app(void* p); @@ -58,6 +63,10 @@ extern int32_t power_settings_app(void* p); const FlipperApplication FLIPPER_SERVICES[] = { /* Services */ +#ifdef SRV_RPC + {.app = rpc_srv, .name = "RPC", .stack_size = 1024 * 4, .icon = NULL}, +#endif + #ifdef SRV_BT {.app = bt_srv, .name = "BT", .stack_size = 1024, .icon = NULL}, #endif @@ -116,24 +125,24 @@ const FlipperApplication FLIPPER_APPS[] = { {.app = subghz_app, .name = "Sub-GHz", .stack_size = 2048, .icon = &A_Sub1ghz_14}, #endif -#ifdef APP_NFC - {.app = nfc_app, .name = "NFC", .stack_size = 4096, .icon = &A_NFC_14}, -#endif - #ifdef APP_LF_RFID {.app = lfrfid_app, .name = "125 kHz RFID", .stack_size = 2048, .icon = &A_125khz_14}, #endif +#ifdef APP_NFC + {.app = nfc_app, .name = "NFC", .stack_size = 4096, .icon = &A_NFC_14}, +#endif + #ifdef APP_IRDA {.app = irda_app, .name = "Infrared", .stack_size = 1024 * 3, .icon = &A_Infrared_14}, #endif -#ifdef APP_IBUTTON - {.app = ibutton_app, .name = "iButton", .stack_size = 2048, .icon = &A_iButton_14}, +#ifdef APP_GPIO + {.app = gpio_app, .name = "GPIO", .stack_size = 1024, .icon = &A_GPIO_14}, #endif -#ifdef APP_GPIO_TEST - {.app = gpio_test_app, .name = "GPIO", .stack_size = 1024, .icon = &A_GPIO_14}, +#ifdef APP_IBUTTON + {.app = ibutton_app, .name = "iButton", .stack_size = 2048, .icon = &A_iButton_14}, #endif }; @@ -177,6 +186,10 @@ const FlipperOnStartHook FLIPPER_ON_SYSTEM_START[] = { #ifdef SRV_STORAGE storage_cli_init, #endif + +#ifdef APP_UNIT_TESTS + unit_tests_cli_init, +#endif }; const size_t FLIPPER_ON_SYSTEM_START_COUNT = @@ -210,8 +223,16 @@ const FlipperApplication FLIPPER_DEBUG_APPS[] = { {.app = accessor_app, .name = "Accessor", .stack_size = 4096, .icon = &A_Plugins_14}, #endif -#ifdef APP_UNIT_TESTS - {.app = flipper_test_app, .name = "Unit Tests", .stack_size = 1024, .icon = &A_Plugins_14}, +#ifdef APP_USB_TEST + {.app = usb_test_app, .name = "USB Test", .stack_size = 1024, .icon = &A_Plugins_14}, +#endif + +#ifdef APP_USB_MOUSE + {.app = usb_mouse_app, .name = "USB Mouse demo", .stack_size = 1024, .icon = &A_Plugins_14}, +#endif + +#ifdef APP_BAD_USB + {.app = bad_usb_app, .name = "Bad USB test", .stack_size = 2048, .icon = &A_Plugins_14}, #endif #ifdef APP_IRDA_MONITOR @@ -229,6 +250,10 @@ const FlipperApplication FLIPPER_DEBUG_APPS[] = { #ifdef SRV_BT {.app = bt_debug_app, .name = "Bluetooth Debug", .stack_size = 1024, .icon = NULL}, #endif + +#ifdef APP_UNIT_TESTS + {.app = delay_test_app, .name = "Delay Test App", .stack_size = 1024, .icon = &A_Plugins_14}, +#endif }; const size_t FLIPPER_DEBUG_APPS_COUNT = sizeof(FLIPPER_DEBUG_APPS) / sizeof(FlipperApplication); diff --git a/applications/applications.mk b/applications/applications.mk index 7bd15518..ade6491c 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -2,8 +2,8 @@ APP_DIR = $(PROJECT_ROOT)/applications LIB_DIR = $(PROJECT_ROOT)/lib CFLAGS += -I$(APP_DIR) -C_SOURCES += $(shell find $(APP_DIR) -name *.c) -CPP_SOURCES += $(shell find $(APP_DIR) -name *.cpp) +C_SOURCES += $(shell find $(APP_DIR) -name "*.c") +CPP_SOURCES += $(shell find $(APP_DIR) -name "*.cpp") APP_RELEASE ?= 1 @@ -19,12 +19,13 @@ SRV_LOADER = 1 SRV_NOTIFICATION = 1 SRV_POWER = 1 SRV_POWER_OBSERVER = 1 +SRV_RPC = 1 SRV_STORAGE = 1 # Apps SRV_DESKTOP = 1 APP_ARCHIVE = 1 -APP_GPIO_TEST = 1 +APP_GPIO = 1 APP_IBUTTON = 1 APP_IRDA = 1 APP_LF_RFID = 1 @@ -41,8 +42,10 @@ APP_BLINK = 1 APP_IRDA_MONITOR = 1 APP_KEYPAD_TEST = 1 APP_SD_TEST = 1 -APP_UNIT_TESTS = 0 APP_VIBRO_DEMO = 1 +APP_USB_TEST = 1 +APP_USB_MOUSE = 1 +APP_BAD_USB = 1 endif @@ -58,7 +61,7 @@ SRV_GUI = 1 endif -APP_UNIT_TESTS ?= 0 +APP_UNIT_TESTS ?= 0 ifeq ($(APP_UNIT_TESTS), 1) CFLAGS += -DAPP_UNIT_TESTS endif @@ -121,6 +124,27 @@ SRV_GUI = 1 endif +APP_USB_TEST ?= 0 +ifeq ($(APP_USB_TEST), 1) +CFLAGS += -DAPP_USB_TEST +SRV_INPUT = 1 +SRV_GUI = 1 +endif + +APP_USB_MOUSE ?= 0 +ifeq ($(APP_USB_MOUSE), 1) +CFLAGS += -DAPP_USB_MOUSE +SRV_INPUT = 1 +SRV_GUI = 1 +endif + +APP_BAD_USB ?= 0 +ifeq ($(APP_BAD_USB), 1) +CFLAGS += -DAPP_BAD_USB +SRV_INPUT = 1 +SRV_GUI = 1 +endif + APP_KEYPAD_TEST ?= 0 ifeq ($(APP_KEYPAD_TEST), 1) CFLAGS += -DAPP_KEYPAD_TEST @@ -135,9 +159,9 @@ SRV_GUI = 1 endif -APP_GPIO_TEST ?= 0 -ifeq ($(APP_GPIO_TEST), 1) -CFLAGS += -DAPP_GPIO_TEST +APP_GPIO ?= 0 +ifeq ($(APP_GPIO), 1) +CFLAGS += -DAPP_GPIO SRV_GUI = 1 endif @@ -197,6 +221,10 @@ SRV_GUI = 1 SRV_CLI = 1 endif +SRV_RPC ?= 0 +ifeq ($(SRV_RPC), 1) +CFLAGS += -DSRV_RPC +endif SRV_LOADER ?= 0 ifeq ($(SRV_LOADER), 1) diff --git a/applications/archive/helpers/archive_browser.c b/applications/archive/helpers/archive_browser.c index 19907984..7e302c4e 100644 --- a/applications/archive/helpers/archive_browser.c +++ b/applications/archive/helpers/archive_browser.c @@ -10,7 +10,9 @@ void archive_update_offset(ArchiveBrowserView* browser) { if(array_size > 3 && model->idx >= array_size - 1) { model->list_offset = model->idx - 3; - } else if(model->last_offset && model->last_offset != model->list_offset) { + } else if( + model->last_offset && model->last_offset != model->list_offset && + model->tab_idx == model->last_tab) { model->list_offset = model->last_offset; model->last_offset = !model->last_offset; } else if(model->list_offset < model->idx - bounds) { @@ -18,7 +20,6 @@ void archive_update_offset(ArchiveBrowserView* browser) { } else if(model->list_offset > model->idx - bounds) { model->list_offset = CLAMP(model->idx - 1, array_size - bounds, 0); } - return true; }); } @@ -75,6 +76,31 @@ void archive_file_array_rm_selected(ArchiveBrowserView* browser) { archive_update_offset(browser); } +void archive_file_array_swap(ArchiveBrowserView* browser, int8_t d) { + with_view_model( + browser->view, (ArchiveBrowserViewModel * model) { + ArchiveFile_t temp; + size_t array_size = files_array_size(model->files) - 1; + uint8_t swap_idx = CLAMP(model->idx + d, array_size, 0); + + if(model->idx == 0 && d < 0) { + ArchiveFile_t_init(&temp); + files_array_pop_at(&temp, model->files, array_size); + files_array_push_at(model->files, model->idx, temp); + ArchiveFile_t_clear(&temp); + } else if(model->idx == array_size && d > 0) { + ArchiveFile_t_init(&temp); + files_array_pop_at(&temp, model->files, model->last_idx); + files_array_push_at(model->files, array_size, temp); + ArchiveFile_t_clear(&temp); + } else { + files_array_swap_at(model->files, model->idx, swap_idx); + } + + return false; + }); +} + void archive_file_array_rm_all(ArchiveBrowserView* browser) { with_view_model( browser->view, (ArchiveBrowserViewModel * model) { @@ -94,6 +120,18 @@ ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser) { return selected; } +ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx) { + ArchiveFile_t* selected; + idx = CLAMP(idx, archive_file_array_size(browser), 0); + + with_view_model( + browser->view, (ArchiveBrowserViewModel * model) { + selected = files_array_size(model->files) ? files_array_get(model->files, idx) : NULL; + return false; + }); + return selected; +} + ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser) { ArchiveTabEnum tab_id; with_view_model( @@ -178,6 +216,14 @@ void archive_show_file_menu(ArchiveBrowserView* browser, bool show) { }); } +void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active) { + with_view_model( + browser->view, (ArchiveBrowserViewModel * model) { + model->move_fav = active; + return true; + }); +} + void archive_switch_dir(ArchiveBrowserView* browser, const char* path) { furi_assert(browser); furi_assert(path); diff --git a/applications/archive/helpers/archive_browser.h b/applications/archive/helpers/archive_browser.h index 23872e17..519fab75 100644 --- a/applications/archive/helpers/archive_browser.h +++ b/applications/archive/helpers/archive_browser.h @@ -52,9 +52,11 @@ void archive_update_focus(ArchiveBrowserView* browser, const char* target); size_t archive_file_array_size(ArchiveBrowserView* browser); void archive_file_array_rm_selected(ArchiveBrowserView* browser); +void archive_file_array_swap(ArchiveBrowserView* browser, int8_t d); void archive_file_array_rm_all(ArchiveBrowserView* browser); ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser); +ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx); ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser); uint8_t archive_get_depth(ArchiveBrowserView* browser); const char* archive_get_path(ArchiveBrowserView* browser); @@ -62,6 +64,7 @@ const char* archive_get_name(ArchiveBrowserView* browser); void archive_add_item(ArchiveBrowserView* browser, FileInfo* file_info, const char* name); void archive_show_file_menu(ArchiveBrowserView* browser, bool show); +void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active); void archive_switch_tab(ArchiveBrowserView* browser, InputKey key); void archive_enter_dir(ArchiveBrowserView* browser, string_t name); diff --git a/applications/archive/helpers/archive_favorites.c b/applications/archive/helpers/archive_favorites.c index 7f419890..c4608480 100644 --- a/applications/archive/helpers/archive_favorites.c +++ b/applications/archive/helpers/archive_favorites.c @@ -34,7 +34,7 @@ uint16_t archive_favorites_count(void* context) { bool archive_favorites_read(void* context) { furi_assert(context); - ArchiveBrowserView* archive_view = context; + ArchiveBrowserView* browser = context; FileWorker* file_worker = file_worker_alloc(true); string_t buffer; @@ -52,7 +52,7 @@ bool archive_favorites_read(void* context) { break; } - archive_add_item(archive_view, &file_info, string_get_cstr(buffer)); + archive_add_item(browser, &file_info, string_get_cstr(buffer)); string_clean(buffer); } } @@ -63,17 +63,15 @@ bool archive_favorites_read(void* context) { } bool archive_favorites_delete(const char* format, ...) { + string_t buffer; + string_t filename; va_list args; va_start(args, format); - uint8_t len = vsnprintf(NULL, 0, format, args); - char filename[len + 1]; - vsnprintf(filename, len + 1, format, args); + string_init_vprintf(filename, format, args); va_end(args); - FileWorker* file_worker = file_worker_alloc(true); - - string_t buffer; string_init(buffer); + FileWorker* file_worker = file_worker_alloc(true); bool result = file_worker_open(file_worker, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING); if(result) { @@ -85,13 +83,14 @@ bool archive_favorites_delete(const char* format, ...) { break; } - if(string_search_str(buffer, filename)) { - archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\r\n", string_get_cstr(buffer)); + if(string_search(buffer, filename)) { + archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer)); } } } string_clear(buffer); + string_clear(filename); file_worker_close(file_worker); file_worker_remove(file_worker, ARCHIVE_FAV_PATH); @@ -103,16 +102,15 @@ bool archive_favorites_delete(const char* format, ...) { } bool archive_is_favorite(const char* format, ...) { + string_t buffer; + string_t filename; va_list args; va_start(args, format); - uint8_t len = vsnprintf(NULL, 0, format, args); - char filename[len + 1]; - vsnprintf(filename, len + 1, format, args); + string_init_vprintf(filename, format, args); va_end(args); - FileWorker* file_worker = file_worker_alloc(true); - string_t buffer; string_init(buffer); + FileWorker* file_worker = file_worker_alloc(true); bool found = false; bool result = file_worker_open(file_worker, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING); @@ -125,7 +123,7 @@ bool archive_is_favorite(const char* format, ...) { if(!string_size(buffer)) { break; } - if(!string_search_str(buffer, filename)) { + if(!string_search(buffer, filename)) { found = true; break; } @@ -133,6 +131,7 @@ bool archive_is_favorite(const char* format, ...) { } string_clear(buffer); + string_clear(filename); file_worker_close(file_worker); file_worker_free(file_worker); @@ -166,7 +165,7 @@ bool archive_favorites_rename(const char* file_path, const char* src, const char archive_file_append( ARCHIVE_FAV_TEMP_PATH, - "%s\r\n", + "%s\n", string_search(buffer, path) ? string_get_cstr(buffer) : dst); } } @@ -186,5 +185,22 @@ bool archive_favorites_rename(const char* file_path, const char* src, const char void archive_add_to_favorites(const char* file_path) { furi_assert(file_path); - archive_file_append(ARCHIVE_FAV_PATH, "%s\r\n", file_path); + archive_file_append(ARCHIVE_FAV_PATH, "%s\n", file_path); } + +void archive_favorites_save(void* context) { + furi_assert(context); + + ArchiveBrowserView* browser = context; + FileWorker* file_worker = file_worker_alloc(true); + + for(size_t i = 0; i < archive_file_array_size(browser); i++) { + ArchiveFile_t* item = archive_get_file_at(browser, i); + archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(item->name)); + } + + file_worker_remove(file_worker, ARCHIVE_FAV_PATH); + file_worker_rename(file_worker, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); + + file_worker_free(file_worker); +} \ No newline at end of file diff --git a/applications/archive/helpers/archive_favorites.h b/applications/archive/helpers/archive_favorites.h index b07d7f87..d49b65fe 100644 --- a/applications/archive/helpers/archive_favorites.h +++ b/applications/archive/helpers/archive_favorites.h @@ -9,4 +9,5 @@ bool archive_favorites_read(void* context); bool archive_favorites_delete(const char* format, ...); bool archive_is_favorite(const char* format, ...); bool archive_favorites_rename(const char* file_path, const char* src, const char* dst); -void archive_add_to_favorites(const char* file_path); \ No newline at end of file +void archive_add_to_favorites(const char* file_path); +void archive_favorites_save(void* context); diff --git a/applications/archive/helpers/archive_files.c b/applications/archive/helpers/archive_files.c index 127b2fd3..fc3508e8 100644 --- a/applications/archive/helpers/archive_files.c +++ b/applications/archive/helpers/archive_files.c @@ -138,11 +138,10 @@ bool archive_read_dir(void* context, const char* path) { void archive_file_append(const char* path, const char* format, ...) { furi_assert(path); + string_t string; va_list args; va_start(args, format); - uint8_t len = vsnprintf(NULL, 0, format, args); - char cstr_buff[len + 1]; - vsnprintf(cstr_buff, len + 1, format, args); + string_init_vprintf(string, format, args); va_end(args); FileWorker* file_worker = file_worker_alloc(false); @@ -151,7 +150,7 @@ void archive_file_append(const char* path, const char* format, ...) { FURI_LOG_E("Archive", "Append open error"); } - if(!file_worker_write(file_worker, cstr_buff, strlen(cstr_buff))) { + if(!file_worker_write(file_worker, string_get_cstr(string), string_size(string))) { FURI_LOG_E("Archive", "Append write error"); } @@ -159,26 +158,28 @@ void archive_file_append(const char* path, const char* format, ...) { file_worker_free(file_worker); } -void archive_delete_file(void* context, string_t path, string_t name) { +void archive_delete_file(void* context, const char* format, ...) { furi_assert(context); - furi_assert(path); - furi_assert(name); + + string_t filename; + va_list args; + va_start(args, format); + string_init_vprintf(filename, format, args); + va_end(args); + ArchiveBrowserView* browser = context; FileWorker* file_worker = file_worker_alloc(true); - string_t full_path; - string_init_printf(full_path, "%s/%s", string_get_cstr(path), string_get_cstr(name)); - - bool res = file_worker_remove(file_worker, string_get_cstr(full_path)); + bool res = file_worker_remove(file_worker, string_get_cstr(filename)); file_worker_free(file_worker); - if(archive_is_favorite(string_get_cstr(full_path))) { - archive_favorites_delete(string_get_cstr(full_path)); + if(archive_is_favorite("%s", string_get_cstr(filename))) { + archive_favorites_delete("%s", string_get_cstr(filename)); } if(res) { archive_file_array_rm_selected(browser); } - string_clear(full_path); -} + string_clear(filename); +} \ No newline at end of file diff --git a/applications/archive/helpers/archive_files.h b/applications/archive/helpers/archive_files.h index 92fb7d20..26ebf199 100644 --- a/applications/archive/helpers/archive_files.h +++ b/applications/archive/helpers/archive_files.h @@ -54,4 +54,4 @@ bool archive_get_filenames(void* context, const char* path); bool archive_dir_empty(void* context, const char* path); bool archive_read_dir(void* context, const char* path); void archive_file_append(const char* path, const char* format, ...); -void archive_delete_file(void* context, string_t path, string_t name); \ No newline at end of file +void archive_delete_file(void* context, const char* format, ...); \ No newline at end of file diff --git a/applications/archive/scenes/archive_scene_browser.c b/applications/archive/scenes/archive_scene_browser.c index 03c78fae..d33aa23e 100644 --- a/applications/archive/scenes/archive_scene_browser.c +++ b/applications/archive/scenes/archive_scene_browser.c @@ -76,25 +76,32 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) { if(favorites) { archive_favorites_delete(name); archive_file_array_rm_selected(browser); + archive_show_file_menu(browser, false); } else if(known_app) { if(archive_is_favorite("%s/%s", path, name)) { archive_favorites_delete("%s/%s", path, name); } else { - archive_file_append(ARCHIVE_FAV_PATH, "%s/%s\r\n", path, name); + archive_file_append(ARCHIVE_FAV_PATH, "%s/%s\n", path, name); } + archive_show_file_menu(browser, false); } - archive_show_file_menu(browser, false); consumed = true; break; - case ArchiveBrowserEventFileMenuRename: - if(known_app && !favorites) { + case ArchiveBrowserEventFileMenuAction: + if(favorites) { + browser->callback(ArchiveBrowserEventEnterFavMove, browser->context); + } else if(known_app) { scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneRename); } consumed = true; break; case ArchiveBrowserEventFileMenuDelete: - archive_delete_file(browser, browser->path, selected->name); + if(favorites) { + archive_delete_file(browser, "%s", name); + } else { + archive_delete_file(browser, "%s/%s", path, name); + } archive_show_file_menu(browser, false); consumed = true; break; @@ -102,6 +109,30 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) { archive_enter_dir(browser, selected->name); consumed = true; break; + case ArchiveBrowserEventFavMoveUp: + archive_file_array_swap(browser, 1); + consumed = true; + break; + case ArchiveBrowserEventFavMoveDown: + archive_file_array_swap(browser, -1); + consumed = true; + break; + case ArchiveBrowserEventEnterFavMove: + strlcpy(archive->text_store, archive_get_name(browser), MAX_NAME_LEN); + archive_show_file_menu(browser, false); + archive_favorites_move_mode(archive->browser, true); + consumed = true; + break; + case ArchiveBrowserEventExitFavMove: + archive_update_focus(browser, archive->text_store); + archive_favorites_move_mode(archive->browser, false); + consumed = true; + break; + case ArchiveBrowserEventSaveFavMove: + archive_favorites_move_mode(archive->browser, false); + archive_favorites_save(archive->browser); + consumed = true; + break; case ArchiveBrowserEventExit: if(archive_get_depth(browser)) { diff --git a/applications/archive/views/archive_browser_view.c b/applications/archive/views/archive_browser_view.c index 7b0a912f..525fbbcb 100644 --- a/applications/archive/views/archive_browser_view.c +++ b/applications/archive/views/archive_browser_view.c @@ -55,7 +55,7 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) { string_set_str(menu[1], "Unpin"); } else if(model->tab_idx == ArchiveTabFavorites) { string_set_str(menu[1], "Unpin"); - string_set_str(menu[2], "---"); + string_set_str(menu[2], "Move"); } for(size_t i = 0; i < MENU_ITEMS; i++) { @@ -66,16 +66,23 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) { canvas_draw_icon(canvas, 74, 20 + model->menu_idx * 11, &I_ButtonRight_4x7); } -static void archive_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) { +static void archive_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar, bool moving) { + uint8_t x_offset = moving ? MOVE_OFFSET : 0; + canvas_set_color(canvas, ColorBlack); - canvas_draw_box(canvas, 0, 15 + idx * FRAME_HEIGHT, scrollbar ? 122 : 127, FRAME_HEIGHT); + canvas_draw_box( + canvas, + 0 + x_offset, + 15 + idx * FRAME_HEIGHT, + (scrollbar ? 122 : 127) - x_offset, + FRAME_HEIGHT); canvas_set_color(canvas, ColorWhite); - canvas_draw_dot(canvas, 0, 15 + idx * FRAME_HEIGHT); - canvas_draw_dot(canvas, 1, 15 + idx * FRAME_HEIGHT); - canvas_draw_dot(canvas, 0, (15 + idx * FRAME_HEIGHT) + 1); + canvas_draw_dot(canvas, 0 + x_offset, 15 + idx * FRAME_HEIGHT); + canvas_draw_dot(canvas, 1 + x_offset, 15 + idx * FRAME_HEIGHT); + canvas_draw_dot(canvas, 0 + x_offset, (15 + idx * FRAME_HEIGHT) + 1); - canvas_draw_dot(canvas, 0, (15 + idx * FRAME_HEIGHT) + 11); + canvas_draw_dot(canvas, 0 + x_offset, (15 + idx * FRAME_HEIGHT) + 11); canvas_draw_dot(canvas, scrollbar ? 121 : 126, 15 + idx * FRAME_HEIGHT); canvas_draw_dot(canvas, scrollbar ? 121 : 126, (15 + idx * FRAME_HEIGHT) + 11); } @@ -89,23 +96,26 @@ static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) { for(size_t i = 0; i < MIN(array_size, MENU_ITEMS); ++i) { string_t str_buff; char cstr_buff[MAX_NAME_LEN]; - size_t idx = CLAMP(i + model->list_offset, array_size, 0); + uint8_t x_offset = (model->move_fav && model->idx == idx) ? MOVE_OFFSET : 0; + ArchiveFile_t* file = files_array_get(model->files, CLAMP(idx, array_size - 1, 0)); strlcpy(cstr_buff, string_get_cstr(file->name), string_size(file->name) + 1); archive_trim_file_path(cstr_buff, is_known_app(file->type)); string_init_set_str(str_buff, cstr_buff); - elements_string_fit_width(canvas, str_buff, scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX); + elements_string_fit_width( + canvas, str_buff, (scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX) - x_offset); if(model->idx == idx) { - archive_draw_frame(canvas, i, scrollbar); + archive_draw_frame(canvas, i, scrollbar, model->move_fav); } else { canvas_set_color(canvas, ColorBlack); } - canvas_draw_icon(canvas, 2, 16 + i * FRAME_HEIGHT, ArchiveItemIcons[file->type]); - canvas_draw_str(canvas, 15, 24 + i * FRAME_HEIGHT, string_get_cstr(str_buff)); + canvas_draw_icon( + canvas, 2 + x_offset, 16 + i * FRAME_HEIGHT, ArchiveItemIcons[file->type]); + canvas_draw_str(canvas, 15 + x_offset, 24 + i * FRAME_HEIGHT, string_get_cstr(str_buff)); string_clear(str_buff); } @@ -139,8 +149,13 @@ static void archive_render_status_bar(Canvas* canvas, ArchiveBrowserViewModel* m canvas_draw_line(canvas, 107, 1, 107, 11); canvas_draw_line(canvas, 108, 12, 126, 12); - canvas_draw_icon(canvas, 112, 2, &I_ButtonLeft_4x7); - canvas_draw_icon(canvas, 120, 2, &I_ButtonRight_4x7); + if(model->move_fav) { + canvas_draw_icon(canvas, 111, 4, &I_ButtonUp_7x4); + canvas_draw_icon(canvas, 118, 4, &I_ButtonDown_7x4); + } else { + canvas_draw_icon(canvas, 112, 2, &I_ButtonLeft_4x7); + canvas_draw_icon(canvas, 120, 2, &I_ButtonRight_4x7); + } canvas_set_color(canvas, ColorWhite); canvas_draw_dot(canvas, 50, 0); @@ -174,9 +189,11 @@ bool archive_view_input(InputEvent* event, void* context) { ArchiveBrowserView* browser = context; bool in_menu; + bool move_fav_mode; with_view_model( browser->view, (ArchiveBrowserViewModel * model) { in_menu = model->menu; + move_fav_mode = model->move_fav; return false; }); @@ -210,11 +227,17 @@ bool archive_view_input(InputEvent* event, void* context) { } else { if(event->type == InputTypeShort) { if(event->key == InputKeyLeft || event->key == InputKeyRight) { + if(move_fav_mode) return false; archive_switch_tab(browser, event->key); } else if(event->key == InputKeyBack) { - browser->callback(ArchiveBrowserEventExit, browser->context); + if(move_fav_mode) { + browser->callback(ArchiveBrowserEventExitFavMove, browser->context); + } else { + browser->callback(ArchiveBrowserEventExit, browser->context); + } } } + if(event->key == InputKeyUp || event->key == InputKeyDown) { with_view_model( browser->view, (ArchiveBrowserViewModel * model) { @@ -222,8 +245,15 @@ bool archive_view_input(InputEvent* event, void* context) { if((event->type == InputTypeShort || event->type == InputTypeRepeat)) { if(event->key == InputKeyUp) { model->idx = ((model->idx - 1) + num_elements) % num_elements; + if(move_fav_mode) { + browser->callback(ArchiveBrowserEventFavMoveUp, browser->context); + } } else if(event->key == InputKeyDown) { model->idx = (model->idx + 1) % num_elements; + if(move_fav_mode) { + browser->callback( + ArchiveBrowserEventFavMoveDown, browser->context); + } } } @@ -241,14 +271,20 @@ bool archive_view_input(InputEvent* event, void* context) { if(event->type == InputTypeShort) { if(favorites) { - browser->callback(ArchiveBrowserEventFileMenuRun, browser->context); + if(move_fav_mode) { + browser->callback(ArchiveBrowserEventSaveFavMove, browser->context); + } else { + browser->callback(ArchiveBrowserEventFileMenuRun, browser->context); + } } else if(folder) { browser->callback(ArchiveBrowserEventEnterDir, browser->context); } else { browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context); } } else if(event->type == InputTypeLong) { - if(folder || favorites) { + if(move_fav_mode) { + browser->callback(ArchiveBrowserEventSaveFavMove, browser->context); + } else if(folder || favorites) { browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context); } } diff --git a/applications/archive/views/archive_browser_view.h b/applications/archive/views/archive_browser_view.h index 9f876b60..91ce9ccc 100644 --- a/applications/archive/views/archive_browser_view.h +++ b/applications/archive/views/archive_browser_view.h @@ -14,14 +14,15 @@ #define FRAME_HEIGHT 12 #define MENU_ITEMS 4 #define MAX_DEPTH 32 +#define MOVE_OFFSET 5 typedef enum { ArchiveTabFavorites, - ArchiveTabLFRFID, ArchiveTabSubGhz, + ArchiveTabLFRFID, ArchiveTabNFC, - ArchiveTabIButton, ArchiveTabIrda, + ArchiveTabIButton, ArchiveTabBrowser, ArchiveTabTotal, } ArchiveTabEnum; @@ -31,16 +32,21 @@ typedef enum { ArchiveBrowserEventFileMenuClose, ArchiveBrowserEventFileMenuRun, ArchiveBrowserEventFileMenuPin, - ArchiveBrowserEventFileMenuRename, + ArchiveBrowserEventFileMenuAction, ArchiveBrowserEventFileMenuDelete, ArchiveBrowserEventEnterDir, + ArchiveBrowserEventFavMoveUp, + ArchiveBrowserEventFavMoveDown, + ArchiveBrowserEventEnterFavMove, + ArchiveBrowserEventExitFavMove, + ArchiveBrowserEventSaveFavMove, ArchiveBrowserEventExit, } ArchiveBrowserEvent; static const uint8_t file_menu_actions[MENU_ITEMS] = { [0] = ArchiveBrowserEventFileMenuRun, [1] = ArchiveBrowserEventFileMenuPin, - [2] = ArchiveBrowserEventFileMenuRename, + [2] = ArchiveBrowserEventFileMenuAction, [3] = ArchiveBrowserEventFileMenuDelete, }; @@ -68,6 +74,7 @@ typedef struct { files_array_t files; uint8_t menu_idx; + bool move_fav; bool menu; uint16_t idx; diff --git a/applications/bt/bt_service/bt.c b/applications/bt/bt_service/bt.c index 91cfad81..4fae0cf6 100755 --- a/applications/bt/bt_service/bt.c +++ b/applications/bt/bt_service/bt.c @@ -33,7 +33,10 @@ static void bt_battery_level_changed_callback(const void* _event, void* context) Bt* bt = context; const PowerEvent* event = _event; if(event->type == PowerEventTypeBatteryLevelChanged) { - bt_update_battery_level(bt, event->data.battery_level); + BtMessage message = { + .type = BtMessageTypeUpdateBatteryLevel, + .data.battery_level = event->data.battery_level}; + furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); } } @@ -61,9 +64,84 @@ Bt* bt_alloc() { PubSub* power_pubsub = power_get_pubsub(bt->power); subscribe_pubsub(power_pubsub, bt_battery_level_changed_callback, bt); + // RPC + bt->rpc = furi_record_open("rpc"); + bt->rpc_sem = osSemaphoreNew(1, 0, NULL); + return bt; } +// Called from GAP thread from Serial service +static void bt_on_data_received_callback(uint8_t* data, uint16_t size, void* context) { + furi_assert(context); + Bt* bt = context; + + size_t bytes_processed = rpc_feed_bytes(bt->rpc_session, data, size, 1000); + if(bytes_processed != size) { + FURI_LOG_E(BT_SERVICE_TAG, "Only %d of %d bytes processed by RPC", bytes_processed, size); + } +} + +// Called from GAP thread from Serial service +static void bt_on_data_sent_callback(void* context) { + furi_assert(context); + Bt* bt = context; + + osSemaphoreRelease(bt->rpc_sem); +} + +// Called from RPC thread +static void bt_rpc_send_bytes_callback(void* context, uint8_t* bytes, size_t bytes_len) { + furi_assert(context); + Bt* bt = context; + + size_t bytes_sent = 0; + while(bytes_sent < bytes_len) { + size_t bytes_remain = bytes_len - bytes_sent; + if(bytes_remain > FURI_HAL_BT_PACKET_SIZE_MAX) { + furi_hal_bt_tx(&bytes[bytes_sent], FURI_HAL_BT_PACKET_SIZE_MAX); + bytes_sent += FURI_HAL_BT_PACKET_SIZE_MAX; + } else { + furi_hal_bt_tx(&bytes[bytes_sent], bytes_remain); + bytes_sent += bytes_remain; + } + osSemaphoreAcquire(bt->rpc_sem, osWaitForever); + } +} + +// Called from GAP thread +static void bt_on_gap_event_callback(BleEvent event, void* context) { + furi_assert(context); + Bt* bt = context; + + if(event.type == BleEventTypeConnected) { + FURI_LOG_I(BT_SERVICE_TAG, "Open RPC connection"); + bt->rpc_session = rpc_open_session(bt->rpc); + rpc_set_send_bytes_callback(bt->rpc_session, bt_rpc_send_bytes_callback, bt); + furi_hal_bt_set_data_event_callbacks( + bt_on_data_received_callback, bt_on_data_sent_callback, bt); + // Update battery level + PowerInfo info; + power_get_info(bt->power, &info); + BtMessage message = { + .type = BtMessageTypeUpdateBatteryLevel, .data.battery_level = info.charge}; + furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); + } else if(event.type == BleEventTypeDisconnected) { + FURI_LOG_I(BT_SERVICE_TAG, "Close RPC connection"); + if(bt->rpc_session) { + rpc_close_session(bt->rpc_session); + bt->rpc_session = NULL; + } + } else if(event.type == BleEventTypeStartAdvertising || event.type == BleEventTypeStopAdvertising) { + BtMessage message = {.type = BtMessageTypeUpdateStatusbar}; + furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); + } else if(event.type == BleEventTypePinCodeShow) { + BtMessage message = { + .type = BtMessageTypePinCodeShow, .data.pin_code = event.data.pin_code}; + furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); + } +} + int32_t bt_srv() { Bt* bt = bt_alloc(); furi_record_create("bt", bt); @@ -72,11 +150,10 @@ int32_t bt_srv() { FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed"); } else { view_port_enabled_set(bt->statusbar_view_port, true); - if(furi_hal_bt_init_app()) { + if(furi_hal_bt_init_app(bt_on_gap_event_callback, bt)) { FURI_LOG_I(BT_SERVICE_TAG, "BLE stack started"); if(bt->bt_settings.enabled) { furi_hal_bt_start_advertising(); - FURI_LOG_I(BT_SERVICE_TAG, "Start advertising"); } } else { FURI_LOG_E(BT_SERVICE_TAG, "BT App start failed"); diff --git a/applications/bt/bt_service/bt.h b/applications/bt/bt_service/bt.h index ccf5e501..0a2a924c 100644 --- a/applications/bt/bt_service/bt.h +++ b/applications/bt/bt_service/bt.h @@ -9,12 +9,6 @@ extern "C" { typedef struct Bt Bt; -void bt_update_statusbar(Bt* bt); - -void bt_update_battery_level(Bt* bt, uint8_t battery_level); - -bool bt_pin_code_show(Bt* bt, uint32_t pin_code); - #ifdef __cplusplus } #endif diff --git a/applications/bt/bt_service/bt_api.c b/applications/bt/bt_service/bt_api.c deleted file mode 100755 index db709871..00000000 --- a/applications/bt/bt_service/bt_api.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "bt.h" -#include "bt_i.h" - -void bt_update_statusbar(Bt* bt) { - furi_assert(bt); - BtMessage message = {.type = BtMessageTypeUpdateStatusbar}; - furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); -} - -void bt_update_battery_level(Bt* bt, uint8_t battery_level) { - furi_assert(bt); - BtMessage message = { - .type = BtMessageTypeUpdateBatteryLevel, .data.battery_level = battery_level}; - furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); -} - -bool bt_pin_code_show(Bt* bt, uint32_t pin_code) { - furi_assert(bt); - BtMessage message = {.type = BtMessageTypePinCodeShow, .data.pin_code = pin_code}; - return osMessageQueuePut(bt->message_queue, &message, 0, 0) == osOK; -} diff --git a/applications/bt/bt_service/bt_i.h b/applications/bt/bt_service/bt_i.h index 624c6c64..882061ee 100644 --- a/applications/bt/bt_service/bt_i.h +++ b/applications/bt/bt_service/bt_i.h @@ -11,6 +11,7 @@ #include #include +#include #include "../bt_settings.h" @@ -38,4 +39,7 @@ struct Bt { DialogsApp* dialogs; DialogMessage* dialog_message; Power* power; + Rpc* rpc; + RpcSession* rpc_session; + osSemaphoreId_t rpc_sem; }; diff --git a/applications/cli/cli.h b/applications/cli/cli.h index b6f524a1..9a166dc5 100644 --- a/applications/cli/cli.h +++ b/applications/cli/cli.h @@ -1,11 +1,16 @@ +/** + * @file cli.h + * Cli API + */ + #pragma once +#include + #ifdef __cplusplus extern "C" { #endif -#include - typedef enum { CliSymbolAsciiSOH = 0x01, CliSymbolAsciiETX = 0x03, @@ -21,30 +26,29 @@ typedef enum { } CliSymbols; typedef enum { - CliCommandFlagDefault = 0, /** Default, loader lock is used */ + CliCommandFlagDefault = 0, /**< Default, loader lock is used */ CliCommandFlagParallelSafe = - (1 << 0), /** Safe to run in parallel with other apps, loader lock is not used */ - CliCommandFlagInsomniaSafe = (1 << 1), /** Safe to run with insomnia mode on */ + (1 << 0), /**< Safe to run in parallel with other apps, loader lock is not used */ + CliCommandFlagInsomniaSafe = (1 << 1), /**< Safe to run with insomnia mode on */ } CliCommandFlag; -/* Cli type - * Anonymous structure. Use cli_i.h if you need to go deeper. - */ +/** Cli type anonymous structure */ typedef struct Cli Cli; -/* Cli callback function pointer. - * Implement this interface and use add_cli_command - * @param args - string with what was passed after command - * @param context - pointer to whatever you gave us on cli_add_command +/** Cli callback function pointer. Implement this interface and use + * add_cli_command + * @param args string with what was passed after command + * @param context pointer to whatever you gave us on cli_add_command */ typedef void (*CliCallback)(Cli* cli, string_t args, void* context); -/* Add cli command - * Registers you command callback - * @param cli - pointer to cli instance - * @param name - command name - * @param callback - callback function - * @param context - pointer to whatever we need to pass to callback +/** Add cli command Registers you command callback + * + * @param cli pointer to cli instance + * @param name command name + * @param flags CliCommandFlag + * @param callback callback function + * @param context pointer to whatever we need to pass to callback */ void cli_add_command( Cli* cli, @@ -53,51 +57,56 @@ void cli_add_command( CliCallback callback, void* context); -/* Print unified cmd usage tip - * @param cmd - cmd name - * @param usage - usage tip - * @param arg - arg passed by user +/** Print unified cmd usage tip + * + * @param cmd cmd name + * @param usage usage tip + * @param arg arg passed by user */ - void cli_print_usage(const char* cmd, const char* usage, const char* arg); -/* Delete cli command - * @param cli - pointer to cli instance - * @param name - command name +/** Delete cli command + * + * @param cli pointer to cli instance + * @param name command name */ void cli_delete_command(Cli* cli, const char* name); -/* Read from terminal - * Do it only from inside of cli call. - * @param cli - Cli instance - * @param buffer - pointer to buffer - * @param size - size of buffer in bytes - * @return bytes written +/** Read from terminal Do it only from inside of cli call. + * + * @param cli Cli instance + * @param buffer pointer to buffer + * @param size size of buffer in bytes + * + * @return bytes written */ size_t cli_read(Cli* cli, uint8_t* buffer, size_t size); -/* Not blocking check for interrupt command received - * @param cli - Cli instance +/** Not blocking check for interrupt command received + * + * @param cli Cli instance + * + * @return true if received */ bool cli_cmd_interrupt_received(Cli* cli); -/* Write to terminal - * Do it only from inside of cli call. - * @param cli - Cli instance - * @param buffer - pointer to buffer - * @param size - size of buffer in bytes - * @return bytes written +/** Write to terminal Do it only from inside of cli call. + * + * @param cli Cli instance + * @param buffer pointer to buffer + * @param size size of buffer in bytes */ void cli_write(Cli* cli, const uint8_t* buffer, size_t size); -/* Read character - * @param cli - Cli instance - * @return char +/** Read character + * + * @param cli Cli instance + * + * @return char */ char cli_getc(Cli* cli); -/* New line - * Send new ine sequence +/** New line Send new ine sequence */ void cli_nl(); diff --git a/applications/cli/cli_commands.c b/applications/cli/cli_commands.c index e43f81a0..255ab3cc 100644 --- a/applications/cli/cli_commands.c +++ b/applications/cli/cli_commands.c @@ -7,14 +7,47 @@ #include #include -#define ENCLAVE_SIGNATURE_KEY_SLOT 1 +#define ENCLAVE_SIGNATURE_KEY_SLOTS 10 #define ENCLAVE_SIGNATURE_SIZE 16 -static const uint8_t enclave_signature_iv[16] = - {0x32, 0xe6, 0xa7, 0x85, 0x20, 0xae, 0x0b, 0xf0, 0x00, 0xb6, 0x30, 0x9b, 0xd5, 0x42, 0x9e, 0xa6}; -static const uint8_t enclave_signature_input[ENCLAVE_SIGNATURE_SIZE] = - {0xdc, 0x76, 0x15, 0x1e, 0x69, 0xe8, 0xdc, 0xd3, 0x4a, 0x71, 0x0b, 0x42, 0x71, 0xe0, 0xa9, 0x78}; -static const uint8_t enclave_signature_expected[ENCLAVE_SIGNATURE_SIZE] = - {0x1b, 0xb3, 0xcf, 0x16, 0xc, 0x27, 0xf7, 0xf2, 0xf0, 0x7e, 0x5f, 0xbe, 0xfe, 0x89, 0x52, 0xe1}; + +static const uint8_t enclave_signature_iv[ENCLAVE_SIGNATURE_KEY_SLOTS][16] = { + {0xac, 0x5d, 0x68, 0xb8, 0x79, 0x74, 0xfc, 0x7f, 0x45, 0x02, 0x82, 0xf1, 0x48, 0x7e, 0x75, 0x8a}, + {0x38, 0xe6, 0x6a, 0x90, 0x5e, 0x5b, 0x8a, 0xa6, 0x70, 0x30, 0x04, 0x72, 0xc2, 0x42, 0xea, 0xaf}, + {0x73, 0xd5, 0x8e, 0xfb, 0x0f, 0x4b, 0xa9, 0x79, 0x0f, 0xde, 0x0e, 0x53, 0x44, 0x7d, 0xaa, 0xfd}, + {0x3c, 0x9a, 0xf4, 0x43, 0x2b, 0xfe, 0xea, 0xae, 0x8c, 0xc6, 0xd1, 0x60, 0xd2, 0x96, 0x64, 0xa9}, + {0x10, 0xac, 0x7b, 0x63, 0x03, 0x7f, 0x43, 0x18, 0xec, 0x9d, 0x9c, 0xc4, 0x01, 0xdc, 0x35, 0xa7}, + {0x26, 0x21, 0x64, 0xe6, 0xd0, 0xf2, 0x47, 0x49, 0xdc, 0x36, 0xcd, 0x68, 0x0c, 0x91, 0x03, 0x44}, + {0x7a, 0xbd, 0xce, 0x9c, 0x24, 0x7a, 0x2a, 0xb1, 0x3c, 0x4f, 0x5a, 0x7d, 0x80, 0x3e, 0xfc, 0x0d}, + {0xcd, 0xdd, 0xd3, 0x02, 0x85, 0x65, 0x43, 0x83, 0xf9, 0xac, 0x75, 0x2f, 0x21, 0xef, 0x28, 0x6b}, + {0xab, 0x73, 0x70, 0xe8, 0xe2, 0x56, 0x0f, 0x58, 0xab, 0x29, 0xa5, 0xb1, 0x13, 0x47, 0x5e, 0xe8}, + {0x4f, 0x3c, 0x43, 0x77, 0xde, 0xed, 0x79, 0xa1, 0x8d, 0x4c, 0x1f, 0xfd, 0xdb, 0x96, 0x87, 0x2e}, +}; + +static const uint8_t enclave_signature_input[ENCLAVE_SIGNATURE_KEY_SLOTS][ENCLAVE_SIGNATURE_SIZE] = { + {0x9f, 0x5c, 0xb1, 0x43, 0x17, 0x53, 0x18, 0x8c, 0x66, 0x3d, 0x39, 0x45, 0x90, 0x13, 0xa9, 0xde}, + {0xc5, 0x98, 0xe9, 0x17, 0xb8, 0x97, 0x9e, 0x03, 0x33, 0x14, 0x13, 0x8f, 0xce, 0x74, 0x0d, 0x54}, + {0x34, 0xba, 0x99, 0x59, 0x9f, 0x70, 0x67, 0xe9, 0x09, 0xee, 0x64, 0x0e, 0xb3, 0xba, 0xfb, 0x75}, + {0xdc, 0xfa, 0x6c, 0x9a, 0x6f, 0x0a, 0x3e, 0xdc, 0x42, 0xf6, 0xae, 0x0d, 0x3c, 0xf7, 0x83, 0xaf}, + {0xea, 0x2d, 0xe3, 0x1f, 0x02, 0x99, 0x1a, 0x7e, 0x6d, 0x93, 0x4c, 0xb5, 0x42, 0xf0, 0x7a, 0x9b}, + {0x53, 0x5e, 0x04, 0xa2, 0x49, 0xa0, 0x73, 0x49, 0x56, 0xb0, 0x88, 0x8c, 0x12, 0xa0, 0xe4, 0x18}, + {0x7d, 0xa7, 0xc5, 0x21, 0x7f, 0x12, 0x95, 0xdd, 0x4d, 0x77, 0x01, 0xfa, 0x71, 0x88, 0x2b, 0x7f}, + {0xdc, 0x9b, 0xc5, 0xa7, 0x6b, 0x84, 0x5c, 0x37, 0x7c, 0xec, 0x05, 0xa1, 0x9f, 0x91, 0x17, 0x3b}, + {0xea, 0xcf, 0xd9, 0x9b, 0x86, 0xcd, 0x2b, 0x43, 0x54, 0x45, 0x82, 0xc6, 0xfe, 0x73, 0x1a, 0x1a}, + {0x77, 0xb8, 0x1b, 0x90, 0xb4, 0xb7, 0x32, 0x76, 0x8f, 0x8a, 0x57, 0x06, 0xc7, 0xdd, 0x08, 0x90}, +}; + +static const uint8_t enclave_signature_expected[ENCLAVE_SIGNATURE_KEY_SLOTS][ENCLAVE_SIGNATURE_SIZE] = { + {0xe9, 0x9a, 0xce, 0xe9, 0x4d, 0xe1, 0x7f, 0x55, 0xcb, 0x8a, 0xbf, 0xf2, 0x4d, 0x98, 0x27, 0x67}, + {0x34, 0x27, 0xa7, 0xea, 0xa8, 0x98, 0x66, 0x9b, 0xed, 0x43, 0xd3, 0x93, 0xb5, 0xa2, 0x87, 0x8e}, + {0x6c, 0xf3, 0x01, 0x78, 0x53, 0x1b, 0x11, 0x32, 0xf0, 0x27, 0x2f, 0xe3, 0x7d, 0xa6, 0xe2, 0xfd}, + {0xdf, 0x7f, 0x37, 0x65, 0x2f, 0xdb, 0x7c, 0xcf, 0x5b, 0xb6, 0xe4, 0x9c, 0x63, 0xc5, 0x0f, 0xe0}, + {0x9b, 0x5c, 0xee, 0x44, 0x0e, 0xd1, 0xcb, 0x5f, 0x28, 0x9f, 0x12, 0x17, 0x59, 0x64, 0x40, 0xbb}, + {0x94, 0xc2, 0x09, 0x98, 0x62, 0xa7, 0x2b, 0x93, 0xed, 0x36, 0x1f, 0x10, 0xbc, 0x26, 0xbd, 0x41}, + {0x4d, 0xb2, 0x2b, 0xc5, 0x96, 0x47, 0x61, 0xf4, 0x16, 0xe0, 0x81, 0xc3, 0x8e, 0xb9, 0x9c, 0x9b}, + {0xc3, 0x6b, 0x83, 0x55, 0x90, 0x38, 0x0f, 0xea, 0xd1, 0x65, 0xbf, 0x32, 0x4f, 0x8e, 0x62, 0x5b}, + {0x8d, 0x5e, 0x27, 0xbc, 0x14, 0x4f, 0x08, 0xa8, 0x2b, 0x14, 0x89, 0x5e, 0xdf, 0x77, 0x04, 0x31}, + {0xc9, 0xf7, 0x03, 0xf1, 0x6c, 0x65, 0xad, 0x49, 0x74, 0xbe, 0x00, 0x54, 0xfd, 0xa6, 0x9c, 0x32}, +}; /* * Device Info Command @@ -99,15 +132,23 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) { // Signature verification uint8_t buffer[ENCLAVE_SIGNATURE_SIZE]; - bool enclave_valid = false; - if(furi_hal_crypto_store_load_key(ENCLAVE_SIGNATURE_KEY_SLOT, enclave_signature_iv)) { - if(furi_hal_crypto_encrypt(enclave_signature_input, buffer, ENCLAVE_SIGNATURE_SIZE)) { - enclave_valid = - memcmp(buffer, enclave_signature_expected, ENCLAVE_SIGNATURE_SIZE) == 0; + size_t enclave_valid_keys = 0; + for(size_t key_slot = 0; key_slot < ENCLAVE_SIGNATURE_KEY_SLOTS; key_slot++) { + if(furi_hal_crypto_store_load_key(key_slot + 1, enclave_signature_iv[key_slot])) { + if(furi_hal_crypto_encrypt( + enclave_signature_input[key_slot], buffer, ENCLAVE_SIGNATURE_SIZE)) { + enclave_valid_keys += memcmp( + buffer, + enclave_signature_expected[key_slot], + ENCLAVE_SIGNATURE_SIZE) == 0; + } + furi_hal_crypto_store_unload_key(key_slot + 1); } - furi_hal_crypto_store_unload_key(ENCLAVE_SIGNATURE_KEY_SLOT); } - printf("enclave_valid : %s\r\n", enclave_valid ? "true" : "false"); + printf("enclave_valid_keys : %d\r\n", enclave_valid_keys); + printf( + "enclave_valid : %s\r\n", + (enclave_valid_keys == ENCLAVE_SIGNATURE_KEY_SLOTS) ? "true" : "false"); } else { printf("radio_alive : false\r\n"); } diff --git a/applications/debug_tools/bad_usb.c b/applications/debug_tools/bad_usb.c new file mode 100644 index 00000000..1bd35d59 --- /dev/null +++ b/applications/debug_tools/bad_usb.c @@ -0,0 +1,364 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef enum { + EventTypeInput, + EventTypeWorkerState, +} EventType; + +typedef enum { + WorkerStateDone, + WorkerStateNoFile, + WorkerStateScriptError, + WorkerStateDisconnected, +} WorkerState; + +typedef enum { + AppStateWait, + AppStateRunning, + AppStateError, + AppStateExit, +} AppState; + +typedef enum { + WorkerCmdStart = (1 << 0), + WorkerCmdStop = (1 << 1), +} WorkerCommandFlags; + +// Event message from worker +typedef struct { + WorkerState state; + uint16_t line; +} BadUsbWorkerState; + +typedef struct { + union { + InputEvent input; + BadUsbWorkerState worker; + }; + EventType type; +} BadUsbEvent; + +typedef struct { + uint32_t defdelay; + char msg_text[32]; + osThreadAttr_t thread_attr; + osThreadId_t thread; + osMessageQueueId_t event_queue; +} BadUsbParams; + +typedef struct { + char* name; + uint16_t keycode; +} DuckyKey; + +static const DuckyKey ducky_keys[] = { + {"CTRL", KEY_MOD_LEFT_CTRL}, + {"CONTROL", KEY_MOD_LEFT_CTRL}, + {"SHIFT", KEY_MOD_LEFT_SHIFT}, + {"ALT", KEY_MOD_LEFT_ALT}, + {"GUI", KEY_MOD_LEFT_GUI}, + {"WINDOWS", KEY_MOD_LEFT_GUI}, + + {"DOWNARROW", KEY_DOWN_ARROW}, + {"DOWN", KEY_DOWN_ARROW}, + {"LEFTARROW", KEY_LEFT_ARROW}, + {"LEFT", KEY_LEFT_ARROW}, + {"RIGHTARROW", KEY_RIGHT_ARROW}, + {"RIGHT", KEY_RIGHT_ARROW}, + {"UPARROW", KEY_UP_ARROW}, + {"UP", KEY_UP_ARROW}, + + {"ENTER", KEY_ENTER}, + {"BREAK", KEY_PAUSE}, + {"PAUSE", KEY_PAUSE}, + {"CAPSLOCK", KEY_CAPS_LOCK}, + {"DELETE", KEY_DELETE}, + {"BACKSPACE", KEY_BACKSPACE}, + {"END", KEY_END}, + {"ESC", KEY_ESC}, + {"ESCAPE", KEY_ESC}, + {"HOME", KEY_HOME}, + {"INSERT", KEY_INSERT}, + {"NUMLOCK", KEY_NUM_LOCK}, + {"PAGEUP", KEY_PAGE_UP}, + {"PAGEDOWN", KEY_PAGE_DOWN}, + {"PRINTSCREEN", KEY_PRINT}, + {"SCROLLOCK", KEY_SCROLL_LOCK}, + {"SPACE", KEY_SPACE}, + {"TAB", KEY_TAB}, + {"MENU", KEY_APPLICATION}, + {"APP", KEY_APPLICATION}, +}; + +static const char ducky_cmd_comment[] = {"REM"}; +static const char ducky_cmd_delay[] = {"DELAY"}; +static const char ducky_cmd_string[] = {"STRING"}; +static const char ducky_cmd_defdelay_1[] = {"DEFAULT_DELAY"}; +static const char ducky_cmd_defdelay_2[] = {"DEFAULTDELAY"}; + +static bool ducky_get_delay_val(char* param, uint32_t* val) { + uint32_t delay_val = 0; + if(sscanf(param, "%lu", &delay_val) == 1) { + *val = delay_val; + return true; + } + return false; +} + +static bool ducky_string(char* param) { + uint32_t i = 0; + while(param[i] != '\0') { + furi_hal_hid_kb_press(HID_ASCII_TO_KEY(param[i])); + furi_hal_hid_kb_release(HID_ASCII_TO_KEY(param[i])); + i++; + } + return true; +} + +static uint16_t ducky_get_keycode(char* param, bool accept_chars) { + for(uint8_t i = 0; i < (sizeof(ducky_keys) / sizeof(ducky_keys[0])); i++) { + if(strncmp(param, ducky_keys[i].name, strlen(ducky_keys[i].name)) == 0) + return ducky_keys[i].keycode; + } + if((accept_chars) && (strlen(param) > 0)) { + return (HID_ASCII_TO_KEY(param[0]) & 0xFF); + } + return 0; +} + +static bool ducky_parse_line(string_t line, BadUsbParams* app) { + //uint32_t line_len = string_size(line); + char* line_t = (char*)string_get_cstr(line); + bool state = false; + + // General commands + if(strncmp(line_t, ducky_cmd_comment, strlen(ducky_cmd_comment)) == 0) { + // REM - comment line + return true; + } else if(strncmp(line_t, ducky_cmd_delay, strlen(ducky_cmd_delay)) == 0) { + // DELAY + line_t = &line_t[args_get_first_word_length(line) + 1]; + uint32_t delay_val = 0; + state = ducky_get_delay_val(line_t, &delay_val); + if((state) && (delay_val > 0)) { + // Using ThreadFlagsWait as delay function allows exiting task on WorkerCmdStop command + if(osThreadFlagsWait(WorkerCmdStop, osFlagsWaitAny | osFlagsNoClear, delay_val) == + WorkerCmdStop) + return true; + } + return state; + } else if( + (strncmp(line_t, ducky_cmd_defdelay_1, strlen(ducky_cmd_defdelay_1)) == 0) || + (strncmp(line_t, ducky_cmd_defdelay_2, strlen(ducky_cmd_defdelay_2)) == 0)) { + // DEFAULT_DELAY + line_t = &line_t[args_get_first_word_length(line) + 1]; + return ducky_get_delay_val(line_t, &app->defdelay); + } else if(strncmp(line_t, ducky_cmd_string, strlen(ducky_cmd_string)) == 0) { + // STRING + if(app->defdelay > 0) { + if(osThreadFlagsWait(WorkerCmdStop, osFlagsWaitAny | osFlagsNoClear, app->defdelay) == + WorkerCmdStop) + return true; + } + line_t = &line_t[args_get_first_word_length(line) + 1]; + return ducky_string(line_t); + } else { + // Special keys + modifiers + uint16_t key = ducky_get_keycode(line_t, false); + if(key == KEY_NONE) return false; + if((key & 0xFF00) != 0) { + // It's a modifier key + line_t = &line_t[args_get_first_word_length(line) + 1]; + key |= ducky_get_keycode(line_t, true); + } + if(app->defdelay > 0) { + if(osThreadFlagsWait(WorkerCmdStop, osFlagsWaitAny | osFlagsNoClear, app->defdelay) == + WorkerCmdStop) + return true; + } + furi_hal_hid_kb_press(key); + furi_hal_hid_kb_release(key); + return true; + } + return false; +} + +static void badusb_worker(void* context) { + BadUsbParams* app = context; + FURI_LOG_I("BadUSB worker", "Init"); + File* script_file = storage_file_alloc(furi_record_open("storage")); + BadUsbEvent evt; + string_t line; + uint32_t line_cnt = 0; + string_init(line); + if(storage_file_open(script_file, "/ext/badusb.txt", FSAM_READ, FSOM_OPEN_EXISTING)) { + char buffer[16]; + uint16_t ret; + uint32_t flags = + osThreadFlagsWait(WorkerCmdStart | WorkerCmdStop, osFlagsWaitAny, osWaitForever); + if(flags & WorkerCmdStart) { + FURI_LOG_I("BadUSB worker", "Start"); + do { + ret = storage_file_read(script_file, buffer, 16); + for(uint16_t i = 0; i < ret; i++) { + if(buffer[i] == '\n' && string_size(line) > 0) { + line_cnt++; + if(ducky_parse_line(line, app) == false) { + ret = 0; + FURI_LOG_E("BadUSB worker", "Unknown command at line %lu", line_cnt); + evt.type = EventTypeWorkerState; + evt.worker.state = WorkerStateScriptError; + evt.worker.line = line_cnt; + osMessageQueuePut(app->event_queue, &evt, 0, osWaitForever); + break; + } + flags = osThreadFlagsGet(); + if(flags == WorkerCmdStop) { + ret = 0; + break; + } + string_clean(line); + } else { + string_push_back(line, buffer[i]); + } + } + } while(ret > 0); + } + } else { + FURI_LOG_E("BadUSB worker", "Script file open error"); + evt.type = EventTypeWorkerState; + evt.worker.state = WorkerStateNoFile; + osMessageQueuePut(app->event_queue, &evt, 0, osWaitForever); + } + string_clean(line); + string_clear(line); + + furi_hal_hid_kb_release_all(); + storage_file_close(script_file); + storage_file_free(script_file); + + FURI_LOG_I("BadUSB worker", "End"); + evt.type = EventTypeWorkerState; + evt.worker.state = WorkerStateDone; + osMessageQueuePut(app->event_queue, &evt, 0, osWaitForever); + + osThreadExit(); +} + +static void bad_usb_render_callback(Canvas* canvas, void* ctx) { + BadUsbParams* app = (BadUsbParams*)ctx; + + canvas_clear(canvas); + + canvas_set_font(canvas, FontPrimary); + canvas_draw_str(canvas, 0, 10, "Bad USB test"); + + if(strlen(app->msg_text) > 0) { + canvas_set_font(canvas, FontSecondary); + canvas_draw_str(canvas, 0, 62, app->msg_text); + } +} + +static void bad_usb_input_callback(InputEvent* input_event, void* ctx) { + osMessageQueueId_t event_queue = ctx; + + BadUsbEvent event; + event.type = EventTypeInput; + event.input = *input_event; + osMessageQueuePut(event_queue, &event, 0, osWaitForever); +} + +int32_t bad_usb_app(void* p) { + BadUsbParams* app = furi_alloc(sizeof(BadUsbParams)); + app->event_queue = osMessageQueueNew(8, sizeof(BadUsbEvent), NULL); + furi_check(app->event_queue); + ViewPort* view_port = view_port_alloc(); + + UsbMode usb_mode_prev = furi_hal_usb_get_config(); + furi_hal_usb_set_config(UsbModeHid); + + view_port_draw_callback_set(view_port, bad_usb_render_callback, app); + view_port_input_callback_set(view_port, bad_usb_input_callback, app->event_queue); + + // Open GUI and register view_port + Gui* gui = furi_record_open("gui"); + gui_add_view_port(gui, view_port, GuiLayerFullscreen); + + app->thread = NULL; + app->thread_attr.name = "bad_usb_worker"; + app->thread_attr.stack_size = 2048; + app->thread = osThreadNew(badusb_worker, app, &app->thread_attr); + bool worker_running = true; + AppState app_state = AppStateWait; + snprintf(app->msg_text, sizeof(app->msg_text), "Press [OK] to start"); + view_port_update(view_port); + + BadUsbEvent event; + while(1) { + osStatus_t event_status = osMessageQueueGet(app->event_queue, &event, NULL, osWaitForever); + + if(event_status == osOK) { + if(event.type == EventTypeInput) { + if(event.input.type == InputTypeShort && event.input.key == InputKeyBack) { + if(worker_running) { + osThreadFlagsSet(app->thread, WorkerCmdStop); + app_state = AppStateExit; + } else + break; + } + + if(event.input.type == InputTypeShort && event.input.key == InputKeyOk) { + if(worker_running) { + app_state = AppStateRunning; + osThreadFlagsSet(app->thread, WorkerCmdStart); + snprintf(app->msg_text, sizeof(app->msg_text), "Running..."); + view_port_update(view_port); + } + } + } else if(event.type == EventTypeWorkerState) { + FURI_LOG_I("BadUSB app", "ev: %d", event.worker.state); + if(event.worker.state == WorkerStateDone) { + worker_running = false; + if(app_state == AppStateExit) + break; + else if(app_state == AppStateRunning) { + //done + app->thread = osThreadNew(badusb_worker, app, &app->thread_attr); + worker_running = true; + app_state = AppStateWait; + snprintf(app->msg_text, sizeof(app->msg_text), "Press [OK] to start"); + view_port_update(view_port); + } + } else if(event.worker.state == WorkerStateNoFile) { + app_state = AppStateError; + snprintf(app->msg_text, sizeof(app->msg_text), "File not found!"); + view_port_update(view_port); + } else if(event.worker.state == WorkerStateScriptError) { + app_state = AppStateError; + snprintf( + app->msg_text, + sizeof(app->msg_text), + "Error at line %u", + event.worker.line); + view_port_update(view_port); + } + } + } + } + furi_hal_usb_set_config(usb_mode_prev); + + // remove & free all stuff created by app + gui_remove_view_port(gui, view_port); + view_port_free(view_port); + + osMessageQueueDelete(app->event_queue); + free(app); + + return 0; +} diff --git a/applications/debug_tools/usb_mouse.c b/applications/debug_tools/usb_mouse.c new file mode 100644 index 00000000..a9b8be6e --- /dev/null +++ b/applications/debug_tools/usb_mouse.c @@ -0,0 +1,121 @@ +#include +#include +#include +#include + +#define MOUSE_MOVE_SHORT 5 +#define MOUSE_MOVE_LONG 20 + +typedef enum { + EventTypeInput, +} EventType; + +typedef struct { + union { + InputEvent input; + }; + EventType type; +} UsbMouseEvent; + +static void usb_mouse_render_callback(Canvas* canvas, void* ctx) { + canvas_clear(canvas); + + canvas_set_font(canvas, FontPrimary); + canvas_draw_str(canvas, 0, 10, "USB Mouse demo"); + + canvas_set_font(canvas, FontSecondary); + canvas_draw_str(canvas, 0, 63, "Hold [back] to exit"); +} + +static void usb_mouse_input_callback(InputEvent* input_event, void* ctx) { + osMessageQueueId_t event_queue = ctx; + + UsbMouseEvent event; + event.type = EventTypeInput; + event.input = *input_event; + osMessageQueuePut(event_queue, &event, 0, osWaitForever); +} + +int32_t usb_mouse_app(void* p) { + osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(UsbMouseEvent), NULL); + furi_check(event_queue); + ViewPort* view_port = view_port_alloc(); + + UsbMode usb_mode_prev = furi_hal_usb_get_config(); + furi_hal_usb_set_config(UsbModeHid); + + view_port_draw_callback_set(view_port, usb_mouse_render_callback, NULL); + view_port_input_callback_set(view_port, usb_mouse_input_callback, event_queue); + + // Open GUI and register view_port + Gui* gui = furi_record_open("gui"); + gui_add_view_port(gui, view_port, GuiLayerFullscreen); + + UsbMouseEvent event; + while(1) { + osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, osWaitForever); + + if(event_status == osOK) { + if(event.type == EventTypeInput) { + if(event.input.type == InputTypeLong && event.input.key == InputKeyBack) { + break; + } + + if(event.input.type == InputTypeShort && event.input.key == InputKeyBack) { + furi_hal_hid_mouse_press(HID_MOUSE_BTN_RIGHT); + furi_hal_hid_mouse_release(HID_MOUSE_BTN_RIGHT); + } + + if(event.input.key == InputKeyOk) { + if(event.input.type == InputTypePress) { + furi_hal_hid_mouse_press(HID_MOUSE_BTN_LEFT); + } else if(event.input.type == InputTypeRelease) { + furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT); + } + } + + if(event.input.key == InputKeyRight) { + if(event.input.type == InputTypePress) { + furi_hal_hid_mouse_move(MOUSE_MOVE_SHORT, 0); + } else if(event.input.type == InputTypeRepeat) { + furi_hal_hid_mouse_move(MOUSE_MOVE_LONG, 0); + } + } + + if(event.input.key == InputKeyLeft) { + if(event.input.type == InputTypePress) { + furi_hal_hid_mouse_move(-MOUSE_MOVE_SHORT, 0); + } else if(event.input.type == InputTypeRepeat) { + furi_hal_hid_mouse_move(-MOUSE_MOVE_LONG, 0); + } + } + + if(event.input.key == InputKeyDown) { + if(event.input.type == InputTypePress) { + furi_hal_hid_mouse_move(0, MOUSE_MOVE_SHORT); + } else if(event.input.type == InputTypeRepeat) { + furi_hal_hid_mouse_move(0, MOUSE_MOVE_LONG); + } + } + + if(event.input.key == InputKeyUp) { + if(event.input.type == InputTypePress) { + furi_hal_hid_mouse_move(0, -MOUSE_MOVE_SHORT); + } else if(event.input.type == InputTypeRepeat) { + furi_hal_hid_mouse_move(0, -MOUSE_MOVE_LONG); + } + } + } + } + view_port_update(view_port); + } + + furi_hal_usb_set_config(usb_mode_prev); + + // remove & free all stuff created by app + gui_remove_view_port(gui, view_port); + view_port_free(view_port); + osMessageQueueDelete(event_queue); + + return 0; +} diff --git a/applications/debug_tools/usb_test.c b/applications/debug_tools/usb_test.c new file mode 100644 index 00000000..f1677cae --- /dev/null +++ b/applications/debug_tools/usb_test.c @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + Gui* gui; + ViewDispatcher* view_dispatcher; + Submenu* submenu; +} UsbTestApp; + +typedef enum { + UsbTestSubmenuIndexEnable, + UsbTestSubmenuIndexDisable, + UsbTestSubmenuIndexVcpSingle, + UsbTestSubmenuIndexVcpDual, + UsbTestSubmenuIndexHid, + UsbTestSubmenuIndexHidU2F, +} SubmenuIndex; + +void usb_test_submenu_callback(void* context, uint32_t index) { + furi_assert(context); + //UsbTestApp* app = context; + if(index == UsbTestSubmenuIndexEnable) { + furi_hal_usb_enable(); + } else if(index == UsbTestSubmenuIndexDisable) { + furi_hal_usb_disable(); + } else if(index == UsbTestSubmenuIndexVcpSingle) { + furi_hal_usb_set_config(UsbModeVcpSingle); + } else if(index == UsbTestSubmenuIndexVcpDual) { + furi_hal_usb_set_config(UsbModeVcpDual); + } else if(index == UsbTestSubmenuIndexHid) { + furi_hal_usb_set_config(UsbModeHid); + } else if(index == UsbTestSubmenuIndexHidU2F) { + //furi_hal_usb_set_config(UsbModeU2F); + } +} + +uint32_t usb_test_exit(void* context) { + return VIEW_NONE; +} + +UsbTestApp* usb_test_app_alloc() { + UsbTestApp* app = furi_alloc(sizeof(UsbTestApp)); + + // Gui + app->gui = furi_record_open("gui"); + + // View dispatcher + app->view_dispatcher = view_dispatcher_alloc(); + view_dispatcher_enable_queue(app->view_dispatcher); + view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); + + // Views + app->submenu = submenu_alloc(); + submenu_add_item( + app->submenu, "Enable", UsbTestSubmenuIndexEnable, usb_test_submenu_callback, app); + submenu_add_item( + app->submenu, "Disable", UsbTestSubmenuIndexDisable, usb_test_submenu_callback, app); + submenu_add_item( + app->submenu, "Single VCP", UsbTestSubmenuIndexVcpSingle, usb_test_submenu_callback, app); + submenu_add_item( + app->submenu, "Dual VCP", UsbTestSubmenuIndexVcpDual, usb_test_submenu_callback, app); + submenu_add_item( + app->submenu, "HID KB+Mouse", UsbTestSubmenuIndexHid, usb_test_submenu_callback, app); + submenu_add_item( + app->submenu, "TODO: HID U2F", UsbTestSubmenuIndexHidU2F, usb_test_submenu_callback, app); + view_set_previous_callback(submenu_get_view(app->submenu), usb_test_exit); + view_dispatcher_add_view(app->view_dispatcher, 0, submenu_get_view(app->submenu)); + + // Switch to menu + view_dispatcher_switch_to_view(app->view_dispatcher, 0); + + return app; +} + +void usb_test_app_free(UsbTestApp* app) { + furi_assert(app); + + // Free views + view_dispatcher_remove_view(app->view_dispatcher, 0); + submenu_free(app->submenu); + view_dispatcher_free(app->view_dispatcher); + + // Close gui record + furi_record_close("gui"); + app->gui = NULL; + + // Free rest + free(app); +} + +int32_t usb_test_app(void* p) { + UsbTestApp* app = usb_test_app_alloc(); + + view_dispatcher_run(app->view_dispatcher); + + usb_test_app_free(app); + return 0; +} diff --git a/applications/desktop/desktop.c b/applications/desktop/desktop.c index ef17fc87..4aa21453 100644 --- a/applications/desktop/desktop.c +++ b/applications/desktop/desktop.c @@ -40,7 +40,7 @@ Desktop* desktop_alloc() { desktop->locked_view = desktop_locked_alloc(); desktop->debug_view = desktop_debug_alloc(); desktop->first_start_view = desktop_first_start_alloc(); - desktop->hw_mismatch_view = desktop_hw_mismatch_alloc(); + desktop->hw_mismatch_popup = popup_alloc(); view_dispatcher_add_view( desktop->view_dispatcher, DesktopViewMain, desktop_main_get_view(desktop->main_view)); @@ -61,7 +61,7 @@ Desktop* desktop_alloc() { view_dispatcher_add_view( desktop->view_dispatcher, DesktopViewHwMismatch, - desktop_hw_mismatch_get_view(desktop->hw_mismatch_view)); + popup_get_view(desktop->hw_mismatch_popup)); // Lock icon desktop->lock_viewport = view_port_alloc(); @@ -91,7 +91,7 @@ void desktop_free(Desktop* desktop) { desktop_locked_free(desktop->locked_view); desktop_debug_free(desktop->debug_view); desktop_first_start_free(desktop->first_start_view); - desktop_hw_mismatch_free(desktop->hw_mismatch_view); + popup_free(desktop->hw_mismatch_popup); furi_record_close("gui"); desktop->gui = NULL; diff --git a/applications/desktop/desktop_i.h b/applications/desktop/desktop_i.h index 8f424183..62caff0f 100644 --- a/applications/desktop/desktop_i.h +++ b/applications/desktop/desktop_i.h @@ -7,24 +7,21 @@ #include #include +#include #include #include #include #include "views/desktop_main.h" #include "views/desktop_first_start.h" -#include "views/desktop_hw_mismatch.h" #include "views/desktop_lock_menu.h" #include "views/desktop_locked.h" #include "views/desktop_debug.h" #include "scenes/desktop_scene.h" - +#include "helpers/desktop_animation.h" #include "desktop/desktop_settings/desktop_settings.h" -#define HINT_TIMEOUT_L 2 -#define HINT_TIMEOUT_H 11 - typedef enum { DesktopViewMain, DesktopViewLockMenu, @@ -44,7 +41,7 @@ struct Desktop { SceneManager* scene_manager; DesktopFirstStartView* first_start_view; - DesktopHwMismatchView* hw_mismatch_view; + Popup* hw_mismatch_popup; DesktopMainView* main_view; DesktopLockMenuView* lock_menu; DesktopLockedView* locked_view; diff --git a/applications/desktop/helpers/desktop_animation.c b/applications/desktop/helpers/desktop_animation.c new file mode 100644 index 00000000..07eaf631 --- /dev/null +++ b/applications/desktop/helpers/desktop_animation.c @@ -0,0 +1,26 @@ +#include "desktop_animation.h" + +static const Icon* idle_scenes[] = {&A_Wink_128x64, &A_WatchingTV_128x64}; + +const Icon* desktop_get_icon() { + uint8_t new = 0; + +#if 0 + // checking dolphin state here to choose appropriate animation + + Dolphin* dolphin = furi_record_open("dolphin"); + DolphinStats stats = dolphin_stats(dolphin); + float timediff = fabs(difftime(stats.timestamp, dolphin_state_timestamp())); + + FURI_LOG_I("desktop-animation", "background change"); + FURI_LOG_I("desktop-animation", "icounter: %d", stats.icounter); + FURI_LOG_I("desktop-animation", "butthurt: %d", stats.butthurt); + FURI_LOG_I("desktop-animation", "time since deeed: %.0f", timediff); +#endif + + if((random() % 100) > 50) { // temp rnd selection + new = random() % COUNT_OF(idle_scenes); + } + + return idle_scenes[new]; +} diff --git a/applications/desktop/helpers/desktop_animation.h b/applications/desktop/helpers/desktop_animation.h new file mode 100644 index 00000000..10ad906f --- /dev/null +++ b/applications/desktop/helpers/desktop_animation.h @@ -0,0 +1,10 @@ +#pragma once + +#include +#include +#include +#include "dolphin/dolphin.h" +#include "dolphin/helpers/dolphin_state.h" +#include "time.h" + +const Icon* desktop_get_icon(); diff --git a/applications/desktop/scenes/desktop_scene_debug.c b/applications/desktop/scenes/desktop_scene_debug.c index 3ae4b852..a1ac208c 100644 --- a/applications/desktop/scenes/desktop_scene_debug.c +++ b/applications/desktop/scenes/desktop_scene_debug.c @@ -26,7 +26,7 @@ bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) { switch(event.event) { case DesktopDebugEventExit: scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain); - dolphin_save(dolphin); + dolphin_flush(dolphin); consumed = true; break; @@ -43,7 +43,7 @@ bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) { break; case DesktopDebugEventSaveState: - dolphin_save(dolphin); + dolphin_flush(dolphin); consumed = true; break; diff --git a/applications/desktop/scenes/desktop_scene_hw_mismatch.c b/applications/desktop/scenes/desktop_scene_hw_mismatch.c index 224ddb58..5a33054d 100644 --- a/applications/desktop/scenes/desktop_scene_hw_mismatch.c +++ b/applications/desktop/scenes/desktop_scene_hw_mismatch.c @@ -1,16 +1,26 @@ #include "../desktop_i.h" -#include "../views/desktop_hw_mismatch.h" +#include -void desktop_scene_hw_mismatch_callback(DesktopHwMismatchEvent event, void* context) { +#define HW_MISMATCH_BACK_EVENT (0UL) + +void desktop_scene_hw_mismatch_callback(void* context) { Desktop* desktop = (Desktop*)context; - view_dispatcher_send_custom_event(desktop->view_dispatcher, event); + view_dispatcher_send_custom_event(desktop->view_dispatcher, HW_MISMATCH_BACK_EVENT); } void desktop_scene_hw_mismatch_on_enter(void* context) { Desktop* desktop = (Desktop*)context; - - desktop_hw_mismatch_set_callback( - desktop->hw_mismatch_view, desktop_scene_hw_mismatch_callback, desktop); + Popup* popup = desktop->hw_mismatch_popup; + char buffer[256]; // strange but smaller buffer not making it + snprintf( + buffer, + sizeof(buffer), + "HW target: F%d\nFW target: " TARGET, + furi_hal_version_get_hw_target()); + popup_set_context(popup, desktop); + popup_set_header(popup, "!!!! HW Mismatch !!!!", 60, 14, AlignCenter, AlignCenter); + popup_set_text(popup, buffer, 60, 37, AlignCenter, AlignCenter); + popup_set_callback(popup, desktop_scene_hw_mismatch_callback); view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewHwMismatch); } @@ -20,7 +30,7 @@ bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event) if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case DesktopHwMismatchEventExit: + case HW_MISMATCH_BACK_EVENT: scene_manager_previous_scene(desktop->scene_manager); consumed = true; break; @@ -33,5 +43,10 @@ bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event) } void desktop_scene_hw_mismatch_on_exit(void* context) { - // Desktop* desktop = (Desktop*)context; + Desktop* desktop = (Desktop*)context; + Popup* popup = desktop->hw_mismatch_popup; + popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); + popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); + popup_set_callback(popup, NULL); + popup_set_context(popup, NULL); } diff --git a/applications/desktop/scenes/desktop_scene_locked.c b/applications/desktop/scenes/desktop_scene_locked.c index c0cfd3c9..6e7064ad 100644 --- a/applications/desktop/scenes/desktop_scene_locked.c +++ b/applications/desktop/scenes/desktop_scene_locked.c @@ -13,6 +13,7 @@ void desktop_scene_locked_on_enter(void* context) { desktop_locked_set_callback(locked_view, desktop_scene_locked_callback, desktop); desktop_locked_reset_door_pos(locked_view); desktop_locked_update_hint_timeout(locked_view); + desktop_locked_set_dolphin_animation(locked_view); view_port_enabled_set(desktop->lock_viewport, true); osTimerStart(locked_view->timer, 63); @@ -45,7 +46,6 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) { void desktop_scene_locked_on_exit(void* context) { Desktop* desktop = (Desktop*)context; - DesktopLockedView* locked_view = desktop->locked_view; desktop_locked_reset_counter(desktop->locked_view); - osTimerStop(locked_view->timer); + osTimerStop(desktop->locked_view->timer); } diff --git a/applications/desktop/scenes/desktop_scene_main.c b/applications/desktop/scenes/desktop_scene_main.c index e63f8418..4826c2cd 100644 --- a/applications/desktop/scenes/desktop_scene_main.c +++ b/applications/desktop/scenes/desktop_scene_main.c @@ -39,6 +39,7 @@ void desktop_scene_main_on_enter(void* context) { desktop_main_unlocked(desktop->main_view); } + desktop_main_switch_dolphin_animation(desktop->main_view); view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewMain); } @@ -59,7 +60,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { break; case DesktopMainEventOpenDebug: - scene_manager_next_scene(desktop->scene_manager, DesktopViewDebug); + scene_manager_next_scene(desktop->scene_manager, DesktopSceneDebug); consumed = true; break; @@ -67,6 +68,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { desktop_switch_to_app(desktop, &FLIPPER_ARCHIVE); consumed = true; break; + case DesktopMainEventOpenFavorite: desktop_settings_load(&desktop->settings); desktop_switch_to_app(desktop, &FLIPPER_APPS[desktop->settings.favorite]); diff --git a/applications/desktop/views/desktop_debug.c b/applications/desktop/views/desktop_debug.c index 00c70d9b..067fd478 100644 --- a/applications/desktop/views/desktop_debug.c +++ b/applications/desktop/views/desktop_debug.c @@ -2,8 +2,8 @@ #include "../desktop_i.h" #include "desktop_debug.h" -#include "applications/dolphin/helpers/dolphin_state.h" -#include "applications/dolphin/dolphin.h" +#include "dolphin/helpers/dolphin_state.h" +#include "dolphin/dolphin.h" void desktop_debug_set_callback( DesktopDebugView* debug_view, @@ -21,7 +21,7 @@ void desktop_debug_render(Canvas* canvas, void* model) { const Version* ver; char buffer[64]; - static const char* headers[] = {"FW Version info:", "Boot Version info:", "Desktop info:"}; + static const char* headers[] = {"FW Version info:", "Boot Version info:", "Dolphin info:"}; canvas_set_color(canvas, ColorBlack); canvas_set_font(canvas, FontPrimary); @@ -56,7 +56,7 @@ void desktop_debug_render(Canvas* canvas, void* model) { "%s [%s]", version_get_version(ver), version_get_builddate(ver)); - canvas_draw_str(canvas, 5, 33, buffer); + canvas_draw_str(canvas, 5, 32, buffer); snprintf( buffer, @@ -68,16 +68,22 @@ void desktop_debug_render(Canvas* canvas, void* model) { snprintf( buffer, sizeof(buffer), "[%s] %s", version_get_target(ver), version_get_gitbranch(ver)); - canvas_draw_str(canvas, 5, 53, buffer); + canvas_draw_str(canvas, 5, 54, buffer); } else { char buffer[64]; + uint32_t current_lvl = dolphin_state_get_level(m->icounter); + uint32_t remaining = dolphin_state_xp_to_levelup(m->icounter, current_lvl, true); canvas_set_font(canvas, FontSecondary); - snprintf(buffer, 64, "Icounter: %ld", m->icounter); - canvas_draw_str(canvas, 5, 30, buffer); - snprintf(buffer, 64, "Butthurt: %ld", m->butthurt); - canvas_draw_str(canvas, 5, 40, buffer); + snprintf(buffer, 64, "Icounter: %ld Butthurt %ld", m->icounter, m->butthurt); + canvas_draw_str(canvas, 5, 23, buffer); + + snprintf(buffer, 64, "Level: %ld To level up: %ld", current_lvl, remaining); + canvas_draw_str(canvas, 5, 33, buffer); + + snprintf(buffer, 64, "%s", asctime(localtime((const time_t*)&m->timestamp))); + canvas_draw_str(canvas, 5, 43, buffer); canvas_draw_str(canvas, 0, 53, "[< >] icounter value [ok] save"); } } @@ -146,11 +152,12 @@ void desktop_debug_free(DesktopDebugView* debug_view) { void desktop_debug_get_dolphin_data(DesktopDebugView* debug_view) { Dolphin* dolphin = furi_record_open("dolphin"); - DolphinDeedWeight stats = dolphin_stats(dolphin); + DolphinStats stats = dolphin_stats(dolphin); with_view_model( debug_view->view, (DesktopDebugViewModel * model) { model->icounter = stats.icounter; model->butthurt = stats.butthurt; + model->timestamp = stats.timestamp; return true; }); diff --git a/applications/desktop/views/desktop_debug.h b/applications/desktop/views/desktop_debug.h index 02ce76a2..b3ff67fc 100644 --- a/applications/desktop/views/desktop_debug.h +++ b/applications/desktop/views/desktop_debug.h @@ -6,6 +6,7 @@ #include #include #include +#include typedef enum { DesktopDebugEventDeed, @@ -35,6 +36,7 @@ struct DesktopDebugView { typedef struct { uint32_t icounter; uint32_t butthurt; + uint64_t timestamp; DesktopViewStatsScreens screen; } DesktopDebugViewModel; diff --git a/applications/desktop/views/desktop_hw_mismatch.c b/applications/desktop/views/desktop_hw_mismatch.c deleted file mode 100644 index bf58d8f9..00000000 --- a/applications/desktop/views/desktop_hw_mismatch.c +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include "../desktop_i.h" -#include -#include - -#include "desktop_hw_mismatch.h" - -void desktop_hw_mismatch_set_callback( - DesktopHwMismatchView* main_view, - DesktopHwMismatchViewCallback callback, - void* context) { - furi_assert(main_view); - furi_assert(callback); - main_view->callback = callback; - main_view->context = context; -} - -void desktop_hw_mismatch_render(Canvas* canvas, void* model) { - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 2, 15, "!!!! HW Mismatch !!!!"); - - char buffer[64]; - canvas_set_font(canvas, FontSecondary); - snprintf(buffer, 64, "HW target: F%d", furi_hal_version_get_hw_target()); - canvas_draw_str(canvas, 5, 27, buffer); - canvas_draw_str(canvas, 5, 38, "FW target: " TARGET); -} - -View* desktop_hw_mismatch_get_view(DesktopHwMismatchView* hw_mismatch_view) { - furi_assert(hw_mismatch_view); - return hw_mismatch_view->view; -} - -bool desktop_hw_mismatch_input(InputEvent* event, void* context) { - furi_assert(event); - furi_assert(context); - - DesktopHwMismatchView* hw_mismatch_view = context; - - if(event->type == InputTypeShort) { - hw_mismatch_view->callback(DesktopHwMismatchEventExit, hw_mismatch_view->context); - } - - return true; -} - -DesktopHwMismatchView* desktop_hw_mismatch_alloc() { - DesktopHwMismatchView* hw_mismatch_view = furi_alloc(sizeof(DesktopHwMismatchView)); - hw_mismatch_view->view = view_alloc(); - view_allocate_model( - hw_mismatch_view->view, ViewModelTypeLocking, sizeof(DesktopHwMismatchViewModel)); - view_set_context(hw_mismatch_view->view, hw_mismatch_view); - view_set_draw_callback(hw_mismatch_view->view, (ViewDrawCallback)desktop_hw_mismatch_render); - view_set_input_callback(hw_mismatch_view->view, desktop_hw_mismatch_input); - - return hw_mismatch_view; -} - -void desktop_hw_mismatch_free(DesktopHwMismatchView* hw_mismatch_view) { - furi_assert(hw_mismatch_view); - - view_free(hw_mismatch_view->view); - free(hw_mismatch_view); -} diff --git a/applications/desktop/views/desktop_hw_mismatch.h b/applications/desktop/views/desktop_hw_mismatch.h deleted file mode 100644 index 68042341..00000000 --- a/applications/desktop/views/desktop_hw_mismatch.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -typedef enum { - DesktopHwMismatchEventExit, -} DesktopHwMismatchEvent; - -typedef struct DesktopHwMismatchView DesktopHwMismatchView; - -typedef void (*DesktopHwMismatchViewCallback)(DesktopHwMismatchEvent event, void* context); - -struct DesktopHwMismatchView { - View* view; - DesktopHwMismatchViewCallback callback; - void* context; -}; - -typedef struct { - IconAnimation* animation; - uint8_t scene_num; - uint8_t hint_timeout; - bool locked; -} DesktopHwMismatchViewModel; - -void desktop_hw_mismatch_set_callback( - DesktopHwMismatchView* hw_mismatch_view, - DesktopHwMismatchViewCallback callback, - void* context); - -View* desktop_hw_mismatch_get_view(DesktopHwMismatchView* hw_mismatch_view); - -DesktopHwMismatchView* desktop_hw_mismatch_alloc(); -void desktop_hw_mismatch_free(DesktopHwMismatchView* hw_mismatch_view); diff --git a/applications/desktop/views/desktop_lock_menu.c b/applications/desktop/views/desktop_lock_menu.c index 5bb065d6..11392cd8 100644 --- a/applications/desktop/views/desktop_lock_menu.c +++ b/applications/desktop/views/desktop_lock_menu.c @@ -29,7 +29,7 @@ static void lock_menu_callback(void* context, uint8_t index) { default: // wip message with_view_model( lock_menu->view, (DesktopLockMenuViewModel * model) { - model->hint_timeout = HINT_TIMEOUT_L; + model->hint_timeout = HINT_TIMEOUT; return true; }); break; diff --git a/applications/desktop/views/desktop_lock_menu.h b/applications/desktop/views/desktop_lock_menu.h index d851bf91..714069cb 100644 --- a/applications/desktop/views/desktop_lock_menu.h +++ b/applications/desktop/views/desktop_lock_menu.h @@ -6,6 +6,8 @@ #include #include +#define HINT_TIMEOUT 2 + typedef enum { DesktopLockMenuEventLock, DesktopLockMenuEventUnlock, @@ -25,7 +27,6 @@ struct DesktopLockMenuView { typedef struct { uint8_t idx; uint8_t hint_timeout; - bool locked; } DesktopLockMenuViewModel; void desktop_lock_menu_set_callback( diff --git a/applications/desktop/views/desktop_locked.c b/applications/desktop/views/desktop_locked.c index 80ec099c..b4942506 100644 --- a/applications/desktop/views/desktop_locked.c +++ b/applications/desktop/views/desktop_locked.c @@ -2,8 +2,6 @@ #include "../desktop_i.h" #include "desktop_locked.h" -static const Icon* idle_scenes[] = {&A_Wink_128x64, &A_WatchingTV_128x64}; - void desktop_locked_set_callback( DesktopLockedView* locked_view, DesktopLockedViewCallback callback, @@ -20,13 +18,12 @@ void locked_view_timer_callback(void* context) { } // temporary locked screen animation managment -static void - desktop_scene_handler_set_scene(DesktopLockedView* locked_view, const Icon* icon_data) { +void desktop_locked_set_dolphin_animation(DesktopLockedView* locked_view) { with_view_model( locked_view->view, (DesktopLockedViewModel * model) { if(model->animation) icon_animation_free(model->animation); - model->animation = icon_animation_alloc(icon_data); - icon_animation_start(model->animation); + model->animation = icon_animation_alloc(desktop_get_icon()); + view_tie_icon_animation(locked_view->view, model->animation); return true; }); } @@ -34,7 +31,7 @@ static void void desktop_locked_update_hint_timeout(DesktopLockedView* locked_view) { with_view_model( locked_view->view, (DesktopLockedViewModel * model) { - model->hint_timeout = HINT_TIMEOUT_H; + model->hint_expire_at = osKernelGetTickCount() + osKernelGetTickFreq(); return true; }); } @@ -43,8 +40,8 @@ void desktop_locked_reset_door_pos(DesktopLockedView* locked_view) { with_view_model( locked_view->view, (DesktopLockedViewModel * model) { model->animation_seq_end = false; - model->door_left_x = -57; - model->door_right_x = 115; + model->door_left_x = DOOR_L_POS; + model->door_right_x = DOOR_R_POS; return true; }); } @@ -58,9 +55,12 @@ void desktop_locked_manage_redraw(DesktopLockedView* locked_view) { animation_seq_end = model->animation_seq_end; if(!model->animation_seq_end) { - model->door_left_x = CLAMP(model->door_left_x + 5, 0, -57); - model->door_right_x = CLAMP(model->door_right_x - 5, 115, 60); + model->door_left_x = CLAMP(model->door_left_x + 5, DOOR_L_POS_MAX, DOOR_L_POS); + model->door_right_x = CLAMP(model->door_right_x - 5, DOOR_R_POS, DOOR_R_POS_MIN); + } else { + model->hint_expire_at = !model->hint_expire_at; } + return true; }); @@ -75,14 +75,14 @@ void desktop_locked_reset_counter(DesktopLockedView* locked_view) { with_view_model( locked_view->view, (DesktopLockedViewModel * model) { - model->hint_timeout = 0; + model->hint_expire_at = 0; return true; }); } void desktop_locked_render(Canvas* canvas, void* model) { DesktopLockedViewModel* m = model; - + uint32_t now = osKernelGetTickCount(); canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); @@ -95,12 +95,11 @@ void desktop_locked_render(Canvas* canvas, void* model) { canvas_draw_icon_animation(canvas, 0, -3, m->animation); } - if(m->hint_timeout) { - m->hint_timeout--; - + if(now < m->hint_expire_at) { if(!m->animation_seq_end) { canvas_set_font(canvas, FontPrimary); elements_multiline_text_framed(canvas, 42, 30, "Locked"); + } else { canvas_set_font(canvas, FontSecondary); canvas_draw_icon(canvas, 13, 5, &I_LockPopup_100x49); @@ -120,15 +119,10 @@ bool desktop_locked_input(InputEvent* event, void* context) { DesktopLockedView* locked_view = context; if(event->type == InputTypeShort) { - with_view_model( - locked_view->view, (DesktopLockedViewModel * model) { - model->hint_timeout = HINT_TIMEOUT_L; - return true; - }); + desktop_locked_update_hint_timeout(locked_view); if(event->key == InputKeyBack) { - uint32_t press_time = HAL_GetTick(); - + uint32_t press_time = osKernelGetTickCount(); // check if pressed sequentially if(press_time - locked_view->lock_lastpress > UNLOCK_RST_TIMEOUT) { locked_view->lock_lastpress = press_time; @@ -148,6 +142,26 @@ bool desktop_locked_input(InputEvent* event, void* context) { return true; } +void desktop_locked_enter(void* context) { + DesktopLockedView* locked_view = context; + + with_view_model( + locked_view->view, (DesktopLockedViewModel * model) { + if(model->animation) icon_animation_start(model->animation); + return false; + }); +} + +void desktop_locked_exit(void* context) { + DesktopLockedView* locked_view = context; + + with_view_model( + locked_view->view, (DesktopLockedViewModel * model) { + if(model->animation) icon_animation_stop(model->animation); + return false; + }); +} + DesktopLockedView* desktop_locked_alloc() { DesktopLockedView* locked_view = furi_alloc(sizeof(DesktopLockedView)); locked_view->view = view_alloc(); @@ -158,8 +172,9 @@ DesktopLockedView* desktop_locked_alloc() { view_set_context(locked_view->view, locked_view); view_set_draw_callback(locked_view->view, (ViewDrawCallback)desktop_locked_render); view_set_input_callback(locked_view->view, desktop_locked_input); + view_set_enter_callback(locked_view->view, desktop_locked_enter); + view_set_exit_callback(locked_view->view, desktop_locked_exit); - desktop_scene_handler_set_scene(locked_view, idle_scenes[random() % COUNT_OF(idle_scenes)]); return locked_view; } diff --git a/applications/desktop/views/desktop_locked.h b/applications/desktop/views/desktop_locked.h index bf8db392..c85705a8 100644 --- a/applications/desktop/views/desktop_locked.h +++ b/applications/desktop/views/desktop_locked.h @@ -6,9 +6,14 @@ #include #include -#define UNLOCK_RST_TIMEOUT 200 +#define UNLOCK_RST_TIMEOUT 300 #define UNLOCK_CNT 2 // 3 actually +#define DOOR_L_POS -57 +#define DOOR_L_POS_MAX 0 +#define DOOR_R_POS 115 +#define DOOR_R_POS_MIN 60 + typedef enum { DesktopLockedEventUnlock, DesktopLockedEventUpdate, @@ -30,10 +35,11 @@ struct DesktopLockedView { typedef struct { IconAnimation* animation; + uint32_t hint_expire_at; + uint8_t scene_num; int8_t door_left_x; int8_t door_right_x; - uint8_t hint_timeout; bool animation_seq_end; } DesktopLockedViewModel; @@ -43,6 +49,7 @@ void desktop_locked_set_callback( DesktopLockedViewCallback callback, void* context); +void desktop_locked_set_dolphin_animation(DesktopLockedView* locked_view); void desktop_locked_update_hint_timeout(DesktopLockedView* locked_view); void desktop_locked_reset_counter(DesktopLockedView* locked_view); void desktop_locked_reset_door_pos(DesktopLockedView* locked_view); diff --git a/applications/desktop/views/desktop_main.c b/applications/desktop/views/desktop_main.c index 171bb42e..a35ba008 100644 --- a/applications/desktop/views/desktop_main.c +++ b/applications/desktop/views/desktop_main.c @@ -2,8 +2,6 @@ #include "../desktop_i.h" #include "desktop_main.h" -static const Icon* idle_scenes[] = {&A_Wink_128x64, &A_WatchingTV_128x64}; - void desktop_main_set_callback( DesktopMainView* main_view, DesktopMainViewCallback callback, @@ -17,30 +15,17 @@ void desktop_main_set_callback( void desktop_main_reset_hint(DesktopMainView* main_view) { with_view_model( main_view->view, (DesktopMainViewModel * model) { - model->hint_timeout = 0; - return true; - }); -} -// temporary main screen animation managment -void desktop_scene_handler_set_scene(DesktopMainView* main_view, const Icon* icon_data) { - with_view_model( - main_view->view, (DesktopMainViewModel * model) { - if(model->animation) icon_animation_free(model->animation); - model->animation = icon_animation_alloc(icon_data); - icon_animation_start(model->animation); + model->hint_expire_at = 0; return true; }); } -void desktop_scene_handler_switch_scene(DesktopMainView* main_view) { +void desktop_main_switch_dolphin_animation(DesktopMainView* main_view) { with_view_model( main_view->view, (DesktopMainViewModel * model) { - if(icon_animation_is_last_frame(model->animation)) { - if(model->animation) icon_animation_free(model->animation); - model->animation = icon_animation_alloc(idle_scenes[model->scene_num]); - icon_animation_start(model->animation); - model->scene_num = random() % COUNT_OF(idle_scenes); - } + if(model->animation) icon_animation_free(model->animation); + model->animation = icon_animation_alloc(desktop_get_icon()); + view_tie_icon_animation(main_view->view, model->animation); return true; }); } @@ -48,13 +33,13 @@ void desktop_scene_handler_switch_scene(DesktopMainView* main_view) { void desktop_main_render(Canvas* canvas, void* model) { canvas_clear(canvas); DesktopMainViewModel* m = model; + uint32_t now = osKernelGetTickCount(); if(m->animation) { canvas_draw_icon_animation(canvas, 0, -3, m->animation); } - if(m->unlocked && m->hint_timeout) { - m->hint_timeout = CLAMP(m->hint_timeout - 1, 2, 0); + if(now < m->hint_expire_at) { canvas_set_font(canvas, FontPrimary); elements_multiline_text_framed(canvas, 42, 30, "Unlocked"); } @@ -87,6 +72,25 @@ bool desktop_main_input(InputEvent* event, void* context) { return true; } +void desktop_main_enter(void* context) { + DesktopMainView* main_view = context; + + with_view_model( + main_view->view, (DesktopMainViewModel * model) { + if(model->animation) icon_animation_start(model->animation); + return false; + }); +} + +void desktop_main_exit(void* context) { + DesktopMainView* main_view = context; + with_view_model( + main_view->view, (DesktopMainViewModel * model) { + if(model->animation) icon_animation_stop(model->animation); + return false; + }); +} + DesktopMainView* desktop_main_alloc() { DesktopMainView* main_view = furi_alloc(sizeof(DesktopMainView)); main_view->view = view_alloc(); @@ -94,8 +98,8 @@ DesktopMainView* desktop_main_alloc() { view_set_context(main_view->view, main_view); view_set_draw_callback(main_view->view, (ViewDrawCallback)desktop_main_render); view_set_input_callback(main_view->view, desktop_main_input); - - desktop_scene_handler_set_scene(main_view, idle_scenes[random() % COUNT_OF(idle_scenes)]); + view_set_enter_callback(main_view->view, desktop_main_enter); + view_set_exit_callback(main_view->view, desktop_main_exit); return main_view; } @@ -109,8 +113,7 @@ void desktop_main_free(DesktopMainView* main_view) { void desktop_main_unlocked(DesktopMainView* main_view) { with_view_model( main_view->view, (DesktopMainViewModel * model) { - model->unlocked = true; - model->hint_timeout = 2; + model->hint_expire_at = osKernelGetTickCount() + osKernelGetTickFreq(); return true; }); } diff --git a/applications/desktop/views/desktop_main.h b/applications/desktop/views/desktop_main.h index eadd1e82..78678b8c 100644 --- a/applications/desktop/views/desktop_main.h +++ b/applications/desktop/views/desktop_main.h @@ -28,8 +28,7 @@ struct DesktopMainView { typedef struct { IconAnimation* animation; uint8_t scene_num; - uint8_t hint_timeout; - bool unlocked; + uint32_t hint_expire_at; } DesktopMainViewModel; void desktop_main_set_callback( @@ -40,4 +39,7 @@ void desktop_main_set_callback( View* desktop_main_get_view(DesktopMainView* main_view); DesktopMainView* desktop_main_alloc(); + void desktop_main_free(DesktopMainView* main_view); + +void desktop_main_switch_dolphin_animation(DesktopMainView* main_view); diff --git a/applications/dialogs/dialogs-api.c b/applications/dialogs/dialogs-api.c index 681724fa..95af3b47 100644 --- a/applications/dialogs/dialogs-api.c +++ b/applications/dialogs/dialogs-api.c @@ -60,3 +60,14 @@ DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage return return_data.dialog_value; } + +/****************** Storage error ******************/ + +void dialog_message_show_storage_error(DialogsApp* context, const char* error_text) { + DialogMessage* message = dialog_message_alloc(); + dialog_message_set_text(message, error_text, 88, 32, AlignCenter, AlignCenter); + dialog_message_set_icon(message, &I_SDQuestion_35x43, 5, 6); + dialog_message_set_buttons(message, "Back", NULL, NULL); + dialog_message_show(context, message); + dialog_message_free(message); +} \ No newline at end of file diff --git a/applications/dialogs/dialogs.h b/applications/dialogs/dialogs.h index 6c756148..2a05ef41 100644 --- a/applications/dialogs/dialogs.h +++ b/applications/dialogs/dialogs.h @@ -123,6 +123,13 @@ void dialog_message_set_buttons( */ DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage* message); +/** + * Show SD error message (with question sign) + * @param context + * @param error_text + */ +void dialog_message_show_storage_error(DialogsApp* context, const char* error_text); + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/applications/dolphin/dolphin.c b/applications/dolphin/dolphin.c index a0d24df9..f1f1e5e5 100644 --- a/applications/dolphin/dolphin.c +++ b/applications/dolphin/dolphin.c @@ -1,34 +1,39 @@ #include "dolphin_i.h" #include - -bool dolphin_load(Dolphin* dolphin) { - furi_assert(dolphin); - return dolphin_state_load(dolphin->state); -} - -void dolphin_save(Dolphin* dolphin) { - furi_assert(dolphin); - DolphinEvent event; - event.type = DolphinEventTypeSave; - furi_check(osMessageQueuePut(dolphin->event_queue, &event, 0, osWaitForever) == osOK); -} +#define DOLPHIN_TIMEGATE 86400 // one day +#define DOLPHIN_LOCK_EVENT_FLAG (0x1) void dolphin_deed(Dolphin* dolphin, DolphinDeed deed) { furi_assert(dolphin); DolphinEvent event; event.type = DolphinEventTypeDeed; event.deed = deed; - furi_check(osMessageQueuePut(dolphin->event_queue, &event, 0, osWaitForever) == osOK); + dolphin_event_send_async(dolphin, &event); } -DolphinDeedWeight dolphin_stats(Dolphin* dolphin) { - DolphinDeedWeight stats; - stats.butthurt = dolphin_state_get_butthurt(dolphin->state); - stats.icounter = dolphin_state_get_icounter(dolphin->state); +DolphinStats dolphin_stats(Dolphin* dolphin) { + furi_assert(dolphin); + + DolphinStats stats; + DolphinEvent event; + + event.type = DolphinEventTypeStats; + event.stats = &stats; + + dolphin_event_send_wait(dolphin, &event); return stats; } +void dolphin_flush(Dolphin* dolphin) { + furi_assert(dolphin); + + DolphinEvent event; + event.type = DolphinEventTypeFlush; + + dolphin_event_send_wait(dolphin, &event); +} + Dolphin* dolphin_alloc() { Dolphin* dolphin = furi_alloc(sizeof(Dolphin)); @@ -47,27 +52,72 @@ void dolphin_free(Dolphin* dolphin) { free(dolphin); } +void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event) { + furi_assert(dolphin); + furi_assert(event); + event->flag = NULL; + furi_check(osMessageQueuePut(dolphin->event_queue, event, 0, osWaitForever) == osOK); +} + +void dolphin_event_send_wait(Dolphin* dolphin, DolphinEvent* event) { + furi_assert(dolphin); + furi_assert(event); + event->flag = osEventFlagsNew(NULL); + furi_check(event->flag); + furi_check(osMessageQueuePut(dolphin->event_queue, event, 0, osWaitForever) == osOK); + furi_check( + osEventFlagsWait(event->flag, DOLPHIN_LOCK_EVENT_FLAG, osFlagsWaitAny, osWaitForever) == + DOLPHIN_LOCK_EVENT_FLAG); + furi_check(osEventFlagsDelete(event->flag) == osOK); +} + +void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event) { + if(event->flag) { + osEventFlagsSet(event->flag, DOLPHIN_LOCK_EVENT_FLAG); + } +} + +static void dolphin_check_butthurt(DolphinState* state) { + furi_assert(state); + float diff_time = difftime(dolphin_state_get_timestamp(state), dolphin_state_timestamp()); + +#if 0 + FURI_LOG_I("dolphin-state", "Butthurt check, time since deed %.0f", fabs(diff_time)); +#endif + + if((fabs(diff_time)) > DOLPHIN_TIMEGATE) { + // increase butthurt + FURI_LOG_I("dolphin-state", "Increasing butthurt"); + dolphin_state_butthurted(state); + } +} + int32_t dolphin_srv(void* p) { Dolphin* dolphin = dolphin_alloc(); furi_record_create("dolphin", dolphin); + dolphin_state_load(dolphin->state); + DolphinEvent event; while(1) { - furi_check(osMessageQueueGet(dolphin->event_queue, &event, NULL, osWaitForever) == osOK); - switch(event.type) { - case DolphinEventTypeDeed: - dolphin_state_on_deed(dolphin->state, event.deed); - break; - - case DolphinEventTypeSave: + if(osMessageQueueGet(dolphin->event_queue, &event, NULL, 60000) == osOK) { + if(event.type == DolphinEventTypeDeed) { + dolphin_state_on_deed(dolphin->state, event.deed); + } else if(event.type == DolphinEventTypeStats) { + event.stats->icounter = dolphin_state_get_icounter(dolphin->state); + event.stats->butthurt = dolphin_state_get_butthurt(dolphin->state); + event.stats->timestamp = dolphin_state_get_timestamp(dolphin->state); + } else if(event.type == DolphinEventTypeFlush) { + dolphin_state_save(dolphin->state); + } + dolphin_event_release(dolphin, &event); + } else { + dolphin_check_butthurt(dolphin->state); dolphin_state_save(dolphin->state); - break; - - default: - break; } } dolphin_free(dolphin); + return 0; } diff --git a/applications/dolphin/dolphin.h b/applications/dolphin/dolphin.h index 0351417b..c8edca61 100644 --- a/applications/dolphin/dolphin.h +++ b/applications/dolphin/dolphin.h @@ -4,27 +4,24 @@ typedef struct Dolphin Dolphin; -/* Load Dolphin state - * Thread safe - */ +typedef struct { + uint32_t icounter; + uint32_t butthurt; + uint64_t timestamp; +} DolphinStats; -bool dolphin_load(Dolphin* dolphin); - -/* Deed complete notification. Call it on deed completion. +/** Deed complete notification. Call it on deed completion. * See dolphin_deed.h for available deeds. In futures it will become part of assets. - * Thread safe + * Thread safe, async */ - void dolphin_deed(Dolphin* dolphin, DolphinDeed deed); -/* Save Dolphin state (write to permanent memory) - * Thread safe +/** Retrieve dolphin stats + * Thread safe, blocking */ +DolphinStats dolphin_stats(Dolphin* dolphin); -void dolphin_save(Dolphin* dolphin); - -/* Retrieve dolphin's icounter and butthurt values - * Thread safe +/** Flush dolphin queue and save state + * Thread safe, blocking */ - -DolphinDeedWeight dolphin_stats(Dolphin* dolphin); \ No newline at end of file +void dolphin_flush(Dolphin* dolphin); \ No newline at end of file diff --git a/applications/dolphin/dolphin_i.h b/applications/dolphin/dolphin_i.h index f9393984..5edba30e 100644 --- a/applications/dolphin/dolphin_i.h +++ b/applications/dolphin/dolphin_i.h @@ -8,14 +8,16 @@ typedef enum { DolphinEventTypeDeed, - DolphinEventTypeSave, - DolphinEventTypeTick, + DolphinEventTypeStats, + DolphinEventTypeFlush, } DolphinEventType; typedef struct { DolphinEventType type; + osEventFlagsId_t flag; union { DolphinDeed deed; + DolphinStats* stats; }; } DolphinEvent; @@ -29,3 +31,9 @@ struct Dolphin { Dolphin* dolphin_alloc(); void dolphin_free(Dolphin* dolphin); + +void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event); + +void dolphin_event_send_wait(Dolphin* dolphin, DolphinEvent* event); + +void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event); diff --git a/applications/dolphin/helpers/dolphin_state.c b/applications/dolphin/helpers/dolphin_state.c index 99b561f1..240b7d95 100644 --- a/applications/dolphin/helpers/dolphin_state.c +++ b/applications/dolphin/helpers/dolphin_state.c @@ -25,6 +25,7 @@ typedef struct { uint32_t flags; uint32_t icounter; uint32_t butthurt; + uint64_t timestamp; } DolphinStoreData; typedef struct { @@ -35,6 +36,7 @@ typedef struct { struct DolphinState { Storage* fs_api; DolphinStoreData data; + bool dirty; }; DolphinState* dolphin_state_alloc() { @@ -49,8 +51,12 @@ void dolphin_state_free(DolphinState* dolphin_state) { } bool dolphin_state_save(DolphinState* dolphin_state) { + if(!dolphin_state->dirty) { + return true; + } + + FURI_LOG_I("dolphin-state", "State is dirty, saving to \"%s\"", DOLPHIN_STORE_KEY); DolphinStore store; - FURI_LOG_I("dolphin-state", "Saving state to \"%s\"", DOLPHIN_STORE_KEY); // Calculate checksum uint8_t* source = (uint8_t*)&dolphin_state->data; uint8_t checksum = 0; @@ -88,7 +94,10 @@ bool dolphin_state_save(DolphinState* dolphin_state) { storage_file_close(file); storage_file_free(file); + dolphin_state->dirty = !save_result; + FURI_LOG_I("dolphin-state", "Saved"); + return save_result; } @@ -99,8 +108,12 @@ bool dolphin_state_load(DolphinState* dolphin_state) { File* file = storage_file_alloc(dolphin_state->fs_api); bool load_result = storage_file_open(file, DOLPHIN_STORE_KEY, FSAM_READ, FSOM_OPEN_EXISTING); - - if(load_result) { + if(!load_result) { + FURI_LOG_E( + "dolphin-state", + "Load failed. Storage returned: %s", + storage_file_get_error_desc(file)); + } else { uint16_t bytes_count = storage_file_read(file, &store, sizeof(DolphinStore)); if(bytes_count != sizeof(DolphinStore)) { @@ -109,12 +122,8 @@ bool dolphin_state_load(DolphinState* dolphin_state) { } if(!load_result) { - FURI_LOG_E( - "dolphin-state", - "Load failed. Storage returned: %s", - storage_file_get_error_desc(file)); + FURI_LOG_E("dolphin-state", "DolphinStore size mismatch"); } else { - FURI_LOG_I("dolphin-state", "State loaded, verifying header"); if(store.header.magic == DOLPHIN_STORE_HEADER_MAGIC && store.header.version == DOLPHIN_STORE_HEADER_VERSION) { FURI_LOG_I( @@ -142,7 +151,7 @@ bool dolphin_state_load(DolphinState* dolphin_state) { } else { FURI_LOG_E( "dolphin-state", - "Magic(%d != %d) and Version(%d != %d) mismatch", + "Magic(%d != %d) or Version(%d != %d) mismatch", store.header.magic, DOLPHIN_STORE_HEADER_MAGIC, store.header.version, @@ -153,6 +162,9 @@ bool dolphin_state_load(DolphinState* dolphin_state) { storage_file_close(file); storage_file_free(file); + + dolphin_state->dirty = !load_result; + return load_result; } @@ -160,13 +172,43 @@ void dolphin_state_clear(DolphinState* dolphin_state) { memset(&dolphin_state->data, 0, sizeof(DolphinStoreData)); } +uint64_t dolphin_state_timestamp() { + RTC_TimeTypeDef time; + RTC_DateTypeDef date; + struct tm current; + + HAL_RTC_GetTime(&hrtc, &time, RTC_FORMAT_BIN); + HAL_RTC_GetDate(&hrtc, &date, RTC_FORMAT_BIN); + + current.tm_year = date.Year + 100; + current.tm_mday = date.Date; + current.tm_mon = date.Month - 1; + + current.tm_hour = time.Hours; + current.tm_min = time.Minutes; + current.tm_sec = time.Seconds; + + return mktime(¤t); +} + void dolphin_state_on_deed(DolphinState* dolphin_state, DolphinDeed deed) { const DolphinDeedWeight* deed_weight = dolphin_deed_weight(deed); int32_t icounter = dolphin_state->data.icounter + deed_weight->icounter; + int32_t butthurt = dolphin_state->data.butthurt; if(icounter >= 0) { dolphin_state->data.icounter = icounter; + dolphin_state->data.butthurt = MAX(butthurt - deed_weight->icounter, 0); + dolphin_state->data.timestamp = dolphin_state_timestamp(); } + + dolphin_state->dirty = true; +} + +void dolphin_state_butthurted(DolphinState* dolphin_state) { + dolphin_state->data.butthurt++; + dolphin_state->data.timestamp = dolphin_state_timestamp(); + dolphin_state->dirty = true; } uint32_t dolphin_state_get_icounter(DolphinState* dolphin_state) { @@ -177,13 +219,14 @@ uint32_t dolphin_state_get_butthurt(DolphinState* dolphin_state) { return dolphin_state->data.butthurt; } -uint32_t dolphin_state_get_level(DolphinState* dolphin_state) { - return 0.5f + - sqrtf(1.0f + 8.0f * ((float)dolphin_state->data.icounter / DOLPHIN_LVL_THRESHOLD)) / - 2.0f; +uint64_t dolphin_state_get_timestamp(DolphinState* dolphin_state) { + return dolphin_state->data.timestamp; } -uint32_t dolphin_state_xp_to_levelup(DolphinState* dolphin_state, uint32_t level, bool remaining) { - return (DOLPHIN_LVL_THRESHOLD * level * (level + 1) / 2) - - (remaining ? dolphin_state->data.icounter : 0); +uint32_t dolphin_state_get_level(uint32_t icounter) { + return 0.5f + sqrtf(1.0f + 8.0f * ((float)icounter / DOLPHIN_LVL_THRESHOLD)) / 2.0f; +} + +uint32_t dolphin_state_xp_to_levelup(uint32_t icounter, uint32_t level, bool remaining) { + return (DOLPHIN_LVL_THRESHOLD * level * (level + 1) / 2) - (remaining ? icounter : 0); } \ No newline at end of file diff --git a/applications/dolphin/helpers/dolphin_state.h b/applications/dolphin/helpers/dolphin_state.h index cbd9611a..7c4a33cd 100644 --- a/applications/dolphin/helpers/dolphin_state.h +++ b/applications/dolphin/helpers/dolphin_state.h @@ -3,6 +3,8 @@ #include "dolphin_deed.h" #include #include +#include +#include typedef struct DolphinState DolphinState; @@ -16,12 +18,18 @@ bool dolphin_state_load(DolphinState* dolphin_state); void dolphin_state_clear(DolphinState* dolphin_state); +uint64_t dolphin_state_timestamp(); + void dolphin_state_on_deed(DolphinState* dolphin_state, DolphinDeed deed); +void dolphin_state_butthurted(DolphinState* dolphin_state); + uint32_t dolphin_state_get_icounter(DolphinState* dolphin_state); uint32_t dolphin_state_get_butthurt(DolphinState* dolphin_state); -uint32_t dolphin_state_get_level(DolphinState* dolphin_state); +uint64_t dolphin_state_get_timestamp(DolphinState* dolphin_state); -uint32_t dolphin_state_xp_to_levelup(DolphinState* dolphin_state, uint32_t level, bool remaining); \ No newline at end of file +uint32_t dolphin_state_get_level(uint32_t icounter); + +uint32_t dolphin_state_xp_to_levelup(uint32_t icounter, uint32_t level, bool remaining); \ No newline at end of file diff --git a/applications/gpio-tester/gpio-tester.c b/applications/gpio-tester/gpio-tester.c deleted file mode 100644 index e994ad73..00000000 --- a/applications/gpio-tester/gpio-tester.c +++ /dev/null @@ -1,148 +0,0 @@ -#include -#include - -#include -#include - -typedef struct { - const char* name; - const GpioPin* pin; -} GpioItem; - -static const GpioItem GPIO_PINS[] = { - {"1.2: PA7", &gpio_ext_pa7}, - {"1.3: PA6", &gpio_ext_pa6}, - {"1.4: PA4", &gpio_ext_pa4}, - {"1.5: PB3", &gpio_ext_pb3}, - {"1.6: PB2", &gpio_ext_pb2}, - {"1.7: PC3", &gpio_ext_pc3}, - {"2.7: PC1", &gpio_ext_pc1}, - {"2.8: PC0", &gpio_ext_pc0}, - {"*.*: ALL", NULL}, -}; - -static const size_t GPIO_PINS_COUNT = sizeof(GPIO_PINS) / sizeof(GPIO_PINS[0]); - -typedef struct { - osMessageQueueId_t input_queue; - uint8_t gpio_index; - ViewPort* view_port; - Gui* gui; - NotificationApp* notification; -} GpioTest; - -static void gpio_test_render_callback(Canvas* canvas, void* ctx) { - GpioTest* gpio_test = ctx; - - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 2, 10, "GPIO Control"); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 2, 25, GPIO_PINS[gpio_test->gpio_index].name); -} - -static void gpio_test_input_callback(InputEvent* input_event, void* ctx) { - GpioTest* gpio_test = ctx; - - osMessageQueuePut(gpio_test->input_queue, input_event, 0, 0); -} - -static void gpio_test_configure_pins(GpioMode mode) { - for(size_t i = 0; i < GPIO_PINS_COUNT; i++) { - if(!GPIO_PINS[i].pin) continue; - hal_gpio_write(GPIO_PINS[i].pin, false); - hal_gpio_init(GPIO_PINS[i].pin, mode, GpioPullNo, GpioSpeedVeryHigh); - } -} - -static void gpio_test_set_pin(uint8_t index, bool level) { - if(GPIO_PINS[index].pin) { - hal_gpio_write(GPIO_PINS[index].pin, level); - } else { - for(size_t i = 0; i < GPIO_PINS_COUNT; i++) { - if(!GPIO_PINS[i].pin) continue; - hal_gpio_write(GPIO_PINS[i].pin, level); - } - } -} - -GpioTest* gpio_test_alloc() { - GpioTest* instance = furi_alloc(sizeof(GpioTest)); - - gpio_test_configure_pins(GpioModeOutputPushPull); - - instance->input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); - furi_check(instance->input_queue); - - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, gpio_test_render_callback, instance); - view_port_input_callback_set(instance->view_port, gpio_test_input_callback, instance); - - instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - instance->notification = furi_record_open("notification"); - - return instance; -} - -void gpio_test_free(GpioTest* instance) { - furi_assert(instance); - - furi_record_close("notification"); - - view_port_enabled_set(instance->view_port, false); - gui_remove_view_port(instance->gui, instance->view_port); - furi_record_close("gui"); - - view_port_free(instance->view_port); - - osMessageQueueDelete(instance->input_queue); - - gpio_test_configure_pins(GpioModeAnalog); - - free(instance); -} - -int32_t gpio_test_app(void* p) { - GpioTest* gpio_test = gpio_test_alloc(); - - InputEvent event; - while(osMessageQueueGet(gpio_test->input_queue, &event, NULL, osWaitForever) == osOK) { - if(event.type == InputTypeShort) { - if(event.key == InputKeyBack) { - notification_message(gpio_test->notification, &sequence_reset_green); - break; - } - - if(event.key == InputKeyRight) { - if(gpio_test->gpio_index < (GPIO_PINS_COUNT - 1)) { - gpio_test->gpio_index++; - } - } - - if(event.key == InputKeyLeft) { - if(gpio_test->gpio_index > 0) { - gpio_test->gpio_index--; - } - } - } else { - if(event.key == InputKeyOk) { - if(event.type == InputTypePress) { - gpio_test_set_pin(gpio_test->gpio_index, true); - notification_message(gpio_test->notification, &sequence_set_green_255); - } else if(event.type == InputTypeRelease) { - gpio_test_set_pin(gpio_test->gpio_index, false); - notification_message(gpio_test->notification, &sequence_reset_green); - } - } - } - - view_port_update(gpio_test->view_port); - } - - gpio_test_free(gpio_test); - - return 0; -} diff --git a/applications/gpio/gpio_app.c b/applications/gpio/gpio_app.c new file mode 100755 index 00000000..32d92af0 --- /dev/null +++ b/applications/gpio/gpio_app.c @@ -0,0 +1,76 @@ +#include "gpio_app_i.h" + +#include +#include + +static bool gpio_app_custom_event_callback(void* context, uint32_t event) { + furi_assert(context); + GpioApp* app = context; + return scene_manager_handle_custom_event(app->scene_manager, event); +} + +static bool gpio_app_back_event_callback(void* context) { + furi_assert(context); + GpioApp* app = context; + return scene_manager_handle_back_event(app->scene_manager); +} + +GpioApp* gpio_app_alloc() { + GpioApp* app = furi_alloc(sizeof(GpioApp)); + + app->gui = furi_record_open("gui"); + app->notifications = furi_record_open("notification"); + + app->view_dispatcher = view_dispatcher_alloc(); + app->scene_manager = scene_manager_alloc(&gpio_scene_handlers, app); + view_dispatcher_enable_queue(app->view_dispatcher); + view_dispatcher_set_event_callback_context(app->view_dispatcher, app); + + view_dispatcher_set_custom_event_callback( + app->view_dispatcher, gpio_app_custom_event_callback); + view_dispatcher_set_navigation_event_callback( + app->view_dispatcher, gpio_app_back_event_callback); + + view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); + + app->var_item_list = variable_item_list_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + GpioAppViewVarItemList, + variable_item_list_get_view(app->var_item_list)); + app->gpio_test = gpio_test_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, GpioAppViewGpioTest, gpio_test_get_view(app->gpio_test)); + + scene_manager_next_scene(app->scene_manager, GpioSceneStart); + + return app; +} + +void gpio_app_free(GpioApp* app) { + furi_assert(app); + + // Views + view_dispatcher_remove_view(app->view_dispatcher, GpioAppViewVarItemList); + variable_item_list_free(app->var_item_list); + view_dispatcher_remove_view(app->view_dispatcher, GpioAppViewGpioTest); + gpio_test_free(app->gpio_test); + // View dispatcher + view_dispatcher_free(app->view_dispatcher); + scene_manager_free(app->scene_manager); + // Close records + furi_record_close("gui"); + furi_record_close("notification"); + + free(app); +} + +int32_t gpio_app(void* p) { + GpioApp* gpio_app = gpio_app_alloc(); + + view_dispatcher_run(gpio_app->view_dispatcher); + + gpio_app_free(gpio_app); + + return 0; +} diff --git a/firmware/targets/f6/usb-glue/usb_device.h b/applications/gpio/gpio_app.h similarity index 57% rename from firmware/targets/f6/usb-glue/usb_device.h rename to applications/gpio/gpio_app.h index 7d80e348..156ddc92 100644 --- a/firmware/targets/f6/usb-glue/usb_device.h +++ b/applications/gpio/gpio_app.h @@ -1,11 +1,11 @@ -#pragma once - -#ifdef __cplusplus - extern "C" { -#endif - -void MX_USB_Device_Init(); - -#ifdef __cplusplus -} -#endif +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct GpioApp GpioApp; + +#ifdef __cplusplus +} +#endif diff --git a/applications/gpio/gpio_app_i.h b/applications/gpio/gpio_app_i.h new file mode 100644 index 00000000..590bedc3 --- /dev/null +++ b/applications/gpio/gpio_app_i.h @@ -0,0 +1,28 @@ +#pragma once + +#include "gpio_app.h" +#include "gpio_item.h" +#include "scenes/gpio_scene.h" + +#include +#include +#include +#include + +#include +#include "views/gpio_test.h" + +struct GpioApp { + Gui* gui; + ViewDispatcher* view_dispatcher; + SceneManager* scene_manager; + NotificationApp* notifications; + + VariableItemList* var_item_list; + GpioTest* gpio_test; +}; + +typedef enum { + GpioAppViewVarItemList, + GpioAppViewGpioTest, +} GpioAppView; diff --git a/applications/gpio/gpio_item.c b/applications/gpio/gpio_item.c new file mode 100644 index 00000000..96823ece --- /dev/null +++ b/applications/gpio/gpio_item.c @@ -0,0 +1,51 @@ +#include "gpio_item.h" + +#include + +typedef struct { + const char* name; + const GpioPin* pin; +} GpioItem; + +static const GpioItem gpio_item[GPIO_ITEM_COUNT] = { + {"1.2: PA7", &gpio_ext_pa7}, + {"1.3: PA6", &gpio_ext_pa6}, + {"1.4: PA4", &gpio_ext_pa4}, + {"1.5: PB3", &gpio_ext_pb3}, + {"1.6: PB2", &gpio_ext_pb2}, + {"1.7: PC3", &gpio_ext_pc3}, + {"2.7: PC1", &gpio_ext_pc1}, + {"2.8: PC0", &gpio_ext_pc0}, +}; + +void gpio_item_configure_pin(uint8_t index, GpioMode mode) { + furi_assert(index < GPIO_ITEM_COUNT); + hal_gpio_write(gpio_item[index].pin, false); + hal_gpio_init(gpio_item[index].pin, mode, GpioPullNo, GpioSpeedVeryHigh); +} + +void gpio_item_configure_all_pins(GpioMode mode) { + for(uint8_t i = 0; i < GPIO_ITEM_COUNT; i++) { + gpio_item_configure_pin(i, mode); + } +} + +void gpio_item_set_pin(uint8_t index, bool level) { + furi_assert(index < GPIO_ITEM_COUNT); + hal_gpio_write(gpio_item[index].pin, level); +} + +void gpio_item_set_all_pins(bool level) { + for(uint8_t i = 0; i < GPIO_ITEM_COUNT; i++) { + gpio_item_set_pin(i, level); + } +} + +const char* gpio_item_get_pin_name(uint8_t index) { + furi_assert(index < GPIO_ITEM_COUNT + 1); + if(index == GPIO_ITEM_COUNT) { + return "ALL"; + } else { + return gpio_item[index].name; + } +} diff --git a/applications/gpio/gpio_item.h b/applications/gpio/gpio_item.h new file mode 100644 index 00000000..25675729 --- /dev/null +++ b/applications/gpio/gpio_item.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#define GPIO_ITEM_COUNT 8 + +void gpio_item_configure_pin(uint8_t index, GpioMode mode); + +void gpio_item_configure_all_pins(GpioMode mode); + +void gpio_item_set_pin(uint8_t index, bool level); + +void gpio_item_set_all_pins(bool level); + +const char* gpio_item_get_pin_name(uint8_t index); diff --git a/applications/gpio/scenes/gpio_scene.c b/applications/gpio/scenes/gpio_scene.c new file mode 100644 index 00000000..d5aa4cbe --- /dev/null +++ b/applications/gpio/scenes/gpio_scene.c @@ -0,0 +1,30 @@ +#include "gpio_scene.h" + +// Generate scene on_enter handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, +void (*const gpio_scene_on_enter_handlers[])(void*) = { +#include "gpio_scene_config.h" +}; +#undef ADD_SCENE + +// Generate scene on_event handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, +bool (*const gpio_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = { +#include "gpio_scene_config.h" +}; +#undef ADD_SCENE + +// Generate scene on_exit handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, +void (*const gpio_scene_on_exit_handlers[])(void* context) = { +#include "gpio_scene_config.h" +}; +#undef ADD_SCENE + +// Initialize scene handlers configuration structure +const SceneManagerHandlers gpio_scene_handlers = { + .on_enter_handlers = gpio_scene_on_enter_handlers, + .on_event_handlers = gpio_scene_on_event_handlers, + .on_exit_handlers = gpio_scene_on_exit_handlers, + .scene_num = GpioSceneNum, +}; diff --git a/applications/gpio/scenes/gpio_scene.h b/applications/gpio/scenes/gpio_scene.h new file mode 100644 index 00000000..15556c8d --- /dev/null +++ b/applications/gpio/scenes/gpio_scene.h @@ -0,0 +1,29 @@ +#pragma once + +#include + +// Generate scene id and total number +#define ADD_SCENE(prefix, name, id) GpioScene##id, +typedef enum { +#include "gpio_scene_config.h" + GpioSceneNum, +} GpioScene; +#undef ADD_SCENE + +extern const SceneManagerHandlers gpio_scene_handlers; + +// Generate scene on_enter handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); +#include "gpio_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_event handlers declaration +#define ADD_SCENE(prefix, name, id) \ + bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); +#include "gpio_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_exit handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); +#include "gpio_scene_config.h" +#undef ADD_SCENE diff --git a/applications/gpio/scenes/gpio_scene_config.h b/applications/gpio/scenes/gpio_scene_config.h new file mode 100644 index 00000000..5f7f78ba --- /dev/null +++ b/applications/gpio/scenes/gpio_scene_config.h @@ -0,0 +1,2 @@ +ADD_SCENE(gpio, start, Start) +ADD_SCENE(gpio, test, Test) diff --git a/applications/gpio/scenes/gpio_scene_start.c b/applications/gpio/scenes/gpio_scene_start.c new file mode 100755 index 00000000..946d8e1b --- /dev/null +++ b/applications/gpio/scenes/gpio_scene_start.c @@ -0,0 +1,92 @@ +#include "../gpio_app_i.h" +#include "furi-hal-power.h" + +#define GPIO_SCENE_START_CUSTOM_EVENT_OTG_OFF (0UL) +#define GPIO_SCENE_START_CUSTOM_EVENT_OTG_ON (1UL) +#define GPIO_SCENE_START_CUSTOM_EVENT_TEST (2UL) + +enum GpioItem { + GpioItemOtg, + GpioItemTest, +}; + +enum GpioOtg { + GpioOtgOff, + GpioOtgOn, + GpioOtgSettingsNum, +}; + +const char* const gpio_otg_text[GpioOtgSettingsNum] = { + "Off", + "On", +}; + +static void gpio_scene_start_var_list_enter_callback(void* context, uint32_t index) { + furi_assert(context); + GpioApp* app = context; + if(index == GpioItemTest) { + view_dispatcher_send_custom_event( + app->view_dispatcher, GPIO_SCENE_START_CUSTOM_EVENT_TEST); + } +} + +static void gpio_scene_start_var_list_change_callback(VariableItem* item) { + GpioApp* app = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + + variable_item_set_current_value_text(item, gpio_otg_text[index]); + if(index == GpioOtgOff) { + view_dispatcher_send_custom_event( + app->view_dispatcher, GPIO_SCENE_START_CUSTOM_EVENT_OTG_OFF); + } else if(index == GpioOtgOn) { + view_dispatcher_send_custom_event( + app->view_dispatcher, GPIO_SCENE_START_CUSTOM_EVENT_OTG_ON); + } +} + +void gpio_scene_start_on_enter(void* context) { + GpioApp* app = context; + VariableItemList* var_item_list = app->var_item_list; + + VariableItem* item; + variable_item_list_set_enter_callback( + var_item_list, gpio_scene_start_var_list_enter_callback, app); + item = variable_item_list_add( + var_item_list, + "5V on GPIO", + GpioOtgSettingsNum, + gpio_scene_start_var_list_change_callback, + app); + if(furi_hal_power_is_otg_enabled()) { + variable_item_set_current_value_index(item, GpioOtgOn); + variable_item_set_current_value_text(item, gpio_otg_text[GpioOtgOn]); + } else { + variable_item_set_current_value_index(item, GpioOtgOff); + variable_item_set_current_value_text(item, gpio_otg_text[GpioOtgOff]); + } + variable_item_list_add(var_item_list, "GPIO tester", 0, NULL, NULL); + + view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewVarItemList); +} + +bool gpio_scene_start_on_event(void* context, SceneManagerEvent event) { + GpioApp* app = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GPIO_SCENE_START_CUSTOM_EVENT_OTG_ON) { + furi_hal_power_enable_otg(); + } else if(event.event == GPIO_SCENE_START_CUSTOM_EVENT_OTG_OFF) { + furi_hal_power_disable_otg(); + } else if(event.event == GPIO_SCENE_START_CUSTOM_EVENT_TEST) { + scene_manager_next_scene(app->scene_manager, GpioSceneTest); + } + consumed = true; + } + return consumed; +} + +void gpio_scene_start_on_exit(void* context) { + GpioApp* app = context; + variable_item_list_clean(app->var_item_list); +} diff --git a/applications/gpio/scenes/gpio_scene_test.c b/applications/gpio/scenes/gpio_scene_test.c new file mode 100644 index 00000000..009e2ff4 --- /dev/null +++ b/applications/gpio/scenes/gpio_scene_test.c @@ -0,0 +1,27 @@ +#include "../gpio_app_i.h" + +void gpio_scene_test_ok_callback(InputType type, void* context) { + furi_assert(context); + GpioApp* app = context; + + if(type == InputTypePress) { + notification_message(app->notifications, &sequence_set_green_255); + } else if(type == InputTypeRelease) { + notification_message(app->notifications, &sequence_reset_green); + } +} + +void gpio_scene_test_on_enter(void* context) { + GpioApp* app = context; + gpio_item_configure_all_pins(GpioModeOutputPushPull); + gpio_test_set_ok_callback(app->gpio_test, gpio_scene_test_ok_callback, app); + view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewGpioTest); +} + +bool gpio_scene_test_on_event(void* context, SceneManagerEvent event) { + return false; +} + +void gpio_scene_test_on_exit(void* context) { + gpio_item_configure_all_pins(GpioModeAnalog); +} diff --git a/applications/gpio/views/gpio_test.c b/applications/gpio/views/gpio_test.c new file mode 100755 index 00000000..62f3426e --- /dev/null +++ b/applications/gpio/views/gpio_test.c @@ -0,0 +1,130 @@ +#include "gpio_test.h" +#include "../gpio_item.h" + +#include + +struct GpioTest { + View* view; + GpioTestOkCallback callback; + void* context; +}; + +typedef struct { + uint8_t pin_idx; +} GpioTestModel; + +static bool gpio_test_process_left(GpioTest* gpio_test); +static bool gpio_test_process_right(GpioTest* gpio_test); +static bool gpio_test_process_ok(GpioTest* gpio_test, InputEvent* event); + +static void gpio_test_draw_callback(Canvas* canvas, void* _model) { + GpioTestModel* model = _model; + canvas_set_font(canvas, FontPrimary); + elements_multiline_text_aligned(canvas, 64, 2, AlignCenter, AlignTop, "Gpio Output mode test"); + canvas_set_font(canvas, FontSecondary); + elements_multiline_text_aligned( + canvas, 64, 16, AlignCenter, AlignTop, "Press < or > to change pin"); + elements_multiline_text_aligned( + canvas, 64, 32, AlignCenter, AlignTop, gpio_item_get_pin_name(model->pin_idx)); +} + +static bool gpio_test_input_callback(InputEvent* event, void* context) { + furi_assert(context); + GpioTest* gpio_test = context; + bool consumed = false; + + if(event->type == InputTypeShort) { + if(event->key == InputKeyRight) { + consumed = gpio_test_process_right(gpio_test); + } else if(event->key == InputKeyLeft) { + consumed = gpio_test_process_left(gpio_test); + } + } else if(event->key == InputKeyOk) { + consumed = gpio_test_process_ok(gpio_test, event); + } + + return consumed; +} + +static bool gpio_test_process_left(GpioTest* gpio_test) { + with_view_model( + gpio_test->view, (GpioTestModel * model) { + if(model->pin_idx) { + model->pin_idx--; + } + return true; + }); + return true; +} + +static bool gpio_test_process_right(GpioTest* gpio_test) { + with_view_model( + gpio_test->view, (GpioTestModel * model) { + if(model->pin_idx < GPIO_ITEM_COUNT) { + model->pin_idx++; + } + return true; + }); + return true; +} + +static bool gpio_test_process_ok(GpioTest* gpio_test, InputEvent* event) { + bool consumed = false; + + with_view_model( + gpio_test->view, (GpioTestModel * model) { + if(event->type == InputTypePress) { + if(model->pin_idx < GPIO_ITEM_COUNT) { + gpio_item_set_pin(model->pin_idx, true); + } else { + gpio_item_set_all_pins(true); + } + consumed = true; + } else if(event->type == InputTypeRelease) { + if(model->pin_idx < GPIO_ITEM_COUNT) { + gpio_item_set_pin(model->pin_idx, false); + } else { + gpio_item_set_all_pins(false); + } + consumed = true; + } + gpio_test->callback(event->type, gpio_test->context); + return true; + }); + + return consumed; +} + +GpioTest* gpio_test_alloc() { + GpioTest* gpio_test = furi_alloc(sizeof(GpioTest)); + + gpio_test->view = view_alloc(); + view_allocate_model(gpio_test->view, ViewModelTypeLocking, sizeof(GpioTestModel)); + view_set_context(gpio_test->view, gpio_test); + view_set_draw_callback(gpio_test->view, gpio_test_draw_callback); + view_set_input_callback(gpio_test->view, gpio_test_input_callback); + + return gpio_test; +} + +void gpio_test_free(GpioTest* gpio_test) { + furi_assert(gpio_test); + view_free(gpio_test->view); + free(gpio_test); +} + +View* gpio_test_get_view(GpioTest* gpio_test) { + furi_assert(gpio_test); + return gpio_test->view; +} + +void gpio_test_set_ok_callback(GpioTest* gpio_test, GpioTestOkCallback callback, void* context) { + furi_assert(gpio_test); + furi_assert(callback); + with_view_model( + gpio_test->view, (GpioTestModel * model) { + gpio_test->callback = callback; + gpio_test->context = context; + return false; + }); +} diff --git a/applications/gpio/views/gpio_test.h b/applications/gpio/views/gpio_test.h new file mode 100755 index 00000000..5cbd11e8 --- /dev/null +++ b/applications/gpio/views/gpio_test.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +typedef struct GpioTest GpioTest; +typedef void (*GpioTestOkCallback)(InputType type, void* context); + +GpioTest* gpio_test_alloc(); + +void gpio_test_free(GpioTest* gpio_test); + +View* gpio_test_get_view(GpioTest* gpio_test); + +void gpio_test_set_ok_callback(GpioTest* gpio_test, GpioTestOkCallback callback, void* context); diff --git a/applications/gui/canvas.c b/applications/gui/canvas.c index 40454339..c9481f86 100644 --- a/applications/gui/canvas.c +++ b/applications/gui/canvas.c @@ -110,11 +110,13 @@ void canvas_set_font(Canvas* canvas, Font font) { furi_assert(canvas); u8g2_SetFontMode(&canvas->fb, 1); if(font == FontPrimary) { - u8g2_SetFont(&canvas->fb, u8g2_font_helvB08_tf); + u8g2_SetFont(&canvas->fb, u8g2_font_helvB08_tr); } else if(font == FontSecondary) { u8g2_SetFont(&canvas->fb, u8g2_font_haxrcorp4089_tr); } else if(font == FontKeyboard) { - u8g2_SetFont(&canvas->fb, u8g2_font_profont11_mf); + u8g2_SetFont(&canvas->fb, u8g2_font_profont11_mr); + } else if(font == FontBigNumbers) { + u8g2_SetFont(&canvas->fb, u8g2_font_profont22_tn); } else { furi_crash(NULL); } diff --git a/applications/gui/canvas.h b/applications/gui/canvas.h index db4bec1f..cbf9d068 100644 --- a/applications/gui/canvas.h +++ b/applications/gui/canvas.h @@ -1,3 +1,8 @@ +/** + * @file canvas.h + * GUI: Canvas API + */ + #pragma once #include @@ -8,13 +13,16 @@ extern "C" { #endif +/** Color enumeration */ typedef enum { ColorWhite = 0x00, ColorBlack = 0x01, } Color; -typedef enum { FontPrimary, FontSecondary, FontKeyboard } Font; +/** Fonts enumeration */ +typedef enum { FontPrimary, FontSecondary, FontKeyboard, FontBigNumbers } Font; +/** Alignment enumeration */ typedef enum { AlignLeft, AlignRight, @@ -23,59 +31,85 @@ typedef enum { AlignCenter, } Align; +/** Canvas Orientation */ typedef enum { CanvasOrientationHorizontal, CanvasOrientationVertical, } CanvasOrientation; +/** Canvas anonymouse structure */ typedef struct Canvas Canvas; -/* - * Canvas width - * @return width in pixels. +/** Get Canvas width + * + * @param canvas Canvas instance + * + * @return width in pixels. */ uint8_t canvas_width(Canvas* canvas); -/* - * Canvas height - * @return height in pixels. +/** Get Canvas height + * + * @param canvas Canvas instance + * + * @return height in pixels. */ uint8_t canvas_height(Canvas* canvas); -/* - * Get current font height - * @return height in pixels. +/** Get current font height + * + * @param canvas Canvas instance + * + * @return height in pixels. */ uint8_t canvas_current_font_height(Canvas* canvas); -/* - * Clear canvas, clear rendering buffer +/** Clear canvas + * + * @param canvas Canvas instance */ void canvas_clear(Canvas* canvas); -/* - * Set drawing color +/** Set drawing color + * + * @param canvas Canvas instance + * @param color Color */ void canvas_set_color(Canvas* canvas, Color color); -/* - * Invert drawing color +/** Invert drawing color + * + * @param canvas Canvas instance */ void canvas_invert_color(Canvas* canvas); -/* - * Set drawing font +/** Set drawing font + * + * @param canvas Canvas instance + * @param font Font */ void canvas_set_font(Canvas* canvas, Font font); -/* - * Draw string at position of baseline defined by x, y. +/** Draw string at position of baseline defined by x, y. + * + * @param canvas Canvas instance + * @param x anchor point x coordinate + * @param y anchor point y coordinate + * @param str C-string */ void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str); -/* - * Draw aligned string defined by x, y. - * Align calculated from position of baseline, string width and ascent (height of the glyphs above the baseline) +/** Draw aligned string defined by x, y. + * + * Align calculated from position of baseline, string width and ascent (height + * of the glyphs above the baseline) + * + * @param canvas Canvas instance + * @param x anchor point x coordinate + * @param y anchor point y coordinate + * @param horizontal horizontal alignment + * @param vertical vertical alignment + * @param str C-string */ void canvas_draw_str_aligned( Canvas* canvas, @@ -85,22 +119,30 @@ void canvas_draw_str_aligned( Align vertical, const char* str); -/* - * Get string width - * @return width in pixels. +/** Get string width + * + * @param canvas Canvas instance + * @param str C-string + * + * @return width in pixels. */ uint16_t canvas_string_width(Canvas* canvas, const char* str); /** Get glyph width - * @return width in pixels + * + * @param canvas Canvas instance + * @param[in] symbol character + * + * @return width in pixels */ uint8_t canvas_glyph_width(Canvas* canvas, char symbol); /** Draw animation at position defined by x,y. - * @param canvas - canvas instance - * @param x - x coordinate - * @param y - y coordinate - * @param icon_animation - data pointer to IconAnimation + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param icon_animation IconAnimation instance */ void canvas_draw_icon_animation( Canvas* canvas, @@ -109,15 +151,22 @@ void canvas_draw_icon_animation( IconAnimation* icon_animation); /** Draw icon at position defined by x,y. - * @param canvas - canvas instance - * @param x - x coordinate - * @param y - y coordinate - * @param icon - data pointer to Icon + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param icon Icon instance */ void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon); -/* - * Draw xbm icon of width, height at position defined by x,y. +/** Draw XBM bitmap + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param w bitmap width + * @param h bitmap height + * @param bitmap pointer to XBM bitmap data */ void canvas_draw_xbm( Canvas* canvas, @@ -127,48 +176,86 @@ void canvas_draw_xbm( uint8_t h, const uint8_t* bitmap); -/* - * Draw dot at x,y +/** Draw dot at x,y + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate */ void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y); -/* - * Draw box of width, height at x,y +/** Draw box of width, height at x,y + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param width box width + * @param height box height */ void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height); -/* - * Draw frame of width, height at x,y +/** Draw frame of width, height at x,y + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param width frame width + * @param height frame height */ void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height); -/* - * Draw line from x1,y1 to x2,y2 +/** Draw line from x1,y1 to x2,y2 + * + * @param canvas Canvas instance + * @param x1 x1 coordinate + * @param y1 y1 coordinate + * @param x2 x2 coordinate + * @param y2 y2 coordinate */ void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2); -/* - * Draw circle at x,y with radius r +/** Draw circle at x,y with radius r + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param r radius */ void canvas_draw_circle(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r); -/* - * Draw disc at x,y with radius r +/** Draw disc at x,y with radius r + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param r radius */ void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r); -/* - * Draw glyph +/** Draw glyph + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param ch character */ void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch); -/* - * Set transparency mode +/** Set transparency mode + * + * @param canvas Canvas instance + * @param alpha transparency mode */ void canvas_set_bitmap_mode(Canvas* canvas, bool alpha); -/* - * Draw rounded-corner frame of width, height at x,y, with round value raduis +/** Draw rounded-corner frame of width, height at x,y, with round value raduis + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param width frame width + * @param height frame height + * @param radius frame corner radius */ void canvas_draw_rframe( Canvas* canvas, @@ -178,8 +265,14 @@ void canvas_draw_rframe( uint8_t height, uint8_t radius); -/* - * Draw rounded-corner box of width, height at x,y, with round value raduis +/** Draw rounded-corner box of width, height at x,y, with round value raduis + * + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param width box width + * @param height box height + * @param radius box corner radius */ void canvas_draw_rbox( Canvas* canvas, diff --git a/applications/gui/canvas_i.h b/applications/gui/canvas_i.h index e6cc6345..d5594c24 100644 --- a/applications/gui/canvas_i.h +++ b/applications/gui/canvas_i.h @@ -1,8 +1,15 @@ +/** + * @file canvas_i.h + * GUI: internal Canvas API + */ + #pragma once #include "canvas.h" #include +/** Canvas structure + */ struct Canvas { u8g2_t fb; CanvasOrientation orientation; @@ -12,40 +19,53 @@ struct Canvas { uint8_t height; }; -/* - * Allocate memory and initialize canvas +/** Allocate memory and initialize canvas + * + * @return Canvas instance */ Canvas* canvas_init(); -/* - * Free canvas memory +/** Free canvas memory + * + * @param canvas Canvas instance */ void canvas_free(Canvas* canvas); -/* - * Reset canvas drawing tools configuration +/** Reset canvas drawing tools configuration + * + * @param canvas Canvas instance */ void canvas_reset(Canvas* canvas); -/* - * Commit canvas. Send buffer to display +/** Commit canvas. Send buffer to display + * + * @param canvas Canvas instance */ void canvas_commit(Canvas* canvas); -/* - * Get canvas buffer. - * @return pointer to buffer +/** Get canvas buffer. + * + * @param canvas Canvas instance + * + * @return pointer to buffer */ uint8_t* canvas_get_buffer(Canvas* canvas); -/* - * Get canvas buffer size. - * @return size of canvas in bytes +/** Get canvas buffer size. + * + * @param canvas Canvas instance + * + * @return size of canvas in bytes */ size_t canvas_get_buffer_size(Canvas* canvas); -/* - * Set drawing region relative to real screen buffer +/** Set drawing region relative to real screen buffer + * + * @param canvas Canvas instance + * @param offset_x x coordinate offset + * @param offset_y y coordinate offset + * @param width width + * @param height height */ void canvas_frame_set( Canvas* canvas, @@ -54,12 +74,17 @@ void canvas_frame_set( uint8_t width, uint8_t height); -/* - * Set canvas orientation +/** Set canvas orientation + * + * @param canvas Canvas instance + * @param orientation CanvasOrientation */ void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation); -/* - * Get canvas orientation +/** Get canvas orientation + * + * @param canvas Canvas instance + * + * @return CanvasOrientation */ CanvasOrientation canvas_get_orientation(const Canvas* canvas); diff --git a/applications/gui/elements.c b/applications/gui/elements.c index 8b1112b3..4a577780 100644 --- a/applications/gui/elements.c +++ b/applications/gui/elements.c @@ -278,7 +278,7 @@ void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, const char* t canvas_draw_str(canvas, x, y, string_get_cstr(str)); start = end + 1; y += font_height; - } while(end); + } while(end && y < 64); string_clear(str); } diff --git a/applications/gui/elements.h b/applications/gui/elements.h index 04ad352b..32156dc2 100644 --- a/applications/gui/elements.h +++ b/applications/gui/elements.h @@ -1,3 +1,11 @@ +/** + * @file elements.h + * GUI: Elements API + * + * Canvas helpers and UI building blocks. + * + */ + #pragma once #include diff --git a/applications/gui/gui.c b/applications/gui/gui.c index b167db70..a7e7f295 100644 --- a/applications/gui/gui.c +++ b/applications/gui/gui.c @@ -335,7 +335,7 @@ void gui_remove_view_port(Gui* gui, ViewPort* view_port) { gui_unlock(gui); } -void gui_send_view_port_front(Gui* gui, ViewPort* view_port) { +void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port) { furi_assert(gui); furi_assert(view_port); @@ -361,7 +361,7 @@ void gui_send_view_port_front(Gui* gui, ViewPort* view_port) { gui_unlock(gui); } -void gui_send_view_port_back(Gui* gui, ViewPort* view_port) { +void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port) { furi_assert(gui); furi_assert(view_port); diff --git a/applications/gui/gui.h b/applications/gui/gui.h index eb557bbc..eb68f520 100644 --- a/applications/gui/gui.h +++ b/applications/gui/gui.h @@ -1,3 +1,8 @@ +/** + * @file gui.h + * GUI: main API + */ + #pragma once #include "view_port.h" @@ -7,60 +12,74 @@ extern "C" { #endif -/* Gui layers */ +/** Gui layers */ typedef enum { - GuiLayerNone, /* Special layer for internal use only */ + GuiLayerNone, /**< Special layer for internal use only */ - GuiLayerStatusBarLeft, /* Status bar left-side layer, auto-layout */ - GuiLayerStatusBarRight, /* Status bar right-side layer, auto-layout */ - GuiLayerMain, /* Main layer, status bar is shown */ - GuiLayerFullscreen, /* Fullscreen layer */ + GuiLayerStatusBarLeft, /**< Status bar left-side layer, auto-layout */ + GuiLayerStatusBarRight, /**< Status bar right-side layer, auto-layout */ + GuiLayerMain, /**< Main layer, status bar is shown */ + GuiLayerFullscreen, /**< Fullscreen layer */ - GuiLayerMAX /* Don't use or move, special value */ + GuiLayerMAX /**< Don't use or move, special value */ } GuiLayer; -/* Gui frame buffer callback */ +/** Gui Canvas Commit Callback */ typedef void (*GuiCanvasCommitCallback)(uint8_t* data, size_t size, void* context); typedef struct Gui Gui; -/* - * Add view_port to view_port tree - * @remarks thread safe +/** Add view_port to view_port tree + * + * @remark thread safe + * + * @param gui Gui instance + * @param view_port ViewPort instance + * @param[in] layer GuiLayer where to place view_port */ void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer); -/* - * Remove view_port from rendering tree - * @remarks thread safe +/** Remove view_port from rendering tree + * + * @remark thread safe + * + * @param gui Gui instance + * @param view_port ViewPort instance */ void gui_remove_view_port(Gui* gui, ViewPort* view_port); -/* Send ViewPort to the front +/** Send ViewPort to the front + * * Places selected ViewPort to the top of the drawing stack - * @param gui - Gui instance - * @param view_port - ViewPort instance + * + * @param gui Gui instance + * @param view_port ViewPort instance */ -void gui_send_view_port_front(Gui* gui, ViewPort* view_port); +void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port); -/* Send ViewPort to the back +/** Send ViewPort to the back + * * Places selected ViewPort to the bottom of the drawing stack - * @param gui - Gui instance - * @param view_port - ViewPort instance + * + * @param gui Gui instance + * @param view_port ViewPort instance */ -void gui_send_view_port_back(Gui* gui, ViewPort* view_port); +void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port); -/* Set gui canvas commit callback - * This callback will be called upon Canvas commit - * Callback dispatched from GUI thread and is time critical - * @param gui - Gui instance - * @param callback - GuiCanvasCommitCallback +/** Set gui canvas commit callback + * + * This callback will be called upon Canvas commit Callback dispatched from GUI + * thread and is time critical + * + * @param gui Gui instance + * @param callback GuiCanvasCommitCallback */ void gui_set_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback); -/* Set gui canvas commit callback context - * @param gui - Gui instance - * @param context - pointer to context +/** Set gui canvas commit callback context + * + * @param gui Gui instance + * @param context pointer to context */ void gui_set_framebuffer_callback_context(Gui* gui, void* context); diff --git a/applications/gui/gui_i.h b/applications/gui/gui_i.h index d67b4599..cfbf604f 100644 --- a/applications/gui/gui_i.h +++ b/applications/gui/gui_i.h @@ -1,3 +1,8 @@ +/** + * @file gui_i.h + * GUI: main API internals + */ + #pragma once #include "gui.h" @@ -31,6 +36,7 @@ ARRAY_DEF(ViewPortArray, ViewPort*, M_PTR_OPLIST); +/** Gui structure */ struct Gui { // Thread and lock osThreadId_t thread; @@ -54,8 +60,9 @@ struct Gui { ViewPort* gui_view_port_find_enabled(ViewPortArray_t array); -/* Update GUI, request redraw - * @param gui, Gui instance +/** Update GUI, request redraw + * + * @param gui Gui instance */ void gui_update(Gui* gui); @@ -67,4 +74,4 @@ void gui_unlock(Gui* gui); void gui_cli_screen_stream_callback(uint8_t* data, size_t size, void* context); -void gui_cli_screen_stream(Cli* cli, string_t args, void* context); \ No newline at end of file +void gui_cli_screen_stream(Cli* cli, string_t args, void* context); diff --git a/applications/gui/icon.h b/applications/gui/icon.h index 058089bb..ebe40266 100644 --- a/applications/gui/icon.h +++ b/applications/gui/icon.h @@ -1,3 +1,8 @@ +/** + * @file icon.h + * GUI: Icon API + */ + #pragma once #include @@ -8,10 +13,28 @@ extern "C" { typedef struct Icon Icon; +/** Get icon width + * + * @param[in] instance pointer to Icon data + * + * @return width in pixels + */ uint8_t icon_get_width(const Icon* instance); +/** Get icon height + * + * @param[in] instance pointer to Icon data + * + * @return height in pixels + */ uint8_t icon_get_height(const Icon* instance); +/** Get Icon XBM bitmap data + * + * @param[in] instance pointer to Icon data + * + * @return pointer to XBM bitmap data + */ const uint8_t* icon_get_data(const Icon* instance); #ifdef __cplusplus diff --git a/applications/gui/icon_animation.c b/applications/gui/icon_animation.c index f992e0e4..22089d63 100644 --- a/applications/gui/icon_animation.c +++ b/applications/gui/icon_animation.c @@ -2,31 +2,32 @@ #include "icon_i.h" #include +#include IconAnimation* icon_animation_alloc(const Icon* icon) { furi_assert(icon); IconAnimation* instance = furi_alloc(sizeof(IconAnimation)); instance->icon = icon; + instance->timer = osTimerNew(icon_animation_timer_callback, osTimerPeriodic, instance, NULL); return instance; } void icon_animation_free(IconAnimation* instance) { furi_assert(instance); + furi_check(osTimerDelete(instance->timer) == osOK); free(instance); } -const uint8_t* icon_animation_get_data(IconAnimation* instance) { +void icon_animation_set_update_callback( + IconAnimation* instance, + IconAnimationCallback callback, + void* context) { furi_assert(instance); - if(instance->tick) { - uint32_t now = osKernelGetTickCount(); - if(now < instance->tick) { - instance->tick = now; - icon_animation_next_frame(instance); - } else if(now - instance->tick > osKernelGetTickFreq() / instance->icon->frame_rate) { - instance->tick = now; - icon_animation_next_frame(instance); - } - } + instance->callback = callback; + instance->callback_context = context; +} + +const uint8_t* icon_animation_get_data(IconAnimation* instance) { return instance->icon->frames[instance->frame]; } @@ -35,6 +36,19 @@ void icon_animation_next_frame(IconAnimation* instance) { instance->frame = (instance->frame + 1) % instance->icon->frame_count; } +void icon_animation_timer_callback(void* context) { + furi_assert(context); + + IconAnimation* instance = context; + + if(!instance->animating) return; + + icon_animation_next_frame(instance); + if(instance->callback) { + instance->callback(instance, instance->callback_context); + } +} + uint8_t icon_animation_get_width(IconAnimation* instance) { furi_assert(instance); return instance->icon->width; @@ -45,33 +59,27 @@ uint8_t icon_animation_get_height(IconAnimation* instance) { return instance->icon->height; } -bool icon_animation_is_animated(IconAnimation* instance) { - furi_assert(instance); - return instance->icon->frame_count > 1; -} - -bool icon_animation_is_animating(IconAnimation* instance) { - furi_assert(instance); - return instance->tick > 0; -} - void icon_animation_start(IconAnimation* instance) { furi_assert(instance); - instance->tick = osKernelGetTickCount(); + if(!instance->animating) { + instance->animating = true; + furi_check( + xTimerChangePeriod( + instance->timer, (osKernelGetTickFreq() / instance->icon->frame_rate), 0) == + pdPASS); + } } void icon_animation_stop(IconAnimation* instance) { furi_assert(instance); - instance->tick = 0; - instance->frame = 0; -} - -uint8_t icon_animation_get_current_frame(IconAnimation* instance) { - furi_assert(instance); - return instance->frame; + if(instance->animating) { + instance->animating = false; + furi_check(xTimerStop(instance->timer, 0) == pdPASS); + instance->frame = 0; + } } bool icon_animation_is_last_frame(IconAnimation* instance) { furi_assert(instance); return instance->icon->frame_count - instance->frame <= 1; -} \ No newline at end of file +} diff --git a/applications/gui/icon_animation.h b/applications/gui/icon_animation.h index 4ef3c78f..dab9d996 100644 --- a/applications/gui/icon_animation.h +++ b/applications/gui/icon_animation.h @@ -1,64 +1,87 @@ +/** + * @file icon_animation.h + * GUI: IconAnimation API + */ + #pragma once #include #include +#include #ifdef __cplusplus extern "C" { #endif -#include - +/** Icon Animation */ typedef struct IconAnimation IconAnimation; -/* - * Allocate icon animation instance with const icon data. +/** Icon Animation Callback. Used for update notification */ +typedef void (*IconAnimationCallback)(IconAnimation* instance, void* context); + +/** Allocate icon animation instance with const icon data. + * * always returns Icon or stops system if not enough memory + * + * @param[in] icon pointer to Icon data + * + * @return IconAnimation instance */ IconAnimation* icon_animation_alloc(const Icon* icon); -/* - * Release icon animation instance +/** Release icon animation instance + * + * @param instance IconAnimation instance */ void icon_animation_free(IconAnimation* instance); -/* - * Get icon animation width +/** Set IconAnimation update callback + * + * Normally you do not need to use this function, use view_tie_icon_animation + * instead. + * + * @param instance IconAnimation instance + * @param[in] callback IconAnimationCallback + * @param context callback context + */ +void icon_animation_set_update_callback( + IconAnimation* instance, + IconAnimationCallback callback, + void* context); + +/** Get icon animation width + * + * @param instance IconAnimation instance + * + * @return width in pixels */ uint8_t icon_animation_get_width(IconAnimation* instance); -/* - * Get icon animation height +/** Get icon animation height + * + * @param instance IconAnimation instance + * + * @return height in pixels */ uint8_t icon_animation_get_height(IconAnimation* instance); -/* - * Check if icon is animated - */ -bool icon_animation_is_animated(IconAnimation* instance); - -/* - * Check if icon animation is active - */ -bool icon_animation_is_animating(IconAnimation* instance); - -/* - * Start icon animation +/** Start icon animation + * + * @param instance IconAnimation instance */ void icon_animation_start(IconAnimation* instance); -/* - * Stop icon animation +/** Stop icon animation + * + * @param instance IconAnimation instance */ void icon_animation_stop(IconAnimation* instance); -/* - * Get current frame - */ -uint8_t icon_animation_get_current_frame(IconAnimation* instance); - -/* - * Returns true if current frame is a last one +/** Returns true if current frame is a last one + * + * @param instance IconAnimation instance + * + * @return true if last frame */ bool icon_animation_is_last_frame(IconAnimation* instance); diff --git a/applications/gui/icon_animation_i.h b/applications/gui/icon_animation_i.h index 0f9960d4..241bcaa3 100644 --- a/applications/gui/icon_animation_i.h +++ b/applications/gui/icon_animation_i.h @@ -1,21 +1,39 @@ +/** + * @file icon_animation_i.h + * GUI: internal IconAnimation API + */ + #pragma once #include "icon_animation.h" -#include +#include struct IconAnimation { const Icon* icon; uint8_t frame; - uint32_t tick; + bool animating; + osTimerId_t timer; + IconAnimationCallback callback; + void* callback_context; }; -/* - * Get pointer to current frame data +/** Get pointer to current frame data + * + * @param instance IconAnimation instance + * + * @return pointer to current frame XBM bitmap data */ const uint8_t* icon_animation_get_data(IconAnimation* instance); -/* - * Advance to next frame +/** Advance to next frame + * + * @param instance IconAnimation instance */ void icon_animation_next_frame(IconAnimation* instance); + +/** IconAnimation timer callback + * + * @param context pointer to IconAnimation + */ +void icon_animation_timer_callback(void* context); diff --git a/applications/gui/icon_i.h b/applications/gui/icon_i.h index 62a7ff39..c01f5cce 100644 --- a/applications/gui/icon_i.h +++ b/applications/gui/icon_i.h @@ -1,3 +1,8 @@ +/** + * @file icon_i.h + * GUI: internal Icon API + */ + #include "icon.h" struct Icon { diff --git a/applications/gui/modules/button_menu.h b/applications/gui/modules/button_menu.h index 35355d6b..a662114b 100644 --- a/applications/gui/modules/button_menu.h +++ b/applications/gui/modules/button_menu.h @@ -1,4 +1,10 @@ +/** + * @file button_menu.h + * GUI: ButtonMenu view module API + */ + #pragma once + #include #include @@ -6,40 +12,48 @@ extern "C" { #endif -/* ButtonMenu anonymous structure */ +/** ButtonMenu anonymous structure */ typedef struct ButtonMenu ButtonMenu; + +/** ButtonMenuItem anonymous structure */ typedef struct ButtonMenuItem ButtonMenuItem; -/* Callback for any button menu actions */ +/** Callback for any button menu actions */ typedef void (*ButtonMenuItemCallback)(void* context, int32_t index, InputType type); -/* Type of button. Difference in drawing buttons. */ +/** Type of button. Difference in drawing buttons. */ typedef enum { ButtonMenuItemTypeCommon, ButtonMenuItemTypeControl, } ButtonMenuItemType; -/** - * @brief Get button menu view - * @param button_menu - ButtonMenu instance - * @return View instance that can be used for embedding +/** Get button menu view + * + * @param button_menu ButtonMenu instance + * + * @return View instance that can be used for embedding */ View* button_menu_get_view(ButtonMenu* button_menu); -/** - * @brief Clean button menu - * @param button_menu - ButtonMenu instance +/** Clean button menu + * + * @param button_menu ButtonMenu instance */ void button_menu_clean(ButtonMenu* button_menu); -/** - * @brief Add item to button menu instance - * @param button_menu - ButtonMenu instance - * @param label - text inside new button - * @param index - value to distinct between buttons inside ButtonMenuItemCallback - * @param type - type of button to create. Differ by button drawing. - * Control buttons have no frames, and have more squared borders. - * @return pointer to just-created item +/** Add item to button menu instance + * + * @param button_menu ButtonMenu instance + * @param label text inside new button + * @param index value to distinct between buttons inside + * ButtonMenuItemCallback + * @param callback The callback + * @param type type of button to create. Differ by button + * drawing. Control buttons have no frames, and + * have more squared borders. + * @param callback_context The callback context + * + * @return pointer to just-created item */ ButtonMenuItem* button_menu_add_item( ButtonMenu* button_menu, @@ -49,29 +63,29 @@ ButtonMenuItem* button_menu_add_item( ButtonMenuItemType type, void* callback_context); -/** - * @brief Allocate and initialize new instance of ButtonMenu model - * @return just-created ButtonMenu model +/** Allocate and initialize new instance of ButtonMenu model + * + * @return just-created ButtonMenu model */ ButtonMenu* button_menu_alloc(void); -/** - * @brief Free ButtonMenu element - * @param button_menu - ButtonMenu instance +/** Free ButtonMenu element + * + * @param button_menu ButtonMenu instance */ void button_menu_free(ButtonMenu* button_menu); -/** - * @brief Set ButtonMenu header on top of canvas - * @param button_menu - ButtonMenu instance - * @param header - header on the top of button menu +/** Set ButtonMenu header on top of canvas + * + * @param button_menu ButtonMenu instance + * @param header header on the top of button menu */ void button_menu_set_header(ButtonMenu* button_menu, const char* header); -/** - * @brief Set selected item - * @param button_menu - ButtonMenu instance - * @param index - index of ButtonMenu to be selected +/** Set selected item + * + * @param button_menu ButtonMenu instance + * @param index index of ButtonMenu to be selected */ void button_menu_set_selected_item(ButtonMenu* button_menu, uint32_t index); diff --git a/applications/gui/modules/button_panel.h b/applications/gui/modules/button_panel.h index 647b3c6e..479aeeaf 100644 --- a/applications/gui/modules/button_panel.h +++ b/applications/gui/modules/button_panel.h @@ -1,4 +1,10 @@ +/** + * @file button_panel.h + * GUI: ButtonPanel view module API + */ + #pragma once + #include #ifdef __cplusplus @@ -10,37 +16,39 @@ typedef struct ButtonPanel ButtonPanel; /** Callback type to call for handling selecting button_panel items */ typedef void (*ButtonItemCallback)(void* context, uint32_t index); + /** Callback type for additional drawings above main button_panel screen */ typedef void (*ButtonPanelDrawCallback)(Canvas* canvas, void* _model); + /** Callback type to intercept input events of button_panel */ typedef bool (*ButtonPanelInputCallback)(InputEvent* event, void* context); /** Allocate new button_panel module. * - * @return just-created module + * @return ButtonPanel instance */ ButtonPanel* button_panel_alloc(void); /** Free button_panel module. * - * @param button_panel - module to free + * @param button_panel ButtonPanel instance */ void button_panel_free(ButtonPanel* button_panel); /** Free items from button_panel module. Preallocated matrix stays unchanged. * - * @param button_panel - module to clean + * @param button_panel ButtonPanel instance */ void button_panel_clean(ButtonPanel* button_panel); /** Reserve space for adding items. * - * One does not simply use button_panel_add_item() without this function. - * It should be allocated space for it first. + * One does not simply use button_panel_add_item() without this function. It + * should be allocated space for it first. * - * @param button_panel - module to modify - * @param reserve_x - number of columns in button_panel - * @param reserve_y - number of rows in button_panel + * @param button_panel ButtonPanel instance + * @param reserve_x number of columns in button_panel + * @param reserve_y number of rows in button_panel */ void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t reserve_y); @@ -48,20 +56,20 @@ void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t re * * Have to set element in bounds of allocated size by X and by Y. * - * @param button_panel - module - * @param index - value to pass to callback - * @param matrix_place_x - coordinates by x-axis on virtual grid, it - * is only used for naviagation - * @param matrix_place_y - coordinates by y-axis on virtual grid, it - * is only used for naviagation - * @param x - x-coordinate to draw icon on - * @param y - y-coordinate to draw icon on - * @param icon_name - name of the icon to draw - * @param icon_name_selected - name of the icon to draw when current - * element is selected - * @param callback - function to call when specific element is selected - * (pressed Ok on selected item) - * @param callback_context - context to pass to callback + * @param button_panel ButtonPanel instance + * @param index value to pass to callback + * @param matrix_place_x coordinates by x-axis on virtual grid, it + * is only used for naviagation + * @param matrix_place_y coordinates by y-axis on virtual grid, it + * is only used for naviagation + * @param x x-coordinate to draw icon on + * @param y y-coordinate to draw icon on + * @param icon_name name of the icon to draw + * @param icon_name_selected name of the icon to draw when current + * element is selected + * @param callback function to call when specific element is + * selected (pressed Ok on selected item) + * @param callback_context context to pass to callback */ void button_panel_add_item( ButtonPanel* button_panel, @@ -77,17 +85,19 @@ void button_panel_add_item( /** Get button_panel view. * - * @param button_panel - module to get view from - * @return acquired view + * @param button_panel ButtonPanel instance + * + * @return acquired view */ View* button_panel_get_view(ButtonPanel* button_panel); /** Add label to button_panel module. * - * @param x - x-coordinate to place label - * @param y - y-coordinate to place label - * @param font - font to write label with - * @param label_str - string label to write + * @param button_panel ButtonPanel instance + * @param x x-coordinate to place label + * @param y y-coordinate to place label + * @param font font to write label with + * @param label_str string label to write */ void button_panel_add_label( ButtonPanel* button_panel, @@ -101,9 +111,9 @@ void button_panel_add_label( * * Used to add popup drawings after main draw callback is done. * - * @param button_panel - module to modify - * @param callback - callback function to set for draw event - * @param context - context to pass to callback + * @param button_panel ButtonPanel instance + * @param callback callback function to set for draw event + * @param context context to pass to callback */ void button_panel_set_popup_draw_callback( ButtonPanel* button_panel, @@ -112,12 +122,12 @@ void button_panel_set_popup_draw_callback( /** Set popup input callback for button_panel module. * - * Used to add popup input callback. It will intercept all input - * events for current view. + * Used to add popup input callback. It will intercept all input events for + * current view. * - * @param button_panel - module to modify - * @param callback - function to overwrite main input callbacks - * @param context - context to pass to callback + * @param button_panel ButtonPanel instance + * @param callback function to overwrite main input callbacks + * @param context context to pass to callback */ void button_panel_set_popup_input_callback( ButtonPanel* button_panel, diff --git a/applications/gui/modules/byte_input.h b/applications/gui/modules/byte_input.h index 347474df..b2f94f3c 100644 --- a/applications/gui/modules/byte_input.h +++ b/applications/gui/modules/byte_input.h @@ -1,59 +1,53 @@ +/** + * @file byte_input.h + * GUI: ByteInput keyboard view module API + */ + #pragma once + #include #ifdef __cplusplus extern "C" { #endif -/** - * @brief Byte input anonymous structure - * - */ +/** Byte input anonymous structure */ typedef struct ByteInput ByteInput; -/** - * @brief callback that is executed on save button press - * - */ +/** callback that is executed on save button press */ typedef void (*ByteInputCallback)(void* context); -/** - * @brief callback that is executed when byte buffer is changed - * - */ +/** callback that is executed when byte buffer is changed */ typedef void (*ByteChangedCallback)(void* context); -/** - * @brief Allocate and initialize byte input. This byte input is used to enter bytes. - * - * @return ByteInput instance pointer +/** Allocate and initialize byte input. This byte input is used to enter bytes. + * + * @return ByteInput instance pointer */ ByteInput* byte_input_alloc(); -/** - * @brief Deinitialize and free byte input - * - * @param byte_input Byte input instance +/** Deinitialize and free byte input + * + * @param byte_input Byte input instance */ void byte_input_free(ByteInput* byte_input); -/** - * @brief Get byte input view - * - * @param byte_input byte input instance - * @return View instance that can be used for embedding +/** Get byte input view + * + * @param byte_input byte input instance + * + * @return View instance that can be used for embedding */ View* byte_input_get_view(ByteInput* byte_input); -/** - * @brief Set byte input result callback - * - * @param byte_input byte input instance - * @param input_callback input callback fn - * @param changed_callback changed callback fn - * @param callback_context callback context - * @param bytes buffer to use - * @param bytes_count buffer length +/** Set byte input result callback + * + * @param byte_input byte input instance + * @param input_callback input callback fn + * @param changed_callback changed callback fn + * @param callback_context callback context + * @param bytes buffer to use + * @param bytes_count buffer length */ void byte_input_set_result_callback( ByteInput* byte_input, @@ -63,11 +57,10 @@ void byte_input_set_result_callback( uint8_t* bytes, uint8_t bytes_count); -/** - * @brief Set byte input header text - * - * @param byte_input byte input instance - * @param text text to be shown +/** Set byte input header text + * + * @param byte_input byte input instance + * @param text text to be shown */ void byte_input_set_header_text(ByteInput* byte_input, const char* text); diff --git a/applications/gui/modules/dialog.h b/applications/gui/modules/dialog.h index 5fae73fe..e9160a35 100644 --- a/applications/gui/modules/dialog.h +++ b/applications/gui/modules/dialog.h @@ -1,77 +1,95 @@ +/** + * @file dialog.h + * GUI: Dialog view module API + */ + #pragma once + #include #ifdef __cplusplus extern "C" { #endif -/* Dialog anonymous structure */ +/** Dialog anonymous structure */ typedef struct Dialog Dialog; -/* Dialog result */ +/** Dialog result */ typedef enum { DialogResultLeft, DialogResultRight, DialogResultBack, } DialogResult; -/* Dialog result callback type - * @warning comes from GUI thread +/** Dialog result callback type + * @warning comes from GUI thread */ typedef void (*DialogResultCallback)(DialogResult result, void* context); -/* Allocate and initialize dialog +/** Allocate and initialize dialog + * * This dialog used to ask simple questions like Yes/ + * + * @return Dialog instance */ Dialog* dialog_alloc(); -/* Deinitialize and free dialog - * @param dialog - Dialog instance +/** Deinitialize and free dialog + * + * @param dialog Dialog instance */ void dialog_free(Dialog* dialog); -/* Get dialog view - * @param dialog - Dialog instance - * @return View instance that can be used for embedding +/** Get dialog view + * + * @param dialog Dialog instance + * + * @return View instance that can be used for embedding */ View* dialog_get_view(Dialog* dialog); -/* Set dialog result callback - * @param dialog - Dialog instance - * @param callback - result callback function +/** Set dialog result callback + * + * @param dialog Dialog instance + * @param callback result callback function */ void dialog_set_result_callback(Dialog* dialog, DialogResultCallback callback); -/* Set dialog context - * @param dialog - Dialog instance - * @param context - context pointer, will be passed to result callback +/** Set dialog context + * + * @param dialog Dialog instance + * @param context context pointer, will be passed to result callback */ void dialog_set_context(Dialog* dialog, void* context); -/* Set dialog header text - * @param dialog - Dialog instance - * @param text - text to be shown +/** Set dialog header text + * + * @param dialog Dialog instance + * @param text text to be shown */ void dialog_set_header_text(Dialog* dialog, const char* text); -/* Set dialog text - * @param dialog - Dialog instance - * @param text - text to be shown +/** Set dialog text + * + * @param dialog Dialog instance + * @param text text to be shown */ void dialog_set_text(Dialog* dialog, const char* text); -/* Set left button text - * @param dialog - Dialog instance - * @param text - text to be shown +/** Set left button text + * + * @param dialog Dialog instance + * @param text text to be shown */ void dialog_set_left_button_text(Dialog* dialog, const char* text); -/* Set right button text - * @param dialog - Dialog instance - * @param text - text to be shown +/** Set right button text + * + * @param dialog Dialog instance + * @param text text to be shown */ void dialog_set_right_button_text(Dialog* dialog, const char* text); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/applications/gui/modules/dialog_ex.h b/applications/gui/modules/dialog_ex.h index 7833128a..1420fe5f 100644 --- a/applications/gui/modules/dialog_ex.h +++ b/applications/gui/modules/dialog_ex.h @@ -1,4 +1,10 @@ +/** + * @file dialog_ex.h + * GUI: DialogEx view module API + */ + #pragma once + #include #ifdef __cplusplus @@ -21,40 +27,51 @@ typedef enum { typedef void (*DialogExResultCallback)(DialogExResult result, void* context); /** Allocate and initialize dialog + * * This dialog used to ask simple questions - * @return DialogEx instance + * + * @return DialogEx instance */ DialogEx* dialog_ex_alloc(); /** Deinitialize and free dialog - * @param dialog - DialogEx instance + * + * @param dialog_ex DialogEx instance */ void dialog_ex_free(DialogEx* dialog_ex); /** Get dialog view - * @param dialog - DialogEx instance - * @return View instance that can be used for embedding + * + * @param dialog_ex DialogEx instance + * + * @return View instance that can be used for embedding */ View* dialog_ex_get_view(DialogEx* dialog_ex); /** Set dialog result callback - * @param dialog_ex - DialogEx instance - * @param callback - result callback function + * + * @param dialog_ex DialogEx instance + * @param callback result callback function */ void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback); /** Set dialog context - * @param dialog_ex - DialogEx instance - * @param context - context pointer, will be passed to result callback + * + * @param dialog_ex DialogEx instance + * @param context context pointer, will be passed to result callback */ void dialog_ex_set_context(DialogEx* dialog_ex, void* context); /** Set dialog header text + * * If text is null, dialog header will not be rendered - * @param dialog - DialogEx instance - * @param text - text to be shown, can be multiline - * @param x, y - text position - * @param horizontal, vertical - text aligment + * + * @param dialog_ex DialogEx instance + * @param text text to be shown, can be multiline + * @param x x position + * @param y y position + * @param horizontal horizontal text aligment + * @param vertical vertical text aligment */ void dialog_ex_set_header( DialogEx* dialog_ex, @@ -65,11 +82,15 @@ void dialog_ex_set_header( Align vertical); /** Set dialog text + * * If text is null, dialog text will not be rendered - * @param dialog - DialogEx instance - * @param text - text to be shown, can be multiline - * @param x, y - text position - * @param horizontal, vertical - text aligment + * + * @param dialog_ex DialogEx instance + * @param text text to be shown, can be multiline + * @param x x position + * @param y y position + * @param horizontal horizontal text aligment + * @param vertical vertical text aligment */ void dialog_ex_set_text( DialogEx* dialog_ex, @@ -80,36 +101,47 @@ void dialog_ex_set_text( Align vertical); /** Set dialog icon + * * If x or y is negative, dialog icon will not be rendered - * @param dialog - DialogEx instance - * @param x, y - icon position - * @param name - icon to be shown + * + * @param dialog_ex DialogEx instance + * @param x x position + * @param y y position + * @param icon The icon + * @param name icon to be shown */ void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon); /** Set left button text + * * If text is null, left button will not be rendered and processed - * @param dialog - DialogEx instance - * @param text - text to be shown + * + * @param dialog_ex DialogEx instance + * @param text text to be shown */ void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text); /** Set center button text + * * If text is null, center button will not be rendered and processed - * @param dialog - DialogEx instance - * @param text - text to be shown + * + * @param dialog_ex DialogEx instance + * @param text text to be shown */ void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text); /** Set right button text + * * If text is null, right button will not be rendered and processed - * @param dialog - DialogEx instance - * @param text - text to be shown + * + * @param dialog_ex DialogEx instance + * @param text text to be shown */ void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text); /** Clean dialog - * @param dialog_ex DialogEx instance + * + * @param dialog_ex DialogEx instance */ void dialog_ex_clean(DialogEx* dialog_ex); diff --git a/applications/gui/modules/empty_screen.h b/applications/gui/modules/empty_screen.h index a0b56219..43d2fe04 100644 --- a/applications/gui/modules/empty_screen.h +++ b/applications/gui/modules/empty_screen.h @@ -1,26 +1,38 @@ +/** + * @file empty_screen.h + * GUI: EmptyScreen view module API + */ + #pragma once + #include #ifdef __cplusplus extern "C" { #endif -/* Empty screen anonymous structure */ +/** Empty screen anonymous structure */ typedef struct EmptyScreen EmptyScreen; -/* Allocate and initialize empty screen +/** Allocate and initialize empty screen + * * This empty screen used to ask simple questions like Yes/ + * + * @return EmptyScreen instance */ EmptyScreen* empty_screen_alloc(); -/* Deinitialize and free empty screen - * @param empty_screen - Empty screen instance +/** Deinitialize and free empty screen + * + * @param empty_screen Empty screen instance */ void empty_screen_free(EmptyScreen* empty_screen); -/* Get empty screen view - * @param empty_screen - Empty screen instance - * @return View instance that can be used for embedding +/** Get empty screen view + * + * @param empty_screen Empty screen instance + * + * @return View instance that can be used for embedding */ View* empty_screen_get_view(EmptyScreen* empty_screen); diff --git a/applications/gui/modules/file_select.h b/applications/gui/modules/file_select.h index 5f666d5a..7318c87c 100644 --- a/applications/gui/modules/file_select.h +++ b/applications/gui/modules/file_select.h @@ -1,4 +1,10 @@ +/** + * @file file_select.h + * GUI: FileSelect view module API + */ + #pragma once + #include #ifdef __cplusplus diff --git a/applications/gui/modules/menu.c b/applications/gui/modules/menu.c old mode 100755 new mode 100644 index 3fe709c7..6450b1d3 --- a/applications/gui/modules/menu.c +++ b/applications/gui/modules/menu.c @@ -20,7 +20,7 @@ ARRAY_DEF(MenuItemArray, MenuItem, M_POD_OPLIST); typedef struct { MenuItemArray_t items; - uint8_t position; + size_t position; } MenuModel; static void menu_process_up(Menu* menu); @@ -32,7 +32,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) { canvas_clear(canvas); - uint8_t position = model->position; + size_t position = model->position; size_t items_count = MenuItemArray_size(model->items); if(items_count) { MenuItem* item; @@ -43,7 +43,6 @@ static void menu_draw_callback(Canvas* canvas, void* _model) { item = MenuItemArray_get(model->items, shift_position); if(item->icon) { canvas_draw_icon_animation(canvas, 4, 3, item->icon); - icon_animation_stop(item->icon); } canvas_draw_str(canvas, 22, 14, item->label); // Second line main @@ -52,7 +51,6 @@ static void menu_draw_callback(Canvas* canvas, void* _model) { item = MenuItemArray_get(model->items, shift_position); if(item->icon) { canvas_draw_icon_animation(canvas, 4, 25, item->icon); - icon_animation_start(item->icon); } canvas_draw_str(canvas, 22, 36, item->label); // Third line @@ -61,7 +59,6 @@ static void menu_draw_callback(Canvas* canvas, void* _model) { item = MenuItemArray_get(model->items, shift_position); if(item->icon) { canvas_draw_icon_animation(canvas, 4, 47, item->icon); - icon_animation_stop(item->icon); } canvas_draw_str(canvas, 22, 58, item->label); // Frame and scrollbar @@ -93,6 +90,30 @@ static bool menu_input_callback(InputEvent* event, void* context) { return consumed; } +static void menu_enter(void* context) { + Menu* menu = context; + with_view_model( + menu->view, (MenuModel * model) { + MenuItem* item = MenuItemArray_get(model->items, model->position); + if(item && item->icon) { + icon_animation_start(item->icon); + } + return false; + }); +} + +static void menu_exit(void* context) { + Menu* menu = context; + with_view_model( + menu->view, (MenuModel * model) { + MenuItem* item = MenuItemArray_get(model->items, model->position); + if(item && item->icon) { + icon_animation_stop(item->icon); + } + return false; + }); +} + Menu* menu_alloc() { Menu* menu = furi_alloc(sizeof(Menu)); menu->view = view_alloc(menu->view); @@ -100,6 +121,8 @@ Menu* menu_alloc() { view_allocate_model(menu->view, ViewModelTypeLocking, sizeof(MenuModel)); view_set_draw_callback(menu->view, menu_draw_callback); view_set_input_callback(menu->view, menu_input_callback); + view_set_enter_callback(menu->view, menu_enter); + view_set_exit_callback(menu->view, menu_exit); with_view_model( menu->view, (MenuModel * model) { @@ -143,6 +166,7 @@ void menu_add_item( item = MenuItemArray_push_new(model->items); item->label = label; item->icon = icon; + view_tie_icon_animation(menu->view, item->icon); item->index = index; item->callback = callback; item->callback_context = context; @@ -175,11 +199,21 @@ void menu_set_selected_item(Menu* menu, uint32_t index) { static void menu_process_up(Menu* menu) { with_view_model( menu->view, (MenuModel * model) { + MenuItem* item = MenuItemArray_get(model->items, model->position); + if(item && item->icon) { + icon_animation_stop(item->icon); + } + if(model->position > 0) { model->position--; } else { model->position = MenuItemArray_size(model->items) - 1; } + + item = MenuItemArray_get(model->items, model->position); + if(item && item->icon) { + icon_animation_start(item->icon); + } return true; }); } @@ -187,11 +221,21 @@ static void menu_process_up(Menu* menu) { static void menu_process_down(Menu* menu) { with_view_model( menu->view, (MenuModel * model) { + MenuItem* item = MenuItemArray_get(model->items, model->position); + if(item && item->icon) { + icon_animation_stop(item->icon); + } + if(model->position < MenuItemArray_size(model->items) - 1) { model->position++; } else { model->position = 0; } + + item = MenuItemArray_get(model->items, model->position); + if(item && item->icon) { + icon_animation_start(item->icon); + } return true; }); } diff --git a/applications/gui/modules/menu.h b/applications/gui/modules/menu.h index 26c83c0c..e7d52c84 100755 --- a/applications/gui/modules/menu.h +++ b/applications/gui/modules/menu.h @@ -1,4 +1,10 @@ +/** + * @file menu.h + * GUI: Menu view module API + */ + #pragma once + #include #ifdef __cplusplus @@ -7,31 +13,38 @@ extern "C" { /** Menu anonymous structure */ typedef struct Menu Menu; + +/** Menu Item Callback */ typedef void (*MenuItemCallback)(void* context, uint32_t index); /** Menu allocation and initialization - * @return Menu instance + * + * @return Menu instance */ Menu* menu_alloc(); /** Free menu - * @param menu - Menu instance + * + * @param menu Menu instance */ void menu_free(Menu* menu); /** Get Menu view - * @param menu - Menu instance - * @return View instance + * + * @param menu Menu instance + * + * @return View instance */ View* menu_get_view(Menu* menu); /** Add item to menu - * @param menu - Menu instance - * @param label - menu item string label - * @param icon - IconAnimation instance - * @param index - menu item index - * @param callback - MenuItemCallback instance - * @param context - pointer to context + * + * @param menu Menu instance + * @param label menu item string label + * @param icon IconAnimation instance + * @param index menu item index + * @param callback MenuItemCallback instance + * @param context pointer to context */ void menu_add_item( Menu* menu, @@ -42,14 +55,16 @@ void menu_add_item( void* context); /** Clean menu - * Note: this function does not free menu instance - * @param menu - Menu instance + * @note this function does not free menu instance + * + * @param menu Menu instance */ void menu_clean(Menu* menu); /** Set current menu item - * @param submenu - * @param index + * + * @param menu Menu instance + * @param index The index */ void menu_set_selected_item(Menu* menu, uint32_t index); diff --git a/applications/gui/modules/popup.h b/applications/gui/modules/popup.h index d65ce4c8..2b87f0ad 100644 --- a/applications/gui/modules/popup.h +++ b/applications/gui/modules/popup.h @@ -1,52 +1,70 @@ +/** + * @file popup.h + * GUI: Popup view module API + */ + #pragma once + #include #ifdef __cplusplus extern "C" { #endif -/* Popup anonymous structure */ +/** Popup anonymous structure */ typedef struct Popup Popup; -/* Popup result callback type - * @warning comes from GUI thread +/** Popup result callback type + * @warning comes from GUI thread */ typedef void (*PopupCallback)(void* context); -/* Allocate and initialize popup +/** Allocate and initialize popup + * * This popup used to ask simple questions like Yes/ + * + * @return Popup instance */ Popup* popup_alloc(); -/* Deinitialize and free popup - * @param popup - Popup instance +/** Deinitialize and free popup + * + * @param popup Popup instance */ void popup_free(Popup* popup); -/* Get popup view - * @param popup - Popup instance - * @return View instance that can be used for embedding +/** Get popup view + * + * @param popup Popup instance + * + * @return View instance that can be used for embedding */ View* popup_get_view(Popup* popup); -/* Set popup header text - * @param popup - Popup instance - * @param text - text to be shown +/** Set popup header text + * + * @param popup Popup instance + * @param callback PopupCallback */ void popup_set_callback(Popup* popup, PopupCallback callback); -/* Set popup context - * @param popup - Popup instance - * @param context - context pointer, will be passed to result callback +/** Set popup context + * + * @param popup Popup instance + * @param context context pointer, will be passed to result callback */ void popup_set_context(Popup* popup, void* context); -/* Set popup header text +/** Set popup header text + * * If text is null, popup header will not be rendered - * @param popup - Popup instance - * @param text - text to be shown, can be multiline - * @param x, y - text position - * @param horizontal, vertical - text aligment + * + * @param popup Popup instance + * @param text text to be shown, can be multiline + * @param x x position + * @param y y position + * @param horizontal horizontal alignment + * @param vertical vertical aligment */ void popup_set_header( Popup* popup, @@ -56,12 +74,16 @@ void popup_set_header( Align horizontal, Align vertical); -/* Set popup text +/** Set popup text + * * If text is null, popup text will not be rendered - * @param popup - Popup instance - * @param text - text to be shown, can be multiline - * @param x, y - text position - * @param horizontal, vertical - text aligment + * + * @param popup Popup instance + * @param text text to be shown, can be multiline + * @param x x position + * @param y y position + * @param horizontal horizontal alignment + * @param vertical vertical aligment */ void popup_set_text( Popup* popup, @@ -71,30 +93,36 @@ void popup_set_text( Align horizontal, Align vertical); -/* Set popup icon +/** Set popup icon + * * If icon position is negative, popup icon will not be rendered - * @param popup - Popup instance - * @param x, y - icon position - * @param name - icon to be shown + * + * @param popup Popup instance + * @param x x position + * @param y y position + * @param icon pointer to Icon data */ void popup_set_icon(Popup* popup, uint8_t x, uint8_t y, const Icon* icon); -/* Set popup timeout - * @param popup - Popup instance - * @param timeout_in_ms - popup timeout value in milliseconds +/** Set popup timeout + * + * @param popup Popup instance + * @param timeout_in_ms popup timeout value in milliseconds */ void popup_set_timeout(Popup* popup, uint32_t timeout_in_ms); -/* Enable popup timeout - * @param popup - Popup instance +/** Enable popup timeout + * + * @param popup Popup instance */ void popup_enable_timeout(Popup* popup); -/* Disable popup timeout - * @param popup - Popup instance +/** Disable popup timeout + * + * @param popup Popup instance */ void popup_disable_timeout(Popup* popup); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/applications/gui/modules/submenu.h b/applications/gui/modules/submenu.h index 50a9211e..fac29e15 100644 --- a/applications/gui/modules/submenu.h +++ b/applications/gui/modules/submenu.h @@ -1,40 +1,50 @@ +/** + * @file submenu.h + * GUI: SubMenu view module API + */ + #pragma once + #include #ifdef __cplusplus extern "C" { #endif -/* Submenu anonymous structure */ +/** Submenu anonymous structure */ typedef struct Submenu Submenu; typedef void (*SubmenuItemCallback)(void* context, uint32_t index); -/** - * @brief Allocate and initialize submenu +/** Allocate and initialize submenu + * * This submenu is used to select one option + * + * @return Submenu instance */ Submenu* submenu_alloc(); -/** - * @brief Deinitialize and free submenu - * @param submenu - Submenu instance +/** Deinitialize and free submenu + * + * @param submenu Submenu instance */ void submenu_free(Submenu* submenu); -/** - * @brief Get submenu view - * @param submenu - Submenu instance - * @return View instance that can be used for embedding +/** Get submenu view + * + * @param submenu Submenu instance + * + * @return View instance that can be used for embedding */ View* submenu_get_view(Submenu* submenu); -/** - * @brief Add item to submenu - * @param submenu - Submenu instance - * @param label - menu item label - * @param index - menu item index, used for callback, may be the same with other items - * @param callback - menu item callback - * @param callback_context - menu item callback context +/** Add item to submenu + * + * @param submenu Submenu instance + * @param label menu item label + * @param index menu item index, used for callback, may be + * the same with other items + * @param callback menu item callback + * @param callback_context menu item callback context */ void submenu_add_item( Submenu* submenu, @@ -43,23 +53,23 @@ void submenu_add_item( SubmenuItemCallback callback, void* callback_context); -/** - * @brief Remove all items from submenu - * @param submenu - Submenu instance +/** Remove all items from submenu + * + * @param submenu Submenu instance */ void submenu_clean(Submenu* submenu); -/** - * @brief Set submenu item selector - * @param submenu - * @param index +/** Set submenu item selector + * + * @param submenu Submenu instance + * @param index The index */ void submenu_set_selected_item(Submenu* submenu, uint32_t index); -/** - * @brief Set optional header for submenu - * @param submenu - submenu entity - * @param header - header to set +/** Set optional header for submenu + * + * @param submenu Submenu instance + * @param header header to set */ void submenu_set_header(Submenu* submenu, const char* header); diff --git a/applications/gui/modules/text_box.h b/applications/gui/modules/text_box.h index e2bfc34f..9aaa0485 100644 --- a/applications/gui/modules/text_box.h +++ b/applications/gui/modules/text_box.h @@ -1,11 +1,17 @@ +/** + * @file text_box.h + * GUI: TextBox view module API + */ + #pragma once + #include #ifdef __cplusplus extern "C" { #endif -/* TextBox anonymous structure */ +/** TextBox anonymous structure */ typedef struct TextBox TextBox; typedef void (*TextBoxExitCallback)(void* context); @@ -15,46 +21,56 @@ typedef enum { } TextBoxFont; /** Allocate and initialize text_box + * + * @return TextBox instance */ TextBox* text_box_alloc(); /** Deinitialize and free text_box - * @param text_box text_box instance + * + * @param text_box text_box instance */ void text_box_free(TextBox* text_box); /** Get text_box view - * @param text_box TextBox instance - * @return View instance that can be used for embedding + * + * @param text_box TextBox instance + * + * @return View instance that can be used for embedding */ View* text_box_get_view(TextBox* text_box); /** Clean text_box - * @param text_box TextBox instance + * + * @param text_box TextBox instance */ void text_box_clean(TextBox* text_box); /** Set text for text_box - * @param text_box TextBox instance - * @param text text to set + * + * @param text_box TextBox instance + * @param text text to set */ void text_box_set_text(TextBox* text_box, const char* text); /** Set TextBox font - * @param text_box TextBox instance - * @param font TextBoxFont instance + * + * @param text_box TextBox instance + * @param font TextBoxFont instance */ void text_box_set_font(TextBox* text_box, TextBoxFont font); /** Set text_box context - * @param text_box TextBox instance - * @param context context pointer + * + * @param text_box TextBox instance + * @param context context pointer */ void text_box_set_context(TextBox* text_box, void* context); /** Set exit callback - * @param text_box TextBox instance - * @param callback TextBoxExitCallback callback pointer + * + * @param text_box TextBox instance + * @param callback TextBoxExitCallback callback pointer */ void text_box_set_exit_callback(TextBox* text_box, TextBoxExitCallback callback); diff --git a/applications/gui/modules/text_input.h b/applications/gui/modules/text_input.h index 4ac7cd5a..d7b32def 100644 --- a/applications/gui/modules/text_input.h +++ b/applications/gui/modules/text_input.h @@ -1,44 +1,59 @@ +/** + * @file text_input.h + * GUI: TextInput keybord view module API + */ + #pragma once + #include #ifdef __cplusplus extern "C" { #endif -/* Text input anonymous structure */ +/** Text input anonymous structure */ typedef struct TextInput TextInput; typedef void (*TextInputCallback)(void* context); -/** Allocate and initialize text input +/** Allocate and initialize text input + * * This text input is used to enter string - * @return TextInput instance + * + * @return TextInput instance */ TextInput* text_input_alloc(); /** Deinitialize and free text input - * @param text_input - TextInput instance + * + * @param text_input TextInput instance */ void text_input_free(TextInput* text_input); -/** Clean text input view - * Note: this function does not free memory - * @param text_input - Text input instance +/** Clean text input view Note: this function does not free memory + * + * @param text_input Text input instance */ void text_input_clean(TextInput* text_input); /** Get text input view - * @param text_input - TextInput instance - * @return View instance that can be used for embedding + * + * @param text_input TextInput instance + * + * @return View instance that can be used for embedding */ View* text_input_get_view(TextInput* text_input); /** Set text input result callback - * @param text_input - TextInput instance - * @param callback - callback fn - * @param callback_context - callback context - * @param text_buffer - pointer to YOUR text buffer, that we going to modify - * @param text_buffer_size - YOUR text buffer size in bytes. Max string length will be text_buffer_size - 1. - * @param clear_default_text - clear text from text_buffer on first OK event + * + * @param text_input TextInput instance + * @param callback callback fn + * @param callback_context callback context + * @param text_buffer pointer to YOUR text buffer, that we going + * to modify + * @param text_buffer_size YOUR text buffer size in bytes. Max string + * length will be text_buffer_size-1. + * @param clear_default_text clear text from text_buffer on first OK + * event */ void text_input_set_result_callback( TextInput* text_input, @@ -49,8 +64,9 @@ void text_input_set_result_callback( bool clear_default_text); /** Set text input header text - * @param text_input - TextInput instance - * @param text - text to be shown + * + * @param text_input TextInput instance + * @param text text to be shown */ void text_input_set_header_text(TextInput* text_input, const char* text); diff --git a/applications/gui/modules/variable-item-list.c b/applications/gui/modules/variable-item-list.c old mode 100644 new mode 100755 index 1879353f..fccfd84a --- a/applications/gui/modules/variable-item-list.c +++ b/applications/gui/modules/variable-item-list.c @@ -18,6 +18,8 @@ ARRAY_DEF(VariableItemArray, VariableItem, M_POD_OPLIST); struct VariableItemList { View* view; + VariableItemListEnterCallback callback; + void* context; }; typedef struct { @@ -30,6 +32,7 @@ static void variable_item_list_process_up(VariableItemList* variable_item_list); static void variable_item_list_process_down(VariableItemList* variable_item_list); static void variable_item_list_process_left(VariableItemList* variable_item_list); static void variable_item_list_process_right(VariableItemList* variable_item_list); +static void variable_item_list_process_ok(VariableItemList* variable_item_list); static void variable_item_list_draw_callback(Canvas* canvas, void* _model) { VariableItemListModel* model = _model; @@ -104,6 +107,9 @@ static bool variable_item_list_input_callback(InputEvent* event, void* context) consumed = true; variable_item_list_process_right(variable_item_list); break; + case InputKeyOk: + variable_item_list_process_ok(variable_item_list); + break; default: break; } @@ -198,6 +204,16 @@ void variable_item_list_process_right(VariableItemList* variable_item_list) { }); } +void variable_item_list_process_ok(VariableItemList* variable_item_list) { + with_view_model( + variable_item_list->view, (VariableItemListModel * model) { + if(variable_item_list->callback) { + variable_item_list->callback(variable_item_list->context, model->position); + } + return false; + }); +} + VariableItemList* variable_item_list_alloc() { VariableItemList* variable_item_list = furi_alloc(sizeof(VariableItemList)); variable_item_list->view = view_alloc(); @@ -280,6 +296,19 @@ VariableItem* variable_item_list_add( return item; } +void variable_item_list_set_enter_callback( + VariableItemList* variable_item_list, + VariableItemListEnterCallback callback, + void* context) { + furi_assert(callback); + with_view_model( + variable_item_list->view, (VariableItemListModel * model) { + variable_item_list->callback = callback; + variable_item_list->context = context; + return false; + }); +} + void variable_item_set_current_value_index(VariableItem* item, uint8_t current_value_index) { item->current_value_index = current_value_index; } diff --git a/applications/gui/modules/variable-item-list.h b/applications/gui/modules/variable-item-list.h old mode 100644 new mode 100755 index 8844b419..e1e3cbf7 --- a/applications/gui/modules/variable-item-list.h +++ b/applications/gui/modules/variable-item-list.h @@ -1,4 +1,10 @@ +/** + * @file variable-item-list.h + * GUI: VariableItemList view module API + */ + #pragma once + #include #ifdef __cplusplus @@ -8,28 +14,43 @@ extern "C" { typedef struct VariableItemList VariableItemList; typedef struct VariableItem VariableItem; typedef void (*VariableItemChangeCallback)(VariableItem* item); +typedef void (*VariableItemListEnterCallback)(void* context, uint32_t index); /** Allocate and initialize VariableItemList - * @return VariableItemList* + * + * @return VariableItemList* */ VariableItemList* variable_item_list_alloc(); /** Deinitialize and free VariableItemList - * @param variable_item_list VariableItemList instance + * + * @param variable_item_list VariableItemList instance */ void variable_item_list_free(VariableItemList* variable_item_list); +/** Clear all elements from list + * + * @param variable_item_list VariableItemList instance + */ void variable_item_list_clean(VariableItemList* variable_item_list); +/** Get VariableItemList View instance + * + * @param variable_item_list VariableItemList instance + * + * @return View instance + */ View* variable_item_list_get_view(VariableItemList* variable_item_list); /** Add item to VariableItemList - * @param variable_item_list VariableItemList instance - * @param label item name - * @param values_count item values count - * @param change_callback called on value change in gui - * @param context item context - * @return VariableItem* item instance + * + * @param variable_item_list VariableItemList instance + * @param label item name + * @param values_count item values count + * @param change_callback called on value change in gui + * @param context item context + * + * @return VariableItem* item instance */ VariableItem* variable_item_list_add( VariableItemList* variable_item_list, @@ -38,30 +59,47 @@ VariableItem* variable_item_list_add( VariableItemChangeCallback change_callback, void* context); +/** Set enter callback + * + * @param variable_item_list VariableItemList instance + * @param callback VariableItemListEnterCallback instance + * @param context pointer to context + */ +void variable_item_list_set_enter_callback( + VariableItemList* variable_item_list, + VariableItemListEnterCallback callback, + void* context); + /** Set item current selected index - * @param item VariableItem* instance - * @param current_value_index + * + * @param item VariableItem* instance + * @param current_value_index The current value index */ void variable_item_set_current_value_index(VariableItem* item, uint8_t current_value_index); /** Set item current selected text - * @param item VariableItem* instance - * @param current_value_text + * + * @param item VariableItem* instance + * @param current_value_text The current value text */ void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text); /** Get item current selected index - * @param item VariableItem* instance - * @return uint8_t current selected index + * + * @param item VariableItem* instance + * + * @return uint8_t current selected index */ uint8_t variable_item_get_current_value_index(VariableItem* item); /** Get item context - * @param item VariableItem* instance - * @return void* item context + * + * @param item VariableItem* instance + * + * @return void* item context */ void* variable_item_get_context(VariableItem* item); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/applications/gui/modules/widget.h b/applications/gui/modules/widget.h index 9a335bce..09177c57 100755 --- a/applications/gui/modules/widget.h +++ b/applications/gui/modules/widget.h @@ -1,38 +1,51 @@ +/** + * @file widget.h + * GUI: Widget view module API + */ + #pragma once + #include "widget_elements/widget_element_i.h" typedef struct Widget Widget; typedef struct WidgetElement WidgetElement; /** Allocate Widget that holds Widget Elements - * @return Widget instance + * + * @return Widget instance */ Widget* widget_alloc(); /** Free Widget - * @note this function free allocated Widget Elements - * @param widget Widget instance + * @note this function free allocated Widget Elements + * + * @param widget Widget instance */ void widget_free(Widget* widget); /** Clear Widget - * @param widget Widget instance + * + * @param widget Widget instance */ void widget_clear(Widget* widget); /** Get Widget view - * @param widget Widget instance - * @return View instance + * + * @param widget Widget instance + * + * @return View instance */ View* widget_get_view(Widget* widget); /** Add Multi String Element - * @param widget Widget instance - * @param x - x coordinate - * @param y - y coordinate - * @param horizontal - Align instance - * @param vertical - Align instance - * @param font Font instance + * + * @param widget Widget instance + * @param x x coordinate + * @param y y coordinate + * @param horizontal Align instance + * @param vertical Align instance + * @param font Font instance + * @param[in] text The text */ void widget_add_string_multiline_element( Widget* widget, @@ -44,12 +57,14 @@ void widget_add_string_multiline_element( const char* text); /** Add String Element - * @param widget Widget instance - * @param x - x coordinate - * @param y - y coordinate - * @param horizontal - Align instance - * @param vertical - Align instance - * @param font Font instance + * + * @param widget Widget instance + * @param x x coordinate + * @param y y coordinate + * @param horizontal Align instance + * @param vertical Align instance + * @param font Font instance + * @param[in] text The text */ void widget_add_string_element( Widget* widget, @@ -61,11 +76,12 @@ void widget_add_string_element( const char* text); /** Add Button Element - * @param widget Widget instance - * @param button_type GuiButtonType instance - * @param text text on allocated button - * @param callback ButtonCallback instance - * @param context pointer to context + * + * @param widget Widget instance + * @param button_type GuiButtonType instance + * @param text text on allocated button + * @param callback ButtonCallback instance + * @param context pointer to context */ void widget_add_button_element( Widget* widget, @@ -75,20 +91,22 @@ void widget_add_button_element( void* context); /** Add Icon Element - * @param widget Widget instance - * @param x top left x coordinate - * @param y top left y coordinate - * @param icon Icon instance + * + * @param widget Widget instance + * @param x top left x coordinate + * @param y top left y coordinate + * @param icon Icon instance */ void widget_add_icon_element(Widget* widget, uint8_t x, uint8_t y, const Icon* icon); /** Add Frame Element - * @param widget Widget instance - * @param x top left x coordinate - * @param y top left y coordinate - * @param width frame width - * @param height frame height - * @param radius frame radius + * + * @param widget Widget instance + * @param x top left x coordinate + * @param y top left y coordinate + * @param width frame width + * @param height frame height + * @param radius frame radius */ void widget_add_frame_element( Widget* widget, diff --git a/applications/gui/modules/widget_elements/widget_element_i.h b/applications/gui/modules/widget_elements/widget_element_i.h index 2930eb1c..bbc58ff9 100755 --- a/applications/gui/modules/widget_elements/widget_element_i.h +++ b/applications/gui/modules/widget_elements/widget_element_i.h @@ -1,3 +1,8 @@ +/** + * @file widget_element_i.h + * GUI: internal Widget Element API + */ + #pragma once #include #include @@ -29,7 +34,7 @@ struct WidgetElement { Widget* parent; }; -/* Create multi string element */ +/** Create multi string element */ WidgetElement* widget_element_string_multiline_create( uint8_t x, uint8_t y, @@ -38,7 +43,7 @@ WidgetElement* widget_element_string_multiline_create( Font font, const char* text); -/* Create string element */ +/** Create string element */ WidgetElement* widget_element_string_create( uint8_t x, uint8_t y, @@ -47,20 +52,20 @@ WidgetElement* widget_element_string_create( Font font, const char* text); -/* Create button element */ +/** Create button element */ WidgetElement* widget_element_button_create( GuiButtonType button_type, const char* text, ButtonCallback callback, void* context); -/* Create icon element */ +/** Create icon element */ WidgetElement* widget_element_icon_create(uint8_t x, uint8_t y, const Icon* icon); -/* Create frame element */ +/** Create frame element */ WidgetElement* widget_element_frame_create( uint8_t x, uint8_t y, uint8_t width, uint8_t height, - uint8_t radius); \ No newline at end of file + uint8_t radius); diff --git a/applications/gui/scene_manager.h b/applications/gui/scene_manager.h index 0318b1cd..53f8d775 100755 --- a/applications/gui/scene_manager.h +++ b/applications/gui/scene_manager.h @@ -1,14 +1,18 @@ +/** + * @file scene_manager.h + * GUI: SceneManager API + */ + #pragma once +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include -#include - -/** Scene Manager events type - */ +/** Scene Manager events type */ typedef enum { SceneManagerEventTypeCustom, SceneManagerEventTypeBack, @@ -44,86 +48,110 @@ typedef struct { typedef struct SceneManager SceneManager; /** Set Scene state - * @param scene_manager SceneManager instance - * @param scene_id Scene ID - * @param state Scene new state + * + * @param scene_manager SceneManager instance + * @param scene_id Scene ID + * @param state Scene new state */ void scene_manager_set_scene_state(SceneManager* scene_manager, uint32_t scene_id, uint32_t state); /** Get Scene state - * @param scene_manager SceneManager instance - * @param scene_id Scene ID - * @return Scene state + * + * @param scene_manager SceneManager instance + * @param scene_id Scene ID + * + * @return Scene state */ uint32_t scene_manager_get_scene_state(SceneManager* scene_manager, uint32_t scene_id); /** Scene Manager allocation and configuration + * * Scene Manager allocates all scenes internally - * @param app_scene_handlers SceneManagerHandlers instance - * @param context context to be set on Scene handlers calls - * @return SceneManager instance + * + * @param app_scene_handlers SceneManagerHandlers instance + * @param context context to be set on Scene handlers calls + * + * @return SceneManager instance */ SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context); /** Free Scene Manager with allocated Scenes - * @param scene_manager SceneManager instance + * + * @param scene_manager SceneManager instance */ void scene_manager_free(SceneManager* scene_manager); /** Custom event handler + * * Calls Scene event handler with Custom event parameter - * @param scene_manager SceneManager instance - * @param custom_event Custom event code - * @return true if event was consumed, false otherwise + * + * @param scene_manager SceneManager instance + * @param custom_event Custom event code + * + * @return true if event was consumed, false otherwise */ bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t custom_event); /** Back event handler + * * Calls Scene event handler with Back event parameter - * @param scene_manager SceneManager instance - * @return true if event was consumed, false otherwise + * + * @param scene_manager SceneManager instance + * + * @return true if event was consumed, false otherwise */ bool scene_manager_handle_back_event(SceneManager* scene_manager); /** Tick event handler + * * Calls Scene event handler with Tick event parameter - * @param scene_manager SceneManager instance - * @return true if event was consumed, false otherwise + * + * @param scene_manager SceneManager instance + * @return true if event was consumed, false otherwise */ void scene_manager_handle_tick_event(SceneManager* scene_manager); /** Add and run next Scene - * @param scene_manager SceneManager instance - * @param next_scene_id next Scene ID + * + * @param scene_manager SceneManager instance + * @param next_scene_id next Scene ID */ void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id); /** Run previous Scene - * @param scene_manager SceneManager instance - * @return true if previous scene was found, false otherwise + * + * @param scene_manager SceneManager instance + * + * @return true if previous scene was found, false otherwise */ bool scene_manager_previous_scene(SceneManager* scene_manager); /** Search previous Scene - * @param scene_manager SceneManager instance - * @param scene_id Scene ID - * @return true if previous scene was found, false otherwise + * + * @param scene_manager SceneManager instance + * @param scene_id Scene ID + * + * @return true if previous scene was found, false otherwise */ bool scene_manager_has_previous_scene(SceneManager* scene_manager, uint32_t scene_id); /** Search and switch to previous Scene - * @param scene_manager SceneManager instance - * @param scene_id Scene ID - * @return true if previous scene was found, false otherwise + * + * @param scene_manager SceneManager instance + * @param scene_id Scene ID + * + * @return true if previous scene was found, false otherwise */ bool scene_manager_search_and_switch_to_previous_scene( SceneManager* scene_manager, uint32_t scene_id); /** Clear Scene stack and switch to another Scene - * @param scene_manager SceneManager instance - * @param scene_id Scene ID - * @return true if previous scene was found, false otherwise + * + * @param scene_manager SceneManager instance + * @param scene_id Scene ID + * + * @return true if previous scene was found, false otherwise */ bool scene_manager_search_and_switch_to_another_scene( SceneManager* scene_manager, diff --git a/applications/gui/scene_manager_i.h b/applications/gui/scene_manager_i.h index bb05d547..fca798d1 100755 --- a/applications/gui/scene_manager_i.h +++ b/applications/gui/scene_manager_i.h @@ -1,3 +1,8 @@ +/** + * @file scene_manager_i.h + * GUI: internal SceneManager API + */ + #pragma once #include "scene_manager.h" diff --git a/applications/gui/view.c b/applications/gui/view.c index 8dea6a43..c0420bd8 100644 --- a/applications/gui/view.c +++ b/applications/gui/view.c @@ -12,6 +12,11 @@ void view_free(View* view) { free(view); } +void view_tie_icon_animation(View* view, IconAnimation* icon_animation) { + furi_assert(view); + icon_animation_set_update_callback(icon_animation, view_icon_animation_callback, view); +} + void view_set_draw_callback(View* view, ViewDrawCallback callback) { furi_assert(view); furi_assert(view->draw_callback == NULL); @@ -120,6 +125,14 @@ void view_commit_model(View* view, bool update) { } } +void view_icon_animation_callback(IconAnimation* instance, void* context) { + furi_assert(context); + View* view = context; + if(view->update_callback) { + view->update_callback(view, view->update_callback_context); + } +} + void view_unlock_model(View* view) { furi_assert(view); if(view->model_type == ViewModelTypeLocking) { diff --git a/applications/gui/view.h b/applications/gui/view.h index 4cef59fa..5b4bf360 100644 --- a/applications/gui/view.h +++ b/applications/gui/view.h @@ -1,6 +1,13 @@ +/** + * @file view.h + * GUI: View API + */ + #pragma once #include + +#include "icon_animation.h" #include "canvas.h" #include @@ -10,9 +17,10 @@ extern "C" { #endif -/* Hides drawing view_port */ +/** Hides drawing view_port */ #define VIEW_NONE 0xFFFFFFFF -/* Ignore navigation event */ + +/** Ignore navigation event */ #define VIEW_IGNORE 0xFFFFFFFE typedef enum { @@ -20,158 +28,181 @@ typedef enum { ViewOrientationVertical, } ViewOrientation; -/* View, anonymous type */ +/** View, anonymous type */ typedef struct View View; -/* View Draw callback - * @param canvas, pointer to canvas - * @param view_model, pointer to context - * @warning called from GUI thread +/** View Draw callback + * @param canvas, pointer to canvas + * @param view_model, pointer to context + * @warning called from GUI thread */ typedef void (*ViewDrawCallback)(Canvas* canvas, void* model); -/* View Input callback - * @param event, pointer to input event data - * @param context, pointer to context - * @return true if event handled, false if event ignored - * @warning called from GUI thread +/** View Input callback + * @param event, pointer to input event data + * @param context, pointer to context + * @return true if event handled, false if event ignored + * @warning called from GUI thread */ typedef bool (*ViewInputCallback)(InputEvent* event, void* context); -/* View Custom callback - * @param event, number of custom event - * @param context, pointer to context - * @return true if event handled, false if event ignored +/** View Custom callback + * @param event, number of custom event + * @param context, pointer to context + * @return true if event handled, false if event ignored */ typedef bool (*ViewCustomCallback)(uint32_t event, void* context); -/* View navigation callback - * @param context, pointer to context - * @return next view id - * @warning called from GUI thread +/** View navigation callback + * @param context, pointer to context + * @return next view id + * @warning called from GUI thread */ typedef uint32_t (*ViewNavigationCallback)(void* context); -/* View callback - * @param context, pointer to context - * @warning called from GUI thread +/** View callback + * @param context, pointer to context + * @warning called from GUI thread */ typedef void (*ViewCallback)(void* context); -/* View Update Callback - * Called upon model change, need to be propagated to GUI throw ViewPort update - * @param view, pointer to view - * @param context, pointer to context - * @warning called from GUI thread +/** View Update Callback Called upon model change, need to be propagated to GUI + * throw ViewPort update + * @param view, pointer to view + * @param context, pointer to context + * @warning called from GUI thread */ typedef void (*ViewUpdateCallback)(View* view, void* context); -/* View model types */ +/** View model types */ typedef enum { - /* Model is not allocated */ + /** Model is not allocated */ ViewModelTypeNone, - /* Model consist of atomic types and/or partial update is not critical for rendering. + /** Model consist of atomic types and/or partial update is not critical for rendering. * Lock free. */ ViewModelTypeLockFree, - /* Model access is guarded with mutex. + /** Model access is guarded with mutex. * Locking gui thread. */ ViewModelTypeLocking, } ViewModelType; -/* Allocate and init View - * @return pointer to View +/** Allocate and init View + * @return View instance */ View* view_alloc(); -/* Free View - * @param pointer to View +/** Free View + * + * @param view instance */ void view_free(View* view); -/* Set View Draw callback - * @param view, pointer to View - * @param callback, draw callback +/** Tie IconAnimation with View + * + * @param view View instance + * @param icon_animation IconAnimation instance + */ +void view_tie_icon_animation(View* view, IconAnimation* icon_animation); + +/** Set View Draw callback + * + * @param view View instance + * @param callback draw callback */ void view_set_draw_callback(View* view, ViewDrawCallback callback); -/* Set View Input callback - * @param view, pointer to View - * @param callback, input callback +/** Set View Input callback + * + * @param view View instance + * @param callback input callback */ void view_set_input_callback(View* view, ViewInputCallback callback); -/* Set View Custom callback - * @param view, pointer to View - * @param callback, input callback +/** Set View Custom callback + * + * @param view View instance + * @param callback input callback */ void view_set_custom_callback(View* view, ViewCustomCallback callback); -/* Set Navigation Previous callback - * @param view, pointer to View - * @param callback, input callback +/** Set Navigation Previous callback + * + * @param view View instance + * @param callback input callback */ void view_set_previous_callback(View* view, ViewNavigationCallback callback); -/* Set Enter callback - * @param view, pointer to View - * @param callback, callback +/** Set Enter callback + * + * @param view View instance + * @param callback callback */ void view_set_enter_callback(View* view, ViewCallback callback); -/* Set Exit callback - * @param view, pointer to View - * @param callback, callback +/** Set Exit callback + * + * @param view View instance + * @param callback callback */ void view_set_exit_callback(View* view, ViewCallback callback); -/* Set Update callback - * @param view, pointer to View - * @param callback, callback +/** Set Update callback + * + * @param view View instance + * @param callback callback */ void view_set_update_callback(View* view, ViewUpdateCallback callback); -/* Set View Draw callback - * @param view, pointer to View - * @param context, context for callbacks +/** Set View Draw callback + * + * @param view View instance + * @param context context for callbacks */ void view_set_update_callback_context(View* view, void* context); -/* Set View Draw callback - * @param view, pointer to View - * @param context, context for callbacks +/** Set View Draw callback + * + * @param view View instance + * @param context context for callbacks */ void view_set_context(View* view, void* context); -/* Set View Orientation - * @param view, pointer to View - * @param orientation, either vertical or horizontal +/** Set View Orientation + * + * @param view View instance + * @param orientation either vertical or horizontal */ void view_set_orientation(View* view, ViewOrientation orientation); -/* Allocate view model. - * @param view, pointer to View - * @param type, View Model Type - * @param size, size +/** Allocate view model. + * + * @param view View instance + * @param type View Model Type + * @param size size */ void view_allocate_model(View* view, ViewModelType type, size_t size); -/* Free view model data memory. - * @param view, pointer to View +/** Free view model data memory. + * + * @param view View instance */ void view_free_model(View* view); -/* Get view model data - * @param view, pointer to View - * @return pointer to model data - * @warning Don't forget to commit model changes +/** Get view model data + * + * @param view View instance + * + * @return pointer to model data + * @warning Don't forget to commit model changes */ void* view_get_model(View* view); -/* Commit view model - * @param view, pointer to View - * @param update, true if you want to emit view update, false otherwise +/** Commit view model + * + * @param view View instance + * @param update true if you want to emit view update, false otherwise */ void view_commit_model(View* view, bool update); @@ -187,11 +218,13 @@ void view_commit_model(View* view, bool update); view_commit_model(view, update); \ } #else -/* - * With clause for view model - * @param view, View instance pointer - * @param function_body a (){} lambda declaration, executed within you parent function context - * @return true if you want to emit view update, false otherwise +/** With clause for view model + * + * @param view View instance pointer + * @param function_body a (){} lambda declaration, executed within you + * parent function context + * + * @return true if you want to emit view update, false otherwise */ #define with_view_model(view, function_body) \ { \ diff --git a/applications/gui/view_dispatcher.c b/applications/gui/view_dispatcher.c index b89e1c9b..c0246d97 100644 --- a/applications/gui/view_dispatcher.c +++ b/applications/gui/view_dispatcher.c @@ -177,6 +177,18 @@ void view_dispatcher_switch_to_view(ViewDispatcher* view_dispatcher, uint32_t vi } } +void view_dispatcher_send_to_front(ViewDispatcher* view_dispatcher) { + furi_assert(view_dispatcher); + furi_assert(view_dispatcher->gui); + gui_view_port_send_to_front(view_dispatcher->gui, view_dispatcher->view_port); +} + +void view_dispatcher_send_to_back(ViewDispatcher* view_dispatcher) { + furi_assert(view_dispatcher); + furi_assert(view_dispatcher->gui); + gui_view_port_send_to_front(view_dispatcher->gui, view_dispatcher->view_port); +} + void view_dispatcher_attach_to_gui( ViewDispatcher* view_dispatcher, Gui* gui, diff --git a/applications/gui/view_dispatcher.h b/applications/gui/view_dispatcher.h index 895c9b78..07dc2ead 100755 --- a/applications/gui/view_dispatcher.h +++ b/applications/gui/view_dispatcher.h @@ -1,3 +1,8 @@ +/** + * @file view_dispatcher.h + * GUI: ViewDispatcher API + */ + #pragma once #include "view.h" @@ -8,8 +13,7 @@ extern "C" { #endif -/** ViewDispatcher view_port placement - */ +/** ViewDispatcher view_port placement */ typedef enum { ViewDispatcherTypeNone, /**< Special layer for internal use only */ ViewDispatcherTypeWindow, /**< Main view_port layer, status bar is shown */ @@ -18,61 +22,70 @@ typedef enum { typedef struct ViewDispatcher ViewDispatcher; -/** Prototype for custom event callback - */ +/** Prototype for custom event callback */ typedef bool (*ViewDispatcherCustomEventCallback)(void* context, uint32_t event); -/** Prototype for navigation event callback - */ +/** Prototype for navigation event callback */ typedef bool (*ViewDispatcherNavigationEventCallback)(void* context); -/** Prototype for tick event callback - */ +/** Prototype for tick event callback */ typedef void (*ViewDispatcherTickEventCallback)(void* context); /** Allocate ViewDispatcher instance - * @return pointer to ViewDispatcher instance + * + * @return pointer to ViewDispatcher instance */ ViewDispatcher* view_dispatcher_alloc(); /** Free ViewDispatcher instance - * @param view_dispatcher pointer to ViewDispatcher + * + * @param view_dispatcher pointer to ViewDispatcher */ void view_dispatcher_free(ViewDispatcher* view_dispatcher); /** Enable queue support - * If queue enabled all input and custom events will be dispatched throw internal queue - * @param view_dispatcher ViewDispatcher instance + * + * If queue enabled all input and custom events will be dispatched throw + * internal queue + * + * @param view_dispatcher ViewDispatcher instance */ void view_dispatcher_enable_queue(ViewDispatcher* view_dispatcher); /** Send custom event - * @param view_dispatcher ViewDispatcher instance + * + * @param view_dispatcher ViewDispatcher instance + * @param[in] event The event */ void view_dispatcher_send_custom_event(ViewDispatcher* view_dispatcher, uint32_t event); /** Set custom event handler + * * Called on Custom Event, if it is not consumed by view - * @param view_dispatcher ViewDispatcher instance - * @param callback ViewDispatcherCustomEventCallback instance + * + * @param view_dispatcher ViewDispatcher instance + * @param callback ViewDispatcherCustomEventCallback instance */ void view_dispatcher_set_custom_event_callback( ViewDispatcher* view_dispatcher, ViewDispatcherCustomEventCallback callback); /** Set navigation event handler + * * Called on Input Short Back Event, if it is not consumed by view - * @param view_dispatcher ViewDispatcher instance - * @param callback ViewDispatcherNavigationEventCallback instance + * + * @param view_dispatcher ViewDispatcher instance + * @param callback ViewDispatcherNavigationEventCallback instance */ void view_dispatcher_set_navigation_event_callback( ViewDispatcher* view_dispatcher, ViewDispatcherNavigationEventCallback callback); /** Set tick event handler - * @param view_dispatcher ViewDispatcher instance - * @param callback ViewDispatcherTickEventCallback - * @param tick_period callback call period + * + * @param view_dispatcher ViewDispatcher instance + * @param callback ViewDispatcherTickEventCallback + * @param tick_period callback call period */ void view_dispatcher_set_tick_event_callback( ViewDispatcher* view_dispatcher, @@ -80,46 +93,69 @@ void view_dispatcher_set_tick_event_callback( uint32_t tick_period); /** Set event callback context - * @param view_dispatcher ViewDispatcher instance - * @param context pointer to context + * + * @param view_dispatcher ViewDispatcher instance + * @param context pointer to context */ void view_dispatcher_set_event_callback_context(ViewDispatcher* view_dispatcher, void* context); /** Run ViewDispatcher + * * Use only after queue enabled - * @param view_dispatcher ViewDispatcher instance + * + * @param view_dispatcher ViewDispatcher instance */ void view_dispatcher_run(ViewDispatcher* view_dispatcher); /** Stop ViewDispatcher + * * Use only after queue enabled - * @param view_dispatcher ViewDispatcher instance + * + * @param view_dispatcher ViewDispatcher instance */ void view_dispatcher_stop(ViewDispatcher* view_dispatcher); /** Add view to ViewDispatcher - * @param view_dispatcher, ViewDispatcher instance - * @param view_id View id to register - * @param view View instance + * + * @param view_dispatcher ViewDispatcher instance + * @param view_id View id to register + * @param view View instance */ void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id, View* view); /** Remove view from ViewDispatcher - * @param view_dispatcher ViewDispatcher instance - * @param view_id View id to remove + * + * @param view_dispatcher ViewDispatcher instance + * @param view_id View id to remove */ void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_id); /** Switch to View - * @param view_dispatcher ViewDispatcher instance - * @param view_id View id to register - * @warning switching may be delayed till input events complementarity reached + * + * @param view_dispatcher ViewDispatcher instance + * @param view_id View id to register + * @warning switching may be delayed till input events complementarity + * reached */ void view_dispatcher_switch_to_view(ViewDispatcher* view_dispatcher, uint32_t view_id); +/** Send ViewPort of this ViewDispatcher instance to front + * + * @param view_dispatcher ViewDispatcher instance + */ +void view_dispatcher_send_to_front(ViewDispatcher* view_dispatcher); + +/** Send ViewPort of this ViewDispatcher instance to back + * + * @param view_dispatcher ViewDispatcher instance + */ +void view_dispatcher_send_to_back(ViewDispatcher* view_dispatcher); + /** Attach ViewDispatcher to GUI - * @param view_dispatcher ViewDispatcher instance - * @param gui GUI instance to attach to + * + * @param view_dispatcher ViewDispatcher instance + * @param gui GUI instance to attach to + * @param[in] type The type */ void view_dispatcher_attach_to_gui( ViewDispatcher* view_dispatcher, diff --git a/applications/gui/view_dispatcher_i.h b/applications/gui/view_dispatcher_i.h index 60c9aa47..ad0f0888 100644 --- a/applications/gui/view_dispatcher_i.h +++ b/applications/gui/view_dispatcher_i.h @@ -1,3 +1,8 @@ +/** + * @file view_dispatcher_i.h + * GUI: ViewDispatcher API + */ + #pragma once #include @@ -41,23 +46,23 @@ typedef struct { }; } ViewDispatcherMessage; -/* ViewPort Draw Callback */ +/** ViewPort Draw Callback */ void view_dispatcher_draw_callback(Canvas* canvas, void* context); -/* ViewPort Input Callback */ +/** ViewPort Input Callback */ void view_dispatcher_input_callback(InputEvent* event, void* context); -/* Input handler */ +/** Input handler */ void view_dispatcher_handle_input(ViewDispatcher* view_dispatcher, InputEvent* event); -/* Tick handler */ +/** Tick handler */ void view_dispatcher_handle_tick_event(ViewDispatcher* view_dispatcher); -/* Custom event handler */ +/** Custom event handler */ void view_dispatcher_handle_custom_event(ViewDispatcher* view_dispatcher, uint32_t event); -/* Set current view, dispatches view enter and exit */ +/** Set current view, dispatches view enter and exit */ void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view); -/* ViewDispatcher update event */ +/** ViewDispatcher update event */ void view_dispatcher_update(View* view, void* context); diff --git a/applications/gui/view_i.h b/applications/gui/view_i.h index a03f3c4e..21b374d5 100644 --- a/applications/gui/view_i.h +++ b/applications/gui/view_i.h @@ -1,3 +1,8 @@ +/** + * @file view_i.h + * GUI: internal View API + */ + #pragma once #include "view.h" @@ -26,23 +31,26 @@ struct View { void* context; }; -/* Unlock model */ +/** IconAnimation tie callback */ +void view_icon_animation_callback(IconAnimation* instance, void* context); + +/** Unlock model */ void view_unlock_model(View* view); -/* Draw Callback for View dispatcher */ +/** Draw Callback for View dispatcher */ void view_draw(View* view, Canvas* canvas); -/* Input Callback for View dispatcher */ +/** Input Callback for View dispatcher */ bool view_input(View* view, InputEvent* event); -/* Custom Callback for View dispatcher */ +/** Custom Callback for View dispatcher */ bool view_custom(View* view, uint32_t event); -/* Previous Callback for View dispatcher */ +/** Previous Callback for View dispatcher */ uint32_t view_previous(View* view); -/* Enter Callback for View dispatcher */ +/** Enter Callback for View dispatcher */ void view_enter(View* view); -/* Exit Callback for View dispatcher */ +/** Exit Callback for View dispatcher */ void view_exit(View* view); diff --git a/applications/gui/view_port.h b/applications/gui/view_port.h index 6d00563b..96f2798e 100644 --- a/applications/gui/view_port.h +++ b/applications/gui/view_port.h @@ -1,3 +1,8 @@ +/** + * @file view_port.h + * GUI: ViewPort API + */ + #pragma once #include @@ -14,59 +19,66 @@ typedef enum { ViewPortOrientationVertical, } ViewPortOrientation; -/* - * ViewPort Draw callback - * @warning called from GUI thread +/** ViewPort Draw callback + * @warning called from GUI thread */ typedef void (*ViewPortDrawCallback)(Canvas* canvas, void* context); -/* - * ViewPort Input callback - * @warning called from GUI thread +/** ViewPort Input callback + * @warning called from GUI thread */ typedef void (*ViewPortInputCallback)(InputEvent* event, void* context); -/* - * ViewPort allocator +/** ViewPort allocator + * * always returns view_port or stops system if not enough memory. + * + * @return ViewPort instance */ ViewPort* view_port_alloc(); -/* - * ViewPort deallocator +/** ViewPort deallocator + * * Ensure that view_port was unregistered in GUI system before use. + * + * @param view_port ViewPort instance */ void view_port_free(ViewPort* view_port); -/* - * Set view_port width. +/** Set view_port width. + * * Will be used to limit canvas drawing area and autolayout feature. - * @param width - wanted width, 0 - auto. + * + * @param view_port ViewPort instance + * @param width wanted width, 0 - auto. */ void view_port_set_width(ViewPort* view_port, uint8_t width); uint8_t view_port_get_width(ViewPort* view_port); -/* - * Set view_port height. +/** Set view_port height. + * * Will be used to limit canvas drawing area and autolayout feature. - * @param height - wanted height, 0 - auto. + * + * @param view_port ViewPort instance + * @param height wanted height, 0 - auto. */ void view_port_set_height(ViewPort* view_port, uint8_t height); uint8_t view_port_get_height(ViewPort* view_port); -/* - * Enable or disable view_port rendering. - * @param view_port - ViewPort instance - * @param enabled - * @warning automatically dispatches update event +/** Enable or disable view_port rendering. + * + * @param view_port ViewPort instance + * @param enabled Indicates if enabled + * @warning automatically dispatches update event */ void view_port_enabled_set(ViewPort* view_port, bool enabled); bool view_port_is_enabled(ViewPort* view_port); -/* - * ViewPort event callbacks - * @param callback - appropriate callback function - * @param context - context to pass to callback +/** ViewPort event callbacks + * + * @param view_port ViewPort instance + * @param callback appropriate callback function + * @param context context to pass to callback */ void view_port_draw_callback_set(ViewPort* view_port, ViewPortDrawCallback callback, void* context); void view_port_input_callback_set( @@ -74,15 +86,18 @@ void view_port_input_callback_set( ViewPortInputCallback callback, void* context); -/* - * Emit update signal to GUI system. +/** Emit update signal to GUI system. + * * Rendering will happen later after GUI system process signal. + * + * @param view_port ViewPort instance */ void view_port_update(ViewPort* view_port); -/* - * Set ViewPort orientation. - * @param orientation, display orientation, horizontal or vertical. +/** Set ViewPort orientation. + * + * @param view_port ViewPort instance + * @param orientation display orientation, horizontal or vertical. */ void view_port_set_orientation(ViewPort* view_port, ViewPortOrientation orientation); ViewPortOrientation view_port_get_orientation(const ViewPort* view_port); diff --git a/applications/gui/view_port_i.h b/applications/gui/view_port_i.h index 55a9aa00..90f48ac9 100644 --- a/applications/gui/view_port_i.h +++ b/applications/gui/view_port_i.h @@ -1,3 +1,8 @@ +/** + * @file view_port_i.h + * GUI: internal ViewPort API + */ + #pragma once #include "gui_i.h" @@ -18,23 +23,29 @@ struct ViewPort { void* input_callback_context; }; -/* - * Set GUI reference. +/** Set GUI reference. + * * To be used by GUI, called upon view_port tree insert - * @param gui - gui instance pointer. + * + * @param view_port ViewPort instance + * @param gui gui instance pointer */ void view_port_gui_set(ViewPort* view_port, Gui* gui); -/* - * Process draw call. Calls draw callback. +/** Process draw call. Calls draw callback. + * * To be used by GUI, called on tree redraw. - * @param canvas - canvas to draw at. + * + * @param view_port ViewPort instance + * @param canvas canvas to draw at */ void view_port_draw(ViewPort* view_port, Canvas* canvas); -/* - * Process input. Calls input callbac +/** Process input. Calls input callback. + * * To be used by GUI, called on input dispatch. - * @param event - pointer to input event. + * + * @param view_port ViewPort instance + * @param event pointer to input event */ void view_port_input(ViewPort* view_port, InputEvent* event); diff --git a/applications/ibutton/ibutton-app.cpp b/applications/ibutton/ibutton-app.cpp index 651d754d..3491c95e 100644 --- a/applications/ibutton/ibutton-app.cpp +++ b/applications/ibutton/ibutton-app.cpp @@ -2,11 +2,12 @@ #include #include #include -#include -#include +#include +#include const char* iButtonApp::app_folder = "/any/ibutton"; const char* iButtonApp::app_extension = ".ibtn"; +const char* iButtonApp::app_filetype = "Flipper iButton key"; void iButtonApp::run(void* args) { iButtonEvent event; @@ -37,7 +38,9 @@ void iButtonApp::run(void* args) { } iButtonApp::iButtonApp() - : notification{"notification"} { + : notification{"notification"} + , storage{"storage"} + , dialogs{"dialogs"} { furi_hal_power_insomnia_enter(); key_worker = new KeyWorker(&ibutton_gpio); } @@ -188,102 +191,90 @@ bool iButtonApp::save_key(const char* key_name) { // Create ibutton directory if necessary make_app_folder(); - FileWorkerCpp file_worker; + FlipperFileCpp file(storage); string_t key_file_name; bool result = false; + string_init(key_file_name); - // First remove key if it was saved - string_init_printf(key_file_name, "%s/%s%s", app_folder, get_key()->get_name(), app_extension); - if(!file_worker.remove(string_get_cstr(key_file_name))) { - string_clear(key_file_name); - return false; - }; + do { + // First remove key if it was saved (we rename the key) + if(!delete_key()) break; - // Save the key - get_key()->set_name(key_name); - string_printf(key_file_name, "%s/%s%s", app_folder, get_key()->get_name(), app_extension); + // Save the key + key.set_name(key_name); - bool res = file_worker.open(string_get_cstr(key_file_name), FSAM_WRITE, FSOM_CREATE_ALWAYS); + // Set full file name, for new key + string_printf(key_file_name, "%s/%s%s", app_folder, key.get_name(), app_extension); + + // Open file for write + if(!file.new_write(string_get_cstr(key_file_name))) break; + + // Write header + if(!file.write_header_cstr(iButtonApp::app_filetype, 1)) break; + + // Write key type + if(!file.write_comment_cstr("Key type can be Cyfral, Dallas or Metakom")) break; + const char* key_type = key.get_key_type_string_by_type(key.get_key_type()); + if(!file.write_string_cstr("Key type", key_type)) break; + + // Write data + if(!file.write_comment_cstr( + "Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8")) + break; + + if(!file.write_hex_array("Data", key.get_data(), key.get_type_data_size())) break; + result = true; + + } while(false); + + file.close(); string_clear(key_file_name); - if(res) { - // type header - const char* key_type = "E "; - - switch(get_key()->get_key_type()) { - case iButtonKeyType::KeyCyfral: - key_type = "C "; - break; - case iButtonKeyType::KeyDallas: - key_type = "D "; - break; - case iButtonKeyType::KeyMetakom: - key_type = "M "; - break; - } - - if(!file_worker.write(key_type, 2)) { - file_worker.close(); - return false; - } - - if(!file_worker.write_hex(get_key()->get_data(), get_key()->get_type_data_size())) { - file_worker.close(); - return false; - } - result = true; + if(!result) { + dialog_message_show_storage_error(dialogs, "Cannot save\nkey file"); } - file_worker.close(); - return result; } bool iButtonApp::load_key_data(string_t key_path) { - FileWorkerCpp file_worker; + FlipperFileCpp file(storage); + bool result = false; + string_t data; + string_init(data); - // Open key file - if(!file_worker.open(string_get_cstr(key_path), FSAM_READ, FSOM_OPEN_EXISTING)) { - file_worker.close(); - return false; + do { + if(!file.open_read(string_get_cstr(key_path))) break; + + // header + uint32_t version; + if(!file.read_header(data, &version)) break; + if(string_cmp_str(data, iButtonApp::app_filetype) != 0) break; + if(version != 1) break; + + // key type + iButtonKeyType type; + if(!file.read_string("Key type", data)) break; + if(!key.get_key_type_by_type_string(string_get_cstr(data), &type)) break; + + // key data + uint8_t key_data[IBUTTON_KEY_DATA_SIZE] = {0}; + if(!file.read_hex_array("Data", key_data, key.get_type_data_size_by_type(type))) break; + + key.set_type(type); + key.set_data(key_data, IBUTTON_KEY_DATA_SIZE); + + result = true; + } while(false); + + file.close(); + string_clear(data); + + if(!result) { + dialog_message_show_storage_error(dialogs, "Cannot load\nkey file"); } - const uint8_t byte_text_size = 4; - char byte_text[byte_text_size] = {0, 0, 0, 0}; - - // Load type header - if(!file_worker.read(byte_text, 2)) { - file_worker.close(); - return false; - } - - iButtonKeyType key_type = iButtonKeyType::KeyCyfral; - if(strcmp(byte_text, "C ") == 0) { - key_type = iButtonKeyType::KeyCyfral; - } else if(strcmp(byte_text, "M ") == 0) { - key_type = iButtonKeyType::KeyMetakom; - } else if(strcmp(byte_text, "D ") == 0) { - key_type = iButtonKeyType::KeyDallas; - } else { - file_worker.show_error("Cannot parse\nkey file"); - file_worker.close(); - return false; - } - - iButtonKeyType old_type = get_key()->get_key_type(); - get_key()->set_type(key_type); - - uint8_t key_data[IBUTTON_KEY_DATA_SIZE] = {0, 0, 0, 0, 0, 0, 0, 0}; - if(!file_worker.read_hex(key_data, get_key()->get_type_data_size())) { - get_key()->set_type(old_type); - file_worker.close(); - return false; - } - - file_worker.close(); - get_key()->set_data(key_data, IBUTTON_KEY_DATA_SIZE); - - return true; + return result; } bool iButtonApp::load_key(const char* key_name) { @@ -303,11 +294,15 @@ bool iButtonApp::load_key(const char* key_name) { bool iButtonApp::load_key() { bool result = false; - FileWorkerCpp file_worker; // Input events and views are managed by file_select - bool res = file_worker.file_select( - app_folder, app_extension, get_file_name(), get_file_name_size(), get_key()->get_name()); + bool res = dialog_file_select_show( + dialogs, + app_folder, + app_extension, + get_file_name(), + get_file_name_size(), + get_key()->get_name()); if(res) { string_t key_str; @@ -328,16 +323,16 @@ bool iButtonApp::load_key() { bool iButtonApp::delete_key() { string_t file_name; bool result = false; - FileWorkerCpp file_worker; string_init_printf(file_name, "%s/%s%s", app_folder, get_key()->get_name(), app_extension); - result = file_worker.remove(string_get_cstr(file_name)); + result = storage_simply_remove(storage, string_get_cstr(file_name)); string_clear(file_name); return result; } void iButtonApp::make_app_folder() { - FileWorkerCpp file_worker; - file_worker.mkdir(app_folder); + if(!storage_simply_mkdir(storage, app_folder)) { + dialog_message_show_storage_error(dialogs, "Cannot create\napp folder"); + } } \ No newline at end of file diff --git a/applications/ibutton/ibutton-app.h b/applications/ibutton/ibutton-app.h index 7e6017d5..9751191f 100644 --- a/applications/ibutton/ibutton-app.h +++ b/applications/ibutton/ibutton-app.h @@ -30,6 +30,8 @@ #include "ibutton-key.h" #include +#include +#include #include @@ -126,6 +128,8 @@ private: iButtonKey key; RecordController notification; + RecordController storage; + RecordController dialogs; static const uint8_t file_name_size = 100; char file_name[file_name_size]; @@ -135,6 +139,7 @@ private: static const char* app_folder; static const char* app_extension; + static const char* app_filetype; bool load_key_data(string_t key_path); void make_app_folder(); diff --git a/applications/ibutton/ibutton-key.cpp b/applications/ibutton/ibutton-key.cpp index f8da3775..3d459c60 100644 --- a/applications/ibutton/ibutton-key.cpp +++ b/applications/ibutton/ibutton-key.cpp @@ -22,21 +22,7 @@ uint8_t* iButtonKey::get_data() { } uint8_t iButtonKey::get_type_data_size() { - uint8_t size = 0; - - switch(type) { - case iButtonKeyType::KeyCyfral: - size = 2; - break; - case iButtonKeyType::KeyMetakom: - size = 4; - break; - case iButtonKeyType::KeyDallas: - size = 8; - break; - } - - return size; + return get_type_data_size_by_type(type); } void iButtonKey::set_name(const char* _name) { @@ -55,5 +41,55 @@ iButtonKeyType iButtonKey::get_key_type() { return type; } +const char* iButtonKey::get_key_type_string_by_type(iButtonKeyType key_type) { + switch(key_type) { + case iButtonKeyType::KeyCyfral: + return "Cyfral"; + break; + case iButtonKeyType::KeyMetakom: + return "Metakom"; + break; + case iButtonKeyType::KeyDallas: + return "Dallas"; + break; + default: + furi_crash("Invalid iButton type"); + return ""; + break; + } +} + +bool iButtonKey::get_key_type_by_type_string(const char* type_string, iButtonKeyType* key_type) { + if(strcmp(type_string, get_key_type_string_by_type(iButtonKeyType::KeyCyfral)) == 0) { + *key_type = iButtonKeyType::KeyCyfral; + } else if(strcmp(type_string, get_key_type_string_by_type(iButtonKeyType::KeyMetakom)) == 0) { + *key_type = iButtonKeyType::KeyMetakom; + } else if(strcmp(type_string, get_key_type_string_by_type(iButtonKeyType::KeyDallas)) == 0) { + *key_type = iButtonKeyType::KeyDallas; + } else { + return false; + } + + return true; +} + +uint8_t iButtonKey::get_type_data_size_by_type(iButtonKeyType key_type) { + uint8_t size = 0; + + switch(key_type) { + case iButtonKeyType::KeyCyfral: + size = 2; + break; + case iButtonKeyType::KeyMetakom: + size = 4; + break; + case iButtonKeyType::KeyDallas: + size = 8; + break; + } + + return size; +} + iButtonKey::iButtonKey() { } diff --git a/applications/ibutton/ibutton-key.h b/applications/ibutton/ibutton-key.h index d7d8de4b..08e68102 100644 --- a/applications/ibutton/ibutton-key.h +++ b/applications/ibutton/ibutton-key.h @@ -17,6 +17,10 @@ public: void set_type(iButtonKeyType key_type); iButtonKeyType get_key_type(); + const char* get_key_type_string_by_type(iButtonKeyType key_type); + bool get_key_type_by_type_string(const char* type_string, iButtonKeyType* key_type); + uint8_t get_type_data_size_by_type(iButtonKeyType key_type); + iButtonKey(); private: diff --git a/applications/input/input.h b/applications/input/input.h index fd6da95d..d848b1c6 100644 --- a/applications/input/input.h +++ b/applications/input/input.h @@ -1,19 +1,24 @@ +/** + * @file input.h + * Input: main API + */ + #pragma once #include -/* Input Types +/** Input Types * Some of them are physical events and some logical */ typedef enum { - InputTypePress, /* Press event, emitted after debounce */ - InputTypeRelease, /* Release event, emitted after debounce */ - InputTypeShort, /* Short event, emitted after InputTypeRelease done withing INPUT_LONG_PRESS interval */ - InputTypeLong, /* Long event, emmited after INPUT_LONG_PRESS interval, asynchronouse to InputTypeRelease */ - InputTypeRepeat, /* Repeat event, emmited with INPUT_REPEATE_PRESS period after InputTypeLong event */ + InputTypePress, /**< Press event, emitted after debounce */ + InputTypeRelease, /**< Release event, emitted after debounce */ + InputTypeShort, /**< Short event, emitted after InputTypeRelease done withing INPUT_LONG_PRESS interval */ + InputTypeLong, /**< Long event, emmited after INPUT_LONG_PRESS interval, asynchronouse to InputTypeRelease */ + InputTypeRepeat, /**< Repeat event, emmited with INPUT_REPEATE_PRESS period after InputTypeLong event */ } InputType; -/* Input Event, dispatches with PubSub */ +/** Input Event, dispatches with PubSub */ typedef struct { uint32_t sequence; InputKey key; diff --git a/applications/input/input_i.h b/applications/input/input_i.h index d0cdfa76..db314dad 100644 --- a/applications/input/input_i.h +++ b/applications/input/input_i.h @@ -1,3 +1,8 @@ +/** + * @file input_i.h + * Input: internal API + */ + #pragma once #include "input.h" @@ -16,7 +21,7 @@ #define INPUT_LONG_PRESS_COUNTS 2 #define INPUT_THREAD_FLAG_ISR 0x00000001 -/* Input pin state */ +/** Input pin state */ typedef struct { const InputPin* pin; // State @@ -27,7 +32,7 @@ typedef struct { volatile uint32_t counter; } InputPinState; -/* Input state */ +/** Input state */ typedef struct { osThreadId_t thread; PubSub event_pubsub; @@ -36,8 +41,8 @@ typedef struct { volatile uint32_t counter; } Input; -/* Input press timer callback */ +/** Input press timer callback */ void input_press_timer_callback(void* arg); -/* Input interrupt handler */ +/** Input interrupt handler */ void input_isr(void* _ctx); diff --git a/applications/irda/scene/irda-app-scene-learn-enter-name.cpp b/applications/irda/scene/irda-app-scene-learn-enter-name.cpp index 821ae9de..f0717d25 100644 --- a/applications/irda/scene/irda-app-scene-learn-enter-name.cpp +++ b/applications/irda/scene/irda-app-scene-learn-enter-name.cpp @@ -27,7 +27,7 @@ void IrdaAppSceneLearnEnterName::on_enter(IrdaApp* app) { app, app->get_text_store(0), IrdaAppRemoteManager::max_button_name_length, - false); + true); view_manager->switch_to(IrdaAppViewManager::ViewType::TextInput); } diff --git a/applications/lfrfid/helpers/decoder-emmarin.h b/applications/lfrfid/helpers/decoder-emmarin.h index dd81a944..2f16df3e 100644 --- a/applications/lfrfid/helpers/decoder-emmarin.h +++ b/applications/lfrfid/helpers/decoder-emmarin.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include "manchester-decoder.h" +#include #include "protocols/protocol-emmarin.h" class DecoderEMMarin { public: diff --git a/applications/lfrfid/helpers/rfid-worker.h b/applications/lfrfid/helpers/rfid-worker.h index c2533a23..3efca849 100644 --- a/applications/lfrfid/helpers/rfid-worker.h +++ b/applications/lfrfid/helpers/rfid-worker.h @@ -43,6 +43,6 @@ private: void sq_write(); void sq_write_start_validate(); void sq_write_validate(); - uint8_t validate_counts; + uint16_t validate_counts; void sq_write_stop_validate(); }; \ No newline at end of file diff --git a/applications/lfrfid/lfrfid-app.cpp b/applications/lfrfid/lfrfid-app.cpp index 41cba8d7..92ddaa63 100644 --- a/applications/lfrfid/lfrfid-app.cpp +++ b/applications/lfrfid/lfrfid-app.cpp @@ -16,15 +16,18 @@ #include "scene/lfrfid-app-scene-delete-confirm.h" #include "scene/lfrfid-app-scene-delete-success.h" -#include #include +#include const char* LfRfidApp::app_folder = "/any/lfrfid"; const char* LfRfidApp::app_extension = ".rfid"; +const char* LfRfidApp::app_filetype = "Flipper RFID key"; LfRfidApp::LfRfidApp() : scene_controller{this} , notification{"notification"} + , storage{"storage"} + , dialogs{"dialogs"} , text_store(40) { furi_hal_power_insomnia_enter(); } @@ -77,20 +80,20 @@ bool LfRfidApp::save_key(RfidKey* key) { } bool LfRfidApp::load_key_from_file_select(bool need_restore) { - FileWorkerCpp file_worker; TextStore* filename_ts = new TextStore(64); - bool result; + bool result = false; if(need_restore) { - result = file_worker.file_select( + result = dialog_file_select_show( + dialogs, app_folder, app_extension, filename_ts->text, filename_ts->text_size, worker.key.get_name()); } else { - result = file_worker.file_select( - app_folder, app_extension, filename_ts->text, filename_ts->text_size, NULL); + result = dialog_file_select_show( + dialogs, app_folder, app_extension, filename_ts->text, filename_ts->text_size, NULL); } if(result) { @@ -105,86 +108,87 @@ bool LfRfidApp::load_key_from_file_select(bool need_restore) { } bool LfRfidApp::delete_key(RfidKey* key) { - FileWorkerCpp file_worker; string_t file_name; bool result = false; string_init_printf(file_name, "%s/%s%s", app_folder, key->get_name(), app_extension); - result = file_worker.remove(string_get_cstr(file_name)); + result = storage_simply_remove(storage, string_get_cstr(file_name)); string_clear(file_name); return result; } bool LfRfidApp::load_key_data(const char* path, RfidKey* key) { - FileWorkerCpp file_worker; + FlipperFileCpp file(storage); bool result = false; + string_t str_result; + string_init(str_result); - bool res = file_worker.open(path, FSAM_READ, FSOM_OPEN_EXISTING); + do { + if(!file.open_read(path)) break; - if(res) { - string_t str_result; - string_init(str_result); + // header + uint32_t version; + if(!file.read_header(str_result, &version)) break; + if(string_cmp_str(str_result, app_filetype) != 0) break; + if(version != 1) break; - do { - RfidKey loaded_key; - LfrfidKeyType loaded_type; + // key type + LfrfidKeyType type; + RfidKey loaded_key; - // load type - if(!file_worker.read_until(str_result, ' ')) break; - if(!lfrfid_key_get_string_type(string_get_cstr(str_result), &loaded_type)) { - file_worker.show_error("Cannot parse\nfile"); - break; - } - loaded_key.set_type(loaded_type); + if(!file.read_string("Key type", str_result)) break; + if(!lfrfid_key_get_string_type(string_get_cstr(str_result), &type)) break; + loaded_key.set_type(type); - // load data - uint8_t tmp_data[loaded_key.get_type_data_count()]; - if(!file_worker.read_hex(tmp_data, loaded_key.get_type_data_count())) break; - loaded_key.set_data(tmp_data, loaded_key.get_type_data_count()); + // key data + uint8_t key_data[loaded_key.get_type_data_count()] = {}; + if(!file.read_hex_array("Data", key_data, loaded_key.get_type_data_count())) break; + loaded_key.set_data(key_data, loaded_key.get_type_data_count()); - *key = loaded_key; - result = true; - } while(0); - - // load name path_extract_filename_no_ext(path, str_result); - key->set_name(string_get_cstr(str_result)); + loaded_key.set_name(string_get_cstr(str_result)); - string_clear(str_result); + *key = loaded_key; + result = true; + } while(0); + + file.close(); + string_clear(str_result); + + if(!result) { + dialog_message_show_storage_error(dialogs, "Cannot load\nkey file"); } - file_worker.close(); - return result; } bool LfRfidApp::save_key_data(const char* path, RfidKey* key) { - FileWorkerCpp file_worker; + FlipperFileCpp file(storage); bool result = false; - bool res = file_worker.open(path, FSAM_WRITE, FSOM_CREATE_ALWAYS); + do { + if(!file.new_write(path)) break; + if(!file.write_header_cstr(app_filetype, 1)) break; + if(!file.write_comment_cstr("Key type can be EM4100, H10301 or I40134")) break; + if(!file.write_string_cstr("Key type", lfrfid_key_get_type_string(key->get_type()))) break; + if(!file.write_comment_cstr("Data size for EM4100 is 5, for H10301 is 3, for I40134 is 3")) + break; + if(!file.write_hex_array("Data", key->get_data(), key->get_type_data_count())) break; + result = true; + } while(0); - if(res) { - do { - // type header - const char* key_type = lfrfid_key_get_type_string(key->get_type()); - char delimeter = ' '; + file.close(); - if(!file_worker.write(key_type, strlen(key_type))) break; - if(!file_worker.write(&delimeter)) break; - if(!file_worker.write_hex(key->get_data(), key->get_type_data_count())) break; - - result = true; - } while(0); + if(!result) { + dialog_message_show_storage_error(dialogs, "Cannot save\nkey file"); } - file_worker.close(); - return result; } void LfRfidApp::make_app_folder() { - FileWorkerCpp file_worker; - file_worker.mkdir(app_folder); + if(!storage_simply_mkdir(storage, app_folder)) { + dialog_message_show_storage_error(dialogs, "Cannot create\napp folder"); + } } \ No newline at end of file diff --git a/applications/lfrfid/lfrfid-app.h b/applications/lfrfid/lfrfid-app.h index b60d6994..d1b44e61 100644 --- a/applications/lfrfid/lfrfid-app.h +++ b/applications/lfrfid/lfrfid-app.h @@ -16,6 +16,8 @@ #include "view/container-vm.h" #include +#include +#include #include "helpers/rfid-worker.h" @@ -63,6 +65,8 @@ public: LfRfidApp(); RecordController notification; + RecordController storage; + RecordController dialogs; RfidWorker worker; @@ -72,6 +76,7 @@ public: static const char* app_folder; static const char* app_extension; + static const char* app_filetype; bool save_key(RfidKey* key); bool load_key_from_file_select(bool need_restore); diff --git a/applications/lfrfid/lfrfid-cli.cpp b/applications/lfrfid/lfrfid-cli.cpp index a039ccc8..2422dc5f 100644 --- a/applications/lfrfid/lfrfid-cli.cpp +++ b/applications/lfrfid/lfrfid-cli.cpp @@ -55,7 +55,7 @@ void lfrfid_cli_read(Cli* cli) { printf("Reading RFID...\r\nPress Ctrl+C to abort\r\n"); while(!cli_cmd_interrupt_received(cli)) { if(reader.read(&type, data, data_size)) { - printf(lfrfid_key_get_type_string(type)); + printf("%s", lfrfid_key_get_type_string(type)); printf(" "); for(uint8_t i = 0; i < lfrfid_key_get_type_data_count(type); i++) { diff --git a/applications/loader/loader.c b/applications/loader/loader.c index d121d139..d52eaa18 100755 --- a/applications/loader/loader.c +++ b/applications/loader/loader.c @@ -1,3 +1,4 @@ +#include "loader/loader.h" #include "loader_i.h" #define LOADER_THREAD_FLAG_SHOW_MENU (1 << 0) @@ -56,7 +57,7 @@ static void loader_cli_callback(Cli* cli, string_t args, void* _ctx) { furi_thread_start(loader_instance->thread); } -bool loader_start(Loader* instance, const char* name, const char* args) { +LoaderStatus loader_start(Loader* instance, const char* name, const char* args) { furi_assert(name); const FlipperApplication* flipper_app = NULL; @@ -79,14 +80,15 @@ bool loader_start(Loader* instance, const char* name, const char* args) { if(!flipper_app) { FURI_LOG_E(LOADER_LOG_TAG, "Can't find application with name %s", name); - return false; + return LoaderStatusErrorUnknownApp; } - loader_lock(instance); + bool locked = loader_lock(instance); - if(furi_thread_get_state(instance->thread) != FuriThreadStateStopped) { + if(!locked || (furi_thread_get_state(instance->thread) != FuriThreadStateStopped)) { FURI_LOG_E(LOADER_LOG_TAG, "Can't start app. %s is running", instance->current_app->name); - return false; + /* no need to call loader_unlock() - it is called as soon as application stops */ + return LoaderStatusErrorAppStarted; } instance->current_app = flipper_app; @@ -106,7 +108,8 @@ bool loader_start(Loader* instance, const char* name, const char* args) { furi_thread_set_context(instance->thread, thread_args); furi_thread_set_callback(instance->thread, flipper_app->app); - return furi_thread_start(instance->thread); + bool thread_started = furi_thread_start(instance->thread); + return thread_started ? LoaderStatusOk : LoaderStatusErrorInternal; } bool loader_lock(Loader* instance) { @@ -127,6 +130,10 @@ void loader_unlock(Loader* instance) { furi_check(osMutexRelease(instance->mutex) == osOK); } +bool loader_is_locked(Loader* instance) { + return (instance->lock_semaphore > 0); +} + static void loader_thread_state_callback(FuriThreadState thread_state, void* context) { furi_assert(context); diff --git a/applications/loader/loader.h b/applications/loader/loader.h index 568cfaa3..6c231b7a 100644 --- a/applications/loader/loader.h +++ b/applications/loader/loader.h @@ -4,12 +4,19 @@ typedef struct Loader Loader; +typedef enum { + LoaderStatusOk, + LoaderStatusErrorAppStarted, + LoaderStatusErrorUnknownApp, + LoaderStatusErrorInternal, +} LoaderStatus; + /** Start application * @param name - application name * @param args - application arguments * @retval true on success */ -bool loader_start(Loader* instance, const char* name, const char* args); +LoaderStatus loader_start(Loader* instance, const char* name, const char* args); /** Lock application start * @retval true on success @@ -19,5 +26,8 @@ bool loader_lock(Loader* instance); /** Unlock application start */ void loader_unlock(Loader* instance); +/** Get loader lock status */ +bool loader_is_locked(Loader* instance); + /** Show primary loader */ void loader_show_menu(); diff --git a/applications/nfc/nfc_device.c b/applications/nfc/nfc_device.c index 46947a2e..24fd8e40 100755 --- a/applications/nfc/nfc_device.c +++ b/applications/nfc/nfc_device.c @@ -200,8 +200,9 @@ uint16_t nfc_device_prepare_bank_card_string(NfcDevice* dev, string_t bank_card_ for(uint8_t i = 0; i < data->aid_len; i++) { string_cat_printf(bank_card_string, " %02X", data->aid[i]); } - string_cat_printf(bank_card_string, "\nName: %s\nNumber:", data->name); - for(uint8_t i = 0; i < sizeof(data->number); i++) { + string_cat_printf( + bank_card_string, "\nName: %s\nNumber len: %d\nNumber:", data->name, data->number_len); + for(uint8_t i = 0; i < data->number_len; i++) { string_cat_printf(bank_card_string, " %02X", data->number[i]); } if(data->exp_mon) { @@ -242,9 +243,15 @@ bool nfc_device_parse_bank_card_string(NfcDevice* dev, string_t bank_card_string } ws = string_search_char(bank_card_string, '\n'); string_right(bank_card_string, ws + 1); + res = sscanf(string_get_cstr(bank_card_string), "Number len: %hhu", &data->number_len); + if(res != 1) { + break; + } + ws = string_search_char(bank_card_string, '\n'); + string_right(bank_card_string, ws + 1); // strlen("Number: ") = 8 string_right(bank_card_string, 8); - if(!nfc_device_read_hex(bank_card_string, data->number, sizeof(data->number), 1)) { + if(!nfc_device_read_hex(bank_card_string, data->number, data->number_len, 1)) { break; } parsed = true; @@ -415,6 +422,10 @@ static bool nfc_device_load_data(FileWorker* file_worker, string_t path, NfcDevi parsed = true; } while(0); + if(!parsed) { + file_worker_show_error(file_worker, "Can not parse\nfile"); + } + string_clear(temp_string); return parsed; } @@ -451,7 +462,7 @@ bool nfc_file_select(NfcDevice* dev) { nfc_app_extension, dev->file_name, sizeof(dev->file_name), - NULL); + dev->dev_name); if(res) { string_t dev_str; @@ -474,7 +485,6 @@ void nfc_device_clear(NfcDevice* dev) { furi_assert(dev); memset(&dev->dev_data, 0, sizeof(dev->dev_data)); - nfc_device_set_name(dev, ""); dev->format = NfcDeviceSaveFormatUid; } diff --git a/applications/nfc/nfc_device.h b/applications/nfc/nfc_device.h index aa9764b5..50f435ca 100644 --- a/applications/nfc/nfc_device.h +++ b/applications/nfc/nfc_device.h @@ -40,7 +40,8 @@ typedef struct { char name[32]; uint8_t aid[16]; uint16_t aid_len; - uint8_t number[8]; + uint8_t number[10]; + uint8_t number_len; uint8_t exp_mon; uint8_t exp_year; uint16_t country_code; @@ -57,7 +58,7 @@ typedef struct { typedef struct { NfcDeviceData dev_data; - char dev_name[NFC_DEV_NAME_MAX_LEN]; + char dev_name[NFC_DEV_NAME_MAX_LEN + 1]; char file_name[NFC_FILE_NAME_MAX_LEN]; NfcDeviceSaveFormat format; bool shadow_file_exist; diff --git a/applications/nfc/nfc_i.h b/applications/nfc/nfc_i.h index 53fd6689..379cc100 100755 --- a/applications/nfc/nfc_i.h +++ b/applications/nfc/nfc_i.h @@ -26,6 +26,8 @@ #include +#define NFC_SEND_NOTIFICATION_FALSE (0UL) +#define NFC_SEND_NOTIFICATION_TRUE (1UL) #define NFC_TEXT_STORE_SIZE 128 struct Nfc { diff --git a/applications/nfc/nfc_worker.c b/applications/nfc/nfc_worker.c index 81a1ed67..97858a94 100755 --- a/applications/nfc/nfc_worker.c +++ b/applications/nfc/nfc_worker.c @@ -268,8 +268,10 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { if(emv_decode_select_app_response(rx_buff, *rx_len, &emv_app)) { FURI_LOG_I(NFC_WORKER_TAG, "Card name: %s", emv_app.name); memcpy(result->emv_data.name, emv_app.name, sizeof(emv_app.name)); + } else if(emv_app.pdol.size > 0) { + FURI_LOG_W(NFC_WORKER_TAG, "Can't find card name, but PDOL is present."); } else { - FURI_LOG_E(NFC_WORKER_TAG, "Can't read card name"); + FURI_LOG_E(NFC_WORKER_TAG, "Can't find card name or PDOL"); furi_hal_nfc_deactivate(); continue; } @@ -284,8 +286,8 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { } if(emv_decode_get_proc_opt(rx_buff, *rx_len, &emv_app)) { FURI_LOG_I(NFC_WORKER_TAG, "Card number parsed"); - memcpy( - result->emv_data.number, emv_app.card_number, sizeof(emv_app.card_number)); + result->emv_data.number_len = emv_app.card_number_len; + memcpy(result->emv_data.number, emv_app.card_number, emv_app.card_number_len); // Notify caller and exit if(nfc_worker->callback) { nfc_worker->callback(nfc_worker->context); @@ -320,10 +322,11 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { } if(pan_found) { FURI_LOG_I(NFC_WORKER_TAG, "Card PAN found"); + result->emv_data.number_len = emv_app.card_number_len; memcpy( result->emv_data.number, emv_app.card_number, - sizeof(emv_app.card_number)); + result->emv_data.number_len); if(emv_app.exp_month) { result->emv_data.exp_mon = emv_app.exp_month; result->emv_data.exp_year = emv_app.exp_year; diff --git a/applications/nfc/scenes/nfc_scene_device_info.c b/applications/nfc/scenes/nfc_scene_device_info.c index 0b0067c0..674b3f6d 100755 --- a/applications/nfc/scenes/nfc_scene_device_info.c +++ b/applications/nfc/scenes/nfc_scene_device_info.c @@ -111,7 +111,7 @@ void nfc_scene_device_info_on_enter(void* context) { NfcEmvData* emv_data = &nfc->dev.dev_data.emv_data; BankCard* bank_card = nfc->bank_card; bank_card_set_name(bank_card, emv_data->name); - bank_card_set_number(bank_card, emv_data->number); + bank_card_set_number(bank_card, emv_data->number, emv_data->number_len); bank_card_set_back_callback(bank_card, nfc_scene_device_info_bank_card_callback, nfc); if(emv_data->exp_mon) { bank_card_set_exp_date(bank_card, emv_data->exp_mon, emv_data->exp_year); diff --git a/applications/nfc/scenes/nfc_scene_mifare_ul_menu.c b/applications/nfc/scenes/nfc_scene_mifare_ul_menu.c index 5c31ab2c..236da374 100755 --- a/applications/nfc/scenes/nfc_scene_mifare_ul_menu.c +++ b/applications/nfc/scenes/nfc_scene_mifare_ul_menu.c @@ -33,6 +33,8 @@ bool nfc_scene_mifare_ul_menu_on_event(void* context, SceneManagerEvent event) { scene_manager_set_scene_state( nfc->scene_manager, NfcSceneMifareUlMenu, SubmenuIndexSave); nfc->dev.format = NfcDeviceSaveFormatMifareUl; + // Clear device name + nfc_device_set_name(&nfc->dev, ""); scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName); return true; } else if(event.event == SubmenuIndexEmulate) { diff --git a/applications/nfc/scenes/nfc_scene_read_card.c b/applications/nfc/scenes/nfc_scene_read_card.c index fda69b05..8853858e 100755 --- a/applications/nfc/scenes/nfc_scene_read_card.c +++ b/applications/nfc/scenes/nfc_scene_read_card.c @@ -1,6 +1,6 @@ #include "../nfc_i.h" -#define NFC_READ_CARD_CUSTOM_EVENT (0UL) +#define NFC_READ_CARD_CUSTOM_EVENT (10UL) void nfc_read_card_worker_callback(void* context) { Nfc* nfc = (Nfc*)context; diff --git a/applications/nfc/scenes/nfc_scene_read_card_success.c b/applications/nfc/scenes/nfc_scene_read_card_success.c index b745eae3..5cac8258 100755 --- a/applications/nfc/scenes/nfc_scene_read_card_success.c +++ b/applications/nfc/scenes/nfc_scene_read_card_success.c @@ -11,9 +11,6 @@ void nfc_scene_read_card_success_dialog_callback(DialogExResult result, void* co void nfc_scene_read_card_success_on_enter(void* context) { Nfc* nfc = (Nfc*)context; - // Clear device name - nfc_device_set_name(&nfc->dev, ""); - // Send notification notification_message(nfc->notifications, &sequence_success); @@ -70,6 +67,8 @@ bool nfc_scene_read_card_success_on_event(void* context, SceneManagerEvent event if(event.event == DialogExResultLeft) { return scene_manager_previous_scene(nfc->scene_manager); } else if(event.event == DialogExResultRight) { + // Clear device name + nfc_device_set_name(&nfc->dev, ""); scene_manager_next_scene(nfc->scene_manager, NfcSceneCardMenu); return true; } diff --git a/applications/nfc/scenes/nfc_scene_read_emv_app.c b/applications/nfc/scenes/nfc_scene_read_emv_app.c index d0198791..63509ad8 100755 --- a/applications/nfc/scenes/nfc_scene_read_emv_app.c +++ b/applications/nfc/scenes/nfc_scene_read_emv_app.c @@ -1,6 +1,6 @@ #include "../nfc_i.h" -#define NFC_READ_EMV_APP_CUSTOM_EVENT (0UL) +#define NFC_READ_EMV_APP_CUSTOM_EVENT (10UL) void nfc_read_emv_app_worker_callback(void* context) { Nfc* nfc = (Nfc*)context; @@ -30,6 +30,8 @@ bool nfc_scene_read_emv_app_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == NFC_READ_EMV_APP_CUSTOM_EVENT) { + scene_manager_set_scene_state( + nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_TRUE); scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvAppSuccess); return true; } diff --git a/applications/nfc/scenes/nfc_scene_read_emv_app_success.c b/applications/nfc/scenes/nfc_scene_read_emv_app_success.c index a3371086..bea8d719 100755 --- a/applications/nfc/scenes/nfc_scene_read_emv_app_success.c +++ b/applications/nfc/scenes/nfc_scene_read_emv_app_success.c @@ -26,12 +26,13 @@ void nfc_scene_read_emv_app_success_on_enter(void* context) { bool aid_found = nfc_emv_parser_get_aid_name(emv_data->aid, emv_data->aid_len, aid); if(!aid_found) { for(uint8_t i = 0; i < emv_data->aid_len; i++) { - string_cat_printf(aid, " %02X", emv_data->aid[i]); + string_cat_printf(aid, "%02X", emv_data->aid[i]); } } nfc_text_store_set( nfc, - NFC_SCENE_READ_SUCCESS_SHIFT "UID: %02X %02X %02X %02X \n\n%s", + NFC_SCENE_READ_SUCCESS_SHIFT "UID: %02X %02X %02X %02X \n" NFC_SCENE_READ_SUCCESS_SHIFT + "Application:\n%s", nfc_data->uid[0], nfc_data->uid[1], nfc_data->uid[2], @@ -42,6 +43,14 @@ void nfc_scene_read_emv_app_success_on_enter(void* context) { dialog_ex_set_context(dialog_ex, nfc); dialog_ex_set_result_callback(dialog_ex, nfc_scene_read_emv_app_success_dialog_callback); + // Send notification + if(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadEmvAppSuccess) == + NFC_SEND_NOTIFICATION_TRUE) { + notification_message(nfc->notifications, &sequence_success); + scene_manager_set_scene_state( + nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_FALSE); + } + view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDialogEx); } diff --git a/applications/nfc/scenes/nfc_scene_read_emv_data.c b/applications/nfc/scenes/nfc_scene_read_emv_data.c old mode 100644 new mode 100755 index 44389e5a..953ac36f --- a/applications/nfc/scenes/nfc_scene_read_emv_data.c +++ b/applications/nfc/scenes/nfc_scene_read_emv_data.c @@ -1,6 +1,6 @@ #include "../nfc_i.h" -#define NFC_READ_EMV_DATA_CUSTOM_EVENT (0UL) +#define NFC_READ_EMV_DATA_CUSTOM_EVENT (10UL) void nfc_read_emv_data_worker_callback(void* context) { Nfc* nfc = (Nfc*)context; @@ -32,6 +32,8 @@ bool nfc_scene_read_emv_data_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == NFC_READ_EMV_DATA_CUSTOM_EVENT) { + scene_manager_set_scene_state( + nfc->scene_manager, NfcSceneReadEmvDataSuccess, NFC_SEND_NOTIFICATION_TRUE); scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvDataSuccess); return true; } @@ -48,9 +50,6 @@ void nfc_scene_read_emv_data_on_exit(void* context) { // Stop worker nfc_worker_stop(nfc->worker); - // Send notification - notification_message(nfc->notifications, &sequence_success); - // Clear view Popup* popup = nfc->popup; popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); diff --git a/applications/nfc/scenes/nfc_scene_read_emv_data_success.c b/applications/nfc/scenes/nfc_scene_read_emv_data_success.c index 8a98f5ae..92402c13 100755 --- a/applications/nfc/scenes/nfc_scene_read_emv_data_success.c +++ b/applications/nfc/scenes/nfc_scene_read_emv_data_success.c @@ -16,9 +16,6 @@ void nfc_scene_read_emv_data_success_on_enter(void* context) { NfcEmvData* emv_data = &nfc->dev.dev_data.emv_data; NfcDeviceCommonData* nfc_data = &nfc->dev.dev_data.nfc_data; - // Clear device name - nfc_device_set_name(&nfc->dev, ""); - // Setup Custom Widget view // Add frame widget_add_frame_element(nfc->widget, 0, 0, 128, 64, 6); @@ -39,20 +36,15 @@ void nfc_scene_read_emv_data_success_on_enter(void* context) { widget_add_string_element( nfc->widget, 64, 3, AlignCenter, AlignTop, FontSecondary, nfc->dev.dev_data.emv_data.name); // Add cad number - char pan_str[32]; - snprintf( - pan_str, - sizeof(pan_str), - "%02X%02X %02X%02X %02X%02X %02X%02X", - emv_data->number[0], - emv_data->number[1], - emv_data->number[2], - emv_data->number[3], - emv_data->number[4], - emv_data->number[5], - emv_data->number[6], - emv_data->number[7]); - widget_add_string_element(nfc->widget, 64, 13, AlignCenter, AlignTop, FontSecondary, pan_str); + string_t pan_str; + string_init(pan_str); + for(uint8_t i = 0; i < emv_data->number_len; i += 2) { + string_cat_printf(pan_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]); + } + string_strim(pan_str); + widget_add_string_element( + nfc->widget, 64, 13, AlignCenter, AlignTop, FontSecondary, string_get_cstr(pan_str)); + string_clear(pan_str); // Parse country code string_t country_name; string_init(country_name); @@ -110,6 +102,14 @@ void nfc_scene_read_emv_data_success_on_enter(void* context) { widget_add_string_element(nfc->widget, 7, 32, AlignLeft, AlignTop, FontSecondary, exp_str); } + // Send notification + if(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadEmvDataSuccess) == + NFC_SEND_NOTIFICATION_TRUE) { + notification_message(nfc->notifications, &sequence_success); + scene_manager_set_scene_state( + nfc->scene_manager, NfcSceneReadEmvDataSuccess, NFC_SEND_NOTIFICATION_FALSE); + } + view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); } @@ -121,6 +121,8 @@ bool nfc_scene_read_emv_data_success_on_event(void* context, SceneManagerEvent e return scene_manager_search_and_switch_to_previous_scene( nfc->scene_manager, NfcSceneReadEmvAppSuccess); } else if(event.event == GuiButtonTypeRight) { + // Clear device name + nfc_device_set_name(&nfc->dev, ""); nfc->dev.format = NfcDeviceSaveFormatBankCard; scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName); return true; diff --git a/applications/nfc/scenes/nfc_scene_read_mifare_ul.c b/applications/nfc/scenes/nfc_scene_read_mifare_ul.c index 95e890b5..f4d4a6dc 100755 --- a/applications/nfc/scenes/nfc_scene_read_mifare_ul.c +++ b/applications/nfc/scenes/nfc_scene_read_mifare_ul.c @@ -1,6 +1,6 @@ #include "../nfc_i.h" -#define NFC_READ_MIFARE_UL_CUSTOM_EVENT (0UL) +#define NFC_READ_MIFARE_UL_CUSTOM_EVENT (10UL) void nfc_read_mifare_ul_worker_callback(void* context) { Nfc* nfc = (Nfc*)context; diff --git a/applications/nfc/scenes/nfc_scene_read_mifare_ul_success.c b/applications/nfc/scenes/nfc_scene_read_mifare_ul_success.c index f1324dfa..55571666 100755 --- a/applications/nfc/scenes/nfc_scene_read_mifare_ul_success.c +++ b/applications/nfc/scenes/nfc_scene_read_mifare_ul_success.c @@ -23,9 +23,6 @@ void nfc_scene_read_mifare_ul_success_text_box_callback(void* context) { void nfc_scene_read_mifare_ul_success_on_enter(void* context) { Nfc* nfc = (Nfc*)context; - // Clear device name - nfc_device_set_name(&nfc->dev, ""); - // Send notification notification_message(nfc->notifications, &sequence_success); diff --git a/applications/nfc/scenes/nfc_scene_save_name.c b/applications/nfc/scenes/nfc_scene_save_name.c index a30b24f6..ca3afdac 100755 --- a/applications/nfc/scenes/nfc_scene_save_name.c +++ b/applications/nfc/scenes/nfc_scene_save_name.c @@ -43,7 +43,7 @@ bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) { if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetUid)) { nfc->dev.dev_data.nfc_data = nfc->dev_edit_data; } - memcpy(&nfc->dev.dev_name, nfc->text_store, strlen(nfc->text_store)); + strlcpy(nfc->dev.dev_name, nfc->text_store, strlen(nfc->text_store) + 1); if(nfc_device_save(&nfc->dev, nfc->text_store)) { scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess); return true; diff --git a/applications/nfc/scenes/nfc_scene_set_type.c b/applications/nfc/scenes/nfc_scene_set_type.c index 7574123f..badab0c0 100755 --- a/applications/nfc/scenes/nfc_scene_set_type.c +++ b/applications/nfc/scenes/nfc_scene_set_type.c @@ -14,7 +14,8 @@ void nfc_scene_set_type_submenu_callback(void* context, uint32_t index) { void nfc_scene_set_type_on_enter(void* context) { Nfc* nfc = (Nfc*)context; Submenu* submenu = nfc->submenu; - + // Clear device name + nfc_device_set_name(&nfc->dev, ""); submenu_add_item( submenu, "NFC-A 7-bytes UID", SubmenuIndexNFCA7, nfc_scene_set_type_submenu_callback, nfc); submenu_add_item( diff --git a/applications/nfc/views/bank_card.c b/applications/nfc/views/bank_card.c index 1be14ba7..483491d6 100755 --- a/applications/nfc/views/bank_card.c +++ b/applications/nfc/views/bank_card.c @@ -35,12 +35,12 @@ void bank_card_set_name(BankCard* bank_card, char* name) { bank_card->widget, 64, 6, AlignCenter, AlignTop, FontSecondary, name); } -void bank_card_set_number(BankCard* bank_card, uint8_t* number) { +void bank_card_set_number(BankCard* bank_card, uint8_t* number, uint8_t len) { furi_assert(bank_card); furi_assert(number); string_t num_str; string_init(num_str); - for(uint8_t i = 0; i < 8; i += 2) { + for(uint8_t i = 0; i < len; i += 2) { string_cat_printf(num_str, "%02X%02X ", number[i], number[i + 1]); } // Add number diff --git a/applications/nfc/views/bank_card.h b/applications/nfc/views/bank_card.h index e50309fa..a4342856 100644 --- a/applications/nfc/views/bank_card.h +++ b/applications/nfc/views/bank_card.h @@ -17,7 +17,7 @@ void bank_card_set_back_callback(BankCard* bank_card, ButtonCallback callback, v void bank_card_set_name(BankCard* bank_card, char* name); -void bank_card_set_number(BankCard* bank_card, uint8_t* number); +void bank_card_set_number(BankCard* bank_card, uint8_t* number, uint8_t len); void bank_card_set_exp_date(BankCard* bank_card, uint8_t mon, uint8_t year); diff --git a/applications/power/power_cli.c b/applications/power/power_cli.c index 6ac955e6..4240ae45 100644 --- a/applications/power/power_cli.c +++ b/applications/power/power_cli.c @@ -5,10 +5,9 @@ #include void power_cli_poweroff(Cli* cli, string_t args, void* context) { - power_off(); + Power* power = furi_record_open("power"); printf("It's now safe to disconnect USB from your flipper\r\n"); - while(cli_getc(cli)) { - } + power_off(power); } void power_cli_reboot(Cli* cli, string_t args, void* context) { diff --git a/applications/power/power_service/power.c b/applications/power/power_service/power.c index db791a20..de712fd4 100755 --- a/applications/power/power_service/power.c +++ b/applications/power/power_service/power.c @@ -41,6 +41,10 @@ Power* power_alloc() { // Gui power->view_dispatcher = view_dispatcher_alloc(); + power->popup = popup_alloc(); + popup_set_header( + power->popup, "Disconnect USB for safe\nshutdown", 64, 26, AlignCenter, AlignTop); + view_dispatcher_add_view(power->view_dispatcher, PowerViewPopup, popup_get_view(power->popup)); power->power_off = power_off_alloc(); view_dispatcher_add_view( power->view_dispatcher, PowerViewOff, power_off_get_view(power->power_off)); @@ -63,6 +67,8 @@ void power_free(Power* power) { // Gui view_dispatcher_remove_view(power->view_dispatcher, PowerViewOff); power_off_free(power->power_off); + view_dispatcher_remove_view(power->view_dispatcher, PowerViewPopup); + popup_free(power->popup); view_port_free(power->battery_view_port); // State @@ -97,29 +103,34 @@ static void power_check_charging_state(Power* power) { } } -static void power_update_info(Power* power) { +static bool power_update_info(Power* power) { + PowerInfo info; + + info.charge = furi_hal_power_get_pct(); + info.health = furi_hal_power_get_bat_health_pct(); + info.capacity_remaining = furi_hal_power_get_battery_remaining_capacity(); + info.capacity_full = furi_hal_power_get_battery_full_capacity(); + info.current_charger = furi_hal_power_get_battery_current(FuriHalPowerICCharger); + info.current_gauge = furi_hal_power_get_battery_current(FuriHalPowerICFuelGauge); + info.voltage_charger = furi_hal_power_get_battery_voltage(FuriHalPowerICCharger); + info.voltage_gauge = furi_hal_power_get_battery_voltage(FuriHalPowerICFuelGauge); + info.voltage_vbus = furi_hal_power_get_usb_voltage(); + info.temperature_charger = furi_hal_power_get_battery_temperature(FuriHalPowerICCharger); + info.temperature_gauge = furi_hal_power_get_battery_temperature(FuriHalPowerICFuelGauge); + osMutexAcquire(power->info_mtx, osWaitForever); - PowerInfo* info = &power->info; - - info->charge = furi_hal_power_get_pct(); - info->health = furi_hal_power_get_bat_health_pct(); - info->capacity_remaining = furi_hal_power_get_battery_remaining_capacity(); - info->capacity_full = furi_hal_power_get_battery_full_capacity(); - info->current_charger = furi_hal_power_get_battery_current(FuriHalPowerICCharger); - info->current_gauge = furi_hal_power_get_battery_current(FuriHalPowerICFuelGauge); - info->voltage_charger = furi_hal_power_get_battery_voltage(FuriHalPowerICCharger); - info->voltage_gauge = furi_hal_power_get_battery_voltage(FuriHalPowerICFuelGauge); - info->voltage_vbus = furi_hal_power_get_usb_voltage(); - info->temperature_charger = furi_hal_power_get_battery_temperature(FuriHalPowerICCharger); - info->temperature_gauge = furi_hal_power_get_battery_temperature(FuriHalPowerICFuelGauge); - + bool need_refresh = power->info.charge != info.charge; + power->info = info; osMutexRelease(power->info_mtx); + + return need_refresh; } static void power_check_low_battery(Power* power) { // Check battery charge and vbus voltage if((power->info.charge == 0) && (power->info.voltage_vbus < 4.0f)) { if(!power->battery_low) { + view_dispatcher_send_to_front(power->view_dispatcher); view_dispatcher_switch_to_view(power->view_dispatcher, PowerViewOff); } power->battery_low = true; @@ -135,7 +146,7 @@ static void power_check_low_battery(Power* power) { if(power->power_off_timeout) { power_off_set_time_left(power->power_off, power->power_off_timeout--); } else { - power_off(); + power_off(power); } } } @@ -156,7 +167,7 @@ int32_t power_srv(void* p) { while(1) { // Update data from gauge and charger - power_update_info(power); + bool need_refresh = power_update_info(power); // Check low battery level power_check_low_battery(power); @@ -168,7 +179,7 @@ int32_t power_srv(void* p) { power_check_battery_level_change(power); // Update battery view port - view_port_update(power->battery_view_port); + if(need_refresh) view_port_update(power->battery_view_port); osDelay(1000); } diff --git a/applications/power/power_service/power_api.c b/applications/power/power_service/power_api.c index 388466d6..4147d17d 100644 --- a/applications/power/power_service/power_api.c +++ b/applications/power/power_service/power_api.c @@ -3,8 +3,13 @@ #include "furi-hal-power.h" #include "furi-hal-boot.h" -void power_off() { +void power_off(Power* power) { furi_hal_power_off(); + // Notify user if USB is plugged + view_dispatcher_send_to_front(power->view_dispatcher); + view_dispatcher_switch_to_view(power->view_dispatcher, PowerViewPopup); + osDelay(10); + furi_crash("Disconnect USB for safe shutdown"); } void power_reboot(PowerBootMode mode) { diff --git a/applications/power/power_service/power_i.h b/applications/power/power_service/power_i.h index 35bba2d8..5bebd8cb 100755 --- a/applications/power/power_service/power_i.h +++ b/applications/power/power_service/power_i.h @@ -5,6 +5,8 @@ #include #include #include + +#include #include "views/power_off.h" #include @@ -17,6 +19,7 @@ typedef enum { struct Power { ViewDispatcher* view_dispatcher; + Popup* popup; PowerOff* power_off; ViewPort* battery_view_port; @@ -34,4 +37,7 @@ struct Power { uint8_t power_off_timeout; }; -typedef enum { PowerViewOff } PowerView; +typedef enum { + PowerViewPopup, + PowerViewOff, +} PowerView; diff --git a/applications/power/power_settings_app/scenes/power_settinfs_scene_usb_disconnect.c b/applications/power/power_settings_app/scenes/power_settinfs_scene_usb_disconnect.c deleted file mode 100755 index 1a76edcb..00000000 --- a/applications/power/power_settings_app/scenes/power_settinfs_scene_usb_disconnect.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "../power_settings_app.h" - -void power_settings_scene_usb_disconnect_on_enter(void* context) { - PowerSettingsApp* app = context; - - dialog_ex_set_header( - app->dialog, "Disconnect USB for safe\nshutdown", 64, 26, AlignCenter, AlignTop); - - view_dispatcher_switch_to_view(app->view_dispatcher, PowerSettingsAppViewDialog); -} - -bool power_settings_scene_usb_disconnect_on_event(void* context, SceneManagerEvent event) { - return true; -} - -void power_settings_scene_usb_disconnect_on_exit(void* context) { -} diff --git a/applications/power/power_settings_app/scenes/power_settings_scene_config.h b/applications/power/power_settings_app/scenes/power_settings_scene_config.h index 569e907a..cc8656dc 100755 --- a/applications/power/power_settings_app/scenes/power_settings_scene_config.h +++ b/applications/power/power_settings_app/scenes/power_settings_scene_config.h @@ -2,4 +2,3 @@ ADD_SCENE(power_settings, start, Start) ADD_SCENE(power_settings, battery_info, BatteryInfo) ADD_SCENE(power_settings, reboot, Reboot) ADD_SCENE(power_settings, power_off, PowerOff) -ADD_SCENE(power_settings, usb_disconnect, UsbDisconnect) diff --git a/applications/power/power_settings_app/scenes/power_settings_scene_power_off.c b/applications/power/power_settings_app/scenes/power_settings_scene_power_off.c index 84a7910a..a389778a 100755 --- a/applications/power/power_settings_app/scenes/power_settings_scene_power_off.c +++ b/applications/power/power_settings_app/scenes/power_settings_scene_power_off.c @@ -30,12 +30,7 @@ bool power_settings_scene_power_off_on_event(void* context, SceneManagerEvent ev if(event.event == DialogExResultLeft) { scene_manager_previous_scene(app->scene_manager); } else if(event.event == DialogExResultRight) { - power_off(); - // Check if USB is connected - power_get_info(app->power, &app->info); - if(app->info.voltage_vbus > 4.0f) { - scene_manager_next_scene(app->scene_manager, PowerSettingsAppSceneUsbDisconnect); - } + power_off(app->power); } consumed = true; } diff --git a/applications/rpc/rpc.c b/applications/rpc/rpc.c new file mode 100644 index 00000000..adb23e78 --- /dev/null +++ b/applications/rpc/rpc.c @@ -0,0 +1,468 @@ +#include "cmsis_os.h" +#include "cmsis_os2.h" +#include "flipper.pb.h" +#include "furi-hal-delay.h" +#include "furi/check.h" +#include "furi/log.h" +#include +#include "pb.h" +#include "pb_decode.h" +#include "pb_encode.h" +#include "portmacro.h" +#include "status.pb.h" +#include "storage.pb.h" +#include +#include +#include +#include +#include +#include "rpc_i.h" + +#define RPC_TAG "RPC" + +#define RPC_EVENT_NEW_DATA (1 << 0) +#define RPC_EVENT_DISCONNECT (1 << 1) +#define RPC_EVENTS_ALL (RPC_EVENT_DISCONNECT | RPC_EVENT_NEW_DATA) + +#define DEBUG_PRINT 0 + +DICT_DEF2(RpcHandlerDict, pb_size_t, M_DEFAULT_OPLIST, RpcHandler, M_POD_OPLIST) + +typedef struct { + RpcSystemAlloc alloc; + RpcSystemFree free; + void* context; +} RpcSystemCallbacks; + +static RpcSystemCallbacks rpc_systems[] = { + { + .alloc = rpc_system_status_alloc, + .free = NULL, + }, + { + .alloc = rpc_system_storage_alloc, + .free = rpc_system_storage_free, + }, + { + .alloc = rpc_system_app_alloc, + .free = NULL, + }, +}; + +struct RpcSession { + RpcSendBytesCallback send_bytes_callback; + void* send_bytes_context; + osMutexId_t send_bytes_mutex; + Rpc* rpc; + bool terminate_session; + void** system_contexts; +}; + +struct Rpc { + bool busy; + osMutexId_t busy_mutex; + RpcSession session; + osEventFlagsId_t events; + StreamBufferHandle_t stream; + RpcHandlerDict_t handlers; + PB_Main* decoded_message; +}; + +static bool content_callback(pb_istream_t* stream, const pb_field_t* field, void** arg); + +static size_t rpc_sprintf_msg_file( + string_t str, + const char* prefix, + const PB_Storage_File* msg_file, + size_t msg_files_size) { + size_t cnt = 0; + + for(int i = 0; i < msg_files_size; ++i, ++msg_file) { + string_cat_printf( + str, + "%s[%c] size: %5ld", + prefix, + msg_file->type == PB_Storage_File_FileType_DIR ? 'd' : 'f', + msg_file->size); + + if(msg_file->name) { + string_cat_printf(str, " \'%s\'", msg_file->name); + } + + if(msg_file->data && msg_file->data->size) { + string_cat_printf( + str, + " (%d):\'%.*s%s\'", + msg_file->data->size, + MIN(msg_file->data->size, 30), + msg_file->data->bytes, + msg_file->data->size > 30 ? "..." : ""); + } + + string_cat_printf(str, "\r\n"); + } + + return cnt; +} + +void rpc_print_message(const PB_Main* message) { + string_t str; + string_init(str); + + string_cat_printf( + str, + "PB_Main: {\r\n\tresult: %d cmd_id: %ld (%s)\r\n", + message->command_status, + message->command_id, + message->has_next ? "has_next" : "last"); + switch(message->which_content) { + default: + /* not implemented yet */ + string_cat_printf(str, "\tNOT_IMPLEMENTED (%d) {\r\n", message->which_content); + break; + case PB_Main_app_start_tag: { + string_cat_printf(str, "\tapp_start {\r\n"); + const char* name = message->content.app_start.name; + const char* args = message->content.app_start.args; + if(name) { + string_cat_printf(str, "\t\tname: %s\r\n", name); + } + if(args) { + string_cat_printf(str, "\t\targs: %s\r\n", args); + } + break; + } + case PB_Main_app_lock_status_request_tag: { + string_cat_printf(str, "\tapp_lock_status_request {\r\n"); + break; + } + case PB_Main_app_lock_status_response_tag: { + string_cat_printf(str, "\tapp_lock_status_response {\r\n"); + bool lock_status = message->content.app_lock_status_response.locked; + string_cat_printf(str, "\t\tlocked: %s\r\n", lock_status ? "true" : "false"); + break; + } + case PB_Main_storage_md5sum_request_tag: { + string_cat_printf(str, "\tmd5sum_request {\r\n"); + const char* path = message->content.storage_md5sum_request.path; + if(path) { + string_cat_printf(str, "\t\tpath: %s\r\n", path); + } + break; + } + case PB_Main_storage_md5sum_response_tag: { + string_cat_printf(str, "\tmd5sum_response {\r\n"); + const char* path = message->content.storage_md5sum_response.md5sum; + if(path) { + string_cat_printf(str, "\t\tmd5sum: %s\r\n", path); + } + break; + } + case PB_Main_ping_request_tag: + string_cat_printf(str, "\tping_request {\r\n"); + break; + case PB_Main_ping_response_tag: + string_cat_printf(str, "\tping_response {\r\n"); + break; + case PB_Main_storage_mkdir_request_tag: + string_cat_printf(str, "\tmkdir {\r\n"); + break; + case PB_Main_storage_delete_request_tag: { + string_cat_printf(str, "\tdelete {\r\n"); + const char* path = message->content.storage_delete_request.path; + if(path) { + string_cat_printf(str, "\t\tpath: %s\r\n", path); + } + break; + } + case PB_Main_empty_tag: + string_cat_printf(str, "\tempty {\r\n"); + break; + case PB_Main_storage_list_request_tag: { + string_cat_printf(str, "\tlist_request {\r\n"); + const char* path = message->content.storage_list_request.path; + if(path) { + string_cat_printf(str, "\t\tpath: %s\r\n", path); + } + break; + } + case PB_Main_storage_read_request_tag: { + string_cat_printf(str, "\tread_request {\r\n"); + const char* path = message->content.storage_read_request.path; + if(path) { + string_cat_printf(str, "\t\tpath: %s\r\n", path); + } + break; + } + case PB_Main_storage_write_request_tag: { + string_cat_printf(str, "\twrite_request {\r\n"); + const char* path = message->content.storage_write_request.path; + if(path) { + string_cat_printf(str, "\t\tpath: %s\r\n", path); + } + if(message->content.storage_write_request.has_file) { + const PB_Storage_File* msg_file = &message->content.storage_write_request.file; + rpc_sprintf_msg_file(str, "\t\t\t", msg_file, 1); + } + break; + } + case PB_Main_storage_read_response_tag: + string_cat_printf(str, "\tread_response {\r\n"); + if(message->content.storage_read_response.has_file) { + const PB_Storage_File* msg_file = &message->content.storage_read_response.file; + rpc_sprintf_msg_file(str, "\t\t\t", msg_file, 1); + } + break; + case PB_Main_storage_list_response_tag: { + const PB_Storage_File* msg_file = message->content.storage_list_response.file; + size_t msg_file_count = message->content.storage_list_response.file_count; + string_cat_printf(str, "\tlist_response {\r\n"); + rpc_sprintf_msg_file(str, "\t\t", msg_file, msg_file_count); + } + } + string_cat_printf(str, "\t}\r\n}\r\n"); + printf("%s", string_get_cstr(str)); + + string_clear(str); +} + +static Rpc* rpc_alloc(void) { + Rpc* rpc = furi_alloc(sizeof(Rpc)); + rpc->busy_mutex = osMutexNew(NULL); + rpc->busy = false; + rpc->events = osEventFlagsNew(NULL); + rpc->stream = xStreamBufferCreate(256, 1); + + rpc->decoded_message = furi_alloc(sizeof(PB_Main)); + rpc->decoded_message->cb_content.funcs.decode = content_callback; + rpc->decoded_message->cb_content.arg = rpc; + + RpcHandlerDict_init(rpc->handlers); + + return rpc; +} + +RpcSession* rpc_open_session(Rpc* rpc) { + furi_assert(rpc); + bool result = false; + furi_check(osMutexAcquire(rpc->busy_mutex, osWaitForever) == osOK); + if(rpc->busy) { + result = false; + } else { + rpc->busy = true; + result = true; + } + furi_check(osMutexRelease(rpc->busy_mutex) == osOK); + + if(result) { + RpcSession* session = &rpc->session; + session->send_bytes_mutex = osMutexNew(NULL); + session->rpc = rpc; + session->terminate_session = false; + session->system_contexts = furi_alloc(COUNT_OF(rpc_systems) * sizeof(void*)); + for(int i = 0; i < COUNT_OF(rpc_systems); ++i) { + session->system_contexts[i] = rpc_systems[i].alloc(rpc); + } + FURI_LOG_D(RPC_TAG, "Session started\r\n"); + } + + return result ? &rpc->session : NULL; /* support 1 open session for now */ +} + +void rpc_close_session(RpcSession* session) { + furi_assert(session); + furi_assert(session->rpc); + furi_assert(session->rpc->busy); + + rpc_set_send_bytes_callback(session, NULL, NULL); + osEventFlagsSet(session->rpc->events, RPC_EVENT_DISCONNECT); +} + +void rpc_set_send_bytes_callback(RpcSession* session, RpcSendBytesCallback callback, void* context) { + furi_assert(session); + furi_assert(session->rpc); + furi_assert(session->rpc->busy); + + osMutexAcquire(session->send_bytes_mutex, osWaitForever); + session->send_bytes_callback = callback; + session->send_bytes_context = context; + osMutexRelease(session->send_bytes_mutex); +} + +size_t + rpc_feed_bytes(RpcSession* session, uint8_t* encoded_bytes, size_t size, TickType_t timeout) { + furi_assert(session); + Rpc* rpc = session->rpc; + furi_assert(rpc->busy); + + size_t bytes_sent = xStreamBufferSend(rpc->stream, encoded_bytes, size, timeout); + osEventFlagsSet(rpc->events, RPC_EVENT_NEW_DATA); + + return bytes_sent; +} + +bool rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) { + Rpc* rpc = istream->state; + uint32_t flags = 0; + size_t bytes_received = 0; + + while(1) { + bytes_received += + xStreamBufferReceive(rpc->stream, buf + bytes_received, count - bytes_received, 0); + if(count == bytes_received) { + break; + } else { + flags = osEventFlagsWait(rpc->events, RPC_EVENTS_ALL, 0, osWaitForever); + if(flags & RPC_EVENT_DISCONNECT) { + if(xStreamBufferIsEmpty(rpc->stream)) { + rpc->session.terminate_session = true; + break; + } else { + /* Save disconnect flag and continue reading buffer */ + osEventFlagsSet(rpc->events, RPC_EVENT_DISCONNECT); + } + } + } + } + + return (count == bytes_received); +} + +void rpc_encode_and_send(Rpc* rpc, PB_Main* main_message) { + furi_assert(rpc); + furi_assert(main_message); + RpcSession* session = &rpc->session; + pb_ostream_t ostream = PB_OSTREAM_SIZING; + +#if DEBUG_PRINT + FURI_LOG_I(RPC_TAG, "OUTPUT:"); + rpc_print_message(main_message); +#endif + + bool result = pb_encode_ex(&ostream, &PB_Main_msg, main_message, PB_ENCODE_DELIMITED); + furi_check(result && ostream.bytes_written); + + uint8_t* buffer = furi_alloc(ostream.bytes_written); + ostream = pb_ostream_from_buffer(buffer, ostream.bytes_written); + + pb_encode_ex(&ostream, &PB_Main_msg, main_message, PB_ENCODE_DELIMITED); + + { +#if DEBUG_PRINT + string_t str; + string_init(str); + string_reserve(str, 100 + ostream.bytes_written * 5); + + string_cat_printf(str, "\r\nREPONSE DEC(%d): {", ostream.bytes_written); + for(int i = 0; i < ostream.bytes_written; ++i) { + string_cat_printf(str, "%d, ", buffer[i]); + } + string_cat_printf(str, "}\r\n"); + + printf("%s", string_get_cstr(str)); + string_clean(str); + string_reserve(str, 100 + ostream.bytes_written * 3); + + string_cat_printf(str, "REPONSE HEX(%d): {", ostream.bytes_written); + for(int i = 0; i < ostream.bytes_written; ++i) { + string_cat_printf(str, "%02X", buffer[i]); + } + string_cat_printf(str, "}\r\n\r\n"); + + printf("%s", string_get_cstr(str)); +#endif // DEBUG_PRINT + + osMutexAcquire(session->send_bytes_mutex, osWaitForever); + if(session->send_bytes_callback) { + session->send_bytes_callback( + session->send_bytes_context, buffer, ostream.bytes_written); + } + osMutexRelease(session->send_bytes_mutex); + } + free(buffer); +} + +static bool content_callback(pb_istream_t* stream, const pb_field_t* field, void** arg) { + furi_assert(stream); + Rpc* rpc = *arg; + + RpcHandler* handler = RpcHandlerDict_get(rpc->handlers, field->tag); + + if(handler && handler->decode_submessage) { + handler->decode_submessage(stream, field, arg); + } + + return true; +} + +int32_t rpc_srv(void* p) { + Rpc* rpc = rpc_alloc(); + furi_record_create("rpc", rpc); + + while(1) { + pb_istream_t istream = { + .callback = rpc_pb_stream_read, + .state = rpc, + .errmsg = NULL, + .bytes_left = 0x7FFFFFFF, + }; + + if(pb_decode_ex(&istream, &PB_Main_msg, rpc->decoded_message, PB_DECODE_DELIMITED)) { +#if DEBUG_PRINT + FURI_LOG_I(RPC_TAG, "INPUT:"); + rpc_print_message(rpc->decoded_message); +#endif + RpcHandler* handler = + RpcHandlerDict_get(rpc->handlers, rpc->decoded_message->which_content); + + if(handler && handler->message_handler) { + handler->message_handler(rpc->decoded_message, handler->context); + } else if(!handler) { + FURI_LOG_E( + RPC_TAG, + "Unhandled message, tag: %d\r\n", + rpc->decoded_message->which_content); + } + pb_release(&PB_Main_msg, rpc->decoded_message); + } else { + pb_release(&PB_Main_msg, rpc->decoded_message); + RpcSession* session = &rpc->session; + if(session->terminate_session) { + session->terminate_session = false; + osEventFlagsClear(rpc->events, RPC_EVENTS_ALL); + FURI_LOG_D(RPC_TAG, "Session terminated\r\n"); + for(int i = 0; i < COUNT_OF(rpc_systems); ++i) { + if(rpc_systems[i].free) { + rpc_systems[i].free(session->system_contexts[i]); + } + } + free(session->system_contexts); + osMutexDelete(session->send_bytes_mutex); + RpcHandlerDict_clean(rpc->handlers); + rpc->busy = false; + } else { + xStreamBufferReset(rpc->stream); + FURI_LOG_E( + RPC_TAG, "Decode failed, error: \'%.128s\'\r\n", PB_GET_ERROR(&istream)); + } + } + } + return 0; +} + +void rpc_add_handler(Rpc* rpc, pb_size_t message_tag, RpcHandler* handler) { + furi_assert(RpcHandlerDict_get(rpc->handlers, message_tag) == NULL); + + RpcHandlerDict_set_at(rpc->handlers, message_tag, *handler); +} + +void rpc_encode_and_send_empty(Rpc* rpc, uint32_t command_id, PB_CommandStatus status) { + PB_Main message = { + .command_id = command_id, + .command_status = status, + .has_next = false, + .which_content = PB_Main_empty_tag, + }; + rpc_encode_and_send(rpc, &message); + pb_release(&PB_Main_msg, &message); +} diff --git a/applications/rpc/rpc.h b/applications/rpc/rpc.h new file mode 100644 index 00000000..91557606 --- /dev/null +++ b/applications/rpc/rpc.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include +#include "cmsis_os.h" + +typedef struct Rpc Rpc; +typedef struct RpcSession RpcSession; + +typedef void (*RpcSendBytesCallback)(void* context, uint8_t* bytes, size_t bytes_len); + +RpcSession* rpc_open_session(Rpc* rpc); +void rpc_close_session(RpcSession* session); +/* WARN: can't call RPC API within RpcSendBytesCallback */ +void rpc_set_send_bytes_callback(RpcSession* session, RpcSendBytesCallback callback, void* context); +size_t + rpc_feed_bytes(RpcSession* session, uint8_t* encoded_bytes, size_t size, TickType_t timeout); diff --git a/applications/rpc/rpc_app.c b/applications/rpc/rpc_app.c new file mode 100644 index 00000000..db4e5567 --- /dev/null +++ b/applications/rpc/rpc_app.c @@ -0,0 +1,78 @@ +#include "flipper.pb.h" +#include "furi/record.h" +#include "status.pb.h" +#include "rpc_i.h" +#include +#include + +void rpc_system_app_start_process(const PB_Main* request, void* context) { + Rpc* rpc = context; + furi_assert(rpc); + furi_assert(request); + furi_assert(request->which_content == PB_Main_app_start_tag); + PB_CommandStatus result = PB_CommandStatus_ERROR_APP_CANT_START; + + Loader* loader = furi_record_open("loader"); + const char* app_name = request->content.app_start.name; + if(app_name) { + const char* app_args = request->content.app_start.args; + LoaderStatus status = loader_start(loader, app_name, app_args); + if(status == LoaderStatusErrorAppStarted) { + result = PB_CommandStatus_ERROR_APP_SYSTEM_LOCKED; + } else if(status == LoaderStatusErrorInternal) { + result = PB_CommandStatus_ERROR_APP_CANT_START; + } else if(status == LoaderStatusErrorUnknownApp) { + result = PB_CommandStatus_ERROR_INVALID_PARAMETERS; + } else if(status == LoaderStatusOk) { + result = PB_CommandStatus_OK; + } else { + furi_assert(0); + } + } else { + result = PB_CommandStatus_ERROR_INVALID_PARAMETERS; + } + + furi_record_close("loader"); + + rpc_encode_and_send_empty(rpc, request->command_id, result); +} + +void rpc_system_app_lock_status_process(const PB_Main* request, void* context) { + Rpc* rpc = context; + furi_assert(rpc); + furi_assert(request); + furi_assert(request->which_content == PB_Main_app_lock_status_request_tag); + + Loader* loader = furi_record_open("loader"); + + PB_Main response = { + .has_next = false, + .command_status = PB_CommandStatus_OK, + .command_id = request->command_id, + .which_content = PB_Main_app_lock_status_response_tag, + }; + + response.content.app_lock_status_response.locked = loader_is_locked(loader); + + furi_record_close("loader"); + + rpc_encode_and_send(rpc, &response); +} + +void* rpc_system_app_alloc(Rpc* rpc) { + furi_assert(rpc); + + RpcHandler rpc_handler = { + .message_handler = NULL, + .decode_submessage = NULL, + .context = rpc, + }; + + rpc_handler.message_handler = rpc_system_app_start_process; + rpc_add_handler(rpc, PB_Main_app_start_tag, &rpc_handler); + + rpc_handler.message_handler = rpc_system_app_lock_status_process; + rpc_add_handler(rpc, PB_Main_app_lock_status_request_tag, &rpc_handler); + + return NULL; +} diff --git a/applications/rpc/rpc_i.h b/applications/rpc/rpc_i.h new file mode 100644 index 00000000..5bcb9d9b --- /dev/null +++ b/applications/rpc/rpc_i.h @@ -0,0 +1,27 @@ +#pragma once +#include "rpc.h" +#include "pb.h" +#include "pb_decode.h" +#include "pb_encode.h" +#include "flipper.pb.h" + +typedef void* (*RpcSystemAlloc)(Rpc*); +typedef void (*RpcSystemFree)(void*); +typedef void (*PBMessageHandler)(const PB_Main* msg_request, void* context); + +typedef struct { + bool (*decode_submessage)(pb_istream_t* stream, const pb_field_t* field, void** arg); + PBMessageHandler message_handler; + void* context; +} RpcHandler; + +void rpc_encode_and_send(Rpc* rpc, PB_Main* main_message); +void rpc_encode_and_send_empty(Rpc* rpc, uint32_t command_id, PB_CommandStatus status); +void rpc_add_handler(Rpc* rpc, pb_size_t message_tag, RpcHandler* handler); + +void* rpc_system_status_alloc(Rpc* rpc); +void* rpc_system_storage_alloc(Rpc* rpc); +void rpc_system_storage_free(void* ctx); +void* rpc_system_app_alloc(Rpc* rpc); + +void rpc_print_message(const PB_Main* message); diff --git a/applications/rpc/rpc_status.c b/applications/rpc/rpc_status.c new file mode 100644 index 00000000..524675d9 --- /dev/null +++ b/applications/rpc/rpc_status.c @@ -0,0 +1,25 @@ +#include "flipper.pb.h" +#include "rpc_i.h" +#include "status.pb.h" + +void rpc_system_status_ping_process(const PB_Main* msg_request, void* context) { + PB_Main msg_response = PB_Main_init_default; + msg_response.has_next = false; + msg_response.command_status = PB_CommandStatus_OK; + msg_response.command_id = msg_request->command_id; + msg_response.which_content = PB_Main_ping_response_tag; + + rpc_encode_and_send(context, &msg_response); +} + +void* rpc_system_status_alloc(Rpc* rpc) { + RpcHandler rpc_handler = { + .message_handler = rpc_system_status_ping_process, + .decode_submessage = NULL, + .context = rpc, + }; + + rpc_add_handler(rpc, PB_Main_ping_request_tag, &rpc_handler); + + return NULL; +} diff --git a/applications/rpc/rpc_storage.c b/applications/rpc/rpc_storage.c new file mode 100644 index 00000000..96842cba --- /dev/null +++ b/applications/rpc/rpc_storage.c @@ -0,0 +1,402 @@ +#include "flipper.pb.h" +#include "furi/common_defines.h" +#include "furi/memmgr.h" +#include "furi/record.h" +#include "pb_decode.h" +#include "rpc/rpc.h" +#include "rpc_i.h" +#include "storage.pb.h" +#include "storage/filesystem-api-defines.h" +#include "storage/storage.h" +#include +#include + +#define RPC_TAG "RPC_STORAGE" +#define MAX_NAME_LENGTH 255 +#define MAX_DATA_SIZE 512 + +typedef enum { + RpcStorageStateIdle = 0, + RpcStorageStateWriting, +} RpcStorageState; + +typedef struct { + Rpc* rpc; + Storage* api; + File* file; + RpcStorageState state; + uint32_t current_command_id; +} RpcStorageSystem; + +void rpc_print_message(const PB_Main* message); + +static void rpc_system_storage_reset_state(RpcStorageSystem* rpc_storage, bool send_error) { + furi_assert(rpc_storage); + + if(rpc_storage->state != RpcStorageStateIdle) { + if(send_error) { + rpc_encode_and_send_empty( + rpc_storage->rpc, + rpc_storage->current_command_id, + PB_CommandStatus_ERROR_CONTINUOUS_COMMAND_INTERRUPTED); + } + + if(rpc_storage->state == RpcStorageStateWriting) { + storage_file_close(rpc_storage->file); + storage_file_free(rpc_storage->file); + furi_record_close("storage"); + } + + rpc_storage->state = RpcStorageStateIdle; + } +} + +static PB_CommandStatus rpc_system_storage_get_error(FS_Error fs_error) { + PB_CommandStatus pb_error; + switch(fs_error) { + case FSE_OK: + pb_error = PB_CommandStatus_OK; + break; + case FSE_INVALID_NAME: + pb_error = PB_CommandStatus_ERROR_STORAGE_INVALID_NAME; + break; + case FSE_INVALID_PARAMETER: + pb_error = PB_CommandStatus_ERROR_STORAGE_INVALID_PARAMETER; + break; + case FSE_INTERNAL: + pb_error = PB_CommandStatus_ERROR_STORAGE_INTERNAL; + break; + case FSE_ALREADY_OPEN: + pb_error = PB_CommandStatus_ERROR_STORAGE_ALREADY_OPEN; + break; + case FSE_DENIED: + pb_error = PB_CommandStatus_ERROR_STORAGE_DENIED; + break; + case FSE_EXIST: + pb_error = PB_CommandStatus_ERROR_STORAGE_EXIST; + break; + case FSE_NOT_EXIST: + pb_error = PB_CommandStatus_ERROR_STORAGE_NOT_EXIST; + break; + case FSE_NOT_READY: + pb_error = PB_CommandStatus_ERROR_STORAGE_NOT_READY; + break; + case FSE_NOT_IMPLEMENTED: + pb_error = PB_CommandStatus_ERROR_STORAGE_NOT_IMPLEMENTED; + break; + default: + pb_error = PB_CommandStatus_ERROR; + break; + } + + return pb_error; +} + +static PB_CommandStatus rpc_system_storage_get_file_error(File* file) { + return rpc_system_storage_get_error(storage_file_get_error(file)); +} + +static void rpc_system_storage_list_process(const PB_Main* request, void* context) { + furi_assert(request); + furi_assert(context); + furi_assert(request->which_content == PB_Main_storage_list_request_tag); + + RpcStorageSystem* rpc_storage = context; + rpc_system_storage_reset_state(rpc_storage, true); + + Storage* fs_api = furi_record_open("storage"); + File* dir = storage_file_alloc(fs_api); + + PB_Main response = { + .command_id = request->command_id, + .has_next = false, + .which_content = PB_Main_storage_list_request_tag, + .command_status = PB_CommandStatus_OK, + }; + PB_Storage_ListResponse* list = &response.content.storage_list_response; + response.which_content = PB_Main_storage_list_response_tag; + + bool finish = false; + int i = 0; + + if(!storage_dir_open(dir, request->content.storage_list_request.path)) { + response.command_status = rpc_system_storage_get_file_error(dir); + response.which_content = PB_Main_empty_tag; + finish = true; + } + + while(!finish) { + FileInfo fileinfo; + char* name = furi_alloc(MAX_NAME_LENGTH + 1); + if(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) { + if(i == COUNT_OF(list->file)) { + list->file_count = i; + response.has_next = true; + rpc_encode_and_send(rpc_storage->rpc, &response); + pb_release(&PB_Main_msg, &response); + i = 0; + } + list->file[i].type = (fileinfo.flags & FSF_DIRECTORY) ? PB_Storage_File_FileType_DIR : + PB_Storage_File_FileType_FILE; + list->file[i].size = fileinfo.size; + list->file[i].data = NULL; + list->file[i].name = name; + ++i; + } else { + list->file_count = i; + finish = true; + free(name); + } + } + + response.has_next = false; + rpc_encode_and_send(rpc_storage->rpc, &response); + pb_release(&PB_Main_msg, &response); + + storage_dir_close(dir); + storage_file_free(dir); + + furi_record_close("storage"); +} + +static void rpc_system_storage_read_process(const PB_Main* request, void* context) { + furi_assert(request); + furi_assert(request->which_content == PB_Main_storage_read_request_tag); + + RpcStorageSystem* rpc_storage = context; + rpc_system_storage_reset_state(rpc_storage, true); + + /* use same message memory to send reponse */ + PB_Main* response = furi_alloc(sizeof(PB_Main)); + response->command_id = request->command_id; + response->which_content = PB_Main_storage_read_response_tag; + response->command_status = PB_CommandStatus_OK; + const char* path = request->content.storage_read_request.path; + Storage* fs_api = furi_record_open("storage"); + File* file = storage_file_alloc(fs_api); + bool result = false; + + if(storage_file_open(file, path, FSAM_READ, FSOM_OPEN_EXISTING)) { + size_t size_left = storage_file_size(file); + response->content.storage_read_response.has_file = true; + response->content.storage_read_response.file.data = + furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(MIN(size_left, MAX_DATA_SIZE))); + do { + uint8_t* buffer = response->content.storage_read_response.file.data->bytes; + uint16_t* read_size_msg = &response->content.storage_read_response.file.data->size; + + size_t read_size = MIN(size_left, MAX_DATA_SIZE); + *read_size_msg = storage_file_read(file, buffer, read_size); + size_left -= read_size; + result = (*read_size_msg == read_size); + + if(result) { + response->has_next = (size_left > 0); + rpc_encode_and_send(rpc_storage->rpc, response); + // no pb_release(...); + } + } while((size_left != 0) && result); + + if(!result) { + rpc_encode_and_send_empty( + rpc_storage->rpc, request->command_id, rpc_system_storage_get_file_error(file)); + } + } else { + rpc_encode_and_send_empty( + rpc_storage->rpc, request->command_id, rpc_system_storage_get_file_error(file)); + } + + pb_release(&PB_Main_msg, response); + free(response); + storage_file_close(file); + storage_file_free(file); + + furi_record_close("storage"); +} + +static void rpc_system_storage_write_process(const PB_Main* request, void* context) { + furi_assert(request); + furi_assert(request->which_content == PB_Main_storage_write_request_tag); + + RpcStorageSystem* rpc_storage = context; + bool result = true; + + if((request->command_id != rpc_storage->current_command_id) && + (rpc_storage->state == RpcStorageStateWriting)) { + rpc_system_storage_reset_state(rpc_storage, true); + } + + if(rpc_storage->state != RpcStorageStateWriting) { + rpc_storage->api = furi_record_open("storage"); + rpc_storage->file = storage_file_alloc(rpc_storage->api); + rpc_storage->current_command_id = request->command_id; + rpc_storage->state = RpcStorageStateWriting; + const char* path = request->content.storage_write_request.path; + result = storage_file_open(rpc_storage->file, path, FSAM_WRITE, FSOM_CREATE_ALWAYS); + } + + File* file = rpc_storage->file; + + if(result) { + uint8_t* buffer = request->content.storage_write_request.file.data->bytes; + size_t buffer_size = request->content.storage_write_request.file.data->size; + + uint16_t written_size = storage_file_write(file, buffer, buffer_size); + result = (written_size == buffer_size); + + if(result && !request->has_next) { + rpc_encode_and_send_empty( + rpc_storage->rpc, rpc_storage->current_command_id, PB_CommandStatus_OK); + rpc_system_storage_reset_state(rpc_storage, false); + } + } + + if(!result) { + rpc_encode_and_send_empty( + rpc_storage->rpc, + rpc_storage->current_command_id, + rpc_system_storage_get_file_error(file)); + rpc_system_storage_reset_state(rpc_storage, false); + } +} + +static void rpc_system_storage_delete_process(const PB_Main* request, void* context) { + furi_assert(request); + furi_assert(request->which_content == PB_Main_storage_delete_request_tag); + furi_assert(context); + RpcStorageSystem* rpc_storage = context; + PB_CommandStatus status; + rpc_system_storage_reset_state(rpc_storage, true); + + Storage* fs_api = furi_record_open("storage"); + char* path = request->content.storage_mkdir_request.path; + if(path) { + FS_Error error = storage_common_remove(fs_api, path); + status = rpc_system_storage_get_error(error); + } else { + status = PB_CommandStatus_ERROR_INVALID_PARAMETERS; + } + rpc_encode_and_send_empty(rpc_storage->rpc, request->command_id, status); +} + +static void rpc_system_storage_mkdir_process(const PB_Main* request, void* context) { + furi_assert(request); + furi_assert(request->which_content == PB_Main_storage_mkdir_request_tag); + furi_assert(context); + RpcStorageSystem* rpc_storage = context; + PB_CommandStatus status; + rpc_system_storage_reset_state(rpc_storage, true); + + Storage* fs_api = furi_record_open("storage"); + char* path = request->content.storage_mkdir_request.path; + if(path) { + FS_Error error = storage_common_mkdir(fs_api, path); + status = rpc_system_storage_get_error(error); + } else { + status = PB_CommandStatus_ERROR_INVALID_PARAMETERS; + } + rpc_encode_and_send_empty(rpc_storage->rpc, request->command_id, status); +} + +static void rpc_system_storage_md5sum_process(const PB_Main* request, void* context) { + furi_assert(request); + furi_assert(request->which_content == PB_Main_storage_md5sum_request_tag); + furi_assert(context); + RpcStorageSystem* rpc_storage = context; + rpc_system_storage_reset_state(rpc_storage, true); + + const char* filename = request->content.storage_md5sum_request.path; + if(!filename) { + rpc_encode_and_send_empty( + rpc_storage->rpc, request->command_id, PB_CommandStatus_ERROR_INVALID_PARAMETERS); + return; + } + + Storage* fs_api = furi_record_open("storage"); + 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 uint8_t hash_size = 16; + uint8_t* data = malloc(read_size); + 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); + } + md5_finish(md5_ctx, hash); + free(md5_ctx); + + PB_Main response = { + .command_id = request->command_id, + .command_status = PB_CommandStatus_OK, + .which_content = PB_Main_storage_md5sum_response_tag, + .has_next = false, + }; + + char* md5sum = response.content.storage_md5sum_response.md5sum; + size_t md5sum_size = sizeof(response.content.storage_md5sum_response.md5sum); + (void)md5sum_size; + furi_assert(hash_size <= ((md5sum_size - 1) / 2)); + for(uint8_t i = 0; i < hash_size; i++) { + md5sum += sprintf(md5sum, "%02x", hash[i]); + } + + free(hash); + free(data); + storage_file_close(file); + rpc_encode_and_send(rpc_storage->rpc, &response); + } else { + rpc_encode_and_send_empty( + rpc_storage->rpc, request->command_id, rpc_system_storage_get_file_error(file)); + } + + storage_file_free(file); + + furi_record_close("storage"); +} + +void* rpc_system_storage_alloc(Rpc* rpc) { + furi_assert(rpc); + + RpcStorageSystem* rpc_storage = furi_alloc(sizeof(RpcStorageSystem)); + rpc_storage->api = furi_record_open("storage"); + rpc_storage->rpc = rpc; + rpc_storage->state = RpcStorageStateIdle; + + RpcHandler rpc_handler = { + .message_handler = NULL, + .decode_submessage = NULL, + .context = rpc_storage, + }; + + rpc_handler.message_handler = rpc_system_storage_list_process; + rpc_add_handler(rpc, PB_Main_storage_list_request_tag, &rpc_handler); + + rpc_handler.message_handler = rpc_system_storage_read_process; + rpc_add_handler(rpc, PB_Main_storage_read_request_tag, &rpc_handler); + + rpc_handler.message_handler = rpc_system_storage_write_process; + rpc_add_handler(rpc, PB_Main_storage_write_request_tag, &rpc_handler); + + rpc_handler.message_handler = rpc_system_storage_delete_process; + rpc_add_handler(rpc, PB_Main_storage_delete_request_tag, &rpc_handler); + + rpc_handler.message_handler = rpc_system_storage_mkdir_process; + rpc_add_handler(rpc, PB_Main_storage_mkdir_request_tag, &rpc_handler); + + rpc_handler.message_handler = rpc_system_storage_md5sum_process; + rpc_add_handler(rpc, PB_Main_storage_md5sum_request_tag, &rpc_handler); + + return rpc_storage; +} + +void rpc_system_storage_free(void* ctx) { + RpcStorageSystem* rpc_storage = ctx; + rpc_system_storage_reset_state(rpc_storage, false); + free(rpc_storage); +} diff --git a/applications/storage/storage-cli.c b/applications/storage/storage-cli.c index f5520e0e..14425993 100644 --- a/applications/storage/storage-cli.c +++ b/applications/storage/storage-cli.c @@ -526,4 +526,4 @@ void storage_cli(Cli* cli, string_t args, void* context) { string_clear(path); string_clear(cmd); -} \ No newline at end of file +} diff --git a/applications/storage/storage-external-api.c b/applications/storage/storage-external-api.c index 7063d182..aa11161e 100644 --- a/applications/storage/storage-external-api.c +++ b/applications/storage/storage-external-api.c @@ -380,4 +380,16 @@ void storage_file_free(File* file) { } free(file); +} + +bool storage_simply_remove(Storage* storage, const char* path) { + FS_Error result; + result = storage_common_remove(storage, path); + return result == FSE_OK || result == FSE_NOT_EXIST; +} + +bool storage_simply_mkdir(Storage* storage, const char* path) { + FS_Error result; + result = storage_common_mkdir(storage, path); + return result == FSE_OK || result == FSE_EXIST; } \ No newline at end of file diff --git a/applications/storage/storage.h b/applications/storage/storage.h index 50e70b84..d38153bf 100644 --- a/applications/storage/storage.h +++ b/applications/storage/storage.h @@ -230,6 +230,24 @@ FS_Error storage_sd_info(Storage* api, SDInfo* info); */ FS_Error storage_sd_status(Storage* api); +/***************** Simplified Functions ******************/ + +/** + * Removes a file/directory from the repository, the directory must be empty and the file/directory must not be open + * @param storage pointer to the api + * @param path + * @return true on success or if file/dir is not exist + */ +bool storage_simply_remove(Storage* storage, const char* path); + +/** + * Creates a directory + * @param storage + * @param path + * @return true on success or if directory is already exist + */ +bool storage_simply_mkdir(Storage* storage, const char* path); + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/applications/subghz/helpers/subghz_frequency_analyzer_worker.c b/applications/subghz/helpers/subghz_frequency_analyzer_worker.c new file mode 100644 index 00000000..5c7199b6 --- /dev/null +++ b/applications/subghz/helpers/subghz_frequency_analyzer_worker.c @@ -0,0 +1,195 @@ +#include "subghz_frequency_analyzer_worker.h" +#include + +#include + +#include "../subghz_i.h" + +static const uint8_t subghz_preset_ook_58khz[][2] = { + {CC1101_FIFOTHR, 0x47}, // The only important bit is ADC_RETENTION, FIFO Tx=33 Rx=32 + {CC1101_MDMCFG4, 0xF5}, // Rx BW filter is 58.035714kHz + {CC1101_TEST2, 0x81}, // FIFOTHR ADC_RETENTION=1 matched value + {CC1101_TEST1, 0x35}, // FIFOTHR ADC_RETENTION=1 matched value + /* End */ + {0, 0}, +}; + +static const uint8_t subghz_preset_ook_650khz[][2] = { + {CC1101_FIFOTHR, 0x07}, // The only important bit is ADC_RETENTION + {CC1101_MDMCFG4, 0x17}, // Rx BW filter is 650.000kHz + {CC1101_TEST2, 0x88}, + {CC1101_TEST1, 0x31}, + /* End */ + {0, 0}, +}; + +struct SubGhzFrequencyAnalyzerWorker { + FuriThread* thread; + + volatile bool worker_running; + uint8_t count_repet; + FrequencyRSSI frequency_rssi_buf; + + float filVal; + + SubGhzFrequencyAnalyzerWorkerPairCallback pair_callback; + void* context; +}; + +// running average with adaptive coefficient +static uint32_t subghz_frequency_analyzer_worker_expRunningAverageAdaptive( + SubGhzFrequencyAnalyzerWorker* instance, + uint32_t newVal) { + float k; + float newValFloat = newVal; + // the sharpness of the filter depends on the absolute value of the difference + if(abs(newValFloat - instance->filVal) > 500000) + k = 0.9; + else + k = 0.03; + + instance->filVal += (newValFloat - instance->filVal) * k; + return (uint32_t)instance->filVal; +} + +/** Worker thread + * + * @param context + * @return exit code + */ +static int32_t subghz_frequency_analyzer_worker_thread(void* context) { + SubGhzFrequencyAnalyzerWorker* instance = context; + + FrequencyRSSI frequency_rssi = {.frequency = 0, .rssi = 0}; + float rssi; + uint32_t frequency; + uint32_t frequency_start; + + //Start CC1101 + furi_hal_subghz_reset(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async); + furi_hal_subghz_set_frequency(433920000); + furi_hal_subghz_flush_rx(); + furi_hal_subghz_rx(); + + while(instance->worker_running) { + osDelay(10); + frequency_rssi.rssi = -127.0f; + furi_hal_subghz_idle(); + furi_hal_subghz_load_registers(subghz_preset_ook_650khz); + for(size_t i = 0; i < subghz_frequencies_count; i++) { + if(furi_hal_subghz_is_frequency_valid(subghz_frequencies[i])) { + furi_hal_subghz_idle(); + frequency = furi_hal_subghz_set_frequency(subghz_frequencies[i]); + furi_hal_subghz_rx(); + osDelay(3); + rssi = furi_hal_subghz_get_rssi(); + if(frequency_rssi.rssi < rssi) { + frequency_rssi.rssi = rssi; + frequency_rssi.frequency = frequency; + } + } + } + + if(frequency_rssi.rssi > -90.0) { + // -0.5 ... 433.92 ... +0.5 + frequency_start = frequency_rssi.frequency - 250000; + //step 10KHz + frequency_rssi.rssi = -127.0; + furi_hal_subghz_idle(); + furi_hal_subghz_load_registers(subghz_preset_ook_58khz); + for(uint32_t i = frequency_start; i < frequency_start + 500000; i += 10000) { + if(furi_hal_subghz_is_frequency_valid(i)) { + furi_hal_subghz_idle(); + frequency = furi_hal_subghz_set_frequency(i); + furi_hal_subghz_rx(); + osDelay(3); + rssi = furi_hal_subghz_get_rssi(); + if(frequency_rssi.rssi < rssi) { + frequency_rssi.rssi = rssi; + frequency_rssi.frequency = frequency; + } + } + } + } + + if(frequency_rssi.rssi > -90.0) { + instance->count_repet = 20; + if(instance->filVal) { + frequency_rssi.frequency = + subghz_frequency_analyzer_worker_expRunningAverageAdaptive( + instance, frequency_rssi.frequency); + } + if(instance->pair_callback) + instance->pair_callback( + instance->context, frequency_rssi.frequency, frequency_rssi.rssi); + + } else { + if(instance->count_repet > 0) { + instance->count_repet--; + } else { + instance->filVal = 0; + if(instance->pair_callback) instance->pair_callback(instance->context, 0, 0); + } + } + } + + //Stop CC1101 + furi_hal_subghz_idle(); + furi_hal_subghz_sleep(); + + return 0; +} + +SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc() { + SubGhzFrequencyAnalyzerWorker* instance = furi_alloc(sizeof(SubGhzFrequencyAnalyzerWorker)); + + instance->thread = furi_thread_alloc(); + furi_thread_set_name(instance->thread, "subghz_frequency_analyzer_worker"); + furi_thread_set_stack_size(instance->thread, 2048); + furi_thread_set_context(instance->thread, instance); + furi_thread_set_callback(instance->thread, subghz_frequency_analyzer_worker_thread); + + return instance; +} + +void subghz_frequency_analyzer_worker_free(SubGhzFrequencyAnalyzerWorker* instance) { + furi_assert(instance); + + furi_thread_free(instance->thread); + + free(instance); +} + +void subghz_frequency_analyzer_worker_set_pair_callback( + SubGhzFrequencyAnalyzerWorker* instance, + SubGhzFrequencyAnalyzerWorkerPairCallback callback, + void* context) { + furi_assert(instance); + furi_assert(context); + instance->pair_callback = callback; + instance->context = context; +} + +void subghz_frequency_analyzer_worker_start(SubGhzFrequencyAnalyzerWorker* instance) { + furi_assert(instance); + furi_assert(!instance->worker_running); + + instance->worker_running = true; + + furi_thread_start(instance->thread); +} + +void subghz_frequency_analyzer_worker_stop(SubGhzFrequencyAnalyzerWorker* instance) { + furi_assert(instance); + furi_assert(instance->worker_running); + + instance->worker_running = false; + + furi_thread_join(instance->thread); +} + +bool subghz_frequency_analyzer_worker_is_running(SubGhzFrequencyAnalyzerWorker* instance) { + furi_assert(instance); + return instance->worker_running; +} diff --git a/applications/subghz/helpers/subghz_frequency_analyzer_worker.h b/applications/subghz/helpers/subghz_frequency_analyzer_worker.h new file mode 100644 index 00000000..34998ff1 --- /dev/null +++ b/applications/subghz/helpers/subghz_frequency_analyzer_worker.h @@ -0,0 +1,54 @@ +#pragma once + +#include + +typedef struct SubGhzFrequencyAnalyzerWorker SubGhzFrequencyAnalyzerWorker; + +typedef void ( + *SubGhzFrequencyAnalyzerWorkerPairCallback)(void* context, uint32_t frequency, float rssi); + +typedef struct { + uint32_t frequency; + float rssi; +} FrequencyRSSI; + +/** Allocate SubGhzFrequencyAnalyzerWorker + * + * @return SubGhzFrequencyAnalyzerWorker* + */ +SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc(); + +/** Free SubGhzFrequencyAnalyzerWorker + * + * @param instance SubGhzFrequencyAnalyzerWorker instance + */ +void subghz_frequency_analyzer_worker_free(SubGhzFrequencyAnalyzerWorker* instance); + +/** Pair callback SubGhzFrequencyAnalyzerWorker + * + * @param instance SubGhzFrequencyAnalyzerWorker instance + * @param callback SubGhzFrequencyAnalyzerWorkerOverrunCallback callback + * @param context + */ +void subghz_frequency_analyzer_worker_set_pair_callback( + SubGhzFrequencyAnalyzerWorker* instance, + SubGhzFrequencyAnalyzerWorkerPairCallback callback, + void* context); + +/** Start SubGhzFrequencyAnalyzerWorker + * + * @param instance SubGhzFrequencyAnalyzerWorker instance + */ +void subghz_frequency_analyzer_worker_start(SubGhzFrequencyAnalyzerWorker* instance); + +/** Stop SubGhzFrequencyAnalyzerWorker + * + * @param instance SubGhzFrequencyAnalyzerWorker instance + */ +void subghz_frequency_analyzer_worker_stop(SubGhzFrequencyAnalyzerWorker* instance); + +/** Check if worker is running + * @param instance SubGhzFrequencyAnalyzerWorker instance + * @return bool - true if running + */ +bool subghz_frequency_analyzer_worker_is_running(SubGhzFrequencyAnalyzerWorker* instance); diff --git a/applications/subghz/scenes/subghz_scene_config.h b/applications/subghz/scenes/subghz_scene_config.h index 7958764d..eca3cc35 100644 --- a/applications/subghz/scenes/subghz_scene_config.h +++ b/applications/subghz/scenes/subghz_scene_config.h @@ -16,3 +16,4 @@ ADD_SCENE(subghz, test_static, TestStatic) ADD_SCENE(subghz, test_carrier, TestCarrier) ADD_SCENE(subghz, test_packet, TestPacket) ADD_SCENE(subghz, set_type, SetType) +ADD_SCENE(subghz, frequency_analyzer, FrequencyAnalyzer) \ No newline at end of file diff --git a/applications/subghz/scenes/subghz_scene_delete.c b/applications/subghz/scenes/subghz_scene_delete.c index e97fd989..94782e88 100644 --- a/applications/subghz/scenes/subghz_scene_delete.c +++ b/applications/subghz/scenes/subghz_scene_delete.c @@ -28,7 +28,9 @@ void subghz_scene_delete_on_enter(void* context) { if(subghz->txrx->preset == FuriHalSubGhzPresetOok650Async || subghz->txrx->preset == FuriHalSubGhzPresetOok270Async) { snprintf(buffer_str, sizeof(buffer_str), "AM"); - } else if(subghz->txrx->preset == FuriHalSubGhzPreset2FSKAsync) { + } else if( + subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev238Async || + subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev476Async) { snprintf(buffer_str, sizeof(buffer_str), "FM"); } else { furi_crash(NULL); diff --git a/applications/subghz/scenes/subghz_scene_frequency_analyzer.c b/applications/subghz/scenes/subghz_scene_frequency_analyzer.c new file mode 100644 index 00000000..b67494f0 --- /dev/null +++ b/applications/subghz/scenes/subghz_scene_frequency_analyzer.c @@ -0,0 +1,30 @@ +#include "../subghz_i.h" +#include "../views/subghz_frequency_analyzer.h" + +void subghz_scene_frequency_analyzer_callback(SubghzFrequencyAnalyzerEvent event, void* context) { + furi_assert(context); + SubGhz* subghz = context; + view_dispatcher_send_custom_event(subghz->view_dispatcher, event); +} + +void subghz_scene_frequency_analyzer_on_enter(void* context) { + SubGhz* subghz = context; + subghz_frequency_analyzer_set_callback( + subghz->subghz_frequency_analyzer, subghz_scene_frequency_analyzer_callback, subghz); + view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewFrequencyAnalyzer); +} + +bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent event) { + SubGhz* subghz = context; + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubghzFrequencyAnalyzerEventOnlyRx) { + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx); + return true; + } + } + return false; +} + +void subghz_scene_frequency_analyzer_on_exit(void* context) { + // SubGhz* subghz = context; +} diff --git a/applications/subghz/scenes/subghz_scene_receiver.c b/applications/subghz/scenes/subghz_scene_receiver.c index f2d66e6b..fe29c0cf 100644 --- a/applications/subghz/scenes/subghz_scene_receiver.c +++ b/applications/subghz/scenes/subghz_scene_receiver.c @@ -17,7 +17,9 @@ static void subghz_scene_receiver_update_statusbar(void* context) { if(subghz->txrx->preset == FuriHalSubGhzPresetOok650Async || subghz->txrx->preset == FuriHalSubGhzPresetOok270Async) { snprintf(preset_str, sizeof(preset_str), "AM"); - } else if(subghz->txrx->preset == FuriHalSubGhzPreset2FSKAsync) { + } else if( + subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev238Async || + subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev476Async) { snprintf(preset_str, sizeof(preset_str), "FM"); } else { furi_crash(NULL); diff --git a/applications/subghz/scenes/subghz_scene_receiver_config.c b/applications/subghz/scenes/subghz_scene_receiver_config.c index 9586c8f3..3991a999 100644 --- a/applications/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/subghz/scenes/subghz_scene_receiver_config.c @@ -1,15 +1,17 @@ #include "../subghz_i.h" -#define PRESET_COUNT 3 +#define PRESET_COUNT 4 const char* const preset_text[PRESET_COUNT] = { "AM270", "AM650", - "FM", + "FM238", + "FM476", }; const uint32_t preset_value[PRESET_COUNT] = { FuriHalSubGhzPresetOok270Async, /** OOK, bandwidth 270kHz, asynchronous */ FuriHalSubGhzPresetOok650Async, /** OOK, bandwidth 650kHz, asynchronous */ - FuriHalSubGhzPreset2FSKAsync, /** FM, asynchronous */ + FuriHalSubGhzPreset2FSKDev238Async, /** FM, deviation 2.380371 kHz, asynchronous */ + FuriHalSubGhzPreset2FSKDev476Async, /** FM, deviation 4.760742 kHz, asynchronous */ }; #define HOPPING_COUNT 2 diff --git a/applications/subghz/scenes/subghz_scene_receiver_info.c b/applications/subghz/scenes/subghz_scene_receiver_info.c index f3a75e54..6b33a686 100644 --- a/applications/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/subghz/scenes/subghz_scene_receiver_info.c @@ -57,7 +57,9 @@ void subghz_scene_receiver_info_on_enter(void* context) { if(subghz->txrx->preset == FuriHalSubGhzPresetOok650Async || subghz->txrx->preset == FuriHalSubGhzPresetOok270Async) { snprintf(buffer_str, sizeof(buffer_str), "AM"); - } else if(subghz->txrx->preset == FuriHalSubGhzPreset2FSKAsync) { + } else if( + subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev238Async || + subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev476Async) { snprintf(buffer_str, sizeof(buffer_str), "FM"); } else { furi_crash(NULL); diff --git a/applications/subghz/scenes/subghz_scene_set_type.c b/applications/subghz/scenes/subghz_scene_set_type.c index 4ec34e23..331b9dc2 100644 --- a/applications/subghz/scenes/subghz_scene_set_type.c +++ b/applications/subghz/scenes/subghz_scene_set_type.c @@ -7,6 +7,7 @@ enum SubmenuIndex { SubmenuIndexNiceFlo24bit, SubmenuIndexCAME12bit, SubmenuIndexCAME24bit, + SubmenuIndexCAMETwee, SubmenuIndexNeroSketch, SubmenuIndexNeroRadio, SubmenuIndexGateTX, @@ -62,6 +63,12 @@ void subghz_scene_set_type_on_enter(void* context) { SubmenuIndexCAME24bit, subghz_scene_set_type_submenu_callback, subghz); + submenu_add_item( + subghz->submenu, + "CAME TWEE", + SubmenuIndexCAMETwee, + subghz_scene_set_type_submenu_callback, + subghz); // submenu_add_item( // subghz->submenu, "Nero Sketch", SubmenuIndexNeroSketch, subghz_scene_set_type_submenu_callback, subghz); // submenu_add_item( @@ -132,6 +139,15 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { generated_protocol = true; } break; + case SubmenuIndexCAMETwee: + if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "CAME TWEE")) { + subghz->txrx->protocol_result->code_last_count_bit = 54; + key = (key & 0x0FFFFFF0); + subghz->txrx->protocol_result->code_last_found = 0x003FFF7200000000 | + (key ^ 0xE0E0E0EE); + generated_protocol = true; + } + break; // case SubmenuIndexNeroSketch: // /* code */ // break; diff --git a/applications/subghz/scenes/subghz_scene_start.c b/applications/subghz/scenes/subghz_scene_start.c index b3713873..c131a0a8 100644 --- a/applications/subghz/scenes/subghz_scene_start.c +++ b/applications/subghz/scenes/subghz_scene_start.c @@ -5,6 +5,7 @@ enum SubmenuIndex { SubmenuIndexSaved, SubmenuIndexTest, SubmenuIndexAddManualy, + SubmenuIndexFrequencyAnalyzer, }; void subghz_scene_start_submenu_callback(void* context, uint32_t index) { @@ -27,6 +28,12 @@ void subghz_scene_start_on_enter(void* context) { SubmenuIndexAddManualy, subghz_scene_start_submenu_callback, subghz); + submenu_add_item( + subghz->submenu, + "Frequency Analyzer", + SubmenuIndexFrequencyAnalyzer, + subghz_scene_start_submenu_callback, + subghz); submenu_add_item( subghz->submenu, "Test", SubmenuIndexTest, subghz_scene_start_submenu_callback, subghz); @@ -55,6 +62,11 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) { subghz->scene_manager, SubGhzSceneStart, SubmenuIndexAddManualy); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetType); return true; + } else if(event.event == SubmenuIndexFrequencyAnalyzer) { + scene_manager_set_scene_state( + subghz->scene_manager, SubGhzSceneStart, SubmenuIndexFrequencyAnalyzer); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneFrequencyAnalyzer); + return true; } else if(event.event == SubmenuIndexTest) { scene_manager_set_scene_state( subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest); diff --git a/applications/subghz/scenes/subghz_scene_transmitter.c b/applications/subghz/scenes/subghz_scene_transmitter.c index 85c61240..4aa5f87f 100644 --- a/applications/subghz/scenes/subghz_scene_transmitter.c +++ b/applications/subghz/scenes/subghz_scene_transmitter.c @@ -36,7 +36,9 @@ static void subghz_scene_transmitter_update_data_show(void* context) { if(subghz->txrx->preset == FuriHalSubGhzPresetOok650Async || subghz->txrx->preset == FuriHalSubGhzPresetOok270Async) { snprintf(preset_str, sizeof(preset_str), "AM"); - } else if(subghz->txrx->preset == FuriHalSubGhzPreset2FSKAsync) { + } else if( + subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev238Async || + subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev476Async) { snprintf(preset_str, sizeof(preset_str), "FM"); } else { furi_crash(NULL); diff --git a/applications/subghz/subghz.c b/applications/subghz/subghz.c index 02da799d..7c71e25f 100644 --- a/applications/subghz/subghz.c +++ b/applications/subghz/subghz.c @@ -133,6 +133,13 @@ SubGhz* subghz_alloc() { SubGhzViewVariableItemList, variable_item_list_get_view(subghz->variable_item_list)); + // Frequency Analyzer + subghz->subghz_frequency_analyzer = subghz_frequency_analyzer_alloc(); + view_dispatcher_add_view( + subghz->view_dispatcher, + SubGhzViewFrequencyAnalyzer, + subghz_frequency_analyzer_get_view(subghz->subghz_frequency_analyzer)); + // Carrier Test Module subghz->subghz_test_carrier = subghz_test_carrier_alloc(); view_dispatcher_add_view( @@ -215,6 +222,10 @@ void subghz_free(SubGhz* subghz) { view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewVariableItemList); variable_item_list_free(subghz->variable_item_list); + // Frequency Analyzer + view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewFrequencyAnalyzer); + subghz_frequency_analyzer_free(subghz->subghz_frequency_analyzer); + // Submenu view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewMenu); submenu_free(subghz->submenu); @@ -260,8 +271,12 @@ int32_t subghz_app(void* p) { scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart); } + furi_hal_power_suppress_charge_enter(); + view_dispatcher_run(subghz->view_dispatcher); + furi_hal_power_suppress_charge_exit(); + subghz_free(subghz); return 0; diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c index 1a33beab..94c2cd03 100644 --- a/applications/subghz/subghz_cli.c +++ b/applications/subghz/subghz_cli.c @@ -48,6 +48,8 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) { hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); hal_gpio_write(&gpio_cc1101_g0, true); + furi_hal_power_suppress_charge_enter(); + if(furi_hal_subghz_tx()) { printf("Transmitting at frequency %lu Hz\r\n", frequency); printf("Press CTRL+C to stop\r\n"); @@ -60,6 +62,8 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) { furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate); furi_hal_subghz_sleep(); + + furi_hal_power_suppress_charge_exit(); } void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) { @@ -86,6 +90,8 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) { printf("Receiving at frequency %lu Hz\r\n", frequency); printf("Press CTRL+C to stop\r\n"); + furi_hal_power_suppress_charge_enter(); + furi_hal_subghz_rx(); while(!cli_cmd_interrupt_received(cli)) { @@ -94,6 +100,8 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) { fflush(stdout); } + furi_hal_power_suppress_charge_exit(); + furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate); furi_hal_subghz_sleep(); } @@ -143,6 +151,9 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { furi_hal_subghz_reset(); furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async); frequency = furi_hal_subghz_set_frequency_and_path(frequency); + + furi_hal_power_suppress_charge_enter(); + furi_hal_subghz_start_async_tx(subghz_protocol_encoder_common_yield, encoder); while(!(furi_hal_subghz_is_async_tx_complete() || cli_cmd_interrupt_received(cli))) { @@ -153,6 +164,8 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { furi_hal_subghz_stop_async_tx(); furi_hal_subghz_sleep(); + furi_hal_power_suppress_charge_exit(); + subghz_decoder_princeton_free(protocol); subghz_protocol_encoder_common_free(encoder); } @@ -218,6 +231,8 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) { frequency = furi_hal_subghz_set_frequency_and_path(frequency); hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow); + furi_hal_power_suppress_charge_enter(); + // Prepare and start RX furi_hal_subghz_start_async_rx(subghz_cli_command_rx_callback, instance); @@ -243,6 +258,8 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) { furi_hal_subghz_stop_async_rx(); furi_hal_subghz_sleep(); + furi_hal_power_suppress_charge_exit(); + printf("\r\nPackets recieved %u\r\n", instance->packet_count); // Cleanup diff --git a/applications/subghz/subghz_i.h b/applications/subghz/subghz_i.h index dc1e5a3f..88be9203 100644 --- a/applications/subghz/subghz_i.h +++ b/applications/subghz/subghz_i.h @@ -3,6 +3,7 @@ #include "subghz.h" #include "views/subghz_receiver.h" #include "views/subghz_transmitter.h" +#include "views/subghz_frequency_analyzer.h" #include "views/subghz_test_static.h" #include "views/subghz_test_carrier.h" @@ -98,6 +99,7 @@ struct SubGhz { SubghzTransmitter* subghz_transmitter; VariableItemList* variable_item_list; + SubghzFrequencyAnalyzer* subghz_frequency_analyzer; SubghzTestStatic* subghz_test_static; SubghzTestCarrier* subghz_test_carrier; SubghzTestPacket* subghz_test_packet; @@ -113,6 +115,7 @@ typedef enum { SubGhzViewWidget, SubGhzViewTransmitter, SubGhzViewVariableItemList, + SubGhzViewFrequencyAnalyzer, SubGhzViewStatic, SubGhzViewTestCarrier, SubGhzViewTestPacket, diff --git a/applications/subghz/views/subghz_frequency_analyzer.c b/applications/subghz/views/subghz_frequency_analyzer.c new file mode 100644 index 00000000..c4e6d6bf --- /dev/null +++ b/applications/subghz/views/subghz_frequency_analyzer.c @@ -0,0 +1,170 @@ +#include "subghz_frequency_analyzer.h" +#include "../subghz_i.h" + +#include +#include +#include +#include +#include +#include +#include "../helpers/subghz_frequency_analyzer_worker.h" + +#include + +typedef enum { + SubghzFrequencyAnalyzerStatusIDLE, +} SubghzFrequencyAnalyzerStatus; + +struct SubghzFrequencyAnalyzer { + View* view; + SubGhzFrequencyAnalyzerWorker* worker; + SubghzFrequencyAnalyzerCallback callback; + void* context; +}; + +typedef struct { + uint32_t frequency; + float rssi; +} SubghzFrequencyAnalyzerModel; + +void subghz_frequency_analyzer_set_callback( + SubghzFrequencyAnalyzer* subghz_frequency_analyzer, + SubghzFrequencyAnalyzerCallback callback, + void* context) { + furi_assert(subghz_frequency_analyzer); + furi_assert(callback); + subghz_frequency_analyzer->callback = callback; + subghz_frequency_analyzer->context = context; +} + +void subghz_frequency_analyzer_draw_rssi(Canvas* canvas, float rssi) { + uint8_t x = 48; + uint8_t y = 56; + uint8_t column_number = 0; + if(rssi) { + rssi = (rssi + 90) / 3; + for(size_t i = 1; i < (uint8_t)rssi; i++) { + if(i > 20) break; + if(i % 4) { + column_number++; + canvas_draw_box(canvas, x + 2 * i, y - column_number, 2, 4 + column_number); + } + } + } +} + +void subghz_frequency_analyzer_draw(Canvas* canvas, SubghzFrequencyAnalyzerModel* model) { + char buffer[64]; + + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + canvas_draw_str(canvas, 20, 8, "Frequency Analyzer"); + + canvas_draw_str(canvas, 28, 60, "RSSI"); + subghz_frequency_analyzer_draw_rssi(canvas, model->rssi); + + //Frequency + canvas_set_font(canvas, FontBigNumbers); + snprintf( + buffer, + sizeof(buffer), + "%03ld.%03ld", + model->frequency / 1000000 % 1000, + model->frequency / 1000 % 1000); + canvas_draw_str(canvas, 8, 35, buffer); + canvas_draw_icon(canvas, 96, 24, &I_MHz_25x11); +} + +bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { + furi_assert(context); + //SubghzFrequencyAnalyzer* instance = context; + + if(event->key == InputKeyBack) { + return false; + } + + return true; +} + +void subghz_frequency_analyzer_pair_callback(void* context, uint32_t frequency, float rssi) { + SubghzFrequencyAnalyzer* instance = context; + with_view_model( + instance->view, (SubghzFrequencyAnalyzerModel * model) { + model->rssi = rssi; + model->frequency = frequency; + return true; + }); +} + +void subghz_frequency_analyzer_enter(void* context) { + furi_assert(context); + SubghzFrequencyAnalyzer* instance = context; + + //Start worker + instance->worker = subghz_frequency_analyzer_worker_alloc(); + + subghz_frequency_analyzer_worker_set_pair_callback( + instance->worker, + (SubGhzFrequencyAnalyzerWorkerPairCallback)subghz_frequency_analyzer_pair_callback, + instance); + + subghz_frequency_analyzer_worker_start(instance->worker); + + with_view_model( + instance->view, (SubghzFrequencyAnalyzerModel * model) { + model->rssi = 0; + model->frequency = 0; + return true; + }); +} + +void subghz_frequency_analyzer_exit(void* context) { + furi_assert(context); + SubghzFrequencyAnalyzer* instance = context; + + //Stop worker + if(subghz_frequency_analyzer_worker_is_running(instance->worker)) { + subghz_frequency_analyzer_worker_stop(instance->worker); + } + subghz_frequency_analyzer_worker_free(instance->worker); + + with_view_model( + instance->view, (SubghzFrequencyAnalyzerModel * model) { + model->rssi = 0; + return true; + }); +} + +SubghzFrequencyAnalyzer* subghz_frequency_analyzer_alloc() { + SubghzFrequencyAnalyzer* instance = furi_alloc(sizeof(SubghzFrequencyAnalyzer)); + + // View allocation and configuration + instance->view = view_alloc(); + view_allocate_model( + instance->view, ViewModelTypeLocking, sizeof(SubghzFrequencyAnalyzerModel)); + view_set_context(instance->view, instance); + view_set_draw_callback(instance->view, (ViewDrawCallback)subghz_frequency_analyzer_draw); + view_set_input_callback(instance->view, subghz_frequency_analyzer_input); + view_set_enter_callback(instance->view, subghz_frequency_analyzer_enter); + view_set_exit_callback(instance->view, subghz_frequency_analyzer_exit); + + with_view_model( + instance->view, (SubghzFrequencyAnalyzerModel * model) { + model->rssi = 0; + return true; + }); + + return instance; +} + +void subghz_frequency_analyzer_free(SubghzFrequencyAnalyzer* instance) { + furi_assert(instance); + + view_free(instance->view); + free(instance); +} + +View* subghz_frequency_analyzer_get_view(SubghzFrequencyAnalyzer* instance) { + furi_assert(instance); + return instance->view; +} \ No newline at end of file diff --git a/applications/subghz/views/subghz_frequency_analyzer.h b/applications/subghz/views/subghz_frequency_analyzer.h new file mode 100644 index 00000000..ebfcb173 --- /dev/null +++ b/applications/subghz/views/subghz_frequency_analyzer.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +typedef enum { + SubghzFrequencyAnalyzerEventOnlyRx, +} SubghzFrequencyAnalyzerEvent; + +typedef struct SubghzFrequencyAnalyzer SubghzFrequencyAnalyzer; + +typedef void (*SubghzFrequencyAnalyzerCallback)(SubghzFrequencyAnalyzerEvent event, void* context); + +void subghz_frequency_analyzer_set_callback( + SubghzFrequencyAnalyzer* subghz_frequency_analyzer, + SubghzFrequencyAnalyzerCallback callback, + void* context); + +SubghzFrequencyAnalyzer* subghz_frequency_analyzer_alloc(); + +void subghz_frequency_analyzer_free(SubghzFrequencyAnalyzer* subghz_static); + +View* subghz_frequency_analyzer_get_view(SubghzFrequencyAnalyzer* subghz_static); diff --git a/applications/tests/rpc/rpc_test.c b/applications/tests/rpc/rpc_test.c new file mode 100644 index 00000000..1ac2b490 --- /dev/null +++ b/applications/tests/rpc/rpc_test.c @@ -0,0 +1,1163 @@ +#include "flipper.pb.h" +#include "furi-hal-delay.h" +#include "furi/check.h" +#include "furi/record.h" +#include "pb_decode.h" +#include "rpc/rpc_i.h" +#include "storage.pb.h" +#include "storage/storage.h" +#include +#include "../minunit.h" +#include +#include +#include +#include +#include +#include +#include +#include + +LIST_DEF(MsgList, PB_Main, M_POD_OPLIST) +#define M_OPL_MsgList_t() LIST_OPLIST(MsgList) + +/* MinUnit test framework doesn't allow passing context into tests, + * so we have to use global variables + */ +static Rpc* rpc = NULL; +static RpcSession* session = NULL; +static StreamBufferHandle_t output_stream = NULL; +static uint32_t command_id = 0; + +#define TEST_RPC_TAG "TEST_RPC" +#define MAX_RECEIVE_OUTPUT_TIMEOUT 3000 +#define MAX_NAME_LENGTH 255 +#define MAX_DATA_SIZE 512 // have to be exact as in rpc_storage.c +#define TEST_DIR TEST_DIR_NAME "/" +#define TEST_DIR_NAME "/ext/unit_tests_tmp" +#define MD5SUM_SIZE 16 + +#define PING_REQUEST 0 +#define PING_RESPONSE 1 +#define WRITE_REQUEST 0 +#define READ_RESPONSE 1 + +#define DEBUG_PRINT 0 + +#define BYTES(x) (x), sizeof(x) + +static void output_bytes_callback(void* ctx, uint8_t* got_bytes, size_t got_size); +static void clean_directory(Storage* fs_api, const char* clean_dir); +static void + test_rpc_add_empty_to_list(MsgList_t msg_list, PB_CommandStatus status, uint32_t command_id); +static void test_rpc_encode_and_feed(MsgList_t msg_list); +static void test_rpc_encode_and_feed_one(PB_Main* request); +static void test_rpc_compare_messages(PB_Main* result, PB_Main* expected); +static void test_rpc_decode_and_compare(MsgList_t expected_msg_list); +static void test_rpc_free_msg_list(MsgList_t msg_list); + +static void test_rpc_storage_setup(void) { + furi_assert(!rpc); + furi_assert(!session); + furi_assert(!output_stream); + + rpc = furi_record_open("rpc"); + for(int i = 0; !session && (i < 10000); ++i) { + session = rpc_open_session(rpc); + delay(1); + } + furi_assert(session); + + Storage* fs_api = furi_record_open("storage"); + clean_directory(fs_api, TEST_DIR_NAME); + furi_record_close("storage"); + + output_stream = xStreamBufferCreate(1000, 1); + mu_assert(session, "failed to start session"); + rpc_set_send_bytes_callback(session, output_bytes_callback, output_stream); +} + +static void test_rpc_storage_teardown(void) { + Storage* fs_api = furi_record_open("storage"); + clean_directory(fs_api, TEST_DIR_NAME); + furi_record_close("storage"); + + rpc_close_session(session); + furi_record_close("rpc"); + vStreamBufferDelete(output_stream); + ++command_id; + output_stream = NULL; + rpc = NULL; + session = NULL; +} + +static void clean_directory(Storage* fs_api, const char* clean_dir) { + furi_assert(fs_api); + furi_assert(clean_dir); + + File* dir = storage_file_alloc(fs_api); + if(storage_dir_open(dir, clean_dir)) { + FileInfo fileinfo; + char* name = furi_alloc(MAX_NAME_LENGTH + 1); + while(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) { + char* fullname = furi_alloc(strlen(clean_dir) + strlen(name) + 1 + 1); + sprintf(fullname, "%s/%s", clean_dir, name); + if(fileinfo.flags & FSF_DIRECTORY) { + clean_directory(fs_api, fullname); + } + storage_common_remove(fs_api, fullname); + free(fullname); + } + free(name); + } else { + FS_Error error = storage_common_mkdir(fs_api, clean_dir); + (void)error; + furi_assert(error == FSE_OK); + } + + storage_dir_close(dir); + storage_file_free(dir); +} + +static void test_rpc_print_message_list(MsgList_t msg_list) { +#if DEBUG_PRINT + MsgList_reverse(msg_list); + for + M_EACH(msg, msg_list, MsgList_t) { + rpc_print_message(msg); + } + MsgList_reverse(msg_list); +#endif +} + +static PB_CommandStatus test_rpc_storage_get_file_error(File* file) { + FS_Error fs_error = storage_file_get_error(file); + PB_CommandStatus pb_error; + switch(fs_error) { + case FSE_OK: + pb_error = PB_CommandStatus_OK; + break; + case FSE_INVALID_NAME: + pb_error = PB_CommandStatus_ERROR_STORAGE_INVALID_NAME; + break; + case FSE_INVALID_PARAMETER: + pb_error = PB_CommandStatus_ERROR_STORAGE_INVALID_PARAMETER; + break; + case FSE_INTERNAL: + pb_error = PB_CommandStatus_ERROR_STORAGE_INTERNAL; + break; + case FSE_ALREADY_OPEN: + pb_error = PB_CommandStatus_ERROR_STORAGE_ALREADY_OPEN; + break; + case FSE_DENIED: + pb_error = PB_CommandStatus_ERROR_STORAGE_DENIED; + break; + case FSE_EXIST: + pb_error = PB_CommandStatus_ERROR_STORAGE_EXIST; + break; + case FSE_NOT_EXIST: + pb_error = PB_CommandStatus_ERROR_STORAGE_NOT_EXIST; + break; + case FSE_NOT_READY: + pb_error = PB_CommandStatus_ERROR_STORAGE_NOT_READY; + break; + case FSE_NOT_IMPLEMENTED: + pb_error = PB_CommandStatus_ERROR_STORAGE_NOT_IMPLEMENTED; + break; + default: + pb_error = PB_CommandStatus_ERROR; + break; + } + + return pb_error; +} + +static void output_bytes_callback(void* ctx, uint8_t* got_bytes, size_t got_size) { + StreamBufferHandle_t stream_buffer = ctx; + + size_t bytes_sent = xStreamBufferSend(stream_buffer, got_bytes, got_size, osWaitForever); + (void)bytes_sent; + furi_assert(bytes_sent == got_size); +} + +static void test_rpc_add_ping_to_list(MsgList_t msg_list, bool request, uint32_t command_id) { + PB_Main* response = MsgList_push_new(msg_list); + response->command_id = command_id; + response->command_status = PB_CommandStatus_OK; + response->cb_content.funcs.encode = NULL; + response->has_next = false; + response->which_content = (request == PING_REQUEST) ? PB_Main_ping_request_tag : + PB_Main_ping_response_tag; +} + +static void test_rpc_create_simple_message( + PB_Main* message, + uint16_t tag, + const char* str, + uint32_t command_id) { + furi_assert(message); + furi_assert(str); + + char* str_copy = furi_alloc(strlen(str) + 1); + strcpy(str_copy, str); + message->command_id = command_id; + message->command_status = PB_CommandStatus_OK; + message->cb_content.funcs.encode = NULL; + message->which_content = tag; + message->has_next = false; + switch(tag) { + case PB_Main_storage_list_request_tag: + message->content.storage_list_request.path = str_copy; + break; + case PB_Main_storage_mkdir_request_tag: + message->content.storage_mkdir_request.path = str_copy; + break; + case PB_Main_storage_read_request_tag: + message->content.storage_read_request.path = str_copy; + break; + case PB_Main_storage_delete_request_tag: + message->content.storage_delete_request.path = str_copy; + break; + case PB_Main_storage_md5sum_request_tag: + message->content.storage_md5sum_request.path = str_copy; + break; + case PB_Main_storage_md5sum_response_tag: { + char* md5sum = message->content.storage_md5sum_response.md5sum; + size_t md5sum_size = sizeof(message->content.storage_md5sum_response.md5sum); + furi_assert((strlen(str) + 1) <= md5sum_size); + memcpy(md5sum, str_copy, md5sum_size); + free(str_copy); + break; + } + default: + furi_assert(0); + break; + } +} + +static void test_rpc_add_read_or_write_to_list( + MsgList_t msg_list, + bool write, + const char* path, + const uint8_t* pattern, + size_t pattern_size, + size_t pattern_repeats, + uint32_t command_id) { + furi_assert(pattern_repeats > 0); + + do { + PB_Main* request = MsgList_push_new(msg_list); + PB_Storage_File* msg_file = NULL; + + request->command_id = command_id; + request->command_status = PB_CommandStatus_OK; + + if(write == WRITE_REQUEST) { + size_t path_size = strlen(path) + 1; + request->content.storage_write_request.path = furi_alloc(path_size); + strncpy(request->content.storage_write_request.path, path, path_size); + request->which_content = PB_Main_storage_write_request_tag; + request->content.storage_write_request.has_file = true; + msg_file = &request->content.storage_write_request.file; + } else { + request->which_content = PB_Main_storage_read_response_tag; + request->content.storage_read_response.has_file = true; + msg_file = &request->content.storage_read_response.file; + } + + msg_file->data = furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(pattern_size)); + msg_file->data->size = pattern_size; + + memcpy(msg_file->data->bytes, pattern, pattern_size); + + --pattern_repeats; + request->has_next = (pattern_repeats > 0); + } while(pattern_repeats); +} + +static void test_rpc_encode_and_feed_one(PB_Main* request) { + furi_assert(request); + + pb_ostream_t ostream = PB_OSTREAM_SIZING; + + bool result = pb_encode_ex(&ostream, &PB_Main_msg, request, PB_ENCODE_DELIMITED); + furi_check(result && ostream.bytes_written); + + uint8_t* buffer = furi_alloc(ostream.bytes_written); + ostream = pb_ostream_from_buffer(buffer, ostream.bytes_written); + + pb_encode_ex(&ostream, &PB_Main_msg, request, PB_ENCODE_DELIMITED); + + size_t bytes_left = ostream.bytes_written; + uint8_t* buffer_ptr = buffer; + do { + size_t bytes_sent = rpc_feed_bytes(session, buffer_ptr, bytes_left, 1000); + mu_check(bytes_sent > 0); + + bytes_left -= bytes_sent; + buffer_ptr += bytes_sent; + } while(bytes_left); + + free(buffer); + pb_release(&PB_Main_msg, request); +} + +static void test_rpc_encode_and_feed(MsgList_t msg_list) { + MsgList_reverse(msg_list); + for + M_EACH(request, msg_list, MsgList_t) { + test_rpc_encode_and_feed_one(request); + } + MsgList_reverse(msg_list); +} + +static void + test_rpc_compare_file(PB_Storage_File* result_msg_file, PB_Storage_File* expected_msg_file) { + mu_check(!result_msg_file->name == !expected_msg_file->name); + if(result_msg_file->name) { + mu_check(!strcmp(result_msg_file->name, expected_msg_file->name)); + } + mu_check(result_msg_file->size == expected_msg_file->size); + mu_check(result_msg_file->type == expected_msg_file->type); + + mu_check(!result_msg_file->data == !expected_msg_file->data); + mu_check(result_msg_file->data->size == expected_msg_file->data->size); + for(int i = 0; i < result_msg_file->data->size; ++i) { + mu_check(result_msg_file->data->bytes[i] == expected_msg_file->data->bytes[i]); + } +} + +static void test_rpc_compare_messages(PB_Main* result, PB_Main* expected) { + mu_check(result->command_id == expected->command_id); + mu_check(result->command_status == expected->command_status); + mu_check(result->has_next == expected->has_next); + mu_check(result->which_content == expected->which_content); + if(result->command_status != PB_CommandStatus_OK) { + mu_check(result->which_content == PB_Main_empty_tag); + } + + switch(result->which_content) { + case PB_Main_empty_tag: + case PB_Main_ping_response_tag: + /* nothing to check */ + break; + case PB_Main_ping_request_tag: + case PB_Main_storage_list_request_tag: + case PB_Main_storage_read_request_tag: + case PB_Main_storage_write_request_tag: + case PB_Main_storage_delete_request_tag: + case PB_Main_storage_mkdir_request_tag: + case PB_Main_storage_md5sum_request_tag: + /* rpc doesn't send it */ + mu_check(0); + break; + case PB_Main_app_lock_status_response_tag: { + bool result_locked = result->content.app_lock_status_response.locked; + bool expected_locked = expected->content.app_lock_status_response.locked; + mu_check(result_locked == expected_locked); + break; + } + case PB_Main_storage_read_response_tag: { + bool result_has_msg_file = result->content.storage_read_response.has_file; + bool expected_has_msg_file = expected->content.storage_read_response.has_file; + mu_check(result_has_msg_file == expected_has_msg_file); + + if(result_has_msg_file) { + PB_Storage_File* result_msg_file = &result->content.storage_read_response.file; + PB_Storage_File* expected_msg_file = &expected->content.storage_read_response.file; + test_rpc_compare_file(result_msg_file, expected_msg_file); + } else { + mu_check(0); + } + } break; + case PB_Main_storage_list_response_tag: { + size_t expected_msg_files = expected->content.storage_list_response.file_count; + size_t result_msg_files = result->content.storage_list_response.file_count; + mu_check(result_msg_files == expected_msg_files); + for(int i = 0; i < expected_msg_files; ++i) { + PB_Storage_File* result_msg_file = &result->content.storage_list_response.file[i]; + PB_Storage_File* expected_msg_file = &expected->content.storage_list_response.file[i]; + test_rpc_compare_file(result_msg_file, expected_msg_file); + } + break; + } + case PB_Main_storage_md5sum_response_tag: { + char* result_md5sum = result->content.storage_md5sum_response.md5sum; + char* expected_md5sum = expected->content.storage_md5sum_response.md5sum; + mu_check(!strcmp(result_md5sum, expected_md5sum)); + break; + } + default: + furi_assert(0); + break; + } +} + +static bool test_rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) { + StreamBufferHandle_t stream_buffer = istream->state; + size_t bytes_received = 0; + + bytes_received = xStreamBufferReceive(stream_buffer, buf, count, MAX_RECEIVE_OUTPUT_TIMEOUT); + return (count == bytes_received); +} + +static void test_rpc_storage_list_create_expected_list( + MsgList_t msg_list, + const char* path, + uint32_t command_id) { + Storage* fs_api = furi_record_open("storage"); + File* dir = storage_file_alloc(fs_api); + + PB_Main response = { + .command_id = command_id, + .has_next = false, + .which_content = PB_Main_storage_list_request_tag, + /* other fields (e.g. msg_files ptrs) explicitly initialized by 0 */ + }; + PB_Storage_ListResponse* list = &response.content.storage_list_response; + response.which_content = PB_Main_storage_list_response_tag; + + bool finish = false; + int i = 0; + + if(storage_dir_open(dir, path)) { + response.command_status = PB_CommandStatus_OK; + } else { + response.command_status = test_rpc_storage_get_file_error(dir); + response.which_content = PB_Main_empty_tag; + finish = true; + } + + while(!finish) { + FileInfo fileinfo; + char* name = furi_alloc(MAX_NAME_LENGTH + 1); + if(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) { + if(i == COUNT_OF(list->file)) { + list->file_count = i; + response.has_next = true; + MsgList_push_back(msg_list, response); + i = 0; + } + list->file[i].type = (fileinfo.flags & FSF_DIRECTORY) ? PB_Storage_File_FileType_DIR : + PB_Storage_File_FileType_FILE; + list->file[i].size = fileinfo.size; + list->file[i].data = NULL; + /* memory free inside rpc_encode_and_send() -> pb_release() */ + list->file[i].name = name; + ++i; + } else { + finish = true; + free(name); + } + } + + list->file_count = i; + response.has_next = false; + MsgList_push_back(msg_list, response); + + storage_dir_close(dir); + storage_file_free(dir); + + furi_record_close("storage"); +} + +static void test_rpc_decode_and_compare(MsgList_t expected_msg_list) { + furi_assert(!MsgList_empty_p(expected_msg_list)); + + pb_istream_t istream = { + .callback = test_rpc_pb_stream_read, + .state = output_stream, + .errmsg = NULL, + .bytes_left = 0x7FFFFFFF, + }; + /* other fields explicitly initialized by 0 */ + PB_Main result = {.cb_content.funcs.decode = NULL}; + + /* mlib adds msg_files into start of list, so reverse it */ + MsgList_reverse(expected_msg_list); + for + M_EACH(expected_msg, expected_msg_list, MsgList_t) { + if(!pb_decode_ex(&istream, &PB_Main_msg, &result, PB_DECODE_DELIMITED)) { + mu_assert( + 0, + "not all expected messages decoded (maybe increase MAX_RECEIVE_OUTPUT_TIMEOUT)"); + break; + } + + test_rpc_compare_messages(&result, expected_msg); + pb_release(&PB_Main_msg, &result); + } + MsgList_reverse(expected_msg_list); +} + +static void test_rpc_free_msg_list(MsgList_t msg_list) { + for + M_EACH(it, msg_list, MsgList_t) { + pb_release(&PB_Main_msg, it); + } + MsgList_clear(msg_list); +} + +static void test_rpc_storage_list_run(const char* path, uint32_t command_id) { + PB_Main request; + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + test_rpc_create_simple_message(&request, PB_Main_storage_list_request_tag, path, command_id); + test_rpc_storage_list_create_expected_list(expected_msg_list, path, command_id); + test_rpc_encode_and_feed_one(&request); + test_rpc_decode_and_compare(expected_msg_list); + + pb_release(&PB_Main_msg, &request); + test_rpc_free_msg_list(expected_msg_list); +} + +MU_TEST(test_storage_list) { + test_rpc_storage_list_run("/ext/nfc", ++command_id); + + test_rpc_storage_list_run("/int", ++command_id); + test_rpc_storage_list_run("/ext", ++command_id); + test_rpc_storage_list_run("/ext/irda", ++command_id); + test_rpc_storage_list_run("/ext/ibutton", ++command_id); + test_rpc_storage_list_run("/ext/lfrfid", ++command_id); + test_rpc_storage_list_run("error_path", ++command_id); +} + +static void + test_rpc_add_empty_to_list(MsgList_t msg_list, PB_CommandStatus status, uint32_t command_id) { + PB_Main* response = MsgList_push_new(msg_list); + response->command_id = command_id; + response->command_status = status; + response->cb_content.funcs.encode = NULL; + response->has_next = false; + response->which_content = PB_Main_empty_tag; +} + +static void test_rpc_add_read_to_list_by_reading_real_file( + MsgList_t msg_list, + const char* path, + uint32_t command_id) { + furi_assert(MsgList_empty_p(msg_list)); + Storage* fs_api = furi_record_open("storage"); + File* file = storage_file_alloc(fs_api); + + bool result = false; + + if(storage_file_open(file, path, FSAM_READ, FSOM_OPEN_EXISTING)) { + size_t size_left = storage_file_size(file); + + do { + PB_Main* response = MsgList_push_new(msg_list); + response->command_id = command_id; + response->command_status = PB_CommandStatus_OK; + response->has_next = false; + response->which_content = PB_Main_storage_read_response_tag; + response->content.storage_read_response.has_file = true; + + response->content.storage_read_response.file.data = + furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(MIN(size_left, MAX_DATA_SIZE))); + uint8_t* buffer = response->content.storage_read_response.file.data->bytes; + uint16_t* read_size_msg = &response->content.storage_read_response.file.data->size; + size_t read_size = MIN(size_left, MAX_DATA_SIZE); + *read_size_msg = storage_file_read(file, buffer, read_size); + size_left -= read_size; + result = (*read_size_msg == read_size); + + if(result) { + response->has_next = (size_left > 0); + } + } while((size_left != 0) && result); + + if(!result) { + test_rpc_add_empty_to_list( + msg_list, test_rpc_storage_get_file_error(file), command_id); + } + } else { + test_rpc_add_empty_to_list(msg_list, test_rpc_storage_get_file_error(file), command_id); + } + + storage_file_close(file); + storage_file_free(file); + + furi_record_close("storage"); +} + +static void test_storage_read_run(const char* path, uint32_t command_id) { + PB_Main request; + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + test_rpc_add_read_to_list_by_reading_real_file(expected_msg_list, path, command_id); + test_rpc_create_simple_message(&request, PB_Main_storage_read_request_tag, path, command_id); + test_rpc_encode_and_feed_one(&request); + test_rpc_decode_and_compare(expected_msg_list); + + pb_release(&PB_Main_msg, &request); + test_rpc_free_msg_list(expected_msg_list); +} + +static void test_create_dir(const char* path) { + Storage* fs_api = furi_record_open("storage"); + FS_Error error = storage_common_mkdir(fs_api, path); + (void)error; + furi_assert((error == FSE_OK) || (error == FSE_EXIST)); + furi_record_close("storage"); +} + +static void test_create_file(const char* path, size_t size) { + Storage* fs_api = furi_record_open("storage"); + File* file = storage_file_alloc(fs_api); + + if(storage_file_open(file, path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) { + uint8_t buf[128] = {0}; + for(int i = 0; i < sizeof(buf); ++i) { + buf[i] = '0' + (i % 10); + } + while(size) { + size_t written = storage_file_write(file, buf, MIN(size, sizeof(buf))); + furi_assert(written); + size -= written; + } + } + + storage_file_close(file); + storage_file_free(file); + + furi_record_close("storage"); +} + +MU_TEST(test_storage_read) { + test_create_file(TEST_DIR "empty.txt", 0); + test_create_file(TEST_DIR "file1.txt", 1); + test_create_file(TEST_DIR "file2.txt", MAX_DATA_SIZE); + test_create_file(TEST_DIR "file3.txt", MAX_DATA_SIZE + 1); + test_create_file(TEST_DIR "file4.txt", (MAX_DATA_SIZE * 2) + 1); + + test_storage_read_run(TEST_DIR "empty.txt", ++command_id); + test_storage_read_run(TEST_DIR "file1.txt", ++command_id); + test_storage_read_run(TEST_DIR "file2.txt", ++command_id); + test_storage_read_run(TEST_DIR "file3.txt", ++command_id); + test_storage_read_run(TEST_DIR "file4.txt", ++command_id); +} + +static void test_storage_write_run( + const char* path, + size_t write_size, + size_t write_count, + uint32_t command_id, + PB_CommandStatus status) { + MsgList_t input_msg_list; + MsgList_init(input_msg_list); + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + uint8_t* buf = furi_alloc(write_size); + for(int i = 0; i < write_size; ++i) { + buf[i] = '0' + (i % 10); + } + + test_rpc_add_read_or_write_to_list( + input_msg_list, WRITE_REQUEST, path, buf, write_size, write_count, command_id); + test_rpc_add_empty_to_list(expected_msg_list, status, command_id); + test_rpc_encode_and_feed(input_msg_list); + test_rpc_decode_and_compare(expected_msg_list); + + test_rpc_free_msg_list(input_msg_list); + test_rpc_free_msg_list(expected_msg_list); + + free(buf); +} + +static void test_storage_write_read_run( + const char* path, + const uint8_t* pattern, + size_t pattern_size, + size_t pattern_repeats, + uint32_t* command_id) { + MsgList_t input_msg_list; + MsgList_init(input_msg_list); + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + test_rpc_add_read_or_write_to_list( + input_msg_list, WRITE_REQUEST, path, pattern, pattern_size, pattern_repeats, ++*command_id); + test_rpc_add_empty_to_list(expected_msg_list, PB_CommandStatus_OK, *command_id); + + test_rpc_create_simple_message( + MsgList_push_raw(input_msg_list), PB_Main_storage_read_request_tag, path, ++*command_id); + test_rpc_add_read_or_write_to_list( + expected_msg_list, + READ_RESPONSE, + path, + pattern, + pattern_size, + pattern_repeats, + *command_id); + + test_rpc_print_message_list(input_msg_list); + test_rpc_print_message_list(expected_msg_list); + + test_rpc_encode_and_feed(input_msg_list); + test_rpc_decode_and_compare(expected_msg_list); + + test_rpc_free_msg_list(input_msg_list); + test_rpc_free_msg_list(expected_msg_list); +} + +MU_TEST(test_storage_write_read) { + uint8_t pattern1[] = "abcdefgh"; + test_storage_write_read_run(TEST_DIR "test1.txt", pattern1, sizeof(pattern1), 1, &command_id); + test_storage_write_read_run(TEST_DIR "test2.txt", pattern1, 1, 1, &command_id); + test_storage_write_read_run(TEST_DIR "test3.txt", pattern1, 0, 1, &command_id); +} + +MU_TEST(test_storage_write) { + test_storage_write_run( + TEST_DIR "afaefo/aefaef/aef/aef/test1.txt", + 1, + 1, + ++command_id, + PB_CommandStatus_ERROR_STORAGE_NOT_EXIST); + test_storage_write_run(TEST_DIR "test1.txt", 100, 1, ++command_id, PB_CommandStatus_OK); + test_storage_write_run(TEST_DIR "test2.txt", 100, 3, ++command_id, PB_CommandStatus_OK); + test_storage_write_run(TEST_DIR "test1.txt", 100, 3, ++command_id, PB_CommandStatus_OK); + test_storage_write_run(TEST_DIR "test2.txt", 100, 3, ++command_id, PB_CommandStatus_OK); + test_storage_write_run( + TEST_DIR "afaefo/aefaef/aef/aef/test1.txt", + 1, + 1, + ++command_id, + PB_CommandStatus_ERROR_STORAGE_NOT_EXIST); + test_storage_write_run(TEST_DIR "test2.txt", 1, 50, ++command_id, PB_CommandStatus_OK); + test_storage_write_run(TEST_DIR "test2.txt", 512, 3, ++command_id, PB_CommandStatus_OK); +} + +MU_TEST(test_storage_interrupt_continuous_same_system) { + MsgList_t input_msg_list; + MsgList_init(input_msg_list); + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + uint8_t pattern[16] = {0}; + + test_rpc_add_read_or_write_to_list( + input_msg_list, + WRITE_REQUEST, + TEST_DIR "test1.txt", + pattern, + sizeof(pattern), + 3, + command_id); + + /* replace last packet (has_next == false) with another command */ + PB_Main message_to_remove; + MsgList_pop_back(&message_to_remove, input_msg_list); + pb_release(&PB_Main_msg, &message_to_remove); + test_rpc_create_simple_message( + MsgList_push_new(input_msg_list), + PB_Main_storage_mkdir_request_tag, + TEST_DIR "dir1", + command_id + 1); + test_rpc_add_read_or_write_to_list( + input_msg_list, + WRITE_REQUEST, + TEST_DIR "test2.txt", + pattern, + sizeof(pattern), + 3, + command_id); + + test_rpc_add_empty_to_list( + expected_msg_list, PB_CommandStatus_ERROR_CONTINUOUS_COMMAND_INTERRUPTED, command_id); + test_rpc_add_empty_to_list(expected_msg_list, PB_CommandStatus_OK, command_id + 1); + + test_rpc_encode_and_feed(input_msg_list); + test_rpc_decode_and_compare(expected_msg_list); + + test_rpc_free_msg_list(input_msg_list); + test_rpc_free_msg_list(expected_msg_list); +} + +MU_TEST(test_storage_interrupt_continuous_another_system) { + MsgList_t input_msg_list; + MsgList_init(input_msg_list); + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + uint8_t pattern[16] = {0}; + + test_rpc_add_read_or_write_to_list( + input_msg_list, + WRITE_REQUEST, + TEST_DIR "test1.txt", + pattern, + sizeof(pattern), + 3, + command_id); + + PB_Main message = { + .command_id = command_id + 1, + .command_status = PB_CommandStatus_OK, + .cb_content.funcs.encode = NULL, + .has_next = false, + .which_content = PB_Main_ping_request_tag, + }; + + MsgList_it_t it; + MsgList_it(it, input_msg_list); + MsgList_next(it); + MsgList_insert(input_msg_list, it, message); + + test_rpc_add_read_or_write_to_list( + input_msg_list, + WRITE_REQUEST, + TEST_DIR "test2.txt", + pattern, + sizeof(pattern), + 3, + command_id + 2); + + test_rpc_add_ping_to_list(expected_msg_list, PING_RESPONSE, command_id + 1); + test_rpc_add_empty_to_list(expected_msg_list, PB_CommandStatus_OK, command_id); + test_rpc_add_empty_to_list(expected_msg_list, PB_CommandStatus_OK, command_id + 2); + + test_rpc_encode_and_feed(input_msg_list); + test_rpc_decode_and_compare(expected_msg_list); + + test_rpc_free_msg_list(input_msg_list); + test_rpc_free_msg_list(expected_msg_list); +} + +static void test_storage_delete_run(const char* path, size_t command_id, PB_CommandStatus status) { + PB_Main request; + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + test_rpc_create_simple_message(&request, PB_Main_storage_delete_request_tag, path, command_id); + test_rpc_add_empty_to_list(expected_msg_list, status, command_id); + + test_rpc_encode_and_feed_one(&request); + test_rpc_decode_and_compare(expected_msg_list); + + pb_release(&PB_Main_msg, &request); + test_rpc_free_msg_list(expected_msg_list); +} + +MU_TEST(test_storage_delete) { + test_create_file(TEST_DIR "empty.txt", 0); + test_storage_delete_run(TEST_DIR "empty.txt", ++command_id, PB_CommandStatus_OK); + test_storage_delete_run( + TEST_DIR "empty.txt", ++command_id, PB_CommandStatus_ERROR_STORAGE_NOT_EXIST); + + test_create_dir(TEST_DIR "dir1"); + test_storage_delete_run(TEST_DIR "dir1", ++command_id, PB_CommandStatus_OK); + test_storage_delete_run( + TEST_DIR "dir1", ++command_id, PB_CommandStatus_ERROR_STORAGE_NOT_EXIST); +} + +static void test_storage_mkdir_run(const char* path, size_t command_id, PB_CommandStatus status) { + PB_Main request; + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + test_rpc_create_simple_message(&request, PB_Main_storage_mkdir_request_tag, path, command_id); + test_rpc_add_empty_to_list(expected_msg_list, status, command_id); + + test_rpc_encode_and_feed_one(&request); + test_rpc_decode_and_compare(expected_msg_list); + + pb_release(&PB_Main_msg, &request); + test_rpc_free_msg_list(expected_msg_list); +} + +MU_TEST(test_storage_mkdir) { + test_storage_mkdir_run(TEST_DIR "dir1", ++command_id, PB_CommandStatus_OK); + test_storage_mkdir_run(TEST_DIR "dir1", ++command_id, PB_CommandStatus_ERROR_STORAGE_EXIST); + test_create_dir(TEST_DIR "dir2"); + test_storage_mkdir_run(TEST_DIR "dir2", ++command_id, PB_CommandStatus_ERROR_STORAGE_EXIST); + + Storage* fs_api = furi_record_open("storage"); + FS_Error error = storage_common_remove(fs_api, TEST_DIR "dir1"); + (void)error; + furi_assert(error == FSE_OK); + furi_record_close("storage"); + + test_storage_mkdir_run(TEST_DIR "dir1", ++command_id, PB_CommandStatus_OK); +} + +static void test_storage_calculate_md5sum(const char* path, char* md5sum) { + Storage* api = furi_record_open("storage"); + File* file = storage_file_alloc(api); + + if(storage_file_open(file, path, FSAM_READ, FSOM_OPEN_EXISTING)) { + const uint16_t once_read_size = 512; + const uint8_t hash_size = MD5SUM_SIZE; + uint8_t* data = malloc(once_read_size); + 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 read_size = storage_file_read(file, data, once_read_size); + if(read_size == 0) break; + md5_update(md5_ctx, data, read_size); + } + md5_finish(md5_ctx, hash); + free(md5_ctx); + + for(uint8_t i = 0; i < hash_size; i++) { + md5sum += sprintf(md5sum, "%02x", hash[i]); + } + + free(hash); + free(data); + } else { + furi_assert(0); + } + + storage_file_close(file); + storage_file_free(file); + + furi_record_close("storage"); +} + +static void test_storage_md5sum_run( + const char* path, + uint32_t command_id, + const char* md5sum, + PB_CommandStatus status) { + PB_Main request; + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + test_rpc_create_simple_message(&request, PB_Main_storage_md5sum_request_tag, path, command_id); + if(status == PB_CommandStatus_OK) { + PB_Main* response = MsgList_push_new(expected_msg_list); + test_rpc_create_simple_message( + response, PB_Main_storage_md5sum_response_tag, md5sum, command_id); + response->command_status = status; + } else { + test_rpc_add_empty_to_list(expected_msg_list, status, command_id); + } + + test_rpc_encode_and_feed_one(&request); + test_rpc_decode_and_compare(expected_msg_list); + + pb_release(&PB_Main_msg, &request); + test_rpc_free_msg_list(expected_msg_list); +} + +MU_TEST(test_storage_md5sum) { + char md5sum1[MD5SUM_SIZE * 2 + 1] = {0}; + char md5sum2[MD5SUM_SIZE * 2 + 1] = {0}; + char md5sum3[MD5SUM_SIZE * 2 + 1] = {0}; + + test_storage_md5sum_run( + TEST_DIR "test1.txt", ++command_id, "", PB_CommandStatus_ERROR_STORAGE_NOT_EXIST); + + test_create_file(TEST_DIR "file1.txt", 0); + test_create_file(TEST_DIR "file2.txt", 1); + test_create_file(TEST_DIR "file3.txt", 512); + test_storage_calculate_md5sum(TEST_DIR "file1.txt", md5sum1); + test_storage_calculate_md5sum(TEST_DIR "file2.txt", md5sum2); + test_storage_calculate_md5sum(TEST_DIR "file3.txt", md5sum3); + + test_storage_md5sum_run(TEST_DIR "file1.txt", ++command_id, md5sum1, PB_CommandStatus_OK); + test_storage_md5sum_run(TEST_DIR "file1.txt", ++command_id, md5sum1, PB_CommandStatus_OK); + + test_storage_md5sum_run(TEST_DIR "file2.txt", ++command_id, md5sum2, PB_CommandStatus_OK); + test_storage_md5sum_run(TEST_DIR "file2.txt", ++command_id, md5sum2, PB_CommandStatus_OK); + + test_storage_md5sum_run(TEST_DIR "file3.txt", ++command_id, md5sum3, PB_CommandStatus_OK); + test_storage_md5sum_run(TEST_DIR "file3.txt", ++command_id, md5sum3, PB_CommandStatus_OK); + + test_storage_md5sum_run(TEST_DIR "file2.txt", ++command_id, md5sum2, PB_CommandStatus_OK); + test_storage_md5sum_run(TEST_DIR "file3.txt", ++command_id, md5sum3, PB_CommandStatus_OK); + test_storage_md5sum_run(TEST_DIR "file1.txt", ++command_id, md5sum1, PB_CommandStatus_OK); + test_storage_md5sum_run(TEST_DIR "file2.txt", ++command_id, md5sum2, PB_CommandStatus_OK); +} + +MU_TEST(test_ping) { + MsgList_t input_msg_list; + MsgList_init(input_msg_list); + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + test_rpc_add_ping_to_list(input_msg_list, PING_REQUEST, 0); + test_rpc_add_ping_to_list(input_msg_list, PING_REQUEST, 1); + test_rpc_add_ping_to_list(input_msg_list, PING_REQUEST, 0); + test_rpc_add_ping_to_list(input_msg_list, PING_REQUEST, 500); + test_rpc_add_ping_to_list(input_msg_list, PING_REQUEST, (uint32_t)-1); + test_rpc_add_ping_to_list(input_msg_list, PING_REQUEST, 700); + test_rpc_add_ping_to_list(input_msg_list, PING_REQUEST, 1); + + test_rpc_add_ping_to_list(expected_msg_list, PING_RESPONSE, 0); + test_rpc_add_ping_to_list(expected_msg_list, PING_RESPONSE, 1); + test_rpc_add_ping_to_list(expected_msg_list, PING_RESPONSE, 0); + test_rpc_add_ping_to_list(expected_msg_list, PING_RESPONSE, 500); + test_rpc_add_ping_to_list(expected_msg_list, PING_RESPONSE, (uint32_t)-1); + test_rpc_add_ping_to_list(expected_msg_list, PING_RESPONSE, 700); + test_rpc_add_ping_to_list(expected_msg_list, PING_RESPONSE, 1); + + test_rpc_encode_and_feed(input_msg_list); + test_rpc_decode_and_compare(expected_msg_list); + + test_rpc_free_msg_list(input_msg_list); + test_rpc_free_msg_list(expected_msg_list); +} + +// TODO: 1) test for rubbish data +// 2) test for unexpected end of packet +// 3) test for one push of several packets +// 4) test for fill buffer till end (great varint) and close connection + +MU_TEST_SUITE(test_rpc_status) { + MU_SUITE_CONFIGURE(&test_rpc_storage_setup, &test_rpc_storage_teardown); + + MU_RUN_TEST(test_ping); +} + +MU_TEST_SUITE(test_rpc_storage) { + MU_SUITE_CONFIGURE(&test_rpc_storage_setup, &test_rpc_storage_teardown); + + MU_RUN_TEST(test_storage_list); + MU_RUN_TEST(test_storage_read); + MU_RUN_TEST(test_storage_write_read); + MU_RUN_TEST(test_storage_write); + MU_RUN_TEST(test_storage_delete); + MU_RUN_TEST(test_storage_mkdir); + MU_RUN_TEST(test_storage_md5sum); + MU_RUN_TEST(test_storage_interrupt_continuous_same_system); + MU_RUN_TEST(test_storage_interrupt_continuous_another_system); +} + +static void test_app_create_request( + PB_Main* request, + const char* app_name, + const char* app_args, + uint32_t command_id) { + request->command_id = command_id; + request->command_status = PB_CommandStatus_OK; + request->cb_content.funcs.encode = NULL; + request->which_content = PB_Main_app_start_tag; + request->has_next = false; + + if(app_name) { + char* msg_app_name = furi_alloc(strlen(app_name) + 1); + strcpy(msg_app_name, app_name); + request->content.app_start.name = msg_app_name; + } else { + request->content.app_start.name = NULL; + } + + if(app_args) { + char* msg_app_args = furi_alloc(strlen(app_args) + 1); + strcpy(msg_app_args, app_args); + request->content.app_start.args = msg_app_args; + } else { + request->content.app_start.args = NULL; + } +} + +static void test_app_start_run( + const char* app_name, + const char* app_args, + PB_CommandStatus status, + uint32_t command_id) { + PB_Main request; + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + + test_app_create_request(&request, app_name, app_args, command_id); + test_rpc_add_empty_to_list(expected_msg_list, status, command_id); + + test_rpc_encode_and_feed_one(&request); + test_rpc_decode_and_compare(expected_msg_list); + + pb_release(&PB_Main_msg, &request); + test_rpc_free_msg_list(expected_msg_list); +} + +static void test_app_get_status_lock_run(bool locked_expected, uint32_t command_id) { + PB_Main request = { + .command_id = command_id, + .command_status = PB_CommandStatus_OK, + .which_content = PB_Main_app_lock_status_request_tag, + .has_next = false, + }; + + MsgList_t expected_msg_list; + MsgList_init(expected_msg_list); + PB_Main* response = MsgList_push_new(expected_msg_list); + response->command_id = command_id; + response->command_status = PB_CommandStatus_OK; + response->which_content = PB_Main_app_lock_status_response_tag; + response->has_next = false; + response->content.app_lock_status_response.locked = locked_expected; + + test_rpc_encode_and_feed_one(&request); + test_rpc_decode_and_compare(expected_msg_list); + + pb_release(&PB_Main_msg, &request); + test_rpc_free_msg_list(expected_msg_list); +} + +MU_TEST(test_app_start_and_lock_status) { + test_app_get_status_lock_run(false, ++command_id); + test_app_start_run(NULL, "/ext/file", PB_CommandStatus_ERROR_INVALID_PARAMETERS, ++command_id); + test_app_start_run(NULL, NULL, PB_CommandStatus_ERROR_INVALID_PARAMETERS, ++command_id); + test_app_get_status_lock_run(false, ++command_id); + test_app_start_run( + "skynet_destroy_world_app", NULL, PB_CommandStatus_ERROR_INVALID_PARAMETERS, ++command_id); + test_app_get_status_lock_run(false, ++command_id); + + test_app_start_run("Delay Test App", "0", PB_CommandStatus_OK, ++command_id); + delay(100); + test_app_get_status_lock_run(false, ++command_id); + + test_app_start_run("Delay Test App", "200", PB_CommandStatus_OK, ++command_id); + test_app_get_status_lock_run(true, ++command_id); + delay(100); + test_app_get_status_lock_run(true, ++command_id); + test_app_start_run( + "Delay Test App", "0", PB_CommandStatus_ERROR_APP_SYSTEM_LOCKED, ++command_id); + delay(200); + test_app_get_status_lock_run(false, ++command_id); + + test_app_start_run("Delay Test App", "500", PB_CommandStatus_OK, ++command_id); + delay(100); + test_app_get_status_lock_run(true, ++command_id); + test_app_start_run("Infrared", "0", PB_CommandStatus_ERROR_APP_SYSTEM_LOCKED, ++command_id); + delay(100); + test_app_get_status_lock_run(true, ++command_id); + test_app_start_run( + "2_girls_1_app", "0", PB_CommandStatus_ERROR_INVALID_PARAMETERS, ++command_id); + delay(100); + test_app_get_status_lock_run(true, ++command_id); + delay(500); + test_app_get_status_lock_run(false, ++command_id); +} + +MU_TEST_SUITE(test_rpc_app) { + MU_SUITE_CONFIGURE(&test_rpc_storage_setup, &test_rpc_storage_teardown); + + MU_RUN_TEST(test_app_start_and_lock_status); +} + +int run_minunit_test_rpc() { + MU_RUN_SUITE(test_rpc_storage); + MU_RUN_SUITE(test_rpc_status); + MU_RUN_SUITE(test_rpc_app); + MU_REPORT(); + + return MU_EXIT_CODE; +} + +int32_t delay_test_app(void* p) { + int timeout = atoi((const char*)p); + + if(timeout > 0) { + delay(timeout); + } + + return 0; +} diff --git a/applications/tests/test_index.c b/applications/tests/test_index.c index c0f8919a..7158b304 100644 --- a/applications/tests/test_index.c +++ b/applications/tests/test_index.c @@ -1,31 +1,51 @@ +#include "m-string.h" #include #include #include #include "minunit_vars.h" #include +#include +#include int run_minunit(); int run_minunit_test_irda_decoder_encoder(); +int run_minunit_test_rpc(); -int32_t flipper_test_app(void* p) { +void unit_tests_cli(Cli* cli, string_t args, void* context) { uint32_t test_result = 0; + minunit_run = 0; + minunit_assert = 0; + minunit_fail = 0; + minunit_status = 0; + + Loader* loader = furi_record_open("loader"); + furi_record_close("loader"); NotificationApp* notification = furi_record_open("notification"); - - notification_message_block(notification, &sequence_set_only_blue_255); - - // test_result |= run_minunit(); // disabled as it fails randomly - test_result |= run_minunit_test_irda_decoder_encoder(); - - if(test_result == 0) { - // test passed - notification_message(notification, &sequence_success); - } else { - // test failed - notification_message(notification, &sequence_error); - } - furi_record_close("notification"); - return 0; + if(loader_is_locked(loader)) { + FURI_LOG_E("UNIT_TESTS", "RPC: stop all applications to run tests"); + notification_message(notification, &sequence_blink_magenta_100); + } else { + notification_message_block(notification, &sequence_set_only_blue_255); + + test_result |= run_minunit(); + test_result |= run_minunit_test_irda_decoder_encoder(); + test_result |= run_minunit_test_rpc(); + + if(test_result == 0) { + notification_message(notification, &sequence_success); + FURI_LOG_I("UNIT_TESTS", "PASSED"); + } else { + notification_message(notification, &sequence_error); + FURI_LOG_E("UNIT_TESTS", "FAILED"); + } + } +} + +void unit_tests_cli_init() { + Cli* cli = furi_record_open("cli"); + cli_add_command(cli, "unit_tests", CliCommandFlagParallelSafe, unit_tests_cli, NULL); + furi_record_close("cli"); } diff --git a/assets/Makefile b/assets/Makefile index 1a379af5..079b7b2a 100644 --- a/assets/Makefile +++ b/assets/Makefile @@ -2,10 +2,20 @@ PROJECT_ROOT = $(abspath $(dir $(abspath $(firstword $(MAKEFILE_LIST))))..) include $(PROJECT_ROOT)/assets/assets.mk +all: icons protobuf + $(ASSETS): $(ASSETS_SOURCES) $(ASSETS_COMPILLER) - @echo "\tASSETS\t" $@ + @echo "\tASSETS\t\t" $@ @$(ASSETS_COMPILLER) icons "$(ASSETS_SOURCE_DIR)" "$(ASSETS_COMPILED_DIR)" +icons: $(ASSETS) + +$(PROTOBUF) &: $(PROTOBUF_SOURCES) $(PROTOBUF_COMPILER) + @echo "\tPROTOBUF\t" $(PROTOBUF_FILENAMES) + @$(PROJECT_ROOT)/lib/nanopb/generator/nanopb_generator.py -q -I$(PROTOBUF_SOURCE_DIR) -D$(PROTOBUF_COMPILED_DIR) $(PROTOBUF_SOURCES) + +protobuf: $(PROTOBUF) + clean: @echo "\tCLEAN\t" - @$(RM) $(ASSETS) + @$(RM) $(ASSETS_COMPILED_DIR)/* diff --git a/assets/assets.mk b/assets/assets.mk index 7bb44a37..8430702e 100644 --- a/assets/assets.mk +++ b/assets/assets.mk @@ -6,5 +6,14 @@ ASSETS_SOURCE_DIR := $(ASSETS_DIR)/icons ASSETS_SOURCES += $(shell find $(ASSETS_SOURCE_DIR) -type f -iname '*.png' -or -iname 'frame_rate') ASSETS += $(ASSETS_COMPILED_DIR)/assets_icons.c -CFLAGS += -I$(ASSETS_COMPILED_DIR) -C_SOURCES += $(ASSETS_COMPILED_DIR)/assets_icons.c +PROTOBUF_SOURCE_DIR := $(ASSETS_DIR)/protobuf +PROTOBUF_COMPILER := $(PROJECT_ROOT)/lib/nanopb/generator/nanopb_generator.py +PROTOBUF_COMPILED_DIR := $(ASSETS_COMPILED_DIR) +PROTOBUF_SOURCES := $(shell find $(PROTOBUF_SOURCE_DIR) -type f -iname '*.proto') +#PROTOBUF_FILENAMES := $(notdir $(PROTOBUF)) +PROTOBUF_FILENAMES := $(notdir $(addsuffix .pb.c,$(basename $(PROTOBUF_SOURCES)))) +PROTOBUF := $(addprefix $(PROTOBUF_COMPILED_DIR)/,$(PROTOBUF_FILENAMES)) +PROTOBUF_CFLAGS += -DPB_ENABLE_MALLOC -DPB_WITHOUT_64BIT + +CFLAGS += -I$(ASSETS_COMPILED_DIR) $(PROTOBUF_CFLAGS) +C_SOURCES += $(wildcard $(ASSETS_COMPILED_DIR)/*.c) diff --git a/assets/compiled/application.pb.c b/assets/compiled/application.pb.c new file mode 100644 index 00000000..097a57b0 --- /dev/null +++ b/assets/compiled/application.pb.c @@ -0,0 +1,18 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.5 */ + +#include "application.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(PB_App_Start, PB_App_Start, AUTO) + + +PB_BIND(PB_App_LockStatusRequest, PB_App_LockStatusRequest, AUTO) + + +PB_BIND(PB_App_LockStatusResponse, PB_App_LockStatusResponse, AUTO) + + + diff --git a/assets/compiled/application.pb.h b/assets/compiled/application.pb.h new file mode 100644 index 00000000..b7a053f3 --- /dev/null +++ b/assets/compiled/application.pb.h @@ -0,0 +1,79 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.5 */ + +#ifndef PB_PB_APP_APPLICATION_PB_H_INCLUDED +#define PB_PB_APP_APPLICATION_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +typedef struct _PB_App_LockStatusRequest { + char dummy_field; +} PB_App_LockStatusRequest; + +typedef struct _PB_App_Start { + char *name; + char *args; +} PB_App_Start; + +typedef struct _PB_App_LockStatusResponse { + bool locked; +} PB_App_LockStatusResponse; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define PB_App_Start_init_default {NULL, NULL} +#define PB_App_LockStatusRequest_init_default {0} +#define PB_App_LockStatusResponse_init_default {0} +#define PB_App_Start_init_zero {NULL, NULL} +#define PB_App_LockStatusRequest_init_zero {0} +#define PB_App_LockStatusResponse_init_zero {0} + +/* Field tags (for use in manual encoding/decoding) */ +#define PB_App_Start_name_tag 1 +#define PB_App_Start_args_tag 2 +#define PB_App_LockStatusResponse_locked_tag 1 + +/* Struct field encoding specification for nanopb */ +#define PB_App_Start_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, name, 1) \ +X(a, POINTER, SINGULAR, STRING, args, 2) +#define PB_App_Start_CALLBACK NULL +#define PB_App_Start_DEFAULT NULL + +#define PB_App_LockStatusRequest_FIELDLIST(X, a) \ + +#define PB_App_LockStatusRequest_CALLBACK NULL +#define PB_App_LockStatusRequest_DEFAULT NULL + +#define PB_App_LockStatusResponse_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, locked, 1) +#define PB_App_LockStatusResponse_CALLBACK NULL +#define PB_App_LockStatusResponse_DEFAULT NULL + +extern const pb_msgdesc_t PB_App_Start_msg; +extern const pb_msgdesc_t PB_App_LockStatusRequest_msg; +extern const pb_msgdesc_t PB_App_LockStatusResponse_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define PB_App_Start_fields &PB_App_Start_msg +#define PB_App_LockStatusRequest_fields &PB_App_LockStatusRequest_msg +#define PB_App_LockStatusResponse_fields &PB_App_LockStatusResponse_msg + +/* Maximum encoded size of messages (where known) */ +/* PB_App_Start_size depends on runtime parameters */ +#define PB_App_LockStatusRequest_size 0 +#define PB_App_LockStatusResponse_size 2 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/assets/compiled/assets_icons.c b/assets/compiled/assets_icons.c index 2af951ef..46822266 100644 --- a/assets/compiled/assets_icons.c +++ b/assets/compiled/assets_icons.c @@ -12,8 +12,7 @@ const uint8_t _A_WatchingTV_128x64_0[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 const uint8_t _A_WatchingTV_128x64_1[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0xC0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0xA0,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x1F,0x00,0x00,0x00,0x00,0x02,0x00,0xE0,0x10,0x00,0x00,0x00,0x00,0x00,0xC0,0x55,0x75,0x00,0x00,0x00,0x00,0x02,0x00,0xA0,0x10,0x00,0x00,0x00,0x00,0x00,0xA0,0xAA,0xAA,0x00,0x00,0x00,0x00,0x04,0x00,0x50,0x09,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x50,0x01,0x00,0x00,0x00,0x08,0x00,0xB0,0x05,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0xA0,0x02,0x00,0x00,0x00,0x10,0x00,0x50,0x02,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x40,0x05,0x00,0x00,0x00,0x10,0x00,0xB0,0x07,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x80,0x0A,0x00,0x00,0x00,0x20,0x00,0x50,0x09,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x15,0x00,0x00,0x00,0x40,0x00,0xB0,0x10,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x1A,0x00,0x00,0x00,0x80,0x00,0x58,0x20,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x34,0x00,0x00,0x00,0x80,0x00,0x28,0xC0,0xFF,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x28,0x00,0x00,0x00,0x00,0x01,0x38,0x00,0x00,0x83,0x03,0x00,0x80,0x03,0x80,0x0F,0x30,0x00,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0xFC,0x02,0x00,0x80,0x03,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x04,0x18,0x00,0x00,0x00,0x02,0x00,0x80,0x03,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x04,0x14,0x00,0x00,0x00,0x01,0x00,0x80,0x03,0xE0,0xBF,0x60,0x00,0x00,0x00,0x00,0x08,0x24,0x00,0x00,0x80,0x00,0x00,0xC0,0x01,0xE0,0x67,0x51,0x00,0x00,0x00,0x00,0x10,0x22,0x00,0x00,0x40,0x00,0x00,0x60,0x00,0x60,0xA7,0xA0,0x00,0x00,0x00,0x00,0xF8,0x47,0x00,0x00,0x30,0x00,0x00,0x18,0x00,0xC0,0x53,0xD1,0x00,0x00,0x00,0x00,0x06,0x58,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x80,0xAF,0xA0,0x00,0x00,0x00,0x00,0x01,0x60,0xF0,0xFF,0x03,0x00,0x00,0x06,0x00,0x00,0x50,0xD0,0x00,0x00,0x00,0x80,0x00,0x40,0x08,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xA8,0x00,0x00,0x00,0x40,0x00,0x80,0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xD4,0x00,0x00,0xFF,0xFF,0x0F,0x80,0x04,0x00,0x00,0x00,0xF0,0x00,0x00,0x80,0x03,0xAA,0x00,0x00,0x55,0x55,0xF5,0xFF,0xFF,0xFF,0x0F,0x00,0xAE,0x00,0x00,0x60,0x04,0xD4,0x0F,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x0E,0x80,0xD5,0x00,0x00,0x1C,0x00,0x7A,0x35,0x00,0x55,0x55,0x55,0x55,0x55,0x55,0x0F,0xC0,0xAA,0xFF,0xE1,0x03,0x00,0xAD,0x6A,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xEA,0x0A,0x60,0xD5,0x01,0x1E,0x60,0x80,0x56,0xD5,0x00,0x55,0x55,0x55,0x55,0x55,0x75,0x0D,0xA0,0xAA,0x03,0x00,0x50,0x40,0x83,0xAA,0x01,0xAA,0xAA,0xAA,0xAA,0xAA,0xAE,0x0A,0x60,0x40,0x0F,0x00,0x2E,0xA0,0x01,0x55,0x03,0x55,0x55,0x55,0x55,0x55,0x57,0x3D,0x3E,0x80,0xF5,0xFF,0x15,0x50,0x01,0xAA,0x02,0xAA,0xAA,0xAA,0xAA,0xEA,0xAA,0xCA,0x21,0x80,0xAA,0xAA,0x0A,0xA8,0x00,0x55,0x03,0xFF,0xFF,0xFF,0xFF,0x7F,0x55,0x0D,0x20,0x80,0x55,0x55,0x05,0xD5,0x00,0xEA,0x07,0x88,0x88,0x88,0x88,0xB8,0xAA,0x0A,0x20,0xC0,0xAA,0xAA,0x82,0xAA,0x00,0x1D,0x18,0x55,0x55,0x55,0x55,0x57,0x55,0x0D,0x20,0x40,0x55,0x05,0x40,0x55,0x00,0x06,0x20,0x22,0x22,0x22,0xA2,0xB3,0xAA,0x0A,0x40,0x40,0x00,0x00,0xA0,0x6A,0x00,0x03,0x20,0x55,0x55,0x55,0x75,0x55,0x55,0x0D,0x80,0x40,0x00,0x00,0x50,0x7D,0x00,0x01,0x40,0x88,0x88,0x88,0x98,0xB8,0xAA,0x0A,0x00,0x21,0x00,0x00,0xA8,0x47,0x80,0x00,0x40,0x55,0x55,0x55,0x57,0x55,0x55,0x0D,0x00,0x3E,0x00,0x00,0xD5,0x40,0x80,0x00,0x40,0xFF,0xFF,0xFF,0x23,0xB2,0xAA,0x0A,0x00,0x00,0x00,0xA0,0x6A,0x40,0x40,0x00,0x80,0x01,0x00,0x80,0x55,0x55,0x55,0x0D,0x00,0x00,0x00,0x50,0x35,0x40,0x40,0x00,0x80,0x01,0x00,0x80,0x88,0xB8,0xAA,0x0A,0x00,0x00,0x00,0xAA,0x1A,0x40,0x20,0x00,0x80,0x01,0x00,0x80,0x55,0x55,0x55,0x0D,0x00,0x00,0x40,0x55,0x15,0x40,0x20,0x00,0x80,0x31,0xFC,0x8F,0x22,0xB2,0xAA,0x0A,0x00,0x00,0xA8,0xAA,0x0A,0x40,0x10,0x00,0x80,0x49,0x02,0x90,0x55,0x55,0x55,0x1D,0x00,0x40,0x55,0x55,0x0D,0x80,0x10,0x00,0x80,0x49,0x02,0x90,0x88,0xB8,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x0E,0x80,0x08,0x00,0x80,0x31,0x02,0x90,0x55,0x55,0x55,0x5D,0x55,0x55,0x55,0x55,0x01,0x00,0x07,0x00,0x80,0x01,0x02,0x90,0x22,0xB2,0xAA,0xF6,0xAA,0xEA,0xFF,0xFF,0x01,0x00,0x04,0x00,0x40,0x11,0xFC,0x8F,0x55,0x55,0x55,0x85,0xD7,0x1F,0x00,0x00,0x1E,0x00,0x04,0x00,0x40,0x29,0x00,0x80,0x88,0xB8,0xAA,0x06,0x6C,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x20,0x29,0x00,0x80,0x55,0x55,0x55,0x05,0x38,0x00,0x00,0x00,0x40,0x00,0x04,0x00,0x20,0x15,0x00,0x80,0x22,0xB2,0xAA,0x06,0x10,0x00,0x00,0x00,0x80,0x00,0x04,0x00,0x20,0x0B,0x00,0x80,0x55,0x55,0x55,0x05,0x10,0x00,0x00,0x00,0x00,0x03,0x04,0x00,0x10,}; const uint8_t _A_WatchingTV_128x64_2[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x18,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x14,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x1F,0x00,0x00,0x00,0x00,0x02,0x00,0x1C,0x10,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x60,0x00,0x00,0x00,0x00,0x02,0x00,0x16,0x10,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x80,0x00,0x00,0x00,0x00,0x04,0x00,0x2A,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x36,0x04,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x02,0x00,0x00,0x00,0x10,0x00,0x62,0x02,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x00,0x10,0x00,0xC6,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x0A,0x07,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x10,0x00,0x00,0x00,0x40,0x00,0x86,0x08,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x10,0x00,0x00,0x00,0x80,0x00,0x4A,0x08,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x20,0x00,0x00,0x00,0x80,0x00,0x24,0x08,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x01,0x3C,0xF0,0x3F,0x80,0x01,0x00,0x80,0x03,0x80,0x0F,0x20,0x00,0x00,0x00,0x00,0x02,0x18,0x00,0xC0,0x60,0x01,0x00,0x80,0x03,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x04,0x38,0x00,0x00,0x1F,0x01,0x00,0x80,0x03,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x04,0x14,0x00,0x00,0x80,0x00,0x00,0x80,0x03,0xE0,0x3F,0x60,0x00,0x00,0x00,0x00,0x08,0x14,0x00,0x00,0x40,0x00,0x00,0xC0,0x01,0x20,0x67,0x40,0x00,0x00,0x00,0x00,0x10,0x22,0x00,0x00,0x20,0x00,0x00,0x60,0x00,0x60,0xA7,0xA0,0x00,0x00,0x00,0x00,0xF8,0x27,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0xC0,0x53,0xC1,0x00,0x00,0x00,0x00,0x06,0x58,0x00,0x00,0x06,0x00,0x00,0x0C,0x00,0x80,0xAF,0xA0,0x00,0x00,0x00,0x00,0x01,0x60,0x80,0xFF,0x01,0x00,0x00,0x06,0x00,0x00,0x50,0xD0,0x00,0x00,0x00,0x80,0x00,0x40,0x78,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xA0,0x00,0x00,0x00,0x40,0x00,0x80,0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xD0,0x00,0x00,0xFF,0xFF,0x0F,0x80,0x04,0x00,0x00,0x00,0xF0,0x00,0x00,0x80,0x03,0xA8,0x00,0x00,0x55,0x55,0xF5,0xFF,0xFF,0xFF,0x0F,0x00,0xAE,0x00,0x00,0x60,0x04,0xD4,0x0F,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x0E,0x80,0xD5,0x00,0x00,0x1C,0x00,0x78,0x35,0x00,0x55,0x55,0x55,0x55,0x55,0x55,0x0F,0xC0,0xAA,0xFF,0xE1,0x03,0x00,0x0C,0x6A,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xEA,0x0A,0x60,0x81,0x01,0x1E,0x60,0x00,0x06,0xD4,0x00,0x55,0x55,0x55,0x55,0x55,0x75,0x0D,0x20,0x00,0x03,0x00,0x10,0x00,0x03,0xA8,0x01,0xAA,0xAA,0xAA,0xAA,0xAA,0xAE,0x0A,0x20,0x00,0x0F,0x00,0x2E,0x80,0x01,0x50,0x03,0x55,0x55,0x55,0x55,0x55,0x57,0x3D,0x3E,0x80,0xF5,0xFF,0x05,0x40,0x01,0xA8,0x02,0xAA,0xAA,0xAA,0xAA,0xEA,0xAA,0xCA,0x21,0x80,0xAA,0xAA,0x02,0xA0,0x00,0x50,0x03,0xFF,0xFF,0xFF,0xFF,0x7F,0x55,0x0D,0x20,0x80,0x55,0x55,0x01,0xD0,0x00,0xE8,0x07,0x88,0x88,0x88,0x88,0xB8,0xAA,0x0A,0x20,0x40,0xAA,0x02,0x00,0xAA,0x00,0x18,0x18,0x55,0x55,0x55,0x55,0x57,0x55,0x0D,0x20,0x40,0x00,0x00,0x00,0x55,0x00,0x04,0x20,0x22,0x22,0x22,0xA2,0xB3,0xAA,0x0A,0x40,0x40,0x00,0x00,0x80,0x6A,0x00,0x02,0x20,0x55,0x55,0x55,0x75,0x55,0x55,0x0D,0x80,0x40,0x00,0x00,0x40,0x7D,0x00,0x01,0x40,0x88,0x88,0x88,0x98,0xB8,0xAA,0x0A,0x00,0x21,0x00,0x00,0xA0,0x47,0x80,0x00,0x40,0x55,0x55,0x55,0x57,0x55,0x55,0x0D,0x00,0x3E,0x00,0x00,0xD0,0x40,0x80,0x00,0x40,0xFF,0xFF,0xFF,0x23,0xB2,0xAA,0x0A,0x00,0x00,0x00,0x00,0x6A,0x40,0x40,0x00,0x80,0x01,0x00,0x80,0x55,0x55,0x55,0x0D,0x00,0x00,0x00,0x40,0x35,0x40,0x40,0x00,0x80,0x01,0x00,0x80,0x88,0xB8,0xAA,0x0A,0x00,0x00,0x00,0xA0,0x1A,0x40,0x20,0x00,0x80,0x01,0x00,0x80,0x55,0x55,0x55,0x0D,0x00,0x00,0x00,0x54,0x15,0x40,0x20,0x00,0x80,0x31,0xFC,0x8F,0x22,0xB2,0xAA,0x0A,0x00,0x00,0x80,0xAA,0x0A,0x40,0x10,0x00,0x80,0x49,0x02,0x90,0x55,0x55,0x55,0x0D,0x00,0x00,0x50,0x55,0x0D,0x80,0x10,0x00,0x80,0x49,0x02,0x90,0x88,0xB8,0xAA,0x2A,0x00,0x80,0xAA,0xAA,0x0E,0x80,0x08,0x00,0x80,0x31,0x02,0x90,0x55,0x55,0x55,0x5D,0x55,0x55,0x55,0x55,0x01,0x00,0x07,0x00,0x80,0x01,0x02,0x90,0x22,0xB2,0xAA,0xF6,0xAA,0xEA,0xFF,0xFF,0x01,0x00,0x04,0x00,0x40,0x11,0xFC,0x8F,0x55,0x55,0x55,0x85,0xD7,0x1F,0x00,0x00,0x1E,0x00,0x04,0x00,0x40,0x29,0x00,0x80,0x88,0xB8,0xAA,0x06,0x6C,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x20,0x29,0x00,0x80,0x55,0x55,0x55,0x05,0x38,0x00,0x00,0x00,0x40,0x00,0x04,0x00,0x20,0x15,0x00,0x80,0x22,0xB2,0xAA,0x06,0x10,0x00,0x00,0x00,0x80,0x00,0x04,0x00,0x20,0x0B,0x00,0x80,0x55,0x55,0x55,0x05,0x10,0x00,0x00,0x00,0x00,0x03,0x04,0x00,0x10,}; const uint8_t _A_WatchingTV_128x64_3[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x04,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x0A,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x1F,0x00,0x00,0x00,0x00,0x02,0x00,0x0A,0x10,0x00,0x00,0x00,0x00,0x00,0xC0,0x55,0x75,0x00,0x00,0x00,0x00,0x02,0x00,0x12,0x10,0x00,0x00,0x00,0x00,0x00,0xA0,0xAA,0xAA,0x00,0x00,0x00,0x00,0x04,0x00,0x11,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x50,0x01,0x00,0x00,0x00,0x08,0x00,0x11,0x04,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0xA0,0x02,0x00,0x00,0x00,0x10,0x00,0x21,0x02,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x40,0x05,0x00,0x00,0x00,0x10,0x00,0xC1,0x02,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x80,0x0A,0x00,0x00,0x00,0x20,0x00,0x81,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x15,0x00,0x00,0x00,0x40,0x00,0x81,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x1A,0x00,0x00,0x00,0x80,0x00,0x41,0x04,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x34,0x00,0x00,0x00,0x80,0x00,0x22,0x08,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x28,0x00,0x00,0x00,0x00,0x01,0x22,0xF0,0x0F,0xC0,0x00,0x00,0x80,0x03,0x80,0x0F,0x30,0x00,0x00,0x00,0x00,0x02,0x14,0x00,0xF0,0xA0,0x00,0x00,0x80,0x03,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x04,0x08,0x00,0x00,0x9F,0x00,0x00,0x80,0x03,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x04,0x14,0x00,0x00,0x40,0x00,0x00,0x80,0x03,0xE0,0xBF,0x60,0x00,0x00,0x00,0x00,0x08,0x14,0x00,0x00,0x40,0x00,0x00,0xC0,0x01,0xE0,0x67,0x51,0x00,0x00,0x00,0x00,0x10,0x22,0x00,0x00,0x30,0x00,0x00,0x60,0x00,0x60,0xA7,0xA0,0x00,0x00,0x00,0x00,0xF8,0x27,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0xC0,0x53,0xD1,0x00,0x00,0x00,0x00,0x06,0x58,0x00,0x00,0x03,0x00,0x00,0x0C,0x00,0x80,0xAF,0xA0,0x00,0x00,0x00,0x00,0x01,0x60,0x00,0xFC,0x00,0x00,0x00,0x06,0x00,0x00,0x50,0xD0,0x00,0x00,0x00,0x80,0x00,0x40,0xF8,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xA8,0x00,0x00,0x00,0x40,0x00,0x80,0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xD4,0x00,0x00,0xFF,0xFF,0x0F,0x80,0x04,0x00,0x00,0x00,0xF0,0x00,0x00,0x80,0x03,0xAA,0x00,0x00,0x55,0x55,0xF5,0xFF,0xFF,0xFF,0x0F,0x00,0xAE,0x00,0x00,0x60,0x04,0xD4,0x0F,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x0E,0x80,0xD5,0x00,0x00,0x1C,0x00,0x7A,0x35,0x00,0x55,0x55,0x55,0x55,0x55,0x55,0x0F,0xC0,0xAA,0xFF,0xE1,0x03,0x00,0xAD,0x6A,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xEA,0x0A,0x60,0xD5,0x01,0x1E,0x60,0x80,0x56,0xD5,0x00,0x55,0x55,0x55,0x55,0x55,0x75,0x0D,0xA0,0xAA,0x03,0x00,0x50,0x40,0x83,0xAA,0x01,0xAA,0xAA,0xAA,0xAA,0xAA,0xAE,0x0A,0x60,0x40,0x0F,0x00,0x2E,0xA0,0x01,0x55,0x03,0x55,0x55,0x55,0x55,0x55,0x57,0x3D,0x3E,0x80,0xF5,0xFF,0x15,0x50,0x01,0xAA,0x02,0xAA,0xAA,0xAA,0xAA,0xEA,0xAA,0xCA,0x21,0x80,0xAA,0xAA,0x0A,0xA8,0x00,0x55,0x03,0xFF,0xFF,0xFF,0xFF,0x7F,0x55,0x0D,0x20,0x80,0x55,0x55,0x05,0xD5,0x00,0xEA,0x07,0x88,0x88,0x88,0x88,0xB8,0xAA,0x0A,0x20,0xC0,0xAA,0xAA,0x82,0xAA,0x00,0x1D,0x18,0x55,0x55,0x55,0x55,0x57,0x55,0x0D,0x20,0x40,0x55,0x05,0x40,0x55,0x00,0x06,0x20,0x22,0x22,0x22,0xA2,0xB3,0xAA,0x0A,0x40,0x40,0x00,0x00,0xA0,0x6A,0x00,0x03,0x20,0x55,0x55,0x55,0x75,0x55,0x55,0x0D,0x80,0x40,0x00,0x00,0x50,0x7D,0x00,0x01,0x40,0x88,0x88,0x88,0x98,0xB8,0xAA,0x0A,0x00,0x21,0x00,0x00,0xA8,0x47,0x80,0x00,0x40,0x55,0x55,0x55,0x57,0x55,0x55,0x0D,0x00,0x3E,0x00,0x00,0xD5,0x40,0x80,0x00,0x40,0xFF,0xFF,0xFF,0x23,0xB2,0xAA,0x0A,0x00,0x00,0x00,0xA0,0x6A,0x40,0x40,0x00,0x80,0x01,0x00,0x80,0x55,0x55,0x55,0x0D,0x00,0x00,0x00,0x50,0x35,0x40,0x40,0x00,0x80,0x01,0x00,0x80,0x88,0xB8,0xAA,0x0A,0x00,0x00,0x00,0xAA,0x1A,0x40,0x20,0x00,0x80,0x01,0x00,0x80,0x55,0x55,0x55,0x0D,0x00,0x00,0x40,0x55,0x15,0x40,0x20,0x00,0x80,0x31,0xFC,0x8F,0x22,0xB2,0xAA,0x0A,0x00,0x00,0xA8,0xAA,0x0A,0x40,0x10,0x00,0x80,0x49,0x02,0x90,0x55,0x55,0x55,0x1D,0x00,0x40,0x55,0x55,0x0D,0x80,0x10,0x00,0x80,0x49,0x02,0x90,0x88,0xB8,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x0E,0x80,0x08,0x00,0x80,0x31,0x02,0x90,0x55,0x55,0x55,0x5D,0x55,0x55,0x55,0x55,0x01,0x00,0x07,0x00,0x80,0x01,0x02,0x90,0x22,0xB2,0xAA,0xF6,0xAA,0xEA,0xFF,0xFF,0x01,0x00,0x04,0x00,0x40,0x11,0xFC,0x8F,0x55,0x55,0x55,0x85,0xD7,0x1F,0x00,0x00,0x1E,0x00,0x04,0x00,0x40,0x29,0x00,0x80,0x88,0xB8,0xAA,0x06,0x6C,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x20,0x29,0x00,0x80,0x55,0x55,0x55,0x05,0x38,0x00,0x00,0x00,0x40,0x00,0x04,0x00,0x20,0x15,0x00,0x80,0x22,0xB2,0xAA,0x06,0x10,0x00,0x00,0x00,0x80,0x00,0x04,0x00,0x20,0x0B,0x00,0x80,0x55,0x55,0x55,0x05,0x10,0x00,0x00,0x00,0x00,0x03,0x04,0x00,0x10,}; -const uint8_t _A_WatchingTV_128x64_4[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x04,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x0A,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x1F,0x00,0x00,0x00,0x00,0x02,0x00,0x0A,0x10,0x00,0x00,0x00,0x00,0x00,0xC0,0x55,0x75,0x00,0x00,0x00,0x00,0x02,0x00,0x12,0x10,0x00,0x00,0x00,0x00,0x00,0xA0,0xAA,0xAA,0x00,0x00,0x00,0x00,0x04,0x00,0x11,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x50,0x01,0x00,0x00,0x00,0x08,0x00,0x11,0x04,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0xA0,0x02,0x00,0x00,0x00,0x10,0x00,0x21,0x02,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x40,0x05,0x00,0x00,0x00,0x10,0x00,0xC1,0x02,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x80,0x0A,0x00,0x00,0x00,0x20,0x00,0x81,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x15,0x00,0x00,0x00,0x40,0x00,0x81,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x1A,0x00,0x00,0x00,0x80,0x00,0x41,0x04,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x34,0x00,0x00,0x00,0x80,0x00,0x22,0x08,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x28,0x00,0x00,0x00,0x00,0x01,0x22,0xF0,0x0F,0xC0,0x00,0x00,0x80,0x03,0x80,0x0F,0x30,0x00,0x00,0x00,0x00,0x02,0x14,0x00,0xF0,0xA0,0x00,0x00,0x80,0x03,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x04,0x08,0x00,0x00,0x9F,0x00,0x00,0x80,0x03,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x04,0x14,0x00,0x00,0x40,0x00,0x00,0x80,0x03,0xE0,0xBF,0x60,0x00,0x00,0x00,0x00,0x08,0x14,0x00,0x00,0x40,0x00,0x00,0xC0,0x01,0xE0,0x67,0x51,0x00,0x00,0x00,0x00,0x10,0x22,0x00,0x00,0x30,0x00,0x00,0x60,0x00,0x60,0xA7,0xA0,0x00,0x00,0x00,0x00,0xF8,0x27,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0xC0,0x53,0xD1,0x00,0x00,0x00,0x00,0x06,0x58,0x00,0x00,0x03,0x00,0x00,0x0C,0x00,0x80,0xAF,0xA0,0x00,0x00,0x00,0x00,0x01,0x60,0x00,0xFC,0x00,0x00,0x00,0x06,0x00,0x00,0x50,0xD0,0x00,0x00,0x00,0x80,0x00,0x40,0xF8,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xA8,0x00,0x00,0x00,0x40,0x00,0x80,0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xD4,0x00,0x00,0xFF,0xFF,0x0F,0x80,0x04,0x00,0x00,0x00,0xF0,0x00,0x00,0x80,0x03,0xAA,0x00,0x00,0x55,0x55,0xF5,0xFF,0xFF,0xFF,0x0F,0x00,0xAE,0x00,0x00,0x60,0x04,0xD4,0x0F,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x0E,0x80,0xD5,0x00,0x00,0x1C,0x00,0x7A,0x35,0x00,0x55,0x55,0x55,0x55,0x55,0x55,0x0F,0xC0,0xAA,0xFF,0xE1,0x03,0x00,0xAD,0x6A,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xEA,0x0A,0x60,0xD5,0x01,0x1E,0x60,0x80,0x56,0xD5,0x00,0x55,0x55,0x55,0x55,0x55,0x75,0x0D,0xA0,0xAA,0x03,0x00,0x50,0x40,0x83,0xAA,0x01,0xAA,0xAA,0xAA,0xAA,0xAA,0xAE,0x0A,0x60,0x40,0x0F,0x00,0x2E,0xA0,0x01,0x55,0x03,0x55,0x55,0x55,0x55,0x55,0x57,0x3D,0x3E,0x80,0xF5,0xFF,0x15,0x50,0x01,0xAA,0x02,0xAA,0xAA,0xAA,0xAA,0xEA,0xAA,0xCA,0x21,0x80,0xAA,0xAA,0x0A,0xA8,0x00,0x55,0x03,0xFF,0xFF,0xFF,0xFF,0x7F,0x55,0x0D,0x20,0x80,0x55,0x55,0x05,0xD5,0x00,0xEA,0x07,0x88,0x88,0x88,0x88,0xB8,0xAA,0x0A,0x20,0xC0,0xAA,0xAA,0x82,0xAA,0x00,0x1D,0x18,0x55,0x55,0x55,0x55,0x57,0x55,0x0D,0x20,0x40,0x55,0x05,0x40,0x55,0x00,0x06,0x20,0x22,0x22,0x22,0xA2,0xB3,0xAA,0x0A,0x40,0x40,0x00,0x00,0xA0,0x6A,0x00,0x03,0x20,0x55,0x55,0x55,0x75,0x55,0x55,0x0D,0x80,0x40,0x00,0x00,0x50,0x7D,0x00,0x01,0x40,0x88,0x88,0x88,0x98,0xB8,0xAA,0x0A,0x00,0x21,0x00,0x00,0xA8,0x47,0x80,0x00,0x40,0x55,0x55,0x55,0x57,0x55,0x55,0x0D,0x00,0x3E,0x00,0x00,0xD5,0x40,0x80,0x00,0x40,0xFF,0xFF,0xFF,0x23,0xB2,0xAA,0x0A,0x00,0x00,0x00,0xA0,0x6A,0x40,0x40,0x00,0x80,0x01,0x00,0x80,0x55,0x55,0x55,0x0D,0x00,0x00,0x00,0x50,0x35,0x40,0x40,0x00,0x80,0x01,0x00,0x80,0x88,0xB8,0xAA,0x0A,0x00,0x00,0x00,0xAA,0x1A,0x40,0x20,0x00,0x80,0x01,0x00,0x80,0x55,0x55,0x55,0x0D,0x00,0x00,0x40,0x55,0x15,0x40,0x20,0x00,0x80,0x31,0xFC,0x8F,0x22,0xB2,0xAA,0x0A,0x00,0x00,0xA8,0xAA,0x0A,0x40,0x10,0x00,0x80,0x49,0x02,0x90,0x55,0x55,0x55,0x1D,0x00,0x40,0x55,0x55,0x0D,0x80,0x10,0x00,0x80,0x49,0x02,0x90,0x88,0xB8,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x0E,0x80,0x08,0x00,0x80,0x31,0x02,0x90,0x55,0x55,0x55,0x5D,0x55,0x55,0x55,0x55,0x01,0x00,0x07,0x00,0x80,0x01,0x02,0x90,0x22,0xB2,0xAA,0xF6,0xAA,0xEA,0xFF,0xFF,0x01,0x00,0x04,0x00,0x40,0x11,0xFC,0x8F,0x55,0x55,0x55,0x85,0xD7,0x1F,0x00,0x00,0x1E,0x00,0x04,0x00,0x40,0x29,0x00,0x80,0x88,0xB8,0xAA,0x06,0x6C,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x20,0x29,0x00,0x80,0x55,0x55,0x55,0x05,0x38,0x00,0x00,0x00,0x40,0x00,0x04,0x00,0x20,0x15,0x00,0x80,0x22,0xB2,0xAA,0x06,0x10,0x00,0x00,0x00,0x80,0x00,0x04,0x00,0x20,0x0B,0x00,0x80,0x55,0x55,0x55,0x05,0x10,0x00,0x00,0x00,0x00,0x03,0x04,0x00,0x10,}; -const uint8_t *_A_WatchingTV_128x64[] = {_A_WatchingTV_128x64_0,_A_WatchingTV_128x64_1,_A_WatchingTV_128x64_2,_A_WatchingTV_128x64_3,_A_WatchingTV_128x64_4}; +const uint8_t *_A_WatchingTV_128x64[] = {_A_WatchingTV_128x64_0,_A_WatchingTV_128x64_1,_A_WatchingTV_128x64_2,_A_WatchingTV_128x64_3}; const uint8_t _A_Wink_128x64_0[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0xE0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xF0,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xBF,0x1E,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x54,0x07,0xD8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0xAA,0x03,0x8E,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x55,0x03,0x13,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xAA,0xC1,0x61,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD5,0x70,0x84,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0xEA,0x18,0x08,0x11,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x55,0x8C,0x10,0x38,0x1C,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x6A,0x04,0x21,0x2C,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x80,0xFF,0x3F,0x0C,0x02,0xE6,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xC0,0x00,0x18,0x18,0x84,0x23,0x00,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x60,0xFE,0x33,0x30,0xE0,0x10,0x00,0xF8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x30,0x01,0x64,0x20,0x38,0x0C,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x90,0x00,0xC8,0xE0,0x0F,0x02,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x48,0xFC,0x91,0x00,0x00,0x01,0xE0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0xFE,0xA3,0x01,0xC0,0x00,0xF0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0xFF,0x27,0x01,0x30,0x00,0xFC,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0xFF,0x47,0x01,0x08,0x00,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0xE7,0x4F,0x01,0x06,0x80,0xFF,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0xE7,0x4F,0x81,0x01,0xC0,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0xFF,0x4F,0x71,0x00,0xE0,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0xFF,0x4F,0x1D,0x00,0xF0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0xFF,0x4F,0x07,0x00,0xF8,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x96,0xFF,0x7F,0x00,0x00,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x25,0xFF,0x41,0x00,0x00,0xFE,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0x2A,0x7E,0x00,0x00,0x00,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x4D,0x1E,0x00,0x00,0x80,0xFF,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x9A,0x02,0x00,0x00,0xC0,0xFF,0x01,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x95,0x01,0x00,0x00,0xF0,0xFF,0xFF,0x7F,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0xEA,0x00,0x00,0x00,0xF8,0x01,0x1F,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x55,0x00,0x00,0x00,0xFC,0x00,0x70,0xC0,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x2A,0x00,0x00,0x00,0x3E,0x00,0xE0,0x39,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x15,0x00,0x60,0x80,0x1F,0x00,0x80,0x0F,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x0A,0x00,0xC0,0xF0,0x3F,0x00,0xF0,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x05,0x00,0x00,0xFF,0xFF,0xFF,0x1F,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}; const uint8_t _A_Wink_128x64_1[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0xE0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xF0,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xBF,0x1E,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x54,0x07,0xD8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0xAA,0x03,0x8E,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x55,0x03,0x13,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xAA,0xC1,0x61,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD5,0x70,0x84,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0xEA,0x18,0x08,0x11,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x55,0x8C,0x10,0x38,0x1C,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x6A,0x04,0x21,0x2C,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x80,0xFF,0x3F,0x0C,0x02,0xE6,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xC0,0x00,0x18,0x18,0x84,0x23,0x00,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x60,0x00,0x30,0x30,0xE0,0x10,0x00,0xF8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x30,0x00,0x60,0x20,0x38,0x0C,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0xF8,0xC3,0xE0,0x0F,0x02,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x08,0xFE,0x8F,0x00,0x00,0x01,0xE0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xFF,0x93,0x01,0xC0,0x00,0xF0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0xFF,0x27,0x01,0x30,0x00,0xFC,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0xFF,0x47,0x01,0x08,0x00,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA4,0xE7,0x4F,0x01,0x06,0x80,0xFF,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA4,0xE7,0x4F,0x81,0x01,0xC0,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0xFF,0x7F,0x71,0x00,0xE0,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0xFF,0x01,0x1D,0x00,0xF0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x3F,0x00,0x07,0x00,0xF8,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x96,0x07,0x3E,0x00,0x00,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x25,0xC3,0x41,0x00,0x00,0xFE,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0xAA,0x70,0x00,0x00,0x00,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x4D,0x1C,0x00,0x00,0x80,0xFF,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x1A,0x02,0x00,0x00,0xC0,0xFF,0x01,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x15,0x01,0x00,0x00,0xF0,0xFF,0xFF,0x7F,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0xEA,0x00,0x00,0x00,0xF8,0x01,0x1F,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x55,0x00,0x00,0x00,0xFC,0x00,0x70,0xC0,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x2A,0x00,0x00,0x00,0x3E,0x00,0xE0,0x39,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x15,0x00,0x60,0x80,0x1F,0x00,0x80,0x0F,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x0A,0x00,0xC0,0xF0,0x3F,0x00,0xF0,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x05,0x00,0x00,0xFF,0xFF,0xFF,0x1F,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}; @@ -65,12 +64,18 @@ const uint8_t *_I_DFU_128x50[] = {_I_DFU_128x50_0}; const uint8_t _I_Warning_30x23_0[] = {0x00,0xC0,0x00,0x00,0x00,0xE0,0x01,0x00,0x00,0xF0,0x03,0x00,0x00,0xF0,0x03,0x00,0x00,0xF8,0x07,0x00,0x00,0x3C,0x0F,0x00,0x00,0x3C,0x0F,0x00,0x00,0x3E,0x1F,0x00,0x00,0x3F,0x3F,0x00,0x00,0x3F,0x3F,0x00,0x80,0x3F,0x7F,0x00,0xC0,0x3F,0xFF,0x00,0xC0,0x3F,0xFF,0x00,0xE0,0x3F,0xFF,0x01,0xF0,0x3F,0xFF,0x03,0xF0,0x3F,0xFF,0x03,0xF8,0x3F,0xFF,0x07,0xFC,0xFF,0xFF,0x0F,0xFC,0xFF,0xFF,0x0F,0xFE,0x3F,0xFF,0x1F,0xFF,0x3F,0xFF,0x3F,0xFF,0xFF,0xFF,0x3F,0xFE,0xFF,0xFF,0x1F,}; const uint8_t *_I_Warning_30x23[] = {_I_Warning_30x23_0}; +const uint8_t _I_ButtonDown_7x4_0[] = {0x7F,0x3E,0x1C,0x08,}; +const uint8_t *_I_ButtonDown_7x4[] = {_I_ButtonDown_7x4_0}; + const uint8_t _I_ButtonRight_4x7_0[] = {0x01,0x03,0x07,0x0F,0x07,0x03,0x01,}; const uint8_t *_I_ButtonRight_4x7[] = {_I_ButtonRight_4x7_0}; const uint8_t _I_ButtonCenter_7x7_0[] = {0x1C,0x22,0x5D,0x5D,0x5D,0x22,0x1C,}; const uint8_t *_I_ButtonCenter_7x7[] = {_I_ButtonCenter_7x7_0}; +const uint8_t _I_ButtonUp_7x4_0[] = {0x08,0x1C,0x3E,0x7F,}; +const uint8_t *_I_ButtonUp_7x4[] = {_I_ButtonUp_7x4_0}; + const uint8_t _I_DolphinOkay_41x43_0[] = {0x00,0x00,0xE0,0x1F,0x00,0x00,0x00,0x00,0x1E,0xE0,0x00,0x00,0x00,0x80,0x01,0x00,0x07,0x00,0x00,0x60,0x00,0x00,0x18,0x00,0x00,0x10,0x00,0x00,0x20,0x00,0x00,0x08,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x80,0x00,0x00,0x04,0x00,0x00,0x80,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x3E,0x00,0x00,0x80,0x00,0x00,0x7D,0x00,0x00,0x80,0x00,0x80,0xFE,0x00,0x00,0x80,0x00,0x40,0xE2,0x01,0x00,0x80,0x00,0x40,0xF2,0x01,0x00,0x80,0x00,0x40,0xFE,0x01,0x00,0x80,0x00,0x40,0xFE,0x05,0x00,0x80,0x00,0x40,0x7C,0x0B,0x00,0x80,0x00,0x80,0x80,0x15,0x00,0x80,0x00,0x00,0xFD,0x0A,0x00,0x00,0x01,0x00,0x02,0x15,0x00,0x00,0x01,0x00,0x01,0x0A,0x00,0x00,0xE1,0x07,0x00,0x06,0x00,0x80,0x1F,0x00,0x00,0x02,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x20,0x00,0x00,0x08,0x00,0x00,0x20,0x00,0x00,0x04,0x00,0x00,0x10,0x00,0x00,0x02,0x00,0x00,0x08,0x00,0x00,0x01,0x00,0x00,0x04,0x00,0x00,0x01,0x00,0x80,0x03,0x00,0x00,0x01,0x00,0x70,0x00,0x00,0x00,0xF9,0x03,0x0F,0x00,0x00,0x00,0x06,0xFC,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0xC0,0x01,0x00,0x08,0x00,0x00,0x78,0x00,0x00,0x30,0x00,0xF8,0xAF,0x00,0x00,0xC0,0xFF,0xFF,0x57,0x00,0x00,0x00,0xF8,0xBF,0x2A,0x00,0x00,0x00,0xF8,0x57,0x15,0x00,0x00,0x00,0xF8,0xAB,0x02,0x00,0x00,}; const uint8_t *_I_DolphinOkay_41x43[] = {_I_DolphinOkay_41x43_0}; @@ -107,15 +112,9 @@ const uint8_t *_I_DolphinFirstStart3_57x48[] = {_I_DolphinFirstStart3_57x48_0}; const uint8_t _I_PassportBottom_128x17_0[] = {0x2C,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8F,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x95,0x2C,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x9A,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x95,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x9A,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x95,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x9A,0xF2,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8F,0xF9,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0D,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x05,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x05,0xF2,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x05,0xFA,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x09,0x79,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xD5,0x80,0x55,0xD5,0x00,0xF3,0xCC,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x6A,0x00,0xAB,0x6A,0x00,0x06,0x86,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x00,0xFE,0x3F,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}; const uint8_t *_I_PassportBottom_128x17[] = {_I_PassportBottom_128x17_0}; -const uint8_t _I_DoorLeft_8x56_0[] = {0x0C,0x0C,0x0C,0x0C,0x0D,0x0D,0x0D,0x0D,0x0C,0x0D,0x0D,0x0D,0x0C,0x1C,0x38,0x70,0xE0,0xC4,0xC8,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xC8,0x44,0x20,0x10,0x08,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x1C,0x38,0x70,0xE1,0xC3,0xC6,0xCC,0xC9,0xC3,0xC6,0xCC,0xC8,0xC0,0xC0,}; -const uint8_t *_I_DoorLeft_8x56[] = {_I_DoorLeft_8x56_0}; - const uint8_t _I_DoorLocked_10x56_0[] = {0x0C,0x00,0x2D,0x00,0x6D,0x00,0xCD,0x00,0x8D,0x01,0x2C,0x01,0x6D,0x00,0xCD,0x00,0x8D,0x01,0x0C,0x01,0x1C,0x00,0x38,0x00,0x70,0x00,0xE0,0x00,0xC4,0x00,0xC8,0x00,0xD0,0x00,0xD0,0x00,0xD0,0x00,0xD0,0x00,0xD0,0x00,0xD0,0x00,0xD0,0x00,0xD0,0x00,0xC8,0x00,0x44,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x2C,0x00,0x2C,0x00,0x0C,0x00,0x2C,0x00,0x2C,0x00,0x2C,0x00,0x2C,0x00,0x2C,0x00,0x2C,0x00,0x0C,0x00,0x1C,0x00,0x38,0x00,0x70,0x00,0xE1,0x00,0xC3,0x00,0xC6,0x02,0xCC,0x00,0xC9,0x02,0xC3,0x02,0xC6,0x02,0xCC,0x00,0xC8,0x02,0xC0,0x02,0xC0,0x02,0xC0,0x02,0xC0,0x00,0xC0,0x00,}; const uint8_t *_I_DoorLocked_10x56[] = {_I_DoorLocked_10x56_0}; -const uint8_t _I_DoorRight_8x56_0[] = {0x03,0x03,0x03,0x03,0x13,0x33,0x63,0xC3,0x93,0x33,0x63,0xC3,0x86,0x0C,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0x0C,0x06,0x16,0x16,0x06,0x16,0x16,0x16,0x16,0x16,0x16,0x06,0x0C,0x18,0x30,0x30,0xB0,0x30,0xB0,0xB0,0xB0,0x30,0xB0,0xB0,0xB0,}; -const uint8_t *_I_DoorRight_8x56[] = {_I_DoorRight_8x56_0}; - const uint8_t _I_DoorLeft_70x55_0[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x40,0x03,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0x04,0x40,0x03,0x00,0x00,0x00,0x00,0x06,0x00,0x04,0x40,0x03,0x00,0x00,0x00,0x00,0x0C,0x00,0x04,0x40,0x03,0x00,0x00,0x00,0x00,0xF8,0x00,0x04,0x00,0x03,0x00,0x00,0x00,0x00,0x30,0x01,0x04,0x40,0x03,0x00,0x00,0x00,0x00,0x18,0x02,0x04,0x40,0x03,0xFF,0xFF,0xFF,0x1F,0x18,0x02,0x04,0x40,0x03,0x00,0x00,0x00,0x30,0x30,0x41,0x06,0x00,0x03,0x00,0x00,0x00,0x60,0xE0,0x20,0x03,0x00,0x07,0x00,0x90,0x24,0xC1,0x00,0x90,0x01,0x00,0x0E,0x00,0x20,0x49,0x82,0x01,0xC0,0x00,0x00,0x1C,0x00,0x40,0x92,0x04,0x03,0x60,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x06,0x3F,0x00,0x00,0x31,0xFF,0x00,0x00,0x00,0x8C,0x01,0x00,0x00,0x32,0x80,0x01,0x00,0x00,0xC8,0x00,0x00,0x00,0x34,0x00,0x03,0xFC,0x01,0x6E,0x00,0x00,0x00,0x34,0x0F,0x06,0x04,0x81,0x39,0x00,0x00,0x00,0x34,0x10,0x0C,0xF8,0x41,0x08,0x00,0x00,0x00,0x34,0xEF,0x08,0x00,0x20,0x08,0x00,0x00,0x00,0x34,0xD0,0x08,0x00,0x20,0x08,0x00,0x00,0x00,0x34,0xB0,0x08,0x00,0x10,0x08,0x00,0x00,0x00,0x34,0x73,0x0C,0xFC,0x11,0x08,0x00,0x00,0x00,0x34,0x06,0x06,0x04,0x11,0x08,0x00,0x00,0x00,0x32,0x0C,0x03,0xF8,0x11,0x08,0x00,0x00,0x00,0x11,0x98,0x01,0x00,0x10,0x08,0x00,0x00,0x00,0x08,0xF0,0x00,0x00,0x20,0x08,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x40,0x08,0x00,0x00,0x00,0x03,0x33,0x03,0x00,0x80,0x09,0x00,0x00,0x00,0x03,0x66,0x06,0x00,0x00,0x0E,0x00,0x00,0x00,0x03,0xCC,0x0C,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x98,0x19,0x00,0x00,0x0C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x03,0x00,0x40,0x92,0x04,0x03,0x00,0x00,0x00,0x03,0x00,0x20,0x49,0x82,0x01,0x00,0x00,0x00,0x03,0x00,0x90,0x24,0xC1,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x1F,0x00,0x00,0x00,0x00,0x0E,0xFF,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x31,0xFF,0xFF,0xFF,0x30,0x33,0x00,0x00,0x00,0x33,0x00,0x00,0x80,0x61,0x66,0x00,0x00,0x40,0x32,0x00,0x00,0x00,0xC3,0xCC,0x00,0x00,0xC0,0x30,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x80,0x31,0x00,0x00,0x00,0xFC,0xFF,0xFF,0x01,0x00,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x30,}; const uint8_t *_I_DoorLeft_70x55[] = {_I_DoorLeft_70x55_0}; @@ -435,6 +434,9 @@ const uint8_t *_I_Quest_7x8[] = {_I_Quest_7x8_0}; const uint8_t _I_Unlock_7x8_0[] = {0x1C,0x22,0x02,0x4F,0x67,0x73,0x79,0x3C,}; const uint8_t *_I_Unlock_7x8[] = {_I_Unlock_7x8_0}; +const uint8_t _I_MHz_25x11_0[] = {0xC3,0x86,0x01,0x00,0xE7,0x86,0x01,0x00,0xFF,0x86,0x01,0x00,0xFF,0x86,0xFD,0x01,0xDB,0xFE,0xFD,0x01,0xDB,0xFE,0xC1,0x00,0xDB,0x86,0x61,0x00,0xC3,0x86,0x31,0x00,0xC3,0x86,0x19,0x00,0xC3,0x86,0xFD,0x01,0xC3,0x86,0xFD,0x01,}; +const uint8_t *_I_MHz_25x11[] = {_I_MHz_25x11_0}; + const uint8_t _I_Lock_7x8_0[] = {0x1C,0x22,0x22,0x7F,0x7F,0x77,0x7F,0x3E,}; const uint8_t *_I_Lock_7x8[] = {_I_Lock_7x8_0}; @@ -461,8 +463,8 @@ const uint8_t *_I_DolphinWait_61x59[] = {_I_DolphinWait_61x59_0}; const Icon I_Certification1_103x23 = {.width=103,.height=23,.frame_count=1,.frame_rate=0,.frames=_I_Certification1_103x23}; const Icon I_Certification2_119x30 = {.width=119,.height=30,.frame_count=1,.frame_rate=0,.frames=_I_Certification2_119x30}; -const Icon A_WatchingTV_128x64 = {.width=128,.height=64,.frame_count=5,.frame_rate=10,.frames=_A_WatchingTV_128x64}; -const Icon A_Wink_128x64 = {.width=128,.height=64,.frame_count=9,.frame_rate=10,.frames=_A_Wink_128x64}; +const Icon A_WatchingTV_128x64 = {.width=128,.height=64,.frame_count=4,.frame_rate=1,.frames=_A_WatchingTV_128x64}; +const Icon A_Wink_128x64 = {.width=128,.height=64,.frame_count=9,.frame_rate=1,.frames=_A_Wink_128x64}; const Icon I_dir_10px = {.width=10,.height=10,.frame_count=1,.frame_rate=0,.frames=_I_dir_10px}; const Icon I_Nfc_10px = {.width=10,.height=10,.frame_count=1,.frame_rate=0,.frames=_I_Nfc_10px}; const Icon I_sub1_10px = {.width=10,.height=10,.frame_count=1,.frame_rate=0,.frames=_I_sub1_10px}; @@ -476,8 +478,10 @@ const Icon I_ButtonLeft_4x7 = {.width=4,.height=7,.frame_count=1,.frame_rate=0,. const Icon I_ButtonLeftSmall_3x5 = {.width=3,.height=5,.frame_count=1,.frame_rate=0,.frames=_I_ButtonLeftSmall_3x5}; const Icon I_DFU_128x50 = {.width=128,.height=50,.frame_count=1,.frame_rate=0,.frames=_I_DFU_128x50}; const Icon I_Warning_30x23 = {.width=30,.height=23,.frame_count=1,.frame_rate=0,.frames=_I_Warning_30x23}; +const Icon I_ButtonDown_7x4 = {.width=7,.height=4,.frame_count=1,.frame_rate=0,.frames=_I_ButtonDown_7x4}; const Icon I_ButtonRight_4x7 = {.width=4,.height=7,.frame_count=1,.frame_rate=0,.frames=_I_ButtonRight_4x7}; const Icon I_ButtonCenter_7x7 = {.width=7,.height=7,.frame_count=1,.frame_rate=0,.frames=_I_ButtonCenter_7x7}; +const Icon I_ButtonUp_7x4 = {.width=7,.height=4,.frame_count=1,.frame_rate=0,.frames=_I_ButtonUp_7x4}; const Icon I_DolphinOkay_41x43 = {.width=41,.height=43,.frame_count=1,.frame_rate=0,.frames=_I_DolphinOkay_41x43}; const Icon I_DolphinFirstStart4_67x53 = {.width=67,.height=53,.frame_count=1,.frame_rate=0,.frames=_I_DolphinFirstStart4_67x53}; const Icon I_DolphinFirstStart2_59x51 = {.width=59,.height=51,.frame_count=1,.frame_rate=0,.frames=_I_DolphinFirstStart2_59x51}; @@ -490,9 +494,7 @@ const Icon I_DolphinFirstStart7_61x51 = {.width=61,.height=51,.frame_count=1,.fr const Icon I_Flipper_young_80x60 = {.width=80,.height=60,.frame_count=1,.frame_rate=0,.frames=_I_Flipper_young_80x60}; const Icon I_DolphinFirstStart3_57x48 = {.width=57,.height=48,.frame_count=1,.frame_rate=0,.frames=_I_DolphinFirstStart3_57x48}; const Icon I_PassportBottom_128x17 = {.width=128,.height=17,.frame_count=1,.frame_rate=0,.frames=_I_PassportBottom_128x17}; -const Icon I_DoorLeft_8x56 = {.width=8,.height=56,.frame_count=1,.frame_rate=0,.frames=_I_DoorLeft_8x56}; const Icon I_DoorLocked_10x56 = {.width=10,.height=56,.frame_count=1,.frame_rate=0,.frames=_I_DoorLocked_10x56}; -const Icon I_DoorRight_8x56 = {.width=8,.height=56,.frame_count=1,.frame_rate=0,.frames=_I_DoorRight_8x56}; const Icon I_DoorLeft_70x55 = {.width=70,.height=55,.frame_count=1,.frame_rate=0,.frames=_I_DoorLeft_70x55}; const Icon I_PassportLeft_6x47 = {.width=6,.height=47,.frame_count=1,.frame_rate=0,.frames=_I_PassportLeft_6x47}; const Icon I_DoorRight_70x55 = {.width=70,.height=55,.frame_count=1,.frame_rate=0,.frames=_I_DoorRight_70x55}; @@ -570,6 +572,7 @@ const Icon I_Background_128x11 = {.width=128,.height=11,.frame_count=1,.frame_ra const Icon I_Scanning_123x52 = {.width=123,.height=52,.frame_count=1,.frame_rate=0,.frames=_I_Scanning_123x52}; const Icon I_Quest_7x8 = {.width=7,.height=8,.frame_count=1,.frame_rate=0,.frames=_I_Quest_7x8}; const Icon I_Unlock_7x8 = {.width=7,.height=8,.frame_count=1,.frame_rate=0,.frames=_I_Unlock_7x8}; +const Icon I_MHz_25x11 = {.width=25,.height=11,.frame_count=1,.frame_rate=0,.frames=_I_MHz_25x11}; const Icon I_Lock_7x8 = {.width=7,.height=8,.frame_count=1,.frame_rate=0,.frames=_I_Lock_7x8}; const Icon I_DolphinMafia_115x62 = {.width=115,.height=62,.frame_count=1,.frame_rate=0,.frames=_I_DolphinMafia_115x62}; const Icon I_DolphinExcited_64x63 = {.width=64,.height=63,.frame_count=1,.frame_rate=0,.frames=_I_DolphinExcited_64x63}; diff --git a/assets/compiled/assets_icons.h b/assets/compiled/assets_icons.h index e16b3cf3..580928c4 100644 --- a/assets/compiled/assets_icons.h +++ b/assets/compiled/assets_icons.h @@ -18,8 +18,10 @@ extern const Icon I_ButtonLeft_4x7; extern const Icon I_ButtonLeftSmall_3x5; extern const Icon I_DFU_128x50; extern const Icon I_Warning_30x23; +extern const Icon I_ButtonDown_7x4; extern const Icon I_ButtonRight_4x7; extern const Icon I_ButtonCenter_7x7; +extern const Icon I_ButtonUp_7x4; extern const Icon I_DolphinOkay_41x43; extern const Icon I_DolphinFirstStart4_67x53; extern const Icon I_DolphinFirstStart2_59x51; @@ -32,9 +34,7 @@ extern const Icon I_DolphinFirstStart7_61x51; extern const Icon I_Flipper_young_80x60; extern const Icon I_DolphinFirstStart3_57x48; extern const Icon I_PassportBottom_128x17; -extern const Icon I_DoorLeft_8x56; extern const Icon I_DoorLocked_10x56; -extern const Icon I_DoorRight_8x56; extern const Icon I_DoorLeft_70x55; extern const Icon I_PassportLeft_6x47; extern const Icon I_DoorRight_70x55; @@ -112,6 +112,7 @@ extern const Icon I_Background_128x11; extern const Icon I_Scanning_123x52; extern const Icon I_Quest_7x8; extern const Icon I_Unlock_7x8; +extern const Icon I_MHz_25x11; extern const Icon I_Lock_7x8; extern const Icon I_DolphinMafia_115x62; extern const Icon I_DolphinExcited_64x63; diff --git a/assets/compiled/flipper.pb.c b/assets/compiled/flipper.pb.c new file mode 100644 index 00000000..d81c78ec --- /dev/null +++ b/assets/compiled/flipper.pb.c @@ -0,0 +1,16 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.5 */ + +#include "flipper.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(PB_Empty, PB_Empty, AUTO) + + +PB_BIND(PB_Main, PB_Main, AUTO) + + + + diff --git a/assets/compiled/flipper.pb.h b/assets/compiled/flipper.pb.h new file mode 100644 index 00000000..4af72479 --- /dev/null +++ b/assets/compiled/flipper.pb.h @@ -0,0 +1,168 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.5 */ + +#ifndef PB_PB_FLIPPER_PB_H_INCLUDED +#define PB_PB_FLIPPER_PB_H_INCLUDED +#include +#include "storage.pb.h" +#include "status.pb.h" +#include "application.pb.h" + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Enum definitions */ +typedef enum _PB_CommandStatus { + PB_CommandStatus_OK = 0, + PB_CommandStatus_ERROR = 1, /* *< Unknown error */ + PB_CommandStatus_ERROR_DECODE = 2, /* *< Command can't be decoded successfully - command_id in response may be wrong! */ + PB_CommandStatus_ERROR_NOT_IMPLEMENTED = 3, /* *< Command succesfully decoded, but not implemented (deprecated or not yet implemented) */ + PB_CommandStatus_ERROR_BUSY = 4, /* *< Somebody took global lock, so not all commands are available */ + PB_CommandStatus_ERROR_CONTINUOUS_COMMAND_INTERRUPTED = 14, /* *< Not received has_next == 0 */ + PB_CommandStatus_ERROR_INVALID_PARAMETERS = 15, /* *< not provided (or provided invalid) crucial parameters to perform rpc */ + PB_CommandStatus_ERROR_STORAGE_NOT_READY = 5, /* *< FS not ready */ + PB_CommandStatus_ERROR_STORAGE_EXIST = 6, /* *< File/Dir alrady exist */ + PB_CommandStatus_ERROR_STORAGE_NOT_EXIST = 7, /* *< File/Dir does not exist */ + PB_CommandStatus_ERROR_STORAGE_INVALID_PARAMETER = 8, /* *< Invalid API parameter */ + PB_CommandStatus_ERROR_STORAGE_DENIED = 9, /* *< Access denied */ + PB_CommandStatus_ERROR_STORAGE_INVALID_NAME = 10, /* *< Invalid name/path */ + PB_CommandStatus_ERROR_STORAGE_INTERNAL = 11, /* *< Internal error */ + PB_CommandStatus_ERROR_STORAGE_NOT_IMPLEMENTED = 12, /* *< Functon not implemented */ + PB_CommandStatus_ERROR_STORAGE_ALREADY_OPEN = 13, /* *< File/Dir already opened */ + PB_CommandStatus_ERROR_APP_CANT_START = 16, /* *< Can't start app - either wrong name, or internal error */ + PB_CommandStatus_ERROR_APP_SYSTEM_LOCKED = 17 /* *< Another app is running */ +} PB_CommandStatus; + +/* Struct definitions */ +/* There are Server commands (e.g. Storage_write), which have no body message + in response. But 'oneof' obligate to have at least 1 encoded message + in scope. For this needs Empty message is implemented. */ +typedef struct _PB_Empty { + char dummy_field; +} PB_Empty; + +typedef struct _PB_Main { + uint32_t command_id; + PB_CommandStatus command_status; + bool has_next; + pb_callback_t cb_content; + pb_size_t which_content; + union { + PB_Empty empty; + PB_Status_PingRequest ping_request; + PB_Status_PingResponse ping_response; + PB_Storage_ListRequest storage_list_request; + PB_Storage_ListResponse storage_list_response; + PB_Storage_ReadRequest storage_read_request; + PB_Storage_ReadResponse storage_read_response; + PB_Storage_WriteRequest storage_write_request; + PB_Storage_DeleteRequest storage_delete_request; + PB_Storage_MkdirRequest storage_mkdir_request; + PB_Storage_Md5sumRequest storage_md5sum_request; + PB_Storage_Md5sumResponse storage_md5sum_response; + PB_App_Start app_start; + PB_App_LockStatusRequest app_lock_status_request; + PB_App_LockStatusResponse app_lock_status_response; + } content; +} PB_Main; + + +/* Helper constants for enums */ +#define _PB_CommandStatus_MIN PB_CommandStatus_OK +#define _PB_CommandStatus_MAX PB_CommandStatus_ERROR_APP_SYSTEM_LOCKED +#define _PB_CommandStatus_ARRAYSIZE ((PB_CommandStatus)(PB_CommandStatus_ERROR_APP_SYSTEM_LOCKED+1)) + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define PB_Empty_init_default {0} +#define PB_Main_init_default {0, _PB_CommandStatus_MIN, 0, {{NULL}, NULL}, 0, {PB_Empty_init_default}} +#define PB_Empty_init_zero {0} +#define PB_Main_init_zero {0, _PB_CommandStatus_MIN, 0, {{NULL}, NULL}, 0, {PB_Empty_init_zero}} + +/* Field tags (for use in manual encoding/decoding) */ +#define PB_Main_command_id_tag 1 +#define PB_Main_command_status_tag 2 +#define PB_Main_has_next_tag 3 +#define PB_Main_empty_tag 4 +#define PB_Main_ping_request_tag 5 +#define PB_Main_ping_response_tag 6 +#define PB_Main_storage_list_request_tag 7 +#define PB_Main_storage_list_response_tag 8 +#define PB_Main_storage_read_request_tag 9 +#define PB_Main_storage_read_response_tag 10 +#define PB_Main_storage_write_request_tag 11 +#define PB_Main_storage_delete_request_tag 12 +#define PB_Main_storage_mkdir_request_tag 13 +#define PB_Main_storage_md5sum_request_tag 14 +#define PB_Main_storage_md5sum_response_tag 15 +#define PB_Main_app_start_tag 16 +#define PB_Main_app_lock_status_request_tag 17 +#define PB_Main_app_lock_status_response_tag 18 + +/* Struct field encoding specification for nanopb */ +#define PB_Empty_FIELDLIST(X, a) \ + +#define PB_Empty_CALLBACK NULL +#define PB_Empty_DEFAULT NULL + +#define PB_Main_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, command_id, 1) \ +X(a, STATIC, SINGULAR, UENUM, command_status, 2) \ +X(a, STATIC, SINGULAR, BOOL, has_next, 3) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,empty,content.empty), 4) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,ping_request,content.ping_request), 5) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,ping_response,content.ping_response), 6) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_list_request,content.storage_list_request), 7) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_list_response,content.storage_list_response), 8) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_read_request,content.storage_read_request), 9) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_read_response,content.storage_read_response), 10) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_write_request,content.storage_write_request), 11) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_delete_request,content.storage_delete_request), 12) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_mkdir_request,content.storage_mkdir_request), 13) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_md5sum_request,content.storage_md5sum_request), 14) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_md5sum_response,content.storage_md5sum_response), 15) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,app_start,content.app_start), 16) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,app_lock_status_request,content.app_lock_status_request), 17) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,app_lock_status_response,content.app_lock_status_response), 18) +#define PB_Main_CALLBACK NULL +#define PB_Main_DEFAULT NULL +#define PB_Main_content_empty_MSGTYPE PB_Empty +#define PB_Main_content_ping_request_MSGTYPE PB_Status_PingRequest +#define PB_Main_content_ping_response_MSGTYPE PB_Status_PingResponse +#define PB_Main_content_storage_list_request_MSGTYPE PB_Storage_ListRequest +#define PB_Main_content_storage_list_response_MSGTYPE PB_Storage_ListResponse +#define PB_Main_content_storage_read_request_MSGTYPE PB_Storage_ReadRequest +#define PB_Main_content_storage_read_response_MSGTYPE PB_Storage_ReadResponse +#define PB_Main_content_storage_write_request_MSGTYPE PB_Storage_WriteRequest +#define PB_Main_content_storage_delete_request_MSGTYPE PB_Storage_DeleteRequest +#define PB_Main_content_storage_mkdir_request_MSGTYPE PB_Storage_MkdirRequest +#define PB_Main_content_storage_md5sum_request_MSGTYPE PB_Storage_Md5sumRequest +#define PB_Main_content_storage_md5sum_response_MSGTYPE PB_Storage_Md5sumResponse +#define PB_Main_content_app_start_MSGTYPE PB_App_Start +#define PB_Main_content_app_lock_status_request_MSGTYPE PB_App_LockStatusRequest +#define PB_Main_content_app_lock_status_response_MSGTYPE PB_App_LockStatusResponse + +extern const pb_msgdesc_t PB_Empty_msg; +extern const pb_msgdesc_t PB_Main_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define PB_Empty_fields &PB_Empty_msg +#define PB_Main_fields &PB_Main_msg + +/* Maximum encoded size of messages (where known) */ +#define PB_Empty_size 0 +#if defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_Start_size) +#define PB_Main_size (10 + sizeof(union PB_Main_content_size_union)) +union PB_Main_content_size_union {char f7[(6 + PB_Storage_ListRequest_size)]; char f8[(6 + PB_Storage_ListResponse_size)]; char f9[(6 + PB_Storage_ReadRequest_size)]; char f10[(6 + PB_Storage_ReadResponse_size)]; char f11[(6 + PB_Storage_WriteRequest_size)]; char f12[(6 + PB_Storage_DeleteRequest_size)]; char f13[(6 + PB_Storage_MkdirRequest_size)]; char f14[(6 + PB_Storage_Md5sumRequest_size)]; char f16[(7 + PB_App_Start_size)]; char f0[36];}; +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/assets/compiled/status.pb.c b/assets/compiled/status.pb.c new file mode 100644 index 00000000..6010eb55 --- /dev/null +++ b/assets/compiled/status.pb.c @@ -0,0 +1,15 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.5 */ + +#include "status.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(PB_Status_PingRequest, PB_Status_PingRequest, AUTO) + + +PB_BIND(PB_Status_PingResponse, PB_Status_PingResponse, AUTO) + + + diff --git a/assets/compiled/status.pb.h b/assets/compiled/status.pb.h new file mode 100644 index 00000000..acc6902a --- /dev/null +++ b/assets/compiled/status.pb.h @@ -0,0 +1,60 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.5 */ + +#ifndef PB_PB_STATUS_STATUS_PB_H_INCLUDED +#define PB_PB_STATUS_STATUS_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +typedef struct _PB_Status_PingRequest { + char dummy_field; +} PB_Status_PingRequest; + +typedef struct _PB_Status_PingResponse { + char dummy_field; +} PB_Status_PingResponse; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define PB_Status_PingRequest_init_default {0} +#define PB_Status_PingResponse_init_default {0} +#define PB_Status_PingRequest_init_zero {0} +#define PB_Status_PingResponse_init_zero {0} + +/* Field tags (for use in manual encoding/decoding) */ + +/* Struct field encoding specification for nanopb */ +#define PB_Status_PingRequest_FIELDLIST(X, a) \ + +#define PB_Status_PingRequest_CALLBACK NULL +#define PB_Status_PingRequest_DEFAULT NULL + +#define PB_Status_PingResponse_FIELDLIST(X, a) \ + +#define PB_Status_PingResponse_CALLBACK NULL +#define PB_Status_PingResponse_DEFAULT NULL + +extern const pb_msgdesc_t PB_Status_PingRequest_msg; +extern const pb_msgdesc_t PB_Status_PingResponse_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define PB_Status_PingRequest_fields &PB_Status_PingRequest_msg +#define PB_Status_PingResponse_fields &PB_Status_PingResponse_msg + +/* Maximum encoded size of messages (where known) */ +#define PB_Status_PingRequest_size 0 +#define PB_Status_PingResponse_size 0 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/assets/compiled/storage.pb.c b/assets/compiled/storage.pb.c new file mode 100644 index 00000000..a74477e1 --- /dev/null +++ b/assets/compiled/storage.pb.c @@ -0,0 +1,40 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.5 */ + +#include "storage.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(PB_Storage_File, PB_Storage_File, AUTO) + + +PB_BIND(PB_Storage_ListRequest, PB_Storage_ListRequest, AUTO) + + +PB_BIND(PB_Storage_ListResponse, PB_Storage_ListResponse, AUTO) + + +PB_BIND(PB_Storage_ReadRequest, PB_Storage_ReadRequest, AUTO) + + +PB_BIND(PB_Storage_ReadResponse, PB_Storage_ReadResponse, AUTO) + + +PB_BIND(PB_Storage_WriteRequest, PB_Storage_WriteRequest, AUTO) + + +PB_BIND(PB_Storage_DeleteRequest, PB_Storage_DeleteRequest, AUTO) + + +PB_BIND(PB_Storage_MkdirRequest, PB_Storage_MkdirRequest, AUTO) + + +PB_BIND(PB_Storage_Md5sumRequest, PB_Storage_Md5sumRequest, AUTO) + + +PB_BIND(PB_Storage_Md5sumResponse, PB_Storage_Md5sumResponse, AUTO) + + + + diff --git a/assets/compiled/storage.pb.h b/assets/compiled/storage.pb.h new file mode 100644 index 00000000..cdb47372 --- /dev/null +++ b/assets/compiled/storage.pb.h @@ -0,0 +1,212 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.5 */ + +#ifndef PB_PB_STORAGE_STORAGE_PB_H_INCLUDED +#define PB_PB_STORAGE_STORAGE_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Enum definitions */ +typedef enum _PB_Storage_File_FileType { + PB_Storage_File_FileType_FILE = 0, + PB_Storage_File_FileType_DIR = 1 +} PB_Storage_File_FileType; + +/* Struct definitions */ +typedef struct _PB_Storage_DeleteRequest { + char *path; +} PB_Storage_DeleteRequest; + +typedef struct _PB_Storage_ListRequest { + char *path; +} PB_Storage_ListRequest; + +typedef struct _PB_Storage_Md5sumRequest { + char *path; +} PB_Storage_Md5sumRequest; + +typedef struct _PB_Storage_MkdirRequest { + char *path; +} PB_Storage_MkdirRequest; + +typedef struct _PB_Storage_ReadRequest { + char *path; +} PB_Storage_ReadRequest; + +typedef struct _PB_Storage_File { + PB_Storage_File_FileType type; + char *name; + uint32_t size; + pb_bytes_array_t *data; +} PB_Storage_File; + +typedef struct _PB_Storage_Md5sumResponse { + char md5sum[33]; +} PB_Storage_Md5sumResponse; + +typedef struct _PB_Storage_ListResponse { + pb_size_t file_count; + PB_Storage_File file[8]; +} PB_Storage_ListResponse; + +typedef struct _PB_Storage_ReadResponse { + bool has_file; + PB_Storage_File file; +} PB_Storage_ReadResponse; + +typedef struct _PB_Storage_WriteRequest { + char *path; + bool has_file; + PB_Storage_File file; +} PB_Storage_WriteRequest; + + +/* Helper constants for enums */ +#define _PB_Storage_File_FileType_MIN PB_Storage_File_FileType_FILE +#define _PB_Storage_File_FileType_MAX PB_Storage_File_FileType_DIR +#define _PB_Storage_File_FileType_ARRAYSIZE ((PB_Storage_File_FileType)(PB_Storage_File_FileType_DIR+1)) + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define PB_Storage_File_init_default {_PB_Storage_File_FileType_MIN, NULL, 0, NULL} +#define PB_Storage_ListRequest_init_default {NULL} +#define PB_Storage_ListResponse_init_default {0, {PB_Storage_File_init_default, PB_Storage_File_init_default, PB_Storage_File_init_default, PB_Storage_File_init_default, PB_Storage_File_init_default, PB_Storage_File_init_default, PB_Storage_File_init_default, PB_Storage_File_init_default}} +#define PB_Storage_ReadRequest_init_default {NULL} +#define PB_Storage_ReadResponse_init_default {false, PB_Storage_File_init_default} +#define PB_Storage_WriteRequest_init_default {NULL, false, PB_Storage_File_init_default} +#define PB_Storage_DeleteRequest_init_default {NULL} +#define PB_Storage_MkdirRequest_init_default {NULL} +#define PB_Storage_Md5sumRequest_init_default {NULL} +#define PB_Storage_Md5sumResponse_init_default {""} +#define PB_Storage_File_init_zero {_PB_Storage_File_FileType_MIN, NULL, 0, NULL} +#define PB_Storage_ListRequest_init_zero {NULL} +#define PB_Storage_ListResponse_init_zero {0, {PB_Storage_File_init_zero, PB_Storage_File_init_zero, PB_Storage_File_init_zero, PB_Storage_File_init_zero, PB_Storage_File_init_zero, PB_Storage_File_init_zero, PB_Storage_File_init_zero, PB_Storage_File_init_zero}} +#define PB_Storage_ReadRequest_init_zero {NULL} +#define PB_Storage_ReadResponse_init_zero {false, PB_Storage_File_init_zero} +#define PB_Storage_WriteRequest_init_zero {NULL, false, PB_Storage_File_init_zero} +#define PB_Storage_DeleteRequest_init_zero {NULL} +#define PB_Storage_MkdirRequest_init_zero {NULL} +#define PB_Storage_Md5sumRequest_init_zero {NULL} +#define PB_Storage_Md5sumResponse_init_zero {""} + +/* Field tags (for use in manual encoding/decoding) */ +#define PB_Storage_DeleteRequest_path_tag 1 +#define PB_Storage_ListRequest_path_tag 1 +#define PB_Storage_Md5sumRequest_path_tag 1 +#define PB_Storage_MkdirRequest_path_tag 1 +#define PB_Storage_ReadRequest_path_tag 1 +#define PB_Storage_File_type_tag 1 +#define PB_Storage_File_name_tag 2 +#define PB_Storage_File_size_tag 3 +#define PB_Storage_File_data_tag 4 +#define PB_Storage_Md5sumResponse_md5sum_tag 1 +#define PB_Storage_ListResponse_file_tag 1 +#define PB_Storage_ReadResponse_file_tag 1 +#define PB_Storage_WriteRequest_path_tag 1 +#define PB_Storage_WriteRequest_file_tag 2 + +/* Struct field encoding specification for nanopb */ +#define PB_Storage_File_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, POINTER, SINGULAR, STRING, name, 2) \ +X(a, STATIC, SINGULAR, UINT32, size, 3) \ +X(a, POINTER, SINGULAR, BYTES, data, 4) +#define PB_Storage_File_CALLBACK NULL +#define PB_Storage_File_DEFAULT NULL + +#define PB_Storage_ListRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, path, 1) +#define PB_Storage_ListRequest_CALLBACK NULL +#define PB_Storage_ListRequest_DEFAULT NULL + +#define PB_Storage_ListResponse_FIELDLIST(X, a) \ +X(a, STATIC, REPEATED, MESSAGE, file, 1) +#define PB_Storage_ListResponse_CALLBACK NULL +#define PB_Storage_ListResponse_DEFAULT NULL +#define PB_Storage_ListResponse_file_MSGTYPE PB_Storage_File + +#define PB_Storage_ReadRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, path, 1) +#define PB_Storage_ReadRequest_CALLBACK NULL +#define PB_Storage_ReadRequest_DEFAULT NULL + +#define PB_Storage_ReadResponse_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, file, 1) +#define PB_Storage_ReadResponse_CALLBACK NULL +#define PB_Storage_ReadResponse_DEFAULT NULL +#define PB_Storage_ReadResponse_file_MSGTYPE PB_Storage_File + +#define PB_Storage_WriteRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, path, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, file, 2) +#define PB_Storage_WriteRequest_CALLBACK NULL +#define PB_Storage_WriteRequest_DEFAULT NULL +#define PB_Storage_WriteRequest_file_MSGTYPE PB_Storage_File + +#define PB_Storage_DeleteRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, path, 1) +#define PB_Storage_DeleteRequest_CALLBACK NULL +#define PB_Storage_DeleteRequest_DEFAULT NULL + +#define PB_Storage_MkdirRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, path, 1) +#define PB_Storage_MkdirRequest_CALLBACK NULL +#define PB_Storage_MkdirRequest_DEFAULT NULL + +#define PB_Storage_Md5sumRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, path, 1) +#define PB_Storage_Md5sumRequest_CALLBACK NULL +#define PB_Storage_Md5sumRequest_DEFAULT NULL + +#define PB_Storage_Md5sumResponse_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, md5sum, 1) +#define PB_Storage_Md5sumResponse_CALLBACK NULL +#define PB_Storage_Md5sumResponse_DEFAULT NULL + +extern const pb_msgdesc_t PB_Storage_File_msg; +extern const pb_msgdesc_t PB_Storage_ListRequest_msg; +extern const pb_msgdesc_t PB_Storage_ListResponse_msg; +extern const pb_msgdesc_t PB_Storage_ReadRequest_msg; +extern const pb_msgdesc_t PB_Storage_ReadResponse_msg; +extern const pb_msgdesc_t PB_Storage_WriteRequest_msg; +extern const pb_msgdesc_t PB_Storage_DeleteRequest_msg; +extern const pb_msgdesc_t PB_Storage_MkdirRequest_msg; +extern const pb_msgdesc_t PB_Storage_Md5sumRequest_msg; +extern const pb_msgdesc_t PB_Storage_Md5sumResponse_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define PB_Storage_File_fields &PB_Storage_File_msg +#define PB_Storage_ListRequest_fields &PB_Storage_ListRequest_msg +#define PB_Storage_ListResponse_fields &PB_Storage_ListResponse_msg +#define PB_Storage_ReadRequest_fields &PB_Storage_ReadRequest_msg +#define PB_Storage_ReadResponse_fields &PB_Storage_ReadResponse_msg +#define PB_Storage_WriteRequest_fields &PB_Storage_WriteRequest_msg +#define PB_Storage_DeleteRequest_fields &PB_Storage_DeleteRequest_msg +#define PB_Storage_MkdirRequest_fields &PB_Storage_MkdirRequest_msg +#define PB_Storage_Md5sumRequest_fields &PB_Storage_Md5sumRequest_msg +#define PB_Storage_Md5sumResponse_fields &PB_Storage_Md5sumResponse_msg + +/* Maximum encoded size of messages (where known) */ +/* PB_Storage_File_size depends on runtime parameters */ +/* PB_Storage_ListRequest_size depends on runtime parameters */ +/* PB_Storage_ListResponse_size depends on runtime parameters */ +/* PB_Storage_ReadRequest_size depends on runtime parameters */ +/* PB_Storage_ReadResponse_size depends on runtime parameters */ +/* PB_Storage_WriteRequest_size depends on runtime parameters */ +/* PB_Storage_DeleteRequest_size depends on runtime parameters */ +/* PB_Storage_MkdirRequest_size depends on runtime parameters */ +/* PB_Storage_Md5sumRequest_size depends on runtime parameters */ +#define PB_Storage_Md5sumResponse_size 34 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/assets/icons/Animations/WatchingTV_128x64/frame_05.png b/assets/icons/Animations/WatchingTV_128x64/frame_05.png deleted file mode 100644 index 15fa1601..00000000 Binary files a/assets/icons/Animations/WatchingTV_128x64/frame_05.png and /dev/null differ diff --git a/assets/icons/Animations/WatchingTV_128x64/frame_rate b/assets/icons/Animations/WatchingTV_128x64/frame_rate index 9a037142..56a6051c 100644 --- a/assets/icons/Animations/WatchingTV_128x64/frame_rate +++ b/assets/icons/Animations/WatchingTV_128x64/frame_rate @@ -1 +1 @@ -10 \ No newline at end of file +1 \ No newline at end of file diff --git a/assets/icons/Animations/Wink_128x64/frame_rate b/assets/icons/Animations/Wink_128x64/frame_rate index 9a037142..56a6051c 100644 --- a/assets/icons/Animations/Wink_128x64/frame_rate +++ b/assets/icons/Animations/Wink_128x64/frame_rate @@ -1 +1 @@ -10 \ No newline at end of file +1 \ No newline at end of file diff --git a/assets/icons/Common/ButtonDown_7x4.png b/assets/icons/Common/ButtonDown_7x4.png new file mode 100644 index 00000000..2954bb6a Binary files /dev/null and b/assets/icons/Common/ButtonDown_7x4.png differ diff --git a/assets/icons/Common/ButtonUp_7x4.png b/assets/icons/Common/ButtonUp_7x4.png new file mode 100644 index 00000000..1be79328 Binary files /dev/null and b/assets/icons/Common/ButtonUp_7x4.png differ diff --git a/assets/icons/Interface/DoorLeft_8x56.png b/assets/icons/Interface/DoorLeft_8x56.png deleted file mode 100644 index f8eab132..00000000 Binary files a/assets/icons/Interface/DoorLeft_8x56.png and /dev/null differ diff --git a/assets/icons/Interface/DoorRight_8x56.png b/assets/icons/Interface/DoorRight_8x56.png deleted file mode 100644 index 4828ebc6..00000000 Binary files a/assets/icons/Interface/DoorRight_8x56.png and /dev/null differ diff --git a/assets/icons/SubGhz/MHz_25x11.png b/assets/icons/SubGhz/MHz_25x11.png new file mode 100644 index 00000000..b9955495 Binary files /dev/null and b/assets/icons/SubGhz/MHz_25x11.png differ diff --git a/assets/protobuf b/assets/protobuf new file mode 160000 index 00000000..8e6db414 --- /dev/null +++ b/assets/protobuf @@ -0,0 +1 @@ +Subproject commit 8e6db414beed5aff0902f2cca2f4146a0dffb7a1 diff --git a/bootloader/Makefile b/bootloader/Makefile index 7207124b..be2cf5dc 100644 --- a/bootloader/Makefile +++ b/bootloader/Makefile @@ -8,7 +8,7 @@ ASM_SOURCES += $(wildcard src/*.s) C_SOURCES += $(wildcard src/*.c) CPP_SOURCES += $(wildcard src/*.cpp) -TARGET ?= f6 +TARGET ?= f7 TARGET_DIR = targets/$(TARGET) include $(TARGET_DIR)/target.mk diff --git a/core/furi-hal/api-interrupt-mgr.h b/core/furi-hal/api-interrupt-mgr.h index 81245cb9..0a9c9d8c 100644 --- a/core/furi-hal/api-interrupt-mgr.h +++ b/core/furi-hal/api-interrupt-mgr.h @@ -1,3 +1,8 @@ +/** + * @file api-interrupt-mgr.h + * Furi: interrupt API + */ + #pragma once #include @@ -23,45 +28,45 @@ typedef struct { bool ready; } InterruptCallbackItem; -/** - * Init interrupt - * @return true on succsessful initialization, false otherwise +/** Init interrupt + * + * @return true on succsessful initialization, false otherwise */ bool api_interrupt_init(); -/** - * Add interrupt - * @param callback InterruptCallback - * @param type InterruptType - * @param context context for callback +/** Add interrupt + * + * @param callback InterruptCallback + * @param type InterruptType + * @param context context for callback */ void api_interrupt_add(InterruptCallback callback, InterruptType type, void* context); -/** - * Remove interrupt - * @param callback InterruptCallback - * @param type InterruptType +/** Remove interrupt + * + * @param callback InterruptCallback + * @param type InterruptType */ void api_interrupt_remove(InterruptCallback callback, InterruptType type); -/** - * Enable interrupt - * @param callback InterruptCallback - * @param type InterruptType +/** Enable interrupt + * + * @param callback InterruptCallback + * @param type InterruptType */ void api_interrupt_enable(InterruptCallback callback, InterruptType type); -/** - * Disable interrupt - * @param callback InterruptCallback - * @param type InterruptType +/** Disable interrupt + * + * @param callback InterruptCallback + * @param type InterruptType */ void api_interrupt_disable(InterruptCallback callback, InterruptType type); -/** - * Call interrupt - * @param type InterruptType - * @param hw pointer to hardware peripheral +/** Call interrupt + * + * @param type InterruptType + * @param hw pointer to hardware peripheral */ void api_interrupt_call(InterruptType type, void* hw); diff --git a/core/furi/check.h b/core/furi/check.h index 5115fda3..7f555d1b 100644 --- a/core/furi/check.h +++ b/core/furi/check.h @@ -8,10 +8,10 @@ extern "C" { #define furi_check(__e) ((__e) ? (void)0 : furi_crash("fury_check failed\r\n")) /** Only in debug build: Assert condition and crash if assert failed */ -#ifdef NDEBUG -#define furi_assert(__e) ((void)0) -#else +#ifdef FURI_DEBUG #define furi_assert(__e) ((__e) ? (void)0 : furi_crash("furi_assert failed\r\n")) +#else +#define furi_assert(__e) ((void)0) #endif /** Crash system */ diff --git a/core/furi/memmgr.c b/core/furi/memmgr.c index a79cc502..12146247 100644 --- a/core/furi/memmgr.c +++ b/core/furi/memmgr.c @@ -68,6 +68,12 @@ size_t memmgr_get_minimum_free_heap(void) { return xPortGetMinimumEverFreeHeapSize(); } +void* furi_alloc(size_t size) { + void* p = malloc(size); + furi_check(p); + return memset(p, 0, size); +} + void* __wrap__malloc_r(struct _reent* r, size_t size) { void* pointer = malloc(size); return pointer; diff --git a/core/furi/memmgr.h b/core/furi/memmgr.h index 98e7c1d8..7c8a3fe9 100644 --- a/core/furi/memmgr.h +++ b/core/furi/memmgr.h @@ -1,3 +1,8 @@ +/** + * @file memmgr.h + * Furi: memory managment API and glue + */ + #pragma once #include @@ -12,14 +17,27 @@ extern "C" { // define for test case "link against furi memmgr" #define FURI_MEMMGR_GUARD 1 +/** Get free heap size + * + * @return free heap size in bytes + */ size_t memmgr_get_free_heap(void); + +/** Get heap watermark + * + * @return minimum heap in bytes + */ size_t memmgr_get_minimum_free_heap(void); -inline static void* furi_alloc(size_t size) { - void* p = malloc(size); - furi_check(p); - return memset(p, 0, size); -} +/** Allocate memory from heap + * + * @note performs memset with 0, will crash system if not enough memory + * + * @param[in] size bytes to allocate + * + * @return pointer to allocated memory + */ +void* furi_alloc(size_t size); #ifdef __cplusplus } diff --git a/core/furi/memmgr_heap.h b/core/furi/memmgr_heap.h index cbb8fa89..04dced06 100644 --- a/core/furi/memmgr_heap.h +++ b/core/furi/memmgr_heap.h @@ -1,3 +1,8 @@ +/** + * @file memmgr_heap.h + * Furi: heap memory managment API and allocator + */ + #pragma once #include @@ -10,28 +15,32 @@ extern "C" { #define MEMMGR_HEAP_UNKNOWN 0xFFFFFFFF /** Memmgr heap enable thread allocation tracking - * @param thread_id - thread id to track + * + * @param thread_id - thread id to track */ void memmgr_heap_enable_thread_trace(osThreadId_t thread_id); /** Memmgr heap disable thread allocation tracking - * @param thread_id - thread id to track + * + * @param thread_id - thread id to track */ void memmgr_heap_disable_thread_trace(osThreadId_t thread_id); /** Memmgr heap get allocatred thread memory - * @param thread_id - thread id to track - * @return bytes allocated right now + * + * @param thread_id - thread id to track + * + * @return bytes allocated right now */ size_t memmgr_heap_get_thread_memory(osThreadId_t thread_id); /** Memmgr heap get the max contiguous block size on the heap - * @return size_t max contiguous block size + * + * @return size_t max contiguous block size */ size_t memmgr_heap_get_max_free_block(); -/** - * Print the address and size of all free blocks to stdout +/** Print the address and size of all free blocks to stdout */ void memmgr_heap_printf_free_blocks(); diff --git a/core/furi/record.c b/core/furi/record.c index 92134091..7bc736df 100644 --- a/core/furi/record.c +++ b/core/furi/record.c @@ -6,127 +6,134 @@ #include #include -#define FURI_RECORD_FLAG_UPDATED 0x00000001U - -DICT_SET_DEF(osThreadIdSet, uint32_t) +#define FURI_RECORD_FLAG_READY (0x1) typedef struct { + osEventFlagsId_t flags; void* data; - osThreadId_t owner; - osThreadIdSet_t holders; -} FuriRecord; - -DICT_DEF2(FuriRecordDict, string_t, STRING_OPLIST, FuriRecord, M_POD_OPLIST) - -typedef struct { - osMutexId_t records_mutex; - FuriRecordDict_t records; + size_t holders_count; } FuriRecordData; -static FuriRecordData* furi_record_data = NULL; +DICT_DEF2(FuriRecordDataDict, string_t, STRING_OPLIST, FuriRecordData, M_POD_OPLIST) + +typedef struct { + osMutexId_t mutex; + FuriRecordDataDict_t records; +} FuriRecord; + +static FuriRecord* furi_record = NULL; void furi_record_init() { - furi_record_data = furi_alloc(sizeof(FuriRecordData)); - furi_record_data->records_mutex = osMutexNew(NULL); - furi_check(furi_record_data->records_mutex); - FuriRecordDict_init(furi_record_data->records); + furi_record = furi_alloc(sizeof(FuriRecord)); + furi_record->mutex = osMutexNew(NULL); + furi_check(furi_record->mutex); + FuriRecordDataDict_init(furi_record->records); } -FuriRecord* furi_record_get_or_create(string_t name_str) { - furi_assert(furi_record_data); - FuriRecord* record = FuriRecordDict_get(furi_record_data->records, name_str); - if(!record) { - FuriRecord new_record; +static FuriRecordData* furi_record_data_get_or_create(string_t name_str) { + furi_assert(furi_record); + FuriRecordData* record_data = FuriRecordDataDict_get(furi_record->records, name_str); + if(!record_data) { + FuriRecordData new_record; + new_record.flags = osEventFlagsNew(NULL); new_record.data = NULL; - new_record.owner = NULL; - osThreadIdSet_init(new_record.holders); - FuriRecordDict_set_at(furi_record_data->records, name_str, new_record); - record = FuriRecordDict_get(furi_record_data->records, name_str); + new_record.holders_count = 0; + FuriRecordDataDict_set_at(furi_record->records, name_str, new_record); + record_data = FuriRecordDataDict_get(furi_record->records, name_str); } - return record; + return record_data; +} + +static void furi_record_lock() { + furi_check(osMutexAcquire(furi_record->mutex, osWaitForever) == osOK); +} + +static void furi_record_unlock() { + furi_check(osMutexRelease(furi_record->mutex) == osOK); } void furi_record_create(const char* name, void* data) { - furi_assert(furi_record_data); - osThreadId_t thread_id = osThreadGetId(); + furi_assert(furi_record); string_t name_str; string_init_set_str(name_str, name); - // Acquire mutex - furi_check(osMutexAcquire(furi_record_data->records_mutex, osWaitForever) == osOK); - FuriRecord* record = furi_record_get_or_create(name_str); - record->data = data; - record->owner = thread_id; + furi_record_lock(); - // For each holder set event flag - osThreadIdSet_it_t it; - for(osThreadIdSet_it(it, record->holders); !osThreadIdSet_end_p(it); osThreadIdSet_next(it)) { - osThreadFlagsSet((osThreadId_t)*osThreadIdSet_ref(it), FURI_RECORD_FLAG_UPDATED); - } - // Release mutex - furi_check(osMutexRelease(furi_record_data->records_mutex) == osOK); + // Get record data and fill it + FuriRecordData* record_data = furi_record_data_get_or_create(name_str); + furi_assert(record_data->data == NULL); + record_data->data = data; + osEventFlagsSet(record_data->flags, FURI_RECORD_FLAG_READY); + + furi_record_unlock(); string_clear(name_str); } bool furi_record_destroy(const char* name) { - furi_assert(furi_record_data); - osThreadId_t thread_id = osThreadGetId(); + furi_assert(furi_record); + + bool ret = false; string_t name_str; string_init_set_str(name_str, name); - bool destroyed = false; - furi_check(osMutexAcquire(furi_record_data->records_mutex, osWaitForever) == osOK); - FuriRecord* record = FuriRecordDict_get(furi_record_data->records, name_str); - if(record && record->owner == thread_id && osThreadIdSet_size(record->holders) == 0) { - osThreadIdSet_clear(record->holders); - FuriRecordDict_erase(furi_record_data->records, name_str); - destroyed = true; + furi_record_lock(); + + FuriRecordData* record_data = FuriRecordDataDict_get(furi_record->records, name_str); + furi_assert(record_data); + if(record_data->holders_count == 0) { + FuriRecordDataDict_erase(furi_record->records, name_str); + ret = true; } - furi_check(osMutexRelease(furi_record_data->records_mutex) == osOK); + + furi_record_unlock(); string_clear(name_str); - return destroyed; + + return ret; } void* furi_record_open(const char* name) { - furi_assert(furi_record_data); - osThreadId_t thread_id = osThreadGetId(); + furi_assert(furi_record); string_t name_str; string_init_set_str(name_str, name); - FuriRecord* record = NULL; - while(1) { - furi_check(osMutexAcquire(furi_record_data->records_mutex, osWaitForever) == osOK); - record = furi_record_get_or_create(name_str); - osThreadIdSet_push(record->holders, (uint32_t)thread_id); - furi_check(osMutexRelease(furi_record_data->records_mutex) == osOK); - // Check if owner is already arrived - if(record->owner) { - break; - } - // Wait for thread flag to appear - osThreadFlagsWait(FURI_RECORD_FLAG_UPDATED, osFlagsWaitAny, osWaitForever); - } + furi_record_lock(); + + FuriRecordData* record_data = furi_record_data_get_or_create(name_str); + record_data->holders_count++; + + furi_record_unlock(); + + // Wait for record to become ready + furi_check( + osEventFlagsWait( + record_data->flags, + FURI_RECORD_FLAG_READY, + osFlagsWaitAny | osFlagsNoClear, + osWaitForever) == FURI_RECORD_FLAG_READY); string_clear(name_str); - return record->data; + + return record_data->data; } void furi_record_close(const char* name) { - furi_assert(furi_record_data); - osThreadId_t thread_id = osThreadGetId(); + furi_assert(furi_record); string_t name_str; string_init_set_str(name_str, name); - furi_check(osMutexAcquire(furi_record_data->records_mutex, osWaitForever) == osOK); - FuriRecord* record = FuriRecordDict_get(furi_record_data->records, name_str); - osThreadIdSet_erase(record->holders, (uint32_t)thread_id); - furi_check(osMutexRelease(furi_record_data->records_mutex) == osOK); + furi_record_lock(); + + FuriRecordData* record_data = FuriRecordDataDict_get(furi_record->records, name_str); + furi_assert(record_data); + record_data->holders_count--; + + furi_record_unlock(); string_clear(name_str); } diff --git a/core/furi/record.h b/core/furi/record.h index b90b0879..d5d92deb 100644 --- a/core/furi/record.h +++ b/core/furi/record.h @@ -1,3 +1,8 @@ +/** + * @file record.h + * Furi: record API + */ + #pragma once #include @@ -6,41 +11,45 @@ extern "C" { #endif -/** - * Initialize record storage - * For internal use only. +/** Initialize record storage For internal use only. */ void furi_record_init(); -/** - * Create record - * @param name - record name - * @param data - data pointer - * @note Thread safe. Create and destroy must be executed from the same thread. +/** Create record + * + * @param name record name + * @param data data pointer + * @note Thread safe. Create and destroy must be executed from the same + * thread. */ void furi_record_create(const char* name, void* data); -/** - * Destroy record - * @param name - record name - * @return true if successful, false if still have holders or thread is not owner. - * @note Thread safe. Create and destroy must be executed from the same thread. +/** Destroy record + * + * @param name record name + * + * @return true if successful, false if still have holders or thread is not + * owner. + * @note Thread safe. Create and destroy must be executed from the same + * thread. */ bool furi_record_destroy(const char* name); -/** - * Open record - * @param name - record name - * @return pointer to the record - * @note Thread safe. Open and close must be executed from the same thread. - * Suspends caller thread till record appear +/** Open record + * + * @param name record name + * + * @return pointer to the record + * @note Thread safe. Open and close must be executed from the same + * thread. Suspends caller thread till record appear */ void* furi_record_open(const char* name); -/** - * Close record - * @param name - record name - * @note Thread safe. Open and close must be executed from the same thread. +/** Close record + * + * @param name record name + * @note Thread safe. Open and close must be executed from the same + * thread. */ void furi_record_close(const char* name); diff --git a/core/furi/stdglue.h b/core/furi/stdglue.h index a13c994d..c83a443e 100644 --- a/core/furi/stdglue.h +++ b/core/furi/stdglue.h @@ -1,3 +1,8 @@ +/** + * @file stdglue.h + * Furi: stdlibc glue + */ + #pragma once #include @@ -7,31 +12,31 @@ extern "C" { #endif -/** - * Write callback - * @param _cookie - pointer to cookie (see stdio gnu extension) - * @param data - pointer to data - * @param size - data size - * @warnign your handler must consume everything +/** Write callback + * @param _cookie pointer to cookie (see stdio gnu extension) + * @param data pointer to data + * @param size data size @warnign your handler must consume everything */ typedef void (*FuriStdglueWriteCallback)(void* _cookie, const char* data, size_t size); /** Initialized std library glue code */ void furi_stdglue_init(); -/** - * Set global STDOUT callback - * @param callback - callback or NULL to clear - * @return true on success, otherwise fail - * @warning function is thread aware, use this API from the same thread +/** Set global STDOUT callback + * + * @param callback callback or NULL to clear + * + * @return true on success, otherwise fail + * @warning function is thread aware, use this API from the same thread */ bool furi_stdglue_set_global_stdout_callback(FuriStdglueWriteCallback callback); -/** - * Set STDOUT callback for your thread - * @param callback - callback or NULL to clear - * @return true on success, otherwise fail - * @warning function is thread aware, use this API from the same thread +/** Set STDOUT callback for your thread + * + * @param callback callback or NULL to clear + * + * @return true on success, otherwise fail + * @warning function is thread aware, use this API from the same thread */ bool furi_stdglue_set_thread_stdout_callback(FuriStdglueWriteCallback callback); diff --git a/core/furi/thread.h b/core/furi/thread.h index a4736265..50342517 100644 --- a/core/furi/thread.h +++ b/core/furi/thread.h @@ -1,3 +1,8 @@ +/** + * @file thread.h + * Furi: Furi Thread API + */ + #pragma once #include @@ -18,109 +23,130 @@ typedef enum { /** FuriThread anonymous structure */ typedef struct FuriThread FuriThread; -/** FuriThreadCallback - * Your callback to run in new thread - * @warning don't use osThreadExit +/** FuriThreadCallback Your callback to run in new thread + * @warning never use osThreadExit in FuriThread */ typedef int32_t (*FuriThreadCallback)(void* context); -/** FuriThread state change calback - * called upon thread state change - * @param state - new thread state - * @param context - callback context +/** FuriThread state change calback called upon thread state change + * @param state new thread state + * @param context callback context */ typedef void (*FuriThreadStateCallback)(FuriThreadState state, void* context); /** Allocate FuriThread - * @return FuriThread instance + * + * @return FuriThread instance */ FuriThread* furi_thread_alloc(); /** Release FuriThread - * @param thread - FuriThread instance + * + * @param thread FuriThread instance */ void furi_thread_free(FuriThread* thread); /** Set FuriThread name - * @param thread - FuriThread instance - * @param name - string + * + * @param thread FuriThread instance + * @param name string */ void furi_thread_set_name(FuriThread* thread, const char* name); /** Set FuriThread stack size - * @param thread - FuriThread instance - * @param stack_size - stack size in bytes + * + * @param thread FuriThread instance + * @param stack_size stack size in bytes */ void furi_thread_set_stack_size(FuriThread* thread, size_t stack_size); /** Set FuriThread callback - * @param thread - FuriThread instance - * @param callback - FuriThreadCallback, called upon thread run + * + * @param thread FuriThread instance + * @param callback FuriThreadCallback, called upon thread run */ void furi_thread_set_callback(FuriThread* thread, FuriThreadCallback callback); /** Set FuriThread context - * @param thread - FuriThread instance - * @param context - pointer to context for thread callback + * + * @param thread FuriThread instance + * @param context pointer to context for thread callback */ void furi_thread_set_context(FuriThread* thread, void* context); /** Set FuriThread state change callback - * @param thread - FuriThread instance - * @param callack - state change callback + * + * @param thread FuriThread instance + * @param callback state change callback */ void furi_thread_set_state_callback(FuriThread* thread, FuriThreadStateCallback callback); /** Set FuriThread state change context - * @param thread - FuriThread instance - * @param context - pointer to context + * + * @param thread FuriThread instance + * @param context pointer to context */ void furi_thread_set_state_context(FuriThread* thread, void* context); /** Get FuriThread state - * @param thread - FuriThread instance - * @return thread state from FuriThreadState + * + * @param thread FuriThread instance + * + * @return thread state from FuriThreadState */ FuriThreadState furi_thread_get_state(FuriThread* thread); /** Start FuriThread - * @param thread - FuriThread instance - * @return true on success + * + * @param thread FuriThread instance + * + * @return true on success */ bool furi_thread_start(FuriThread* thread); /** Treminate FuriThread - * @param thread - FuriThread instance - * @return osStatus_t - * @warning terminating statefull thread is dangerous - * use only if you know what you doing + * + * @param thread FuriThread instance + * + * @return osStatus_t + * @warning terminating statefull thread is dangerous use only if you know + * what you doing */ osStatus_t furi_thread_terminate(FuriThread* thread); /** Join FuriThread - * @param thread - FuriThread instance - * @return osStatus_t + * + * @param thread FuriThread instance + * + * @return osStatus_t */ osStatus_t furi_thread_join(FuriThread* thread); /** Get CMSIS Thread ID - * @param thread - FuriThread instance - * @return osThreadId_t or NULL + * + * @param thread FuriThread instance + * + * @return osThreadId_t or NULL */ osThreadId_t furi_thread_get_thread_id(FuriThread* thread); /** Enable heap tracing - * @param thread - FuriThread instance + * + * @param thread FuriThread instance */ void furi_thread_enable_heap_trace(FuriThread* thread); /** Disable heap tracing - * @param thread - FuriThread instance + * + * @param thread FuriThread instance */ void furi_thread_disable_heap_trace(FuriThread* thread); /** Get thread heap size - * @param thread - FuriThread instance + * + * @param thread FuriThread instance + * + * @return size in bytes */ size_t furi_thread_get_heap_size(FuriThread* thread); diff --git a/documentation/Doxyfile b/documentation/Doxyfile new file mode 100644 index 00000000..08760acf --- /dev/null +++ b/documentation/Doxyfile @@ -0,0 +1,2608 @@ +# Doxyfile 1.9.2 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "FlipperZero Firmware" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = documentation + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = YES + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:^^" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = applications \ + core \ + lib/irda \ + lib/subghz \ + lib/toolbox \ + lib/onewire \ + firmware/targets/furi-hal-include + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, +# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C +# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use gray-scales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATOR_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see https://docs.mathjax.org/en/v2.7-latest/tex.html +# #tex-and-latex-extensions): +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /