Merge branch 'release-candidate' into release
This commit is contained in:
		
						commit
						b629ae18f2
					
				
							
								
								
									
										17
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							| @ -66,7 +66,8 @@ jobs: | |||||||
|             do |             do | ||||||
|               hex2dfu \ |               hex2dfu \ | ||||||
|                 -i bootloader/.obj/${TARGET}/bootloader.hex \ |                 -i bootloader/.obj/${TARGET}/bootloader.hex \ | ||||||
|                 -o bootloader/.obj/${TARGET}/bootloader.dfu |                 -o bootloader/.obj/${TARGET}/bootloader.dfu \ | ||||||
|  |                 -l "Flipper Zero $(echo $TARGET | tr a-z A-Z)" | ||||||
|             done |             done | ||||||
| 
 | 
 | ||||||
|       - name: 'Build firmware in docker' |       - name: 'Build firmware in docker' | ||||||
| @ -86,7 +87,8 @@ jobs: | |||||||
|             do |             do | ||||||
|               hex2dfu \ |               hex2dfu \ | ||||||
|                 -i firmware/.obj/${TARGET}/firmware.hex \ |                 -i firmware/.obj/${TARGET}/firmware.hex \ | ||||||
|                 -o firmware/.obj/${TARGET}/firmware.dfu |                 -o firmware/.obj/${TARGET}/firmware.dfu \ | ||||||
|  |                 -l "Flipper Zero $(echo $TARGET | tr a-z A-Z)" | ||||||
|             done |             done | ||||||
| 
 | 
 | ||||||
|       - name: 'Generate full hex file' |       - name: 'Generate full hex file' | ||||||
| @ -129,7 +131,8 @@ jobs: | |||||||
|             do |             do | ||||||
|               hex2dfu \ |               hex2dfu \ | ||||||
|                 -i firmware/.obj/${TARGET}/full.hex \ |                 -i firmware/.obj/${TARGET}/full.hex \ | ||||||
|                 -o artifacts/flipper-z-${TARGET}-full-${SUFFIX}.dfu |                 -o artifacts/flipper-z-${TARGET}-full-${SUFFIX}.dfu \ | ||||||
|  |                 -l "Flipper Zero $(echo $TARGET | tr a-z A-Z)" | ||||||
|             done |             done | ||||||
| 
 | 
 | ||||||
|       - name: 'Full flash asssembly: bootloader as base' |       - name: 'Full flash asssembly: bootloader as base' | ||||||
| @ -157,14 +160,6 @@ jobs: | |||||||
|               >> artifacts/flipper-z-${TARGET}-full-${SUFFIX}.bin |               >> artifacts/flipper-z-${TARGET}-full-${SUFFIX}.bin | ||||||
|           done |           done | ||||||
| 
 | 
 | ||||||
|       - name: 'Publish artifacts' |  | ||||||
|         uses: actions/upload-artifact@v2 |  | ||||||
|         with: |  | ||||||
|           name: artifacts |  | ||||||
|           path: artifacts/* |  | ||||||
|           if-no-files-found: error |  | ||||||
|           retention-days: 7 |  | ||||||
| 
 |  | ||||||
|       - name: 'Upload artifacts to update server' |       - name: 'Upload artifacts to update server' | ||||||
|         uses: burnett01/rsync-deployments@4.1 |         uses: burnett01/rsync-deployments@4.1 | ||||||
|         with: |         with: | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								.github/workflows/lint_c.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/lint_c.yml
									
									
									
									
										vendored
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| name: 'Lint C/C++ with clang-format' | name: 'Lint C/C++ with clang-format' | ||||||
| 
 | 
 | ||||||
| on: push | on: pull_request | ||||||
| 
 | 
 | ||||||
| env: | env: | ||||||
|   TARGETS: f6 |   TARGETS: f6 | ||||||
|  | |||||||
							
								
								
									
										6
									
								
								.github/workflows/lint_python.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/lint_python.yml
									
									
									
									
										vendored
									
									
								
							| @ -1,10 +1,6 @@ | |||||||
| name: 'Python Lint' | name: 'Python Lint' | ||||||
| 
 | 
 | ||||||
| on:  | on: pull_request | ||||||
|   push: |  | ||||||
|     paths: |  | ||||||
|       - '**.py' |  | ||||||
|   pull_request: |  | ||||||
| 
 | 
 | ||||||
| jobs: | jobs: | ||||||
|   lint_python: |   lint_python: | ||||||
|  | |||||||
							
								
								
									
										64
									
								
								ReadMe.md
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								ReadMe.md
									
									
									
									
									
								
							| @ -66,3 +66,67 @@ One liner: `./flash_core1_main.sh` | |||||||
| * Project website: [flipperzero.one](https://flipperzero.one) | * Project website: [flipperzero.one](https://flipperzero.one) | ||||||
| * Kickstarter page: [kickstarter.com](https://www.kickstarter.com/projects/flipper-devices/flipper-zero-tamagochi-for-hackers) | * Kickstarter page: [kickstarter.com](https://www.kickstarter.com/projects/flipper-devices/flipper-zero-tamagochi-for-hackers) | ||||||
| * Forum: [forum.flipperzero.one](https://forum.flipperzero.one/) | * Forum: [forum.flipperzero.one](https://forum.flipperzero.one/) | ||||||
|  | 
 | ||||||
|  | # Folders structure | ||||||
|  | 
 | ||||||
|  | - applications - application and services | ||||||
|  |  * accessor - Wiegand server | ||||||
|  |  * archive - Archive and file manager  | ||||||
|  |  * bt - BLE service and application | ||||||
|  |  * cli - Console service | ||||||
|  |  * debug_tools - different tools that we use on factory and for debug | ||||||
|  |  * dialogs - service for showing GUI dialogs | ||||||
|  |  * dolphin - dolphin service and supplientary apps | ||||||
|  |  * gpio-tester - GPIO control application | ||||||
|  |  * gui - GUI service | ||||||
|  |  * ibutton - ibutton application, onewire keys and more | ||||||
|  |  * input - input service | ||||||
|  |  * irda - irda application, controls your IR devices  | ||||||
|  |  * irda_monitor - irda debug tool  | ||||||
|  |  * lfrfid - LF RFID application | ||||||
|  |  * lfrfid-debug - LF RFID debug tool | ||||||
|  |  * loader - application loader service | ||||||
|  |  * menu - main menu service | ||||||
|  |  * music-player - music player app (demo) | ||||||
|  |  * nfc - NFC application, HF rfid, EMV and etc | ||||||
|  |  * notification - notification service  | ||||||
|  |  * power - power service | ||||||
|  |  * power-observer - power debug tool | ||||||
|  |  * scened-app-example - c++ application example  | ||||||
|  |  * storage - storage service, internal + sdcard | ||||||
|  |  * storage-settings - storage settings app | ||||||
|  |  * subghz - subghz application, 433 fobs and etc | ||||||
|  |  * tests - unit tests and etc | ||||||
|  | - assets - assets used by applications and services | ||||||
|  |  * compiled - compilation results | ||||||
|  |  * icons - source icons images | ||||||
|  | - bootloader - bootloader for flipper | ||||||
|  |  * src - bootloader sources | ||||||
|  |  * targets - targets' hal and implementation | ||||||
|  | - core - core libraries: home for furi | ||||||
|  | - debug - debug helpers, plugins and tools | ||||||
|  | - docker - docker image sources (used for automated firmware build) | ||||||
|  | - firmware - firmware for flipper | ||||||
|  |  * targets - targets' hal and implementation | ||||||
|  | - lib - different libraries and drivers that apps and firmware uses | ||||||
|  |  * ST25RFAL002 - ST253916 driver and NFC hal | ||||||
|  |  * STM32CubeWB - STM32WB hal | ||||||
|  |  * app-scened-template - scened template app library | ||||||
|  |  * app-template - template app library | ||||||
|  |  * callback-connector - callback connector library | ||||||
|  |  * common-api - common api delaration library | ||||||
|  |  * cyfral - cyfral library | ||||||
|  |  * drivers - drivers that we wrote | ||||||
|  |  * fatfs - external storage file system | ||||||
|  |  * fnv1a-hash - fnv1a hash library  | ||||||
|  |  * irda - irda library | ||||||
|  |  * littlefs - internal storage file system | ||||||
|  |  * mlib - algorithms and containers  | ||||||
|  |  * nfc_protocols - nfc protocols library | ||||||
|  |  * onewire - one wire library  | ||||||
|  |  * qrcode - qr code generator library | ||||||
|  |  * subghz - subghz library | ||||||
|  |  * toolbox - toolbox of things that we are using but don't place in core | ||||||
|  |  * u8g2 - graphics library that we use to draw GUI | ||||||
|  | - make - make helpers | ||||||
|  | - scripts - supplimentary scripts | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "accessor-app.h" | #include "accessor-app.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include <stdarg.h> | #include <stdarg.h> | ||||||
| 
 | 
 | ||||||
| void AccessorApp::run(void) { | void AccessorApp::run(void) { | ||||||
| @ -33,16 +33,16 @@ void AccessorApp::run(void) { | |||||||
| 
 | 
 | ||||||
| AccessorApp::AccessorApp() | AccessorApp::AccessorApp() | ||||||
|     : onewire_master{&ibutton_gpio} { |     : onewire_master{&ibutton_gpio} { | ||||||
|     api_hal_power_insomnia_enter(); |     furi_hal_power_insomnia_enter(); | ||||||
|     notification = static_cast<NotificationApp*>(furi_record_open("notification")); |     notification = static_cast<NotificationApp*>(furi_record_open("notification")); | ||||||
|     notify_init(); |     notify_init(); | ||||||
|     api_hal_power_enable_otg(); |     furi_hal_power_enable_otg(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AccessorApp::~AccessorApp() { | AccessorApp::~AccessorApp() { | ||||||
|     api_hal_power_disable_otg(); |     furi_hal_power_disable_otg(); | ||||||
|     furi_record_close("notification"); |     furi_record_close("notification"); | ||||||
|     api_hal_power_insomnia_exit(); |     furi_hal_power_insomnia_exit(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AccessorAppViewManager* AccessorApp::get_view_manager() { | AccessorAppViewManager* AccessorApp::get_view_manager() { | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #include "accessor-app.h" | #include "accessor-app.h" | ||||||
| 
 | 
 | ||||||
| // app enter function
 | // app enter function
 | ||||||
| extern "C" int32_t app_accessor(void* p) { | extern "C" int32_t accessor_app(void* p) { | ||||||
|     AccessorApp* app = new AccessorApp(); |     AccessorApp* app = new AccessorApp(); | ||||||
|     app->run(); |     app->run(); | ||||||
|     delete app; |     delete app; | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "wiegand.h" | #include "wiegand.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| volatile unsigned long WIEGAND::_cardTempHigh = 0; | volatile unsigned long WIEGAND::_cardTempHigh = 0; | ||||||
| volatile unsigned long WIEGAND::_cardTemp = 0; | volatile unsigned long WIEGAND::_cardTemp = 0; | ||||||
|  | |||||||
| @ -1,103 +1,107 @@ | |||||||
| #include "applications.h" | #include "applications.h" | ||||||
|  | #include <assets_icons.h> | ||||||
| 
 | 
 | ||||||
| // Services and apps decalartion
 | // Services
 | ||||||
| int32_t application_vertical_screen(void* p); | extern int32_t bt_srv(void* p); | ||||||
| int32_t irda_monitor_app(void* p); | extern int32_t cli_srv(void* p); | ||||||
| int32_t flipper_test_app(void* p); | extern int32_t dialogs_srv(void* p); | ||||||
| int32_t application_blink(void* p); | extern int32_t dolphin_srv(void* p); | ||||||
| int32_t application_uart_write(void* p); | extern int32_t gui_srv(void* p); | ||||||
| int32_t application_input_dump(void* p); | extern int32_t input_srv(void* p); | ||||||
| int32_t u8g2_example(void* p); | extern int32_t loader_srv(void* p); | ||||||
| int32_t input_task(void* p); | extern int32_t menu_srv(void* p); | ||||||
| int32_t menu_task(void* p); | extern int32_t notification_srv(void* p); | ||||||
| int32_t coreglitch_demo_0(void* p); | extern int32_t power_observer_srv(void* p); | ||||||
| int32_t u8g2_qrcode(void* p); | extern int32_t power_srv(void* p); | ||||||
| int32_t gui_task(void* p); | extern int32_t storage_srv(void* p); | ||||||
| int32_t irda(void* p); | 
 | ||||||
| int32_t loader(void* p); | // Apps
 | ||||||
| int32_t nfc_task(void* p); | extern int32_t accessor_app(void* p); | ||||||
| int32_t dolphin_task(void* p); | extern int32_t archive_app(void* p); | ||||||
| int32_t power_task(void* p); | extern int32_t blink_test_app(void* p); | ||||||
| int32_t bt_task(void* p); | extern int32_t flipper_test_app(void* p); | ||||||
| int32_t application_vibro(void* p); | extern int32_t gpio_test_app(void* p); | ||||||
| int32_t app_gpio_test(void* p); | extern int32_t ibutton_app(void* p); | ||||||
| int32_t app_ibutton(void* p); | extern int32_t irda_app(void* p); | ||||||
| int32_t cli_task(void* p); | extern int32_t irda_monitor_app(void* p); | ||||||
| int32_t music_player(void* p); | extern int32_t keypad_test_app(void* p); | ||||||
| int32_t sdnfc(void* p); | extern int32_t lfrfid_app(void* p); | ||||||
| int32_t subghz_app(void* p); | extern int32_t lfrfid_debug_app(void* p); | ||||||
| int32_t gui_test(void* p); | extern int32_t nfc_app(void* p); | ||||||
| int32_t keypad_test(void* p); | extern int32_t passport_app(void* p); | ||||||
| int32_t scene_app(void* p); | extern int32_t food_minigame_app(void* p); | ||||||
| int32_t passport(void* p); | extern int32_t scene_app(void* p); | ||||||
| int32_t app_accessor(void* p); | extern int32_t scened_app(void* p); | ||||||
| int32_t app_archive(void* p); | extern int32_t storage_test_app(void* p); | ||||||
| int32_t notification_app(void* p); | extern int32_t subghz_app(void* p); | ||||||
| int32_t scened_app(void* p); | extern int32_t vibro_test_app(void* p); | ||||||
| int32_t lfrfid_app(void* p); | 
 | ||||||
| int32_t lfrfid_debug_app(void* p); | // Plugins
 | ||||||
| int32_t storage_app(void* p); | extern int32_t music_player_app(void* p); | ||||||
| int32_t storage_app_test(void* p); |  | ||||||
| int32_t dialogs_app(void* p); |  | ||||||
| int32_t power_observer(void* p); |  | ||||||
| 
 | 
 | ||||||
| // On system start hooks declaration
 | // On system start hooks declaration
 | ||||||
| void irda_cli_init(); | extern void bt_cli_init(); | ||||||
| void nfc_cli_init(); | extern void ibutton_cli_init(); | ||||||
| void subghz_cli_init(); | extern void irda_cli_init(); | ||||||
| void bt_cli_init(); | extern void lfrfid_cli_init(); | ||||||
| void lfrfid_cli_init(); | extern void nfc_cli_init(); | ||||||
| void ibutton_cli_init(); | extern void storage_cli_init(); | ||||||
| void storage_cli_init(); | extern void subghz_cli_init(); | ||||||
| 
 | 
 | ||||||
| // Settings
 | // Settings
 | ||||||
| int32_t notification_app_settings(void* p); | extern int32_t notification_settings_app(void* p); | ||||||
| int32_t storage_settings(void* p); | extern int32_t storage_settings_app(void* p); | ||||||
| 
 | 
 | ||||||
| const FlipperApplication FLIPPER_SERVICES[] = { | const FlipperApplication FLIPPER_SERVICES[] = { | ||||||
|  | /* Services */ | ||||||
|  | #ifdef SRV_BT | ||||||
|  |     {.app = bt_srv, .name = "BT", .stack_size = 1024, .icon = NULL}, | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #ifdef SRV_CLI | #ifdef SRV_CLI | ||||||
|     {.app = cli_task, .name = "cli_task", .stack_size = 4096, .icon = &A_Plugins_14}, |     {.app = cli_srv, .name = "Cli", .stack_size = 4096, .icon = NULL}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_EXAMPLE_BLINK | #ifdef SRV_DIALOGS | ||||||
|     {.app = application_blink, .name = "blink", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = dialogs_srv, .name = "Dialogs", .stack_size = 1024, .icon = NULL}, | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_INPUT |  | ||||||
|     {.app = input_task, .name = "input_task", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_EXAMPLE_INPUT_DUMP |  | ||||||
|     {.app = application_input_dump, |  | ||||||
|      .name = "input dump", |  | ||||||
|      .stack_size = 1024, |  | ||||||
|      .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_GUI |  | ||||||
|     // TODO: fix stack size when sd api will be in separate thread
 |  | ||||||
|     {.app = gui_task, .name = "gui_task", .stack_size = 8192, .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_MENU |  | ||||||
|     {.app = menu_task, .name = "menu_task", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
|     {.app = loader, .name = "loader", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_DOLPHIN | #ifdef SRV_DOLPHIN | ||||||
|     {.app = dolphin_task, .name = "dolphin_task", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = dolphin_srv, .name = "Dolphin", .stack_size = 1024, .icon = NULL}, | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef SRV_GUI | ||||||
|  |     {.app = gui_srv, .name = "Gui", .stack_size = 8192, .icon = NULL}, | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef SRV_INPUT | ||||||
|  |     {.app = input_srv, .name = "Input", .stack_size = 1024, .icon = NULL}, | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef SRV_MENU | ||||||
|  |     {.app = menu_srv, .name = "Menu", .stack_size = 1024, .icon = NULL}, | ||||||
|  |     {.app = loader_srv, .name = "Loader", .stack_size = 1024, .icon = NULL}, | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef SRV_NOTIFICATION | ||||||
|  |     {.app = notification_srv, .name = "Notification", .stack_size = 1024, .icon = NULL}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_POWER | #ifdef SRV_POWER | ||||||
|     {.app = power_task, .name = "power_task", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = power_srv, .name = "Power", .stack_size = 1024, .icon = NULL}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_POWER_OBSERVER | #ifdef SRV_POWER_OBSERVER | ||||||
|     {.app = power_observer, .name = "power_observer", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = power_observer_srv, .name = "PowerObserver", .stack_size = 1024, .icon = NULL}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_BT | #ifdef SRV_STORAGE | ||||||
|     {.app = bt_task, .name = "bt_task", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = storage_srv, .name = "Storage", .stack_size = 4096, .icon = NULL}, | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | /* Fake services (autorun) */ | ||||||
|  | #ifdef SRV_BLINK | ||||||
|  |     {.app = blink_test_app, .name = "Blink", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_LF_RFID | #ifdef SRV_LF_RFID | ||||||
| @ -105,66 +109,31 @@ const FlipperApplication FLIPPER_SERVICES[] = { | |||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_IRDA | #ifdef SRV_IRDA | ||||||
|     {.app = irda, .name = "irda", .stack_size = 1024 * 3, .icon = &A_Plugins_14}, |     {.app = irda_app, .name = "Infrared", .stack_size = 1024 * 3, .icon = &A_Plugins_14}, | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_EXAMPLE_QRCODE |  | ||||||
|     {.app = u8g2_qrcode, .name = "u8g2_qrcode", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_EXAMPLE_DISPLAY |  | ||||||
|     {.app = u8g2_example, .name = "u8g2_example", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_SPEAKER_DEMO |  | ||||||
|     {.app = coreglitch_demo_0, |  | ||||||
|      .name = "coreglitch_demo_0", |  | ||||||
|      .stack_size = 1024, |  | ||||||
|      .icon = &A_Plugins_14}, |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_MUSIC_PLAYER | #ifdef SRV_MUSIC_PLAYER | ||||||
|     {.app = music_player, .name = "music player", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = music_player_app, .name = "Music Player", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_IBUTTON | #ifdef SRV_IBUTTON | ||||||
|     {.app = app_ibutton, .name = "ibutton", .stack_size = 2048, .icon = &A_Plugins_14}, |     {.app = ibutton_app, .name = "iButton", .stack_size = 2048, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_GPIO_DEMO | #ifdef SRV_GPIO_TEST | ||||||
|     {.app = app_gpio_test, .name = "gpio test", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = gpio_test_app, .name = "GPIO Test", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_SDNFC |  | ||||||
|     {.app = sdnfc, .name = "sdnfc", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_GUI_TEST |  | ||||||
|     {.app = gui_test, .name = "gui_test", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_KEYPAD_TEST | #ifdef SRV_KEYPAD_TEST | ||||||
|     {.app = keypad_test, .name = "keypad_test", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = keypad_test_app, .name = "Keypad Test", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_ACCESSOR | #ifdef SRV_ACCESSOR | ||||||
|     {.app = app_accessor, .name = "accessor", .stack_size = 4096, .icon = &A_Plugins_14}, |     {.app = accessor_app, .name = "Accessor", .stack_size = 4096, .icon = &A_Plugins_14}, | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_NOTIFICATION |  | ||||||
|     {.app = notification_app, .name = "notification", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_STORAGE |  | ||||||
|     {.app = storage_app, .name = "storage", .stack_size = 4096, .icon = &A_Plugins_14}, |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_STORAGE_TEST | #ifdef SRV_STORAGE_TEST | ||||||
|     {.app = storage_app_test, .name = "storage test", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = storage_test_app, .name = "Storage Test", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef SRV_DIALOGS |  | ||||||
|     {.app = dialogs_app, .name = "dialogs", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif | #endif | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -174,29 +143,27 @@ const size_t FLIPPER_SERVICES_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(FlipperA | |||||||
| const FlipperApplication FLIPPER_APPS[] = { | const FlipperApplication FLIPPER_APPS[] = { | ||||||
| 
 | 
 | ||||||
| #ifdef APP_IBUTTON | #ifdef APP_IBUTTON | ||||||
|     {.app = app_ibutton, .name = "iButton", .stack_size = 2048, .icon = &A_iButton_14}, |     {.app = ibutton_app, .name = "iButton", .stack_size = 2048, .icon = &A_iButton_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_NFC | #ifdef APP_NFC | ||||||
|     {.app = nfc_task, .name = "NFC", .stack_size = 4096, .icon = &A_NFC_14}, |     {.app = nfc_app, .name = "NFC", .stack_size = 4096, .icon = &A_NFC_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_SUBGHZ | #ifdef APP_SUBGHZ | ||||||
|     // TODO: decrease stack after SD API refactoring
 |     {.app = subghz_app, .name = "Sub-1 GHz", .stack_size = 2048, .icon = &A_Sub1ghz_14}, | ||||||
|     {.app = subghz_app, .name = "Sub-1 GHz", .stack_size = 4096, .icon = &A_Sub1ghz_14}, |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_LF_RFID | #ifdef APP_LF_RFID | ||||||
|     // TODO: fix stack size when sd api will be in separate thread
 |  | ||||||
|     {.app = lfrfid_app, .name = "125 kHz RFID", .stack_size = 2048, .icon = &A_125khz_14}, |     {.app = lfrfid_app, .name = "125 kHz RFID", .stack_size = 2048, .icon = &A_125khz_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_IRDA | #ifdef APP_IRDA | ||||||
|     {.app = irda, .name = "Infrared", .stack_size = 1024 * 3, .icon = &A_Infrared_14}, |     {.app = irda_app, .name = "Infrared", .stack_size = 1024 * 3, .icon = &A_Infrared_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_GPIO_DEMO | #ifdef APP_GPIO_TEST | ||||||
|     {.app = app_gpio_test, .name = "GPIO", .stack_size = 1024, .icon = &A_GPIO_14}, |     {.app = gpio_test_app, .name = "GPIO", .stack_size = 1024, .icon = &A_GPIO_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| }; | }; | ||||||
| @ -233,51 +200,28 @@ const size_t FLIPPER_ON_SYSTEM_START_COUNT = | |||||||
| const FlipperApplication FLIPPER_PLUGINS[] = { | const FlipperApplication FLIPPER_PLUGINS[] = { | ||||||
| 
 | 
 | ||||||
| #ifdef APP_MUSIC_PLAYER | #ifdef APP_MUSIC_PLAYER | ||||||
|     {.app = music_player, .name = "music player", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = music_player_app, .name = "Music Player", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| 
 |  | ||||||
| #ifdef APP_SPEAKER_DEMO |  | ||||||
|     {.app = coreglitch_demo_0, |  | ||||||
|      .name = "coreglitch_demo_0", |  | ||||||
|      .stack_size = 1024, |  | ||||||
|      .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const size_t FLIPPER_PLUGINS_COUNT = sizeof(FLIPPER_PLUGINS) / sizeof(FlipperApplication); | const size_t FLIPPER_PLUGINS_COUNT = sizeof(FLIPPER_PLUGINS) / sizeof(FlipperApplication); | ||||||
| 
 | 
 | ||||||
| // Plugin menu
 | // Plugin menu
 | ||||||
| const FlipperApplication FLIPPER_DEBUG_APPS[] = { | const FlipperApplication FLIPPER_DEBUG_APPS[] = { | ||||||
| #ifdef APP_EXAMPLE_BLINK | #ifdef APP_BLINK | ||||||
|     {.app = application_blink, .name = "blink", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = blink_test_app, .name = "Blink Test", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef APP_EXAMPLE_INPUT_DUMP |  | ||||||
|     {.app = application_input_dump, |  | ||||||
|      .name = "input dump", |  | ||||||
|      .stack_size = 1024, |  | ||||||
|      .icon = &A_Plugins_14}, |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_VIBRO_DEMO | #ifdef APP_VIBRO_DEMO | ||||||
|     {.app = application_vibro, .name = "vibro", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = vibro_test_app, .name = "Vibro Test", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef APP_SDNFC |  | ||||||
|     {.app = sdnfc, .name = "sdnfc", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef APP_GUI_TEST |  | ||||||
|     {.app = gui_test, .name = "gui_test", .stack_size = 1024, .icon = &A_Plugins_14}, |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_KEYPAD_TEST | #ifdef APP_KEYPAD_TEST | ||||||
|     {.app = keypad_test, .name = "keypad_test", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = keypad_test_app, .name = "Keypad Test", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_ACCESSOR | #ifdef APP_ACCESSOR | ||||||
|     {.app = app_accessor, .name = "accessor", .stack_size = 4096, .icon = &A_Plugins_14}, |     {.app = accessor_app, .name = "Accessor", .stack_size = 4096, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_UNIT_TESTS | #ifdef APP_UNIT_TESTS | ||||||
| @ -288,13 +232,6 @@ const FlipperApplication FLIPPER_DEBUG_APPS[] = { | |||||||
|     {.app = irda_monitor_app, .name = "Irda Monitor", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = irda_monitor_app, .name = "Irda Monitor", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef APP_VERTICAL_SCREEN |  | ||||||
|     {.app = application_vertical_screen, |  | ||||||
|      .name = "Vertical Screen", |  | ||||||
|      .stack_size = 1024, |  | ||||||
|      .icon = &A_Plugins_14}, |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef APP_SCENED | #ifdef APP_SCENED | ||||||
|     {.app = scened_app, .name = "Templated Scene", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = scened_app, .name = "Templated Scene", .stack_size = 1024, .icon = &A_Plugins_14}, | ||||||
| #endif | #endif | ||||||
| @ -308,7 +245,7 @@ const size_t FLIPPER_DEBUG_APPS_COUNT = sizeof(FLIPPER_DEBUG_APPS) / sizeof(Flip | |||||||
| 
 | 
 | ||||||
| #ifdef APP_ARCHIVE | #ifdef APP_ARCHIVE | ||||||
| const FlipperApplication FLIPPER_ARCHIVE = | const FlipperApplication FLIPPER_ARCHIVE = | ||||||
|     {.app = app_archive, .name = "Archive", .stack_size = 4096, .icon = &A_FileManager_14}; |     {.app = archive_app, .name = "Archive", .stack_size = 4096, .icon = &A_FileManager_14}; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_DOLPHIN | #ifdef SRV_DOLPHIN | ||||||
| @ -316,8 +253,8 @@ const FlipperApplication FLIPPER_SCENE = | |||||||
|     {.app = scene_app, .name = "Scenes", .stack_size = 1024, .icon = &A_Games_14}; |     {.app = scene_app, .name = "Scenes", .stack_size = 1024, .icon = &A_Games_14}; | ||||||
| 
 | 
 | ||||||
| const FlipperApplication FLIPPER_SCENE_APPS[] = { | const FlipperApplication FLIPPER_SCENE_APPS[] = { | ||||||
|     {.app = passport, .name = "Passport", .stack_size = 1024, .icon = &A_Games_14}, |     {.app = passport_app, .name = "Passport", .stack_size = 1024, .icon = &A_Games_14}, | ||||||
|     {.app = music_player, .name = "Music player", .stack_size = 1024, .icon = &A_Plugins_14}, |     {.app = food_minigame_app, .name = "Food minigame", .stack_size = 1024, .icon = &A_Games_14}, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const size_t FLIPPER_SCENE_APPS_COUNT = sizeof(FLIPPER_SCENE_APPS) / sizeof(FlipperApplication); | const size_t FLIPPER_SCENE_APPS_COUNT = sizeof(FLIPPER_SCENE_APPS) / sizeof(FlipperApplication); | ||||||
| @ -327,11 +264,11 @@ const size_t FLIPPER_SCENE_APPS_COUNT = sizeof(FLIPPER_SCENE_APPS) / sizeof(Flip | |||||||
| // Settings menu
 | // Settings menu
 | ||||||
| const FlipperApplication FLIPPER_SETTINGS_APPS[] = { | const FlipperApplication FLIPPER_SETTINGS_APPS[] = { | ||||||
| #ifdef SRV_NOTIFICATION | #ifdef SRV_NOTIFICATION | ||||||
|     {.app = notification_app_settings, .name = "Notification", .stack_size = 1024, .icon = NULL}, |     {.app = notification_settings_app, .name = "Notification", .stack_size = 1024, .icon = NULL}, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef SRV_STORAGE | #ifdef SRV_STORAGE | ||||||
|     {.app = storage_settings, .name = "Storage", .stack_size = 2048, .icon = NULL}, |     {.app = storage_settings_app, .name = "Storage", .stack_size = 2048, .icon = NULL}, | ||||||
| #endif | #endif | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <assets_icons.h> | #include <gui/icon.h> | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     const FuriThreadCallback app; |     const FuriThreadCallback app; | ||||||
|  | |||||||
| @ -11,40 +11,46 @@ CPP_SOURCES += $(shell find $(APP_DIR) -name *.cpp) | |||||||
| 
 | 
 | ||||||
| APP_RELEASE ?= 1 | APP_RELEASE ?= 1 | ||||||
| ifeq ($(APP_RELEASE), 1) | ifeq ($(APP_RELEASE), 1) | ||||||
| # Main services
 | # Services
 | ||||||
| SRV_MENU = 1 |  | ||||||
| SRV_POWER = 1 |  | ||||||
| SRV_BT = 1 | SRV_BT = 1 | ||||||
| SRV_CLI = 1 | SRV_CLI = 1 | ||||||
| SRV_DOLPHIN = 1 |  | ||||||
| SRV_NOTIFICATION = 1 |  | ||||||
| SRV_STORAGE = 1 |  | ||||||
| SRV_DIALOGS = 1 | SRV_DIALOGS = 1 | ||||||
|  | SRV_DOLPHIN = 1 | ||||||
|  | SRV_GUI = 1 | ||||||
|  | SRV_INPUT = 1 | ||||||
|  | SRV_MENU = 1 | ||||||
|  | SRV_NOTIFICATION = 1 | ||||||
|  | SRV_POWER = 1 | ||||||
| SRV_POWER_OBSERVER = 1 | SRV_POWER_OBSERVER = 1 | ||||||
|  | SRV_STORAGE = 1 | ||||||
| 
 | 
 | ||||||
| # Main Apps
 | # Apps
 | ||||||
|  | APP_ARCHIVE = 1 | ||||||
|  | APP_GPIO_TEST = 1 | ||||||
|  | APP_IBUTTON = 1 | ||||||
| APP_IRDA  = 1 | APP_IRDA  = 1 | ||||||
| APP_SUBGHZ = 1 |  | ||||||
| APP_LF_RFID = 1 | APP_LF_RFID = 1 | ||||||
| APP_NFC = 1 | APP_NFC = 1 | ||||||
| APP_GPIO_DEMO = 1 | APP_SUBGHZ = 1 | ||||||
| APP_MUSIC_PLAYER = 1 |  | ||||||
| APP_IBUTTON = 1 |  | ||||||
| APP_ARCHIVE = 1 |  | ||||||
| 
 | 
 | ||||||
| # Debug and misc
 | # Plugins
 | ||||||
| APP_GUI_TEST = 1 | APP_MUSIC_PLAYER = 1 | ||||||
| APP_KEYPAD_TEST = 1 | 
 | ||||||
|  | # Debug
 | ||||||
| APP_ACCESSOR = 1 | APP_ACCESSOR = 1 | ||||||
| APP_SD_TEST = 1 | APP_BLINK = 1 | ||||||
| APP_VIBRO_DEMO = 1 |  | ||||||
| APP_SPEAKER_DEMO = 1 |  | ||||||
| APP_EXAMPLE_BLINK = 1 |  | ||||||
| APP_EXAMPLE_UART_WRITE = 1 |  | ||||||
| APP_EXAMPLE_INPUT_DUMP = 1 |  | ||||||
| APP_UNIT_TESTS = 0 |  | ||||||
| APP_IRDA_MONITOR = 1 | APP_IRDA_MONITOR = 1 | ||||||
| APP_VERTICAL_SCREEN = 1 | APP_KEYPAD_TEST = 1 | ||||||
|  | APP_SD_TEST = 1 | ||||||
|  | APP_UNIT_TESTS = 0 | ||||||
|  | APP_VIBRO_DEMO = 1 | ||||||
|  | endif | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SRV_BT ?= 0 | ||||||
|  | ifeq ($(SRV_BT), 1) | ||||||
|  | SRV_CLI		= 1 | ||||||
|  | CFLAGS		+= -DSRV_BT | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_DOLPHIN ?= 0 | SRV_DOLPHIN ?= 0 | ||||||
| @ -66,12 +72,6 @@ SRV_POWER	= 1 | |||||||
| CFLAGS		+= -DSRV_POWER_OBSERVER | CFLAGS		+= -DSRV_POWER_OBSERVER | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_BT ?= 0 |  | ||||||
| ifeq ($(SRV_BT), 1) |  | ||||||
| SRV_CLI		= 1 |  | ||||||
| CFLAGS		+= -DSRV_BT |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| SRV_MENU ?= 0 | SRV_MENU ?= 0 | ||||||
| ifeq ($(SRV_MENU), 1) | ifeq ($(SRV_MENU), 1) | ||||||
| CFLAGS += -DSRV_MENU | CFLAGS += -DSRV_MENU | ||||||
| @ -84,11 +84,6 @@ SRV_GUI		= 1 | |||||||
| CFLAGS		+= -DAPP_MENU | CFLAGS		+= -DAPP_MENU | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| APP_VERTICAL_SCREEN	?= 0 |  | ||||||
| ifeq ($(APP_VERTICAL_SCREEN), 1) |  | ||||||
| CFLAGS		+= -DAPP_VERTICAL_SCREEN |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| APP_IRDA_MONITOR	?= 0 | APP_IRDA_MONITOR	?= 0 | ||||||
| ifeq ($(APP_IRDA_MONITOR), 1) | ifeq ($(APP_IRDA_MONITOR), 1) | ||||||
| CFLAGS		+= -DAPP_IRDA_MONITOR | CFLAGS		+= -DAPP_IRDA_MONITOR | ||||||
| @ -105,56 +100,35 @@ CFLAGS		+= -DAPP_ARCHIVE | |||||||
| APP_ARCHIVE = 1 | APP_ARCHIVE = 1 | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_EXAMPLE_BLINK ?= 0 | SRV_BLINK ?= 0 | ||||||
| ifeq ($(SRV_EXAMPLE_BLINK), 1) | ifeq ($(SRV_BLINK), 1) | ||||||
| CFLAGS		+= -DSRV_EXAMPLE_BLINK | CFLAGS		+= -DSRV_BLINK | ||||||
| APP_EXAMPLE_BLINK = 1 | APP_BLINK = 1 | ||||||
| endif | endif | ||||||
| APP_EXAMPLE_BLINK ?= 0 | APP_BLINK ?= 0 | ||||||
| ifeq ($(APP_EXAMPLE_BLINK), 1) | ifeq ($(APP_BLINK), 1) | ||||||
| CFLAGS		+= -DAPP_EXAMPLE_BLINK | CFLAGS		+= -DAPP_BLINK | ||||||
| SRV_INPUT = 1 | SRV_INPUT = 1 | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_EXAMPLE_UART_WRITE ?= 0 | SRV_UART_WRITE ?= 0 | ||||||
| ifeq ($(SRV_EXAMPLE_UART_WRITE), 1) | ifeq ($(SRV_UART_WRITE), 1) | ||||||
| CFLAGS		+= -DSRV_EXAMPLE_UART_WRITE | CFLAGS		+= -DSRV_UART_WRITE | ||||||
| APP_EXAMPLE_UART_WRITE = 1 | APP_UART_WRITE = 1 | ||||||
| endif | endif | ||||||
| APP_EXAMPLE_UART_WRITE ?= 0 | APP_UART_WRITE ?= 0 | ||||||
| ifeq ($(APP_EXAMPLE_UART_WRITE), 1) | ifeq ($(APP_UART_WRITE), 1) | ||||||
| CFLAGS		+= -DAPP_EXAMPLE_UART_WRITE | CFLAGS		+= -DAPP_UART_WRITE | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_EXAMPLE_IPC ?= 0 | SRV_IPC ?= 0 | ||||||
| ifeq ($(SRV_EXAMPLE_IPC), 1) | ifeq ($(SRV_IPC), 1) | ||||||
| CFLAGS		+= -DSRV_EXAMPLE_IPC | CFLAGS		+= -DSRV_IPC | ||||||
| APP_EXAMPLE_IPC = 1 | APP_IPC = 1 | ||||||
| endif | endif | ||||||
| APP_EXAMPLE_IPC ?= 0 | APP_IPC ?= 0 | ||||||
| ifeq ($(APP_EXAMPLE_IPC), 1) | ifeq ($(APP_IPC), 1) | ||||||
| CFLAGS		+= -DAPP_EXAMPLE_IPC | CFLAGS		+= -DAPP_IPC | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| SRV_EXAMPLE_INPUT_DUMP ?= 0 |  | ||||||
| ifeq ($(SRV_EXAMPLE_INPUT_DUMP), 1) |  | ||||||
| CFLAGS		+= -DSRV_EXAMPLE_INPUT_DUMP |  | ||||||
| APP_EXAMPLE_INPUT_DUMP = 1 |  | ||||||
| endif |  | ||||||
| APP_EXAMPLE_INPUT_DUMP ?= 0 |  | ||||||
| ifeq ($(APP_EXAMPLE_INPUT_DUMP), 1) |  | ||||||
| CFLAGS		+= -DAPP_EXAMPLE_INPUT_DUMP |  | ||||||
| SRV_INPUT = 1 |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| SRV_EXAMPLE_QRCODE ?= 0 |  | ||||||
| ifeq ($(SRV_EXAMPLE_QRCODE), 1) |  | ||||||
| CFLAGS		+= -DSRV_EXAMPLE_QRCODE |  | ||||||
| APP_EXAMPLE_QRCODE = 1 |  | ||||||
| endif |  | ||||||
| APP_EXAMPLE_QRCODE ?= 0 |  | ||||||
| ifeq ($(APP_EXAMPLE_QRCODE), 1) |  | ||||||
| CFLAGS		+= -DAPP_EXAMPLE_QRCODE |  | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| ifeq ($(APP_SUBGHZ), 1) | ifeq ($(APP_SUBGHZ), 1) | ||||||
| @ -196,18 +170,6 @@ SRV_INPUT = 1 | |||||||
| SRV_GUI = 1 | SRV_GUI = 1 | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_SPEAKER_DEMO ?= 0 |  | ||||||
| ifeq ($(SRV_SPEAKER_DEMO), 1) |  | ||||||
| CFLAGS		+= -DSRV_SPEAKER_DEMO |  | ||||||
| APP_SPEAKER_DEMO = 1 |  | ||||||
| endif |  | ||||||
| APP_SPEAKER_DEMO ?= 0 |  | ||||||
| ifeq ($(APP_SPEAKER_DEMO), 1) |  | ||||||
| CFLAGS		+= -DAPP_SPEAKER_DEMO |  | ||||||
| SRV_INPUT = 1 |  | ||||||
| SRV_GUI = 1 |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| APP_VIBRO_DEMO ?= 0 | APP_VIBRO_DEMO ?= 0 | ||||||
| ifeq ($(APP_VIBRO_DEMO), 1) | ifeq ($(APP_VIBRO_DEMO), 1) | ||||||
| CFLAGS		+= -DAPP_VIBRO_DEMO | CFLAGS		+= -DAPP_VIBRO_DEMO | ||||||
| @ -236,14 +198,14 @@ CFLAGS		+= -DAPP_ACCESSOR | |||||||
| APP_ACCESSOR = 1 | APP_ACCESSOR = 1 | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_GPIO_DEMO ?= 0 | SRV_GPIO_TEST ?= 0 | ||||||
| ifeq ($(SRV_GPIO_DEMO), 1) | ifeq ($(SRV_GPIO_TEST), 1) | ||||||
| CFLAGS		+= -DSRV_GPIO_DEMO | CFLAGS		+= -DSRV_GPIO_TEST | ||||||
| APP_GPIO_DEMO = 1 | APP_GPIO_TEST = 1 | ||||||
| endif | endif | ||||||
| APP_GPIO_DEMO ?= 0 | APP_GPIO_TEST ?= 0 | ||||||
| ifeq ($(APP_GPIO_DEMO), 1) | ifeq ($(APP_GPIO_TEST), 1) | ||||||
| CFLAGS		+= -DAPP_GPIO_DEMO | CFLAGS		+= -DAPP_GPIO_TEST | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_MUSIC_PLAYER ?= 0 | SRV_MUSIC_PLAYER ?= 0 | ||||||
| @ -266,17 +228,9 @@ ifeq ($(APP_IBUTTON), 1) | |||||||
| CFLAGS		+= -DAPP_IBUTTON | CFLAGS		+= -DAPP_IBUTTON | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_GUI_TEST ?= 0 | #
 | ||||||
| ifeq ($(SRV_GUI_TEST), 1) | # Essential services
 | ||||||
| CFLAGS		+= -DSRV_GUI_TEST | #
 | ||||||
| APP_GUI_TEST = 1 |  | ||||||
| endif |  | ||||||
| APP_GUI_TEST ?= 0 |  | ||||||
| ifeq ($(APP_GUI_TEST), 1) |  | ||||||
| CFLAGS		+= -DAPP_GUI_TEST |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| # device drivers
 |  | ||||||
| 
 | 
 | ||||||
| SRV_GUI	?= 0 | SRV_GUI	?= 0 | ||||||
| ifeq ($(SRV_GUI), 1) | ifeq ($(SRV_GUI), 1) | ||||||
| @ -307,4 +261,4 @@ endif | |||||||
| SRV_DIALOGS ?= 0 | SRV_DIALOGS ?= 0 | ||||||
| ifeq ($(SRV_DIALOGS), 1) | ifeq ($(SRV_DIALOGS), 1) | ||||||
| CFLAGS		+= -DSRV_DIALOGS | CFLAGS		+= -DSRV_DIALOGS | ||||||
| endif | endif | ||||||
|  | |||||||
| @ -629,7 +629,7 @@ ArchiveApp* archive_alloc() { | |||||||
|     return archive; |     return archive; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t app_archive(void* p) { | int32_t archive_app(void* p) { | ||||||
|     ArchiveApp* archive = archive_alloc(); |     ArchiveApp* archive = archive_alloc(); | ||||||
| 
 | 
 | ||||||
|     // default tab
 |     // default tab
 | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ static const char* flipper_app_name[] = { | |||||||
| static const char* known_ext[] = { | static const char* known_ext[] = { | ||||||
|     [ArchiveFileTypeIButton] = ".ibtn", |     [ArchiveFileTypeIButton] = ".ibtn", | ||||||
|     [ArchiveFileTypeNFC] = ".nfc", |     [ArchiveFileTypeNFC] = ".nfc", | ||||||
|     [ArchiveFileTypeSubOne] = ".sub1", |     [ArchiveFileTypeSubOne] = ".sub", | ||||||
|     [ArchiveFileTypeLFRFID] = ".rfid", |     [ArchiveFileTypeLFRFID] = ".rfid", | ||||||
|     [ArchiveFileTypeIrda] = ".ir", |     [ArchiveFileTypeIrda] = ".ir", | ||||||
| }; | }; | ||||||
| @ -44,7 +44,7 @@ static const char* tab_default_paths[] = { | |||||||
|     [ArchiveTabFavorites] = "/any/favorites", |     [ArchiveTabFavorites] = "/any/favorites", | ||||||
|     [ArchiveTabIButton] = "/any/ibutton", |     [ArchiveTabIButton] = "/any/ibutton", | ||||||
|     [ArchiveTabNFC] = "/any/nfc", |     [ArchiveTabNFC] = "/any/nfc", | ||||||
|     [ArchiveTabSubOne] = "/any/subone", |     [ArchiveTabSubOne] = "/any/subghz/saved", | ||||||
|     [ArchiveTabLFRFID] = "/any/lfrfid", |     [ArchiveTabLFRFID] = "/any/lfrfid", | ||||||
|     [ArchiveTabIrda] = "/any/irda", |     [ArchiveTabIrda] = "/any/irda", | ||||||
|     [ArchiveTabBrowser] = "/any", |     [ArchiveTabBrowser] = "/any", | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ static const char* ArchiveTabNames[] = { | |||||||
|     [ArchiveTabFavorites] = "Favorites", |     [ArchiveTabFavorites] = "Favorites", | ||||||
|     [ArchiveTabIButton] = "iButton", |     [ArchiveTabIButton] = "iButton", | ||||||
|     [ArchiveTabNFC] = "NFC", |     [ArchiveTabNFC] = "NFC", | ||||||
|     [ArchiveTabSubOne] = "SubOne", |     [ArchiveTabSubOne] = "SubGhz", | ||||||
|     [ArchiveTabLFRFID] = "RFID LF", |     [ArchiveTabLFRFID] = "RFID LF", | ||||||
|     [ArchiveTabIrda] = "Infrared", |     [ArchiveTabIrda] = "Infrared", | ||||||
|     [ArchiveTabBrowser] = "Browser"}; |     [ArchiveTabBrowser] = "Browser"}; | ||||||
|  | |||||||
| @ -148,29 +148,29 @@ void bt_menu_start_app(void* context) { | |||||||
|     furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); |     furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t bt_task() { | int32_t bt_srv() { | ||||||
|     Bt* bt = bt_alloc(); |     Bt* bt = bt_alloc(); | ||||||
| 
 | 
 | ||||||
|     furi_record_create("bt", bt); |     furi_record_create("bt", bt); | ||||||
| 
 | 
 | ||||||
|     api_hal_bt_init(); |     furi_hal_bt_init(); | ||||||
|     BtMessage message; |     BtMessage message; | ||||||
|     while(1) { |     while(1) { | ||||||
|         furi_check(osMessageQueueGet(bt->message_queue, &message, NULL, osWaitForever) == osOK); |         furi_check(osMessageQueueGet(bt->message_queue, &message, NULL, osWaitForever) == osOK); | ||||||
|         if(message.type == BtMessageTypeStartTestCarrier) { |         if(message.type == BtMessageTypeStartTestCarrier) { | ||||||
|             // Start carrier test
 |             // Start carrier test
 | ||||||
|             api_hal_bt_stop_tone_tx(); |             furi_hal_bt_stop_tone_tx(); | ||||||
|             if(bt->state.type == BtStateCarrierTx) { |             if(bt->state.type == BtStateCarrierTx) { | ||||||
|                 api_hal_bt_start_tone_tx(message.param.channel, message.param.power); |                 furi_hal_bt_start_tone_tx(message.param.channel, message.param.power); | ||||||
|             } else if(bt->state.type == BtStateHoppingTx) { |             } else if(bt->state.type == BtStateHoppingTx) { | ||||||
|                 bt->state.param.channel = |                 bt->state.param.channel = | ||||||
|                     bt_switch_channel(InputKeyRight, bt->state.param.channel); |                     bt_switch_channel(InputKeyRight, bt->state.param.channel); | ||||||
|                 api_hal_bt_start_tone_tx(bt->state.param.channel, bt->state.param.power); |                 furi_hal_bt_start_tone_tx(bt->state.param.channel, bt->state.param.power); | ||||||
|             } else if(bt->state.type == BtStateCarrierRxStart) { |             } else if(bt->state.type == BtStateCarrierRxStart) { | ||||||
|                 api_hal_bt_start_packet_rx(bt->state.param.channel, bt->state.param.datarate); |                 furi_hal_bt_start_packet_rx(bt->state.param.channel, bt->state.param.datarate); | ||||||
|                 bt->state.type = BtStateCarrierRxRunning; |                 bt->state.type = BtStateCarrierRxRunning; | ||||||
|             } else if(bt->state.type == BtStateCarrierRxRunning) { |             } else if(bt->state.type == BtStateCarrierRxRunning) { | ||||||
|                 bt->state.param.rssi = api_hal_bt_get_rssi(); |                 bt->state.param.rssi = furi_hal_bt_get_rssi(); | ||||||
|             } |             } | ||||||
|             with_view_model( |             with_view_model( | ||||||
|                 bt->view_test_carrier, (BtViewTestCarrierModel * model) { |                 bt->view_test_carrier, (BtViewTestCarrierModel * model) { | ||||||
| @ -183,14 +183,14 @@ int32_t bt_task() { | |||||||
|             view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestCarrier); |             view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestCarrier); | ||||||
|         } else if(message.type == BtMessageTypeStopTestCarrier) { |         } else if(message.type == BtMessageTypeStopTestCarrier) { | ||||||
|             if(bt->state.type == BtStateCarrierRxRunning) { |             if(bt->state.type == BtStateCarrierRxRunning) { | ||||||
|                 api_hal_bt_stop_packet_test(); |                 furi_hal_bt_stop_packet_test(); | ||||||
|             } else { |             } else { | ||||||
|                 api_hal_bt_stop_tone_tx(); |                 furi_hal_bt_stop_tone_tx(); | ||||||
|             } |             } | ||||||
|             bt->state.type = BtStateReady; |             bt->state.type = BtStateReady; | ||||||
|         } else if(message.type == BtMessageTypeSetupTestPacketTx) { |         } else if(message.type == BtMessageTypeSetupTestPacketTx) { | ||||||
|             // Update packet test setup
 |             // Update packet test setup
 | ||||||
|             api_hal_bt_stop_packet_test(); |             furi_hal_bt_stop_packet_test(); | ||||||
|             with_view_model( |             with_view_model( | ||||||
|                 bt->view_test_packet_tx, (BtViewTestPacketTxModel * model) { |                 bt->view_test_packet_tx, (BtViewTestPacketTxModel * model) { | ||||||
|                     model->type = bt->state.type; |                     model->type = bt->state.type; | ||||||
| @ -202,10 +202,10 @@ int32_t bt_task() { | |||||||
|         } else if(message.type == BtMessageTypeStartTestPacketTx) { |         } else if(message.type == BtMessageTypeStartTestPacketTx) { | ||||||
|             // Start sending packets
 |             // Start sending packets
 | ||||||
|             if(bt->state.type == BtStatePacketStart) { |             if(bt->state.type == BtStatePacketStart) { | ||||||
|                 api_hal_bt_start_packet_tx(message.param.channel, 1, message.param.datarate); |                 furi_hal_bt_start_packet_tx(message.param.channel, 1, message.param.datarate); | ||||||
|             } else if(bt->state.type == BtStatePacketSetup) { |             } else if(bt->state.type == BtStatePacketSetup) { | ||||||
|                 api_hal_bt_stop_packet_test(); |                 furi_hal_bt_stop_packet_test(); | ||||||
|                 bt->state.param.packets_sent = api_hal_bt_get_transmitted_packets(); |                 bt->state.param.packets_sent = furi_hal_bt_get_transmitted_packets(); | ||||||
|             } |             } | ||||||
|             with_view_model( |             with_view_model( | ||||||
|                 bt->view_test_packet_tx, (BtViewTestPacketTxModel * model) { |                 bt->view_test_packet_tx, (BtViewTestPacketTxModel * model) { | ||||||
| @ -218,7 +218,7 @@ int32_t bt_task() { | |||||||
|             view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketTx); |             view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketTx); | ||||||
|         } else if(message.type == BtMessageTypeSetupTestPacketRx) { |         } else if(message.type == BtMessageTypeSetupTestPacketRx) { | ||||||
|             // Update packet test setup
 |             // Update packet test setup
 | ||||||
|             api_hal_bt_stop_packet_test(); |             furi_hal_bt_stop_packet_test(); | ||||||
|             with_view_model( |             with_view_model( | ||||||
|                 bt->view_test_packet_rx, (BtViewTestPacketRxModel * model) { |                 bt->view_test_packet_rx, (BtViewTestPacketRxModel * model) { | ||||||
|                     model->type = bt->state.type; |                     model->type = bt->state.type; | ||||||
| @ -230,12 +230,12 @@ int32_t bt_task() { | |||||||
|         } else if(message.type == BtMessageTypeStartTestPacketRx) { |         } else if(message.type == BtMessageTypeStartTestPacketRx) { | ||||||
|             // Start test rx
 |             // Start test rx
 | ||||||
|             if(bt->state.type == BtStatePacketStart) { |             if(bt->state.type == BtStatePacketStart) { | ||||||
|                 api_hal_bt_start_packet_rx(message.param.channel, message.param.datarate); |                 furi_hal_bt_start_packet_rx(message.param.channel, message.param.datarate); | ||||||
|                 bt->state.type = BtStatePacketRunning; |                 bt->state.type = BtStatePacketRunning; | ||||||
|             } else if(bt->state.type == BtStatePacketRunning) { |             } else if(bt->state.type == BtStatePacketRunning) { | ||||||
|                 bt->state.param.rssi = api_hal_bt_get_rssi(); |                 bt->state.param.rssi = furi_hal_bt_get_rssi(); | ||||||
|             } else if(bt->state.type == BtStatePacketSetup) { |             } else if(bt->state.type == BtStatePacketSetup) { | ||||||
|                 bt->state.param.packets_received = api_hal_bt_stop_packet_test(); |                 bt->state.param.packets_received = furi_hal_bt_stop_packet_test(); | ||||||
|             } |             } | ||||||
|             with_view_model( |             with_view_model( | ||||||
|                 bt->view_test_packet_rx, (BtViewTestPacketRxModel * model) { |                 bt->view_test_packet_rx, (BtViewTestPacketRxModel * model) { | ||||||
| @ -249,17 +249,17 @@ int32_t bt_task() { | |||||||
|             view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketRx); |             view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketRx); | ||||||
|         } else if(message.type == BtMessageTypeStopTestPacket) { |         } else if(message.type == BtMessageTypeStopTestPacket) { | ||||||
|             // Stop test packet tx
 |             // Stop test packet tx
 | ||||||
|             api_hal_bt_stop_packet_test(); |             furi_hal_bt_stop_packet_test(); | ||||||
|             bt->state.type = BtStateReady; |             bt->state.type = BtStateReady; | ||||||
|         } else if(message.type == BtMessageTypeStartApp) { |         } else if(message.type == BtMessageTypeStartApp) { | ||||||
|             // Start app
 |             // Start app
 | ||||||
|             view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewStartApp); |             view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewStartApp); | ||||||
|             if(api_hal_bt_start_app()) { |             if(furi_hal_bt_start_app()) { | ||||||
|                 bt->state.type = BtStateStartedApp; |                 bt->state.type = BtStateStartedApp; | ||||||
|             } |             } | ||||||
|         } else if(message.type == BtMessageTypeUpdateStatusbar) { |         } else if(message.type == BtMessageTypeUpdateStatusbar) { | ||||||
|             // Update statusbar
 |             // Update statusbar
 | ||||||
|             view_port_enabled_set(bt->statusbar_view_port, api_hal_bt_is_alive()); |             view_port_enabled_set(bt->statusbar_view_port, furi_hal_bt_is_alive()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     return 0; |     return 0; | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "bt_cli.h" | #include "bt_cli.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| void bt_cli_init() { | void bt_cli_init() { | ||||||
|     Cli* cli = furi_record_open("cli"); |     Cli* cli = furi_record_open("cli"); | ||||||
| @ -17,7 +17,7 @@ void bt_cli_init() { | |||||||
| void bt_cli_command_info(Cli* cli, string_t args, void* context) { | void bt_cli_command_info(Cli* cli, string_t args, void* context) { | ||||||
|     string_t buffer; |     string_t buffer; | ||||||
|     string_init(buffer); |     string_init(buffer); | ||||||
|     api_hal_bt_dump_state(buffer); |     furi_hal_bt_dump_state(buffer); | ||||||
|     printf(string_get_cstr(buffer)); |     printf(string_get_cstr(buffer)); | ||||||
|     string_clear(buffer); |     string_clear(buffer); | ||||||
| } | } | ||||||
| @ -41,12 +41,12 @@ void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) { | |||||||
|     } |     } | ||||||
|     printf("Transmitting carrier at %hu channel at %hu dB power\r\n", channel, power); |     printf("Transmitting carrier at %hu channel at %hu dB power\r\n", channel, power); | ||||||
|     printf("Press CTRL+C to stop\r\n"); |     printf("Press CTRL+C to stop\r\n"); | ||||||
|     api_hal_bt_start_tone_tx(channel, 0x19 + power); |     furi_hal_bt_start_tone_tx(channel, 0x19 + power); | ||||||
| 
 | 
 | ||||||
|     while(!cli_cmd_interrupt_received(cli)) { |     while(!cli_cmd_interrupt_received(cli)) { | ||||||
|         osDelay(250); |         osDelay(250); | ||||||
|     } |     } | ||||||
|     api_hal_bt_stop_tone_tx(); |     furi_hal_bt_stop_tone_tx(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) { | void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) { | ||||||
| @ -64,15 +64,15 @@ void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) { | |||||||
|     printf("Receiving carrier at %hu channel\r\n", channel); |     printf("Receiving carrier at %hu channel\r\n", channel); | ||||||
|     printf("Press CTRL+C to stop\r\n"); |     printf("Press CTRL+C to stop\r\n"); | ||||||
| 
 | 
 | ||||||
|     api_hal_bt_start_packet_rx(channel, 1); |     furi_hal_bt_start_packet_rx(channel, 1); | ||||||
| 
 | 
 | ||||||
|     while(!cli_cmd_interrupt_received(cli)) { |     while(!cli_cmd_interrupt_received(cli)) { | ||||||
|         osDelay(1024 / 4); |         osDelay(1024 / 4); | ||||||
|         printf("RSSI: %6.1f dB\r", api_hal_bt_get_rssi()); |         printf("RSSI: %6.1f dB\r", furi_hal_bt_get_rssi()); | ||||||
|         fflush(stdout); |         fflush(stdout); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     api_hal_bt_stop_packet_test(); |     furi_hal_bt_stop_packet_test(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) { | void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) { | ||||||
| @ -111,13 +111,13 @@ void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) { | |||||||
|         channel, |         channel, | ||||||
|         datarate); |         datarate); | ||||||
|     printf("Press CTRL+C to stop\r\n"); |     printf("Press CTRL+C to stop\r\n"); | ||||||
|     api_hal_bt_start_packet_tx(channel, pattern, datarate); |     furi_hal_bt_start_packet_tx(channel, pattern, datarate); | ||||||
| 
 | 
 | ||||||
|     while(!cli_cmd_interrupt_received(cli)) { |     while(!cli_cmd_interrupt_received(cli)) { | ||||||
|         osDelay(250); |         osDelay(250); | ||||||
|     } |     } | ||||||
|     api_hal_bt_stop_packet_test(); |     furi_hal_bt_stop_packet_test(); | ||||||
|     printf("Transmitted %lu packets", api_hal_bt_get_transmitted_packets()); |     printf("Transmitted %lu packets", furi_hal_bt_get_transmitted_packets()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) { | void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) { | ||||||
| @ -139,15 +139,15 @@ void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) { | |||||||
|     } |     } | ||||||
|     printf("Receiving packets at %hu channel at %hu M datarate\r\n", channel, datarate); |     printf("Receiving packets at %hu channel at %hu M datarate\r\n", channel, datarate); | ||||||
|     printf("Press CTRL+C to stop\r\n"); |     printf("Press CTRL+C to stop\r\n"); | ||||||
|     api_hal_bt_start_packet_rx(channel, datarate); |     furi_hal_bt_start_packet_rx(channel, datarate); | ||||||
| 
 | 
 | ||||||
|     float rssi_raw = 0; |     float rssi_raw = 0; | ||||||
|     while(!cli_cmd_interrupt_received(cli)) { |     while(!cli_cmd_interrupt_received(cli)) { | ||||||
|         osDelay(250); |         osDelay(250); | ||||||
|         rssi_raw = api_hal_bt_get_rssi(); |         rssi_raw = furi_hal_bt_get_rssi(); | ||||||
|         printf("RSSI: %03.1f dB\r", rssi_raw); |         printf("RSSI: %03.1f dB\r", rssi_raw); | ||||||
|         fflush(stdout); |         fflush(stdout); | ||||||
|     } |     } | ||||||
|     uint16_t packets_received = api_hal_bt_stop_packet_test(); |     uint16_t packets_received = furi_hal_bt_stop_packet_test(); | ||||||
|     printf("Received %hu packets", packets_received); |     printf("Received %hu packets", packets_received); | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ | |||||||
| #include "bt_types.h" | #include "bt_types.h" | ||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #include <cli/cli.h> | #include <cli/cli.h> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #include "cli_i.h" | #include "cli_i.h" | ||||||
| #include "cli_commands.h" | #include "cli_commands.h" | ||||||
| 
 | 
 | ||||||
| #include <api-hal-version.h> | #include <furi-hal-version.h> | ||||||
| #include <loader/loader.h> | #include <loader/loader.h> | ||||||
| 
 | 
 | ||||||
| Cli* cli_alloc() { | Cli* cli_alloc() { | ||||||
| @ -30,33 +30,33 @@ void cli_free(Cli* cli) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void cli_putc(char c) { | void cli_putc(char c) { | ||||||
|     api_hal_vcp_tx((uint8_t*)&c, 1); |     furi_hal_vcp_tx((uint8_t*)&c, 1); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| char cli_getc(Cli* cli) { | char cli_getc(Cli* cli) { | ||||||
|     furi_assert(cli); |     furi_assert(cli); | ||||||
|     char c; |     char c; | ||||||
|     if(api_hal_vcp_rx((uint8_t*)&c, 1) == 0) { |     if(furi_hal_vcp_rx((uint8_t*)&c, 1) == 0) { | ||||||
|         cli_reset(cli); |         cli_reset(cli); | ||||||
|     } |     } | ||||||
|     return c; |     return c; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void cli_stdout_callback(void* _cookie, const char* data, size_t size) { | void cli_stdout_callback(void* _cookie, const char* data, size_t size) { | ||||||
|     api_hal_vcp_tx((const uint8_t*)data, size); |     furi_hal_vcp_tx((const uint8_t*)data, size); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void cli_write(Cli* cli, uint8_t* buffer, size_t size) { | void cli_write(Cli* cli, uint8_t* buffer, size_t size) { | ||||||
|     return api_hal_vcp_tx(buffer, size); |     return furi_hal_vcp_tx(buffer, size); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) { | size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) { | ||||||
|     return api_hal_vcp_rx(buffer, size); |     return furi_hal_vcp_rx(buffer, size); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool cli_cmd_interrupt_received(Cli* cli) { | bool cli_cmd_interrupt_received(Cli* cli) { | ||||||
|     char c = '\0'; |     char c = '\0'; | ||||||
|     if(api_hal_vcp_rx_with_timeout((uint8_t*)&c, 1, 0) == 1) { |     if(furi_hal_vcp_rx_with_timeout((uint8_t*)&c, 1, 0) == 1) { | ||||||
|         return c == CliSymbolAsciiETX; |         return c == CliSymbolAsciiETX; | ||||||
|     } else { |     } else { | ||||||
|         return false; |         return false; | ||||||
| @ -92,7 +92,7 @@ void cli_motd() { | |||||||
|            "Read Manual https://docs.flipperzero.one\r\n" |            "Read Manual https://docs.flipperzero.one\r\n" | ||||||
|            "\r\n"); |            "\r\n"); | ||||||
| 
 | 
 | ||||||
|     const Version* firmware_version = api_hal_version_get_firmware_version(); |     const Version* firmware_version = furi_hal_version_get_firmware_version(); | ||||||
|     if(firmware_version) { |     if(firmware_version) { | ||||||
|         printf( |         printf( | ||||||
|             "Firmware version: %s %s (%s built on %s)\r\n", |             "Firmware version: %s %s (%s built on %s)\r\n", | ||||||
| @ -143,7 +143,7 @@ static void cli_normalize_line(Cli* cli) { | |||||||
| 
 | 
 | ||||||
| static void cli_execute_command(Cli* cli, CliCommand* command, string_t args) { | static void cli_execute_command(Cli* cli, CliCommand* command, string_t args) { | ||||||
|     if(!(command->flags & CliCommandFlagInsomniaSafe)) { |     if(!(command->flags & CliCommandFlagInsomniaSafe)) { | ||||||
|         api_hal_power_insomnia_enter(); |         furi_hal_power_insomnia_enter(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Ensure that we running alone
 |     // Ensure that we running alone
 | ||||||
| @ -164,7 +164,7 @@ static void cli_execute_command(Cli* cli, CliCommand* command, string_t args) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(!(command->flags & CliCommandFlagInsomniaSafe)) { |     if(!(command->flags & CliCommandFlagInsomniaSafe)) { | ||||||
|         api_hal_power_insomnia_exit(); |         furi_hal_power_insomnia_exit(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -302,12 +302,15 @@ void cli_process_input(Cli* cli) { | |||||||
|     } else if(c == CliSymbolAsciiSOH) { |     } else if(c == CliSymbolAsciiSOH) { | ||||||
|         cli_motd(); |         cli_motd(); | ||||||
|         cli_prompt(cli); |         cli_prompt(cli); | ||||||
|  |     } else if(c == CliSymbolAsciiETX) { | ||||||
|  |         cli_reset(cli); | ||||||
|  |         cli_prompt(cli); | ||||||
|     } else if(c == CliSymbolAsciiEOT) { |     } else if(c == CliSymbolAsciiEOT) { | ||||||
|         cli_reset(cli); |         cli_reset(cli); | ||||||
|     } else if(c == CliSymbolAsciiEsc) { |     } else if(c == CliSymbolAsciiEsc) { | ||||||
|         r = api_hal_vcp_rx((uint8_t*)&c, 1); |         r = furi_hal_vcp_rx((uint8_t*)&c, 1); | ||||||
|         if(r && c == '[') { |         if(r && c == '[') { | ||||||
|             api_hal_vcp_rx((uint8_t*)&c, 1); |             furi_hal_vcp_rx((uint8_t*)&c, 1); | ||||||
|             cli_handle_escape(cli, c); |             cli_handle_escape(cli, c); | ||||||
|         } else { |         } else { | ||||||
|             cli_putc(CliSymbolAsciiBell); |             cli_putc(CliSymbolAsciiBell); | ||||||
| @ -383,7 +386,7 @@ void cli_delete_command(Cli* cli, const char* name) { | |||||||
|     string_clear(name_str); |     string_clear(name_str); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t cli_task(void* p) { | int32_t cli_srv(void* p) { | ||||||
|     Cli* cli = cli_alloc(); |     Cli* cli = cli_alloc(); | ||||||
| 
 | 
 | ||||||
|     // Init basic cli commands
 |     // Init basic cli commands
 | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "cli_commands.h" | #include "cli_commands.h" | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include <api-hal-gpio.h> | #include <furi-hal-gpio.h> | ||||||
| #include <rtc.h> | #include <rtc.h> | ||||||
| #include <task-control-block.h> | #include <task-control-block.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| @ -14,33 +14,33 @@ | |||||||
|  */ |  */ | ||||||
| void cli_command_device_info(Cli* cli, string_t args, void* context) { | void cli_command_device_info(Cli* cli, string_t args, void* context) { | ||||||
|     // Model name
 |     // Model name
 | ||||||
|     printf("hardware_model      : %s\r\n", api_hal_version_get_model_name()); |     printf("hardware_model      : %s\r\n", furi_hal_version_get_model_name()); | ||||||
|     const char* name = api_hal_version_get_name_ptr(); |     const char* name = furi_hal_version_get_name_ptr(); | ||||||
|     if(name) { |     if(name) { | ||||||
|         printf("hardware_name       : %s\r\n", name); |         printf("hardware_name       : %s\r\n", name); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Unique ID
 |     // Unique ID
 | ||||||
|     printf("hardware_uid        : "); |     printf("hardware_uid        : "); | ||||||
|     const uint8_t* uid = api_hal_version_uid(); |     const uint8_t* uid = furi_hal_version_uid(); | ||||||
|     for(size_t i = 0; i < api_hal_version_uid_size(); i++) { |     for(size_t i = 0; i < furi_hal_version_uid_size(); i++) { | ||||||
|         printf("%02X", uid[i]); |         printf("%02X", uid[i]); | ||||||
|     } |     } | ||||||
|     printf("\r\n"); |     printf("\r\n"); | ||||||
| 
 | 
 | ||||||
|     // Board Revision
 |     // Board Revision
 | ||||||
|     printf("hardware_ver        : %d\r\n", api_hal_version_get_hw_version()); |     printf("hardware_ver        : %d\r\n", furi_hal_version_get_hw_version()); | ||||||
|     printf("hardware_target     : %d\r\n", api_hal_version_get_hw_target()); |     printf("hardware_target     : %d\r\n", furi_hal_version_get_hw_target()); | ||||||
|     printf("hardware_body       : %d\r\n", api_hal_version_get_hw_body()); |     printf("hardware_body       : %d\r\n", furi_hal_version_get_hw_body()); | ||||||
|     printf("hardware_connect    : %d\r\n", api_hal_version_get_hw_connect()); |     printf("hardware_connect    : %d\r\n", furi_hal_version_get_hw_connect()); | ||||||
|     printf("hardware_timestamp  : %lu\r\n", api_hal_version_get_hw_timestamp()); |     printf("hardware_timestamp  : %lu\r\n", furi_hal_version_get_hw_timestamp()); | ||||||
| 
 | 
 | ||||||
|     // Color and Region
 |     // Color and Region
 | ||||||
|     printf("hardware_color      : %d\r\n", api_hal_version_get_hw_color()); |     printf("hardware_color      : %d\r\n", furi_hal_version_get_hw_color()); | ||||||
|     printf("hardware_region     : %d\r\n", api_hal_version_get_hw_region()); |     printf("hardware_region     : %d\r\n", furi_hal_version_get_hw_region()); | ||||||
| 
 | 
 | ||||||
|     // Bootloader Version
 |     // Bootloader Version
 | ||||||
|     const Version* boot_version = api_hal_version_get_boot_version(); |     const Version* boot_version = furi_hal_version_get_boot_version(); | ||||||
|     if(boot_version) { |     if(boot_version) { | ||||||
|         printf("boot_version        : %s\r\n", version_get_version(boot_version)); |         printf("boot_version        : %s\r\n", version_get_version(boot_version)); | ||||||
|         printf("boot_commit         : %s\r\n", version_get_githash(boot_version)); |         printf("boot_commit         : %s\r\n", version_get_githash(boot_version)); | ||||||
| @ -49,7 +49,7 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Firmware version
 |     // Firmware version
 | ||||||
|     const Version* firmware_version = api_hal_version_get_firmware_version(); |     const Version* firmware_version = furi_hal_version_get_firmware_version(); | ||||||
|     if(firmware_version) { |     if(firmware_version) { | ||||||
|         printf("firmware_version    : %s\r\n", version_get_version(firmware_version)); |         printf("firmware_version    : %s\r\n", version_get_version(firmware_version)); | ||||||
|         printf("firmware_commit     : %s\r\n", version_get_githash(firmware_version)); |         printf("firmware_commit     : %s\r\n", version_get_githash(firmware_version)); | ||||||
| @ -58,7 +58,7 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     WirelessFwInfo_t pWirelessInfo; |     WirelessFwInfo_t pWirelessInfo; | ||||||
|     if(api_hal_bt_is_alive() && SHCI_GetWirelessFwInfo(&pWirelessInfo) == SHCI_Success) { |     if(furi_hal_bt_is_alive() && SHCI_GetWirelessFwInfo(&pWirelessInfo) == SHCI_Success) { | ||||||
|         printf("radio_alive         : true\r\n"); |         printf("radio_alive         : true\r\n"); | ||||||
|         // FUS Info
 |         // FUS Info
 | ||||||
|         printf("radio_fus_major     : %d\r\n", pWirelessInfo.FusVersionMajor); |         printf("radio_fus_major     : %d\r\n", pWirelessInfo.FusVersionMajor); | ||||||
| @ -80,7 +80,7 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) { | |||||||
|         printf("radio_stack_flash   : %dK\r\n", pWirelessInfo.MemorySizeFlash * 4); |         printf("radio_stack_flash   : %dK\r\n", pWirelessInfo.MemorySizeFlash * 4); | ||||||
|         // Mac address
 |         // Mac address
 | ||||||
|         printf("radio_ble_mac       : "); |         printf("radio_ble_mac       : "); | ||||||
|         const uint8_t* ble_mac = api_hal_version_get_ble_mac(); |         const uint8_t* ble_mac = furi_hal_version_get_ble_mac(); | ||||||
|         for(size_t i = 0; i < 6; i++) { |         for(size_t i = 0; i < 6; i++) { | ||||||
|             printf("%02X", ble_mac[i]); |             printf("%02X", ble_mac[i]); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ | |||||||
| #include "cli.h" | #include "cli.h" | ||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #include <m-dict.h> | #include <m-dict.h> | ||||||
| #include <m-bptree.h> | #include <m-bptree.h> | ||||||
|  | |||||||
| @ -1,92 +0,0 @@ | |||||||
| #include <furi.h> |  | ||||||
| #include <input/input.h> |  | ||||||
| #include <gui/gui.h> |  | ||||||
| #include <api-hal.h> |  | ||||||
| 
 |  | ||||||
| #include "u8g2/u8g2.h" |  | ||||||
| 
 |  | ||||||
| extern TIM_HandleTypeDef SPEAKER_TIM; |  | ||||||
| 
 |  | ||||||
| bool exit_app; |  | ||||||
| 
 |  | ||||||
| static void event_cb(const void* value, void* ctx) { |  | ||||||
|     furi_assert(value); |  | ||||||
|     const InputEvent* event = value; |  | ||||||
|     if(event->key == InputKeyBack && event->type == InputTypeShort) { |  | ||||||
|         exit_app = true; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void coreglitch_draw_callback(Canvas* canvas, void* ctx) { |  | ||||||
|     canvas_clear(canvas); |  | ||||||
|     canvas_set_font(canvas, FontPrimary); |  | ||||||
|     canvas_draw_str(canvas, 2, 10, "Coreglitch demo application"); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int32_t coreglitch_demo_0(void* p) { |  | ||||||
|     printf("coreglitch demo!\r\n"); |  | ||||||
| 
 |  | ||||||
|     exit_app = false; |  | ||||||
|     PubSub* event_record = furi_record_open("input_events"); |  | ||||||
|     PubSubItem* event_pubsub = subscribe_pubsub(event_record, event_cb, NULL); |  | ||||||
| 
 |  | ||||||
|     // Configure view port
 |  | ||||||
|     ViewPort* view_port = view_port_alloc(); |  | ||||||
|     furi_check(view_port); |  | ||||||
|     view_port_draw_callback_set(view_port, coreglitch_draw_callback, NULL); |  | ||||||
| 
 |  | ||||||
|     // Register view port in GUI
 |  | ||||||
|     Gui* gui = furi_record_open("gui"); |  | ||||||
|     gui_add_view_port(gui, view_port, GuiLayerFullscreen); |  | ||||||
| 
 |  | ||||||
|     float notes[] = { |  | ||||||
|         0.0, |  | ||||||
|         330.0, |  | ||||||
|         220.0, |  | ||||||
|         0.0, |  | ||||||
|         110.0 + 55.0, |  | ||||||
|         440.0, |  | ||||||
|         330.0, |  | ||||||
|         55.0, |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     float scales[] = { |  | ||||||
|         1.0, |  | ||||||
|         1.5, |  | ||||||
|         0.75, |  | ||||||
|         0.8, |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     uint8_t cnt = 0; |  | ||||||
| 
 |  | ||||||
|     while(1) { |  | ||||||
|         for(size_t note_idx = 0; (note_idx < 400) && (!exit_app); note_idx++) { |  | ||||||
|             float scale = scales[((cnt + note_idx) / 16) % 4]; |  | ||||||
| 
 |  | ||||||
|             float freq = notes[(note_idx + cnt / 2) % 8] * scale; |  | ||||||
|             float width = 0.001 + 0.05 * (note_idx % (cnt / 7 + 5)); |  | ||||||
| 
 |  | ||||||
|             if(note_idx % 8 == 0) { |  | ||||||
|                 freq = 0; |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // TODO get sound from FURI
 |  | ||||||
|             hal_pwm_set(width, freq, &SPEAKER_TIM, SPEAKER_CH); |  | ||||||
| 
 |  | ||||||
|             // delay(1);
 |  | ||||||
| 
 |  | ||||||
|             cnt++; |  | ||||||
|             delay(100); |  | ||||||
|         } |  | ||||||
|         if(exit_app) { |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     hal_pwm_stop(&SPEAKER_TIM, SPEAKER_CH); |  | ||||||
|     view_port_enabled_set(view_port, false); |  | ||||||
|     gui_remove_view_port(gui, view_port); |  | ||||||
|     view_port_free(view_port); |  | ||||||
|     unsubscribe_pubsub(event_pubsub); |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| @ -1,5 +1,5 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| #include <input/input.h> | #include <input/input.h> | ||||||
| @ -18,7 +18,7 @@ typedef struct { | |||||||
|     InputEvent input; |     InputEvent input; | ||||||
| } BlinkEvent; | } BlinkEvent; | ||||||
| 
 | 
 | ||||||
| void blink_update(void* ctx) { | static void blink_test_update(void* ctx) { | ||||||
|     furi_assert(ctx); |     furi_assert(ctx); | ||||||
|     osMessageQueueId_t event_queue = ctx; |     osMessageQueueId_t event_queue = ctx; | ||||||
| 
 | 
 | ||||||
| @ -26,13 +26,13 @@ void blink_update(void* ctx) { | |||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |     osMessageQueuePut(event_queue, &event, 0, 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void blink_draw_callback(Canvas* canvas, void* ctx) { | static void blink_test_draw_callback(Canvas* canvas, void* ctx) { | ||||||
|     canvas_clear(canvas); |     canvas_clear(canvas); | ||||||
|     canvas_set_font(canvas, FontPrimary); |     canvas_set_font(canvas, FontPrimary); | ||||||
|     canvas_draw_str(canvas, 2, 10, "Blink application"); |     canvas_draw_str(canvas, 2, 10, "Blink application"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void blink_input_callback(InputEvent* input_event, void* ctx) { | static void blink_test_input_callback(InputEvent* input_event, void* ctx) { | ||||||
|     furi_assert(ctx); |     furi_assert(ctx); | ||||||
|     osMessageQueueId_t event_queue = ctx; |     osMessageQueueId_t event_queue = ctx; | ||||||
| 
 | 
 | ||||||
| @ -40,15 +40,15 @@ void blink_input_callback(InputEvent* input_event, void* ctx) { | |||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |     osMessageQueuePut(event_queue, &event, 0, 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t application_blink(void* p) { | int32_t blink_test_app(void* p) { | ||||||
|     osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(BlinkEvent), NULL); |     osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(BlinkEvent), NULL); | ||||||
| 
 | 
 | ||||||
|     // Configure view port
 |     // Configure view port
 | ||||||
|     ViewPort* view_port = view_port_alloc(); |     ViewPort* view_port = view_port_alloc(); | ||||||
|     furi_check(view_port); |     furi_check(view_port); | ||||||
|     view_port_draw_callback_set(view_port, blink_draw_callback, NULL); |     view_port_draw_callback_set(view_port, blink_test_draw_callback, NULL); | ||||||
|     view_port_input_callback_set(view_port, blink_input_callback, event_queue); |     view_port_input_callback_set(view_port, blink_test_input_callback, event_queue); | ||||||
|     osTimerId_t timer = osTimerNew(blink_update, osTimerPeriodic, event_queue, NULL); |     osTimerId_t timer = osTimerNew(blink_test_update, osTimerPeriodic, event_queue, NULL); | ||||||
|     osTimerStart(timer, 1000); |     osTimerStart(timer, 1000); | ||||||
| 
 | 
 | ||||||
|     // Register view port in GUI
 |     // Register view port in GUI
 | ||||||
							
								
								
									
										225
									
								
								applications/debug_tools/keypad_test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										225
									
								
								applications/debug_tools/keypad_test.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,225 @@ | |||||||
|  | #include <furi.h> | ||||||
|  | #include <gui/gui.h> | ||||||
|  | #include <input/input.h> | ||||||
|  | 
 | ||||||
|  | typedef struct { | ||||||
|  |     bool press[5]; | ||||||
|  |     uint16_t up; | ||||||
|  |     uint16_t down; | ||||||
|  |     uint16_t left; | ||||||
|  |     uint16_t right; | ||||||
|  |     uint16_t ok; | ||||||
|  | } KeypadTestState; | ||||||
|  | 
 | ||||||
|  | typedef enum { | ||||||
|  |     EventTypeInput, | ||||||
|  | } EventType; | ||||||
|  | 
 | ||||||
|  | typedef struct { | ||||||
|  |     union { | ||||||
|  |         InputEvent input; | ||||||
|  |     }; | ||||||
|  |     EventType type; | ||||||
|  | } KeypadTestEvent; | ||||||
|  | 
 | ||||||
|  | static const char* keypad_test_get_key_name(InputKey key) { | ||||||
|  |     switch(key) { | ||||||
|  |     case InputKeyOk: | ||||||
|  |         return "Ok"; | ||||||
|  |     case InputKeyBack: | ||||||
|  |         return "Back"; | ||||||
|  |     case InputKeyLeft: | ||||||
|  |         return "Left"; | ||||||
|  |     case InputKeyRight: | ||||||
|  |         return "Right"; | ||||||
|  |     case InputKeyUp: | ||||||
|  |         return "Up"; | ||||||
|  |     case InputKeyDown: | ||||||
|  |         return "Down"; | ||||||
|  |     default: | ||||||
|  |         return "Unknown"; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static const char* keypad_test_get_type_name(InputType type) { | ||||||
|  |     switch(type) { | ||||||
|  |     case InputTypePress: | ||||||
|  |         return "Press"; | ||||||
|  |     case InputTypeRelease: | ||||||
|  |         return "Release"; | ||||||
|  |     case InputTypeShort: | ||||||
|  |         return "Short"; | ||||||
|  |     case InputTypeLong: | ||||||
|  |         return "Long"; | ||||||
|  |     case InputTypeRepeat: | ||||||
|  |         return "Repeat"; | ||||||
|  |     default: | ||||||
|  |         return "Unknown"; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void keypad_test_reset_state(KeypadTestState* state) { | ||||||
|  |     state->left = 0; | ||||||
|  |     state->right = 0; | ||||||
|  |     state->up = 0; | ||||||
|  |     state->down = 0; | ||||||
|  |     state->ok = 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void keypad_test_render_callback(Canvas* canvas, void* ctx) { | ||||||
|  |     KeypadTestState* state = (KeypadTestState*)acquire_mutex((ValueMutex*)ctx, 25); | ||||||
|  |     canvas_clear(canvas); | ||||||
|  |     char strings[5][20]; | ||||||
|  | 
 | ||||||
|  |     sprintf(strings[0], "Ok: %d", state->ok); | ||||||
|  |     sprintf(strings[1], "L: %d", state->left); | ||||||
|  |     sprintf(strings[2], "R: %d", state->right); | ||||||
|  |     sprintf(strings[3], "U: %d", state->up); | ||||||
|  |     sprintf(strings[4], "D: %d", state->down); | ||||||
|  | 
 | ||||||
|  |     canvas_set_font(canvas, FontPrimary); | ||||||
|  |     canvas_draw_str(canvas, 0, 10, "Keypad test"); | ||||||
|  | 
 | ||||||
|  |     canvas_set_font(canvas, FontSecondary); | ||||||
|  |     canvas_draw_str(canvas, 0, 24, strings[1]); | ||||||
|  |     canvas_draw_str(canvas, 35, 24, strings[2]); | ||||||
|  |     canvas_draw_str(canvas, 0, 36, strings[3]); | ||||||
|  |     canvas_draw_str(canvas, 35, 36, strings[4]); | ||||||
|  |     canvas_draw_str(canvas, 0, 48, strings[0]); | ||||||
|  |     canvas_draw_circle(canvas, 100, 26, 25); | ||||||
|  | 
 | ||||||
|  |     if(state->press[0]) canvas_draw_disc(canvas, 118, 26, 5); | ||||||
|  |     if(state->press[1]) canvas_draw_disc(canvas, 82, 26, 5); | ||||||
|  |     if(state->press[2]) canvas_draw_disc(canvas, 100, 8, 5); | ||||||
|  |     if(state->press[3]) canvas_draw_disc(canvas, 100, 44, 5); | ||||||
|  |     if(state->press[4]) canvas_draw_disc(canvas, 100, 26, 5); | ||||||
|  | 
 | ||||||
|  |     canvas_draw_str(canvas, 10, 63, "[back] - reset, hold to exit"); | ||||||
|  | 
 | ||||||
|  |     release_mutex((ValueMutex*)ctx, state); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void keypad_test_input_callback(InputEvent* input_event, void* ctx) { | ||||||
|  |     osMessageQueueId_t event_queue = ctx; | ||||||
|  | 
 | ||||||
|  |     KeypadTestEvent event; | ||||||
|  |     event.type = EventTypeInput; | ||||||
|  |     event.input = *input_event; | ||||||
|  |     osMessageQueuePut(event_queue, &event, 0, osWaitForever); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int32_t keypad_test_app(void* p) { | ||||||
|  |     osMessageQueueId_t event_queue = osMessageQueueNew(32, sizeof(KeypadTestEvent), NULL); | ||||||
|  |     furi_check(event_queue); | ||||||
|  | 
 | ||||||
|  |     KeypadTestState _state = {{false, false, false, false, false}, 0, 0, 0, 0, 0}; | ||||||
|  | 
 | ||||||
|  |     ValueMutex state_mutex; | ||||||
|  |     if(!init_mutex(&state_mutex, &_state, sizeof(KeypadTestState))) { | ||||||
|  |         FURI_LOG_E("KeypadTest", "cannot create mutex"); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ViewPort* view_port = view_port_alloc(); | ||||||
|  | 
 | ||||||
|  |     view_port_draw_callback_set(view_port, keypad_test_render_callback, &state_mutex); | ||||||
|  |     view_port_input_callback_set(view_port, keypad_test_input_callback, event_queue); | ||||||
|  | 
 | ||||||
|  |     // Open GUI and register view_port
 | ||||||
|  |     Gui* gui = furi_record_open("gui"); | ||||||
|  |     gui_add_view_port(gui, view_port, GuiLayerFullscreen); | ||||||
|  | 
 | ||||||
|  |     KeypadTestEvent event; | ||||||
|  |     while(1) { | ||||||
|  |         osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, osWaitForever); | ||||||
|  |         KeypadTestState* state = (KeypadTestState*)acquire_mutex_block(&state_mutex); | ||||||
|  | 
 | ||||||
|  |         if(event_status == osOK) { | ||||||
|  |             if(event.type == EventTypeInput) { | ||||||
|  |                 FURI_LOG_I( | ||||||
|  |                     "KeypadTest", | ||||||
|  |                     "key: %s type: %s", | ||||||
|  |                     keypad_test_get_key_name(event.input.key), | ||||||
|  |                     keypad_test_get_type_name(event.input.type)); | ||||||
|  | 
 | ||||||
|  |                 if(event.input.type == InputTypeLong && event.input.key == InputKeyBack) { | ||||||
|  |                     release_mutex(&state_mutex, state); | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if(event.input.type == InputTypeShort && event.input.key == InputKeyBack) { | ||||||
|  |                     keypad_test_reset_state(state); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if(event.input.key == InputKeyRight) { | ||||||
|  |                     if(event.input.type == InputTypePress) { | ||||||
|  |                         state->press[0] = true; | ||||||
|  |                     } else if(event.input.type == InputTypeRelease) { | ||||||
|  |                         state->press[0] = false; | ||||||
|  |                     } | ||||||
|  | 
 | ||||||
|  |                     if(event.input.type == InputTypeShort) { | ||||||
|  |                         ++state->right; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if(event.input.key == InputKeyLeft) { | ||||||
|  |                     if(event.input.type == InputTypePress) { | ||||||
|  |                         state->press[1] = true; | ||||||
|  |                     } else if(event.input.type == InputTypeRelease) { | ||||||
|  |                         state->press[1] = false; | ||||||
|  |                     } | ||||||
|  | 
 | ||||||
|  |                     if(event.input.type == InputTypeShort) { | ||||||
|  |                         ++state->left; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if(event.input.key == InputKeyUp) { | ||||||
|  |                     if(event.input.type == InputTypePress) { | ||||||
|  |                         state->press[2] = true; | ||||||
|  |                     } else if(event.input.type == InputTypeRelease) { | ||||||
|  |                         state->press[2] = false; | ||||||
|  |                     } | ||||||
|  | 
 | ||||||
|  |                     if(event.input.type == InputTypeShort) { | ||||||
|  |                         ++state->up; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if(event.input.key == InputKeyDown) { | ||||||
|  |                     if(event.input.type == InputTypePress) { | ||||||
|  |                         state->press[3] = true; | ||||||
|  |                     } else if(event.input.type == InputTypeRelease) { | ||||||
|  |                         state->press[3] = false; | ||||||
|  |                     } | ||||||
|  | 
 | ||||||
|  |                     if(event.input.type == InputTypeShort) { | ||||||
|  |                         ++state->down; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if(event.input.key == InputKeyOk) { | ||||||
|  |                     if(event.input.type == InputTypePress) { | ||||||
|  |                         state->press[4] = true; | ||||||
|  |                     } else if(event.input.type == InputTypeRelease) { | ||||||
|  |                         state->press[4] = false; | ||||||
|  |                     } | ||||||
|  | 
 | ||||||
|  |                     if(event.input.type == InputTypeShort) { | ||||||
|  |                         ++state->ok; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         view_port_update(view_port); | ||||||
|  |         release_mutex(&state_mutex, state); | ||||||
|  |     } | ||||||
|  |     // remove & free all stuff created by app
 | ||||||
|  |     gui_remove_view_port(gui, view_port); | ||||||
|  |     view_port_free(view_port); | ||||||
|  |     osMessageQueueDelete(event_queue); | ||||||
|  |     delete_mutex(&state_mutex); | ||||||
|  | 
 | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
| @ -1,5 +1,5 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| #include <input/input.h> | #include <input/input.h> | ||||||
| @ -9,7 +9,7 @@ typedef struct { | |||||||
|     InputEvent input; |     InputEvent input; | ||||||
| } VibroEvent; | } VibroEvent; | ||||||
| 
 | 
 | ||||||
| void vibro_draw_callback(Canvas* canvas, void* ctx) { | void vibro_test_draw_callback(Canvas* canvas, void* ctx) { | ||||||
|     canvas_clear(canvas); |     canvas_clear(canvas); | ||||||
|     canvas_set_font(canvas, FontPrimary); |     canvas_set_font(canvas, FontPrimary); | ||||||
|     canvas_draw_str(canvas, 2, 10, "Vibro application"); |     canvas_draw_str(canvas, 2, 10, "Vibro application"); | ||||||
| @ -19,7 +19,7 @@ void vibro_draw_callback(Canvas* canvas, void* ctx) { | |||||||
|     canvas_draw_str(canvas, 2, 34, "Release OK turns off vibro"); |     canvas_draw_str(canvas, 2, 34, "Release OK turns off vibro"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void vibro_input_callback(InputEvent* input_event, void* ctx) { | void vibro_test_input_callback(InputEvent* input_event, void* ctx) { | ||||||
|     furi_assert(ctx); |     furi_assert(ctx); | ||||||
|     osMessageQueueId_t event_queue = ctx; |     osMessageQueueId_t event_queue = ctx; | ||||||
| 
 | 
 | ||||||
| @ -27,14 +27,14 @@ void vibro_input_callback(InputEvent* input_event, void* ctx) { | |||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |     osMessageQueuePut(event_queue, &event, 0, 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t application_vibro(void* p) { | int32_t vibro_test_app(void* p) { | ||||||
|     osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(VibroEvent), NULL); |     osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(VibroEvent), NULL); | ||||||
| 
 | 
 | ||||||
|     // Configure view port
 |     // Configure view port
 | ||||||
|     ViewPort* view_port = view_port_alloc(); |     ViewPort* view_port = view_port_alloc(); | ||||||
|     furi_check(view_port); |     furi_check(view_port); | ||||||
|     view_port_draw_callback_set(view_port, vibro_draw_callback, NULL); |     view_port_draw_callback_set(view_port, vibro_test_draw_callback, NULL); | ||||||
|     view_port_input_callback_set(view_port, vibro_input_callback, event_queue); |     view_port_input_callback_set(view_port, vibro_test_input_callback, event_queue); | ||||||
| 
 | 
 | ||||||
|     // Register view port in GUI
 |     // Register view port in GUI
 | ||||||
|     Gui* gui = furi_record_open("gui"); |     Gui* gui = furi_record_open("gui"); | ||||||
| @ -24,7 +24,7 @@ static void dialogs_app_process_message(DialogsApp* app, DialogsAppMessage* mess | |||||||
|     API_LOCK_UNLOCK(message->semaphore); |     API_LOCK_UNLOCK(message->semaphore); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t dialogs_app(void* p) { | int32_t dialogs_srv(void* p) { | ||||||
|     DialogsApp* app = dialogs_app_alloc(); |     DialogsApp* app = dialogs_app_alloc(); | ||||||
|     furi_record_create("dialogs", app); |     furi_record_create("dialogs", app); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -393,7 +393,7 @@ void dolphin_deed(Dolphin* dolphin, DolphinDeed deed) { | |||||||
|     furi_check(osMessageQueuePut(dolphin->event_queue, &event, 0, osWaitForever) == osOK); |     furi_check(osMessageQueuePut(dolphin->event_queue, &event, 0, osWaitForever) == osOK); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t dolphin_task() { | int32_t dolphin_srv() { | ||||||
|     Dolphin* dolphin = dolphin_alloc(); |     Dolphin* dolphin = dolphin_alloc(); | ||||||
| 
 | 
 | ||||||
|     if(dolphin_state_load(dolphin->state)) { |     if(dolphin_state_load(dolphin->state)) { | ||||||
| @ -411,7 +411,7 @@ int32_t dolphin_task() { | |||||||
| 
 | 
 | ||||||
|     furi_record_create("dolphin", dolphin); |     furi_record_create("dolphin", dolphin); | ||||||
| 
 | 
 | ||||||
|     if(!api_hal_version_do_i_belong_here()) { |     if(!furi_hal_version_do_i_belong_here()) { | ||||||
|         view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewHwMismatch); |         view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewHwMismatch); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ | |||||||
| #include "dolphin_views.h" | #include "dolphin_views.h" | ||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| #include <gui/view_dispatcher.h> | #include <gui/view_dispatcher.h> | ||||||
| #include <gui/canvas.h> | #include <gui/canvas.h> | ||||||
|  | |||||||
| @ -2,8 +2,8 @@ | |||||||
| #include <gui/view.h> | #include <gui/view.h> | ||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| #include <gui/elements.h> | #include <gui/elements.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include <api-hal-version.h> | #include <furi-hal-version.h> | ||||||
| 
 | 
 | ||||||
| static char* Lockmenu_Items[3] = {"Lock", "Set PIN", "DUMB mode"}; | static char* Lockmenu_Items[3] = {"Lock", "Set PIN", "DUMB mode"}; | ||||||
| 
 | 
 | ||||||
| @ -14,7 +14,7 @@ void dolphin_view_first_start_draw(Canvas* canvas, void* model) { | |||||||
|     canvas_set_font(canvas, FontSecondary); |     canvas_set_font(canvas, FontSecondary); | ||||||
|     uint8_t width = canvas_width(canvas); |     uint8_t width = canvas_width(canvas); | ||||||
|     uint8_t height = canvas_height(canvas); |     uint8_t height = canvas_height(canvas); | ||||||
|     const char* my_name = api_hal_version_get_name_ptr(); |     const char* my_name = furi_hal_version_get_name_ptr(); | ||||||
|     if(m->page == 0) { |     if(m->page == 0) { | ||||||
|         canvas_draw_icon(canvas, 0, height - 48, &I_DolphinFirstStart0_70x53); |         canvas_draw_icon(canvas, 0, height - 48, &I_DolphinFirstStart0_70x53); | ||||||
|         elements_multiline_text_framed(canvas, 75, 20, "Hey m8,\npress > to\ncontinue"); |         elements_multiline_text_framed(canvas, 75, 20, "Hey m8,\npress > to\ncontinue"); | ||||||
| @ -119,20 +119,20 @@ void dolphin_view_idle_down_draw(Canvas* canvas, void* model) { | |||||||
| 
 | 
 | ||||||
|     if(m->screen != DolphinViewStatsMeta) { |     if(m->screen != DolphinViewStatsMeta) { | ||||||
|         // Hardware version
 |         // Hardware version
 | ||||||
|         const char* my_name = api_hal_version_get_name_ptr(); |         const char* my_name = furi_hal_version_get_name_ptr(); | ||||||
|         snprintf( |         snprintf( | ||||||
|             buffer, |             buffer, | ||||||
|             sizeof(buffer), |             sizeof(buffer), | ||||||
|             "HW: %d.F%dB%dC%d %s", |             "HW: %d.F%dB%dC%d %s", | ||||||
|             api_hal_version_get_hw_version(), |             furi_hal_version_get_hw_version(), | ||||||
|             api_hal_version_get_hw_target(), |             furi_hal_version_get_hw_target(), | ||||||
|             api_hal_version_get_hw_body(), |             furi_hal_version_get_hw_body(), | ||||||
|             api_hal_version_get_hw_connect(), |             furi_hal_version_get_hw_connect(), | ||||||
|             my_name ? my_name : "Unknown"); |             my_name ? my_name : "Unknown"); | ||||||
|         canvas_draw_str(canvas, 5, 23, buffer); |         canvas_draw_str(canvas, 5, 23, buffer); | ||||||
| 
 | 
 | ||||||
|         ver = m->screen == DolphinViewStatsBoot ? api_hal_version_get_boot_version() : |         ver = m->screen == DolphinViewStatsBoot ? furi_hal_version_get_boot_version() : | ||||||
|                                                   api_hal_version_get_firmware_version(); |                                                   furi_hal_version_get_firmware_version(); | ||||||
| 
 | 
 | ||||||
|         if(!ver) { |         if(!ver) { | ||||||
|             canvas_draw_str(canvas, 5, 33, "No info"); |             canvas_draw_str(canvas, 5, 33, "No info"); | ||||||
| @ -178,7 +178,7 @@ void dolphin_view_hw_mismatch_draw(Canvas* canvas, void* model) { | |||||||
| 
 | 
 | ||||||
|     char buffer[64]; |     char buffer[64]; | ||||||
|     canvas_set_font(canvas, FontSecondary); |     canvas_set_font(canvas, FontSecondary); | ||||||
|     snprintf(buffer, 64, "HW target: F%d", api_hal_version_get_hw_target()); |     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, 27, buffer); | ||||||
|     canvas_draw_str(canvas, 5, 38, "FW target: " TARGET); |     canvas_draw_str(canvas, 5, 38, "FW target: " TARGET); | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										321
									
								
								applications/dolphin/games/food.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										321
									
								
								applications/dolphin/games/food.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,321 @@ | |||||||
|  | #include <furi.h> | ||||||
|  | #include <gui/gui.h> | ||||||
|  | #include "dolphin/dolphin_state.h" | ||||||
|  | 
 | ||||||
|  | #define MAX_TRIES 3 | ||||||
|  | #define DISHES_TOTAL 3 | ||||||
|  | #define LID_POS_MAX 20 | ||||||
|  | #define TRY_TIMEOUT 10 | ||||||
|  | 
 | ||||||
|  | typedef enum { | ||||||
|  |     EventTypeTick, | ||||||
|  |     EventTypeKey, | ||||||
|  |     EventTypeDeed, | ||||||
|  | } EventType; | ||||||
|  | 
 | ||||||
|  | typedef struct { | ||||||
|  |     union { | ||||||
|  |         InputEvent input; | ||||||
|  |     } value; | ||||||
|  |     EventType type; | ||||||
|  | } AppEvent; | ||||||
|  | 
 | ||||||
|  | typedef enum { | ||||||
|  |     PlayerChoiceEvent, | ||||||
|  |     OpenLootEvent, | ||||||
|  |     WinEvent, | ||||||
|  |     LooseEvent, | ||||||
|  |     FinishedEvent, | ||||||
|  |     ExitGameEvent, | ||||||
|  |     GameEventTotal, | ||||||
|  | } GameEventType; | ||||||
|  | 
 | ||||||
|  | typedef enum { | ||||||
|  |     LootSkeleton, | ||||||
|  |     LootFish, | ||||||
|  |     LootShit, | ||||||
|  |     LootTotalNum, | ||||||
|  | } LootIdEnum; | ||||||
|  | 
 | ||||||
|  | typedef struct { | ||||||
|  |     GameEventType current_event; | ||||||
|  |     osMessageQueueId_t event_queue; | ||||||
|  |     LootIdEnum loot_list[DISHES_TOTAL]; | ||||||
|  | 
 | ||||||
|  |     uint8_t cursor_pos; | ||||||
|  |     uint8_t lid_pos; | ||||||
|  |     uint8_t timeout; | ||||||
|  |     uint8_t try; | ||||||
|  | 
 | ||||||
|  |     bool selected; | ||||||
|  |     bool deed; | ||||||
|  | 
 | ||||||
|  | } GameState; | ||||||
|  | 
 | ||||||
|  | typedef struct { | ||||||
|  |     const Icon* f; | ||||||
|  |     const Icon* b; | ||||||
|  | } LootGfx; | ||||||
|  | 
 | ||||||
|  | static const Icon* letters[DISHES_TOTAL] = {&I_letterA_10x10, &I_letterB_10x10, &I_letterC_10x10}; | ||||||
|  | 
 | ||||||
|  | static const LootGfx loot[LootTotalNum] = { | ||||||
|  |     [LootSkeleton] = | ||||||
|  |         { | ||||||
|  |             .f = &I_skeleton_25x17, | ||||||
|  |             .b = &I_blackskeleton_25x17, | ||||||
|  |         }, | ||||||
|  |     [LootFish] = | ||||||
|  |         { | ||||||
|  |             .f = &I_fish_25x17, | ||||||
|  |             .b = &I_blackfish_25x17, | ||||||
|  |         }, | ||||||
|  |     [LootShit] = | ||||||
|  |         { | ||||||
|  |             .f = &I_shit_25x17, | ||||||
|  |             .b = &I_blackshit_25x17, | ||||||
|  |         }, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | static void input_callback(InputEvent* input_event, void* ctx) { | ||||||
|  |     osMessageQueueId_t event_queue = ctx; | ||||||
|  |     AppEvent event; | ||||||
|  |     event.type = EventTypeKey; | ||||||
|  |     event.value.input = *input_event; | ||||||
|  |     osMessageQueuePut(event_queue, &event, 0, osWaitForever); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void draw_dish(Canvas* canvas, GameState* state, uint8_t x, uint8_t y, uint8_t id) { | ||||||
|  |     bool active = state->cursor_pos == id; | ||||||
|  |     bool opened = state->current_event == OpenLootEvent && active; | ||||||
|  | 
 | ||||||
|  |     canvas_set_bitmap_mode(canvas, true); | ||||||
|  |     canvas_set_color(canvas, ColorBlack); | ||||||
|  | 
 | ||||||
|  |     if(active) { | ||||||
|  |         canvas_draw_icon(canvas, x, y, &I_active_plate_48x18); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if(opened) { | ||||||
|  |         state->lid_pos = CLAMP(state->lid_pos + 1, LID_POS_MAX, 0); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     uint8_t lid_pos = (y - 17) - (opened ? state->lid_pos : 0); | ||||||
|  | 
 | ||||||
|  |     canvas_draw_icon(canvas, x + 3, y - 6, &I_plate_42x19); | ||||||
|  | 
 | ||||||
|  |     canvas_set_color(canvas, ColorWhite); | ||||||
|  |     canvas_draw_icon(canvas, x + 11, y - 10, loot[state->loot_list[id]].b); | ||||||
|  |     canvas_set_color(canvas, ColorBlack); | ||||||
|  |     canvas_draw_icon(canvas, x + 11, y - 10, loot[state->loot_list[id]].f); | ||||||
|  | 
 | ||||||
|  |     canvas_set_color(canvas, ColorWhite); | ||||||
|  |     canvas_draw_icon(canvas, x + 6, lid_pos, &I_blacklid_36x27); | ||||||
|  |     canvas_set_color(canvas, ColorBlack); | ||||||
|  |     canvas_draw_icon(canvas, x + 6, lid_pos, &I_lid_36x27); | ||||||
|  |     canvas_set_bitmap_mode(canvas, false); | ||||||
|  | 
 | ||||||
|  |     canvas_draw_icon(canvas, x + 19, y + 8, letters[id]); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void draw_dishes_scene(Canvas* canvas, GameState* state) { | ||||||
|  |     uint8_t tries_left = MAX_TRIES - state->try; | ||||||
|  |     for(size_t i = 0; i < MAX_TRIES; i++) { | ||||||
|  |         if(i < tries_left) { | ||||||
|  |             canvas_draw_disc(canvas, 5 + i * 8, 5, 2); | ||||||
|  |         } else { | ||||||
|  |             canvas_draw_circle(canvas, 5 + i * 8, 5, 2); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     for(size_t i = 0; i < DISHES_TOTAL; i++) { | ||||||
|  |         draw_dish(canvas, state, i * 40, i % 2 ? 26 : 44, i); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void render_callback(Canvas* canvas, void* ctx) { | ||||||
|  |     GameState* state = (GameState*)acquire_mutex((ValueMutex*)ctx, 25); | ||||||
|  |     canvas_clear(canvas); | ||||||
|  | 
 | ||||||
|  |     switch(state->current_event) { | ||||||
|  |     case WinEvent: | ||||||
|  |         canvas_draw_str(canvas, 30, 30, "Dolphin_happy.png"); | ||||||
|  |         break; | ||||||
|  |     case LooseEvent: | ||||||
|  |         canvas_draw_str_aligned(canvas, 64, 30, AlignCenter, AlignCenter, "Try again!"); | ||||||
|  |         break; | ||||||
|  |     case ExitGameEvent: | ||||||
|  |         break; | ||||||
|  |     case FinishedEvent: | ||||||
|  |         break; | ||||||
|  |     default: | ||||||
|  |         draw_dishes_scene(canvas, state); | ||||||
|  |         break; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     release_mutex((ValueMutex*)ctx, state); | ||||||
|  | } | ||||||
|  | static void reset_lid_pos(GameState* state) { | ||||||
|  |     state->selected = false; | ||||||
|  |     state->lid_pos = 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void dolphin_food_deed(GameState* state) { | ||||||
|  |     furi_assert(state); | ||||||
|  |     AppEvent event; | ||||||
|  |     event.type = EventTypeDeed; | ||||||
|  |     furi_check(osMessageQueuePut(state->event_queue, &event, 0, osWaitForever) == osOK); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void reset_loot_array(GameState* state) { | ||||||
|  |     for(size_t i = 0; i < LootTotalNum; i++) { | ||||||
|  |         state->loot_list[i] = i; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     for(size_t i = 0; i < LootTotalNum; i++) { | ||||||
|  |         int temp = state->loot_list[i]; | ||||||
|  |         int r_idx = rand() % LootTotalNum; | ||||||
|  | 
 | ||||||
|  |         state->loot_list[i] = state->loot_list[r_idx]; | ||||||
|  |         state->loot_list[r_idx] = temp; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static bool selected_is_food(GameState* state) { | ||||||
|  |     return state->loot_list[state->cursor_pos] == LootFish; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static bool tries_exceed(GameState* state) { | ||||||
|  |     return state->try == MAX_TRIES; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static bool timeout_exceed(GameState* state) { | ||||||
|  |     return state->timeout == TRY_TIMEOUT; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void gamestate_update(GameState* state, DolphinState* dolphin_state) { | ||||||
|  |     switch(state->current_event) { | ||||||
|  |     case PlayerChoiceEvent: | ||||||
|  |         if(state->selected) { | ||||||
|  |             state->current_event = OpenLootEvent; | ||||||
|  |         } | ||||||
|  |         break; | ||||||
|  |     case OpenLootEvent: | ||||||
|  |         state->timeout = CLAMP(state->timeout + 1, TRY_TIMEOUT, 0); | ||||||
|  |         if(timeout_exceed(state)) { | ||||||
|  |             state->timeout = 0; | ||||||
|  |             state->current_event = selected_is_food(state) ? WinEvent : LooseEvent; | ||||||
|  |             state->deed = selected_is_food(state); | ||||||
|  |         } | ||||||
|  |         break; | ||||||
|  |     case LooseEvent: | ||||||
|  |         state->timeout = CLAMP(state->timeout + 1, TRY_TIMEOUT, 0); | ||||||
|  |         if(timeout_exceed(state)) { | ||||||
|  |             state->timeout = 0; | ||||||
|  |             state->current_event = FinishedEvent; | ||||||
|  |         } | ||||||
|  |         break; | ||||||
|  |     case WinEvent: | ||||||
|  |         if(state->deed) { | ||||||
|  |             dolphin_food_deed(state); | ||||||
|  |         } | ||||||
|  |         break; | ||||||
|  |     case FinishedEvent: | ||||||
|  |         reset_lid_pos(state); | ||||||
|  |         reset_loot_array(state); | ||||||
|  | 
 | ||||||
|  |         state->try++; | ||||||
|  |         state->current_event = tries_exceed(state) ? ExitGameEvent : PlayerChoiceEvent; | ||||||
|  |         break; | ||||||
|  | 
 | ||||||
|  |     default: | ||||||
|  |         break; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void food_minigame_controls(GameState* state, AppEvent* event) { | ||||||
|  |     furi_assert(state); | ||||||
|  |     furi_assert(event); | ||||||
|  | 
 | ||||||
|  |     if(event->value.input.key == InputKeyRight) { | ||||||
|  |         if(state->current_event == PlayerChoiceEvent) { | ||||||
|  |             state->cursor_pos = CLAMP(state->cursor_pos + 1, DISHES_TOTAL - 1, 0); | ||||||
|  |         } | ||||||
|  |     } else if(event->value.input.key == InputKeyLeft) { | ||||||
|  |         if(state->current_event == PlayerChoiceEvent) { | ||||||
|  |             state->cursor_pos = CLAMP(state->cursor_pos - 1, DISHES_TOTAL - 1, 0); | ||||||
|  |         } | ||||||
|  |     } else if(event->value.input.key == InputKeyOk) { | ||||||
|  |         switch(state->current_event) { | ||||||
|  |         case PlayerChoiceEvent: | ||||||
|  |             state->selected = true; | ||||||
|  |             break; | ||||||
|  |         case WinEvent: | ||||||
|  |             state->current_event = FinishedEvent; | ||||||
|  |             break; | ||||||
|  |         default: | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int32_t food_minigame_app(void* p) { | ||||||
|  |     GameState* state = furi_alloc(sizeof(GameState)); | ||||||
|  |     DolphinState* dolphin_state = dolphin_state_alloc(); | ||||||
|  |     dolphin_state_load(dolphin_state); | ||||||
|  | 
 | ||||||
|  |     ValueMutex state_mutex; | ||||||
|  | 
 | ||||||
|  |     state->event_queue = osMessageQueueNew(2, sizeof(AppEvent), NULL); | ||||||
|  | 
 | ||||||
|  |     furi_check(state->event_queue); | ||||||
|  | 
 | ||||||
|  |     if(!init_mutex(&state_mutex, state, sizeof(GameState*))) { | ||||||
|  |         printf("[Food minigame] cannot create mutex\r\n"); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ViewPort* view_port = view_port_alloc(); | ||||||
|  | 
 | ||||||
|  |     view_port_draw_callback_set(view_port, render_callback, &state_mutex); | ||||||
|  |     view_port_input_callback_set(view_port, input_callback, state->event_queue); | ||||||
|  | 
 | ||||||
|  |     Gui* gui = furi_record_open("gui"); | ||||||
|  |     gui_add_view_port(gui, view_port, GuiLayerFullscreen); | ||||||
|  | 
 | ||||||
|  |     reset_loot_array(state); | ||||||
|  | 
 | ||||||
|  |     AppEvent event; | ||||||
|  |     while(1) { | ||||||
|  |         osStatus_t event_status = osMessageQueueGet(state->event_queue, &event, NULL, 100); | ||||||
|  |         if(event_status == osOK) { | ||||||
|  |             if(event.type == EventTypeKey && event.value.input.type == InputTypeShort) { | ||||||
|  |                 food_minigame_controls(state, &event); | ||||||
|  | 
 | ||||||
|  |                 if(event.value.input.key == InputKeyBack) { | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } else if(event.type == EventTypeDeed) { | ||||||
|  |                 dolphin_state_on_deed(dolphin_state, DolphinDeedIButtonRead); | ||||||
|  |                 dolphin_state_save(dolphin_state); | ||||||
|  |                 state->deed = false; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if(state->current_event == ExitGameEvent) { | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|  |         gamestate_update(state, dolphin_state); | ||||||
|  |         view_port_update(view_port); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     gui_remove_view_port(gui, view_port); | ||||||
|  |     view_port_free(view_port); | ||||||
|  |     furi_record_close("gui"); | ||||||
|  |     delete_mutex(&state_mutex); | ||||||
|  |     osMessageQueueDelete(state->event_queue); | ||||||
|  |     dolphin_state_free(dolphin_state); | ||||||
|  |     free(state); | ||||||
|  | 
 | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
| @ -1,6 +1,6 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| #include <api-hal-version.h> | #include <furi-hal-version.h> | ||||||
| #include "dolphin/dolphin.h" | #include "dolphin/dolphin.h" | ||||||
| #include "dolphin/dolphin_state.h" | #include "dolphin/dolphin_state.h" | ||||||
| #include "math.h" | #include "math.h" | ||||||
| @ -80,7 +80,7 @@ static void render_callback(Canvas* canvas, void* ctx) { | |||||||
|     canvas_draw_line(canvas, 59, 31, 124, 31); |     canvas_draw_line(canvas, 59, 31, 124, 31); | ||||||
|     canvas_draw_line(canvas, 59, 44, 124, 44); |     canvas_draw_line(canvas, 59, 44, 124, 44); | ||||||
| 
 | 
 | ||||||
|     const char* my_name = api_hal_version_get_name_ptr(); |     const char* my_name = furi_hal_version_get_name_ptr(); | ||||||
|     canvas_draw_str(canvas, 59, 15, my_name ? my_name : "Unknown"); |     canvas_draw_str(canvas, 59, 15, my_name ? my_name : "Unknown"); | ||||||
| 
 | 
 | ||||||
|     snprintf(level, 20, "Level: %ld", current_level); |     snprintf(level, 20, "Level: %ld", current_level); | ||||||
| @ -97,7 +97,7 @@ static void render_callback(Canvas* canvas, void* ctx) { | |||||||
|     release_mutex((ValueMutex*)ctx, state); |     release_mutex((ValueMutex*)ctx, state); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t passport(void* p) { | int32_t passport_app(void* p) { | ||||||
|     DolphinState* dolphin_state = dolphin_state_alloc(); |     DolphinState* dolphin_state = dolphin_state_alloc(); | ||||||
|     ValueMutex state_mutex; |     ValueMutex state_mutex; | ||||||
|     dolphin_state_load(dolphin_state); |     dolphin_state_load(dolphin_state); | ||||||
|  | |||||||
| @ -228,6 +228,6 @@ void console_callback(Canvas* canvas, void* s) { | |||||||
|     furi_assert(s); |     furi_assert(s); | ||||||
|     SceneState* state = s; |     SceneState* state = s; | ||||||
|     if(state->use_pending) { |     if(state->use_pending) { | ||||||
|         dolphin_scene_start_app(state, &FLIPPER_SCENE_APPS[1]); |         dolphin_scene_start_app(state, &FLIPPER_SCENE_APPS[0]); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -1,5 +1,5 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include "scene.h" | #include "scene.h" | ||||||
| 
 | 
 | ||||||
| static SceneAppGui* scene_app_gui = NULL; | static SceneAppGui* scene_app_gui = NULL; | ||||||
| @ -109,7 +109,7 @@ void scene_free() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t scene_app(void* p) { | int32_t scene_app(void* p) { | ||||||
|     api_hal_power_insomnia_enter(); |     furi_hal_power_insomnia_enter(); | ||||||
|     scene_alloc(); |     scene_alloc(); | ||||||
| 
 | 
 | ||||||
|     osTimerStart(scene_app_gui->timer, 40); |     osTimerStart(scene_app_gui->timer, 40); | ||||||
| @ -146,6 +146,6 @@ int32_t scene_app(void* p) { | |||||||
|     osDelay(15); |     osDelay(15); | ||||||
| 
 | 
 | ||||||
|     scene_free(); |     scene_free(); | ||||||
|     api_hal_power_insomnia_exit(); |     furi_hal_power_insomnia_exit(); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| @ -1,100 +0,0 @@ | |||||||
| #include <furi.h> |  | ||||||
| #include <api-hal.h> |  | ||||||
| #include <stdio.h> |  | ||||||
| #include <gui/gui.h> |  | ||||||
| #include <input/input.h> |  | ||||||
| 
 |  | ||||||
| typedef struct { |  | ||||||
|     InputEvent input; |  | ||||||
| } InputDumpEvent; |  | ||||||
| 
 |  | ||||||
| void input_dump_draw_callback(Canvas* canvas, void* ctx) { |  | ||||||
|     canvas_clear(canvas); |  | ||||||
|     canvas_set_font(canvas, FontPrimary); |  | ||||||
|     canvas_draw_str(canvas, 2, 10, "Input dump application"); |  | ||||||
|     canvas_set_font(canvas, FontSecondary); |  | ||||||
|     canvas_draw_str(canvas, 2, 22, "Press long back to exit"); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void input_dump_input_callback(InputEvent* input_event, void* ctx) { |  | ||||||
|     furi_assert(ctx); |  | ||||||
|     osMessageQueueId_t event_queue = ctx; |  | ||||||
|     InputDumpEvent event = {.input = *input_event}; |  | ||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static const char* input_dump_get_key_name(InputKey key) { |  | ||||||
|     switch(key) { |  | ||||||
|     case InputKeyOk: |  | ||||||
|         return "Ok"; |  | ||||||
|     case InputKeyBack: |  | ||||||
|         return "Back"; |  | ||||||
|     case InputKeyLeft: |  | ||||||
|         return "Left"; |  | ||||||
|     case InputKeyRight: |  | ||||||
|         return "Right"; |  | ||||||
|     case InputKeyUp: |  | ||||||
|         return "Up"; |  | ||||||
|     case InputKeyDown: |  | ||||||
|         return "Down"; |  | ||||||
|     default: |  | ||||||
|         return "Unknown"; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static const char* input_dump_get_type_name(InputType type) { |  | ||||||
|     switch(type) { |  | ||||||
|     case InputTypePress: |  | ||||||
|         return "Press"; |  | ||||||
|     case InputTypeRelease: |  | ||||||
|         return "Release"; |  | ||||||
|     case InputTypeShort: |  | ||||||
|         return "Short"; |  | ||||||
|     case InputTypeLong: |  | ||||||
|         return "Long"; |  | ||||||
|     case InputTypeRepeat: |  | ||||||
|         return "Repeat"; |  | ||||||
|     default: |  | ||||||
|         return "Unknown"; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int32_t application_input_dump(void* p) { |  | ||||||
|     osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(InputDumpEvent), NULL); |  | ||||||
| 
 |  | ||||||
|     // Configure view port
 |  | ||||||
|     ViewPort* view_port = view_port_alloc(); |  | ||||||
|     furi_check(view_port); |  | ||||||
|     view_port_draw_callback_set(view_port, input_dump_draw_callback, NULL); |  | ||||||
|     view_port_input_callback_set(view_port, input_dump_input_callback, event_queue); |  | ||||||
| 
 |  | ||||||
|     // Register view port in GUI
 |  | ||||||
|     Gui* gui = furi_record_open("gui"); |  | ||||||
|     gui_add_view_port(gui, view_port, GuiLayerFullscreen); |  | ||||||
| 
 |  | ||||||
|     FURI_LOG_I("INPUT DUMP", "waiting for input events"); |  | ||||||
|     InputDumpEvent event; |  | ||||||
| 
 |  | ||||||
|     while(1) { |  | ||||||
|         furi_check(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK); |  | ||||||
| 
 |  | ||||||
|         FURI_LOG_I( |  | ||||||
|             "INPUT DUMP", |  | ||||||
|             "key: %s type: %s", |  | ||||||
|             input_dump_get_key_name(event.input.key), |  | ||||||
|             input_dump_get_type_name(event.input.type)); |  | ||||||
| 
 |  | ||||||
|         if(event.input.type == InputTypeLong && event.input.key == InputKeyBack) { |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     FURI_LOG_I("INPUT DUMP", "shutting down, byebye!"); |  | ||||||
| 
 |  | ||||||
|     view_port_enabled_set(view_port, false); |  | ||||||
|     gui_remove_view_port(gui, view_port); |  | ||||||
|     view_port_free(view_port); |  | ||||||
|     osMessageQueueDelete(event_queue); |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| @ -1,189 +0,0 @@ | |||||||
| #include <furi.h> |  | ||||||
| #include <gui/gui.h> |  | ||||||
| #include <input/input.h> |  | ||||||
| 
 |  | ||||||
| extern TIM_HandleTypeDef SPEAKER_TIM; |  | ||||||
| 
 |  | ||||||
| typedef struct { |  | ||||||
|     bool press[5]; |  | ||||||
|     uint16_t up; |  | ||||||
|     uint16_t down; |  | ||||||
|     uint16_t left; |  | ||||||
|     uint16_t right; |  | ||||||
|     uint16_t ok; |  | ||||||
| } State; |  | ||||||
| 
 |  | ||||||
| typedef enum { |  | ||||||
|     EventTypeTick, |  | ||||||
|     EventTypeKey, |  | ||||||
| } EventType; |  | ||||||
| 
 |  | ||||||
| typedef struct { |  | ||||||
|     union { |  | ||||||
|         InputEvent input; |  | ||||||
|     } value; |  | ||||||
|     EventType type; |  | ||||||
| } AppEvent; |  | ||||||
| 
 |  | ||||||
| static void reset_state(State* state) { |  | ||||||
|     state->left = 0; |  | ||||||
|     state->right = 0; |  | ||||||
|     state->up = 0; |  | ||||||
|     state->down = 0; |  | ||||||
|     state->ok = 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void render_callback(Canvas* canvas, void* ctx) { |  | ||||||
|     State* state = (State*)acquire_mutex((ValueMutex*)ctx, 25); |  | ||||||
|     canvas_clear(canvas); |  | ||||||
|     char strings[5][20]; |  | ||||||
| 
 |  | ||||||
|     sprintf(strings[0], "Ok: %d", state->ok); |  | ||||||
|     sprintf(strings[1], "L: %d", state->left); |  | ||||||
|     sprintf(strings[2], "R: %d", state->right); |  | ||||||
|     sprintf(strings[3], "U: %d", state->up); |  | ||||||
|     sprintf(strings[4], "D: %d", state->down); |  | ||||||
| 
 |  | ||||||
|     canvas_set_font(canvas, FontPrimary); |  | ||||||
|     canvas_draw_str(canvas, 0, 10, "Keypad test"); |  | ||||||
| 
 |  | ||||||
|     canvas_set_font(canvas, FontSecondary); |  | ||||||
|     canvas_draw_str(canvas, 0, 24, strings[1]); |  | ||||||
|     canvas_draw_str(canvas, 35, 24, strings[2]); |  | ||||||
|     canvas_draw_str(canvas, 0, 36, strings[3]); |  | ||||||
|     canvas_draw_str(canvas, 35, 36, strings[4]); |  | ||||||
|     canvas_draw_str(canvas, 0, 48, strings[0]); |  | ||||||
|     canvas_draw_circle(canvas, 100, 26, 25); |  | ||||||
| 
 |  | ||||||
|     if(state->press[0]) canvas_draw_disc(canvas, 118, 26, 5); |  | ||||||
|     if(state->press[1]) canvas_draw_disc(canvas, 82, 26, 5); |  | ||||||
|     if(state->press[2]) canvas_draw_disc(canvas, 100, 8, 5); |  | ||||||
|     if(state->press[3]) canvas_draw_disc(canvas, 100, 44, 5); |  | ||||||
|     if(state->press[4]) canvas_draw_disc(canvas, 100, 26, 5); |  | ||||||
| 
 |  | ||||||
|     canvas_draw_str(canvas, 10, 63, "[back] - reset, hold to exit"); |  | ||||||
| 
 |  | ||||||
|     release_mutex((ValueMutex*)ctx, state); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void input_callback(InputEvent* input_event, void* ctx) { |  | ||||||
|     osMessageQueueId_t event_queue = ctx; |  | ||||||
| 
 |  | ||||||
|     AppEvent event; |  | ||||||
|     event.type = EventTypeKey; |  | ||||||
|     event.value.input = *input_event; |  | ||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int32_t keypad_test(void* p) { |  | ||||||
|     osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(AppEvent), NULL); |  | ||||||
|     furi_check(event_queue); |  | ||||||
| 
 |  | ||||||
|     State _state = {{false, false, false, false, false}, 0, 0, 0, 0, 0}; |  | ||||||
| 
 |  | ||||||
|     ValueMutex state_mutex; |  | ||||||
|     if(!init_mutex(&state_mutex, &_state, sizeof(State))) { |  | ||||||
|         printf("[keypad_test] cannot create mutex\r\n"); |  | ||||||
|         return 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     ViewPort* view_port = view_port_alloc(); |  | ||||||
| 
 |  | ||||||
|     view_port_draw_callback_set(view_port, render_callback, &state_mutex); |  | ||||||
|     view_port_input_callback_set(view_port, input_callback, event_queue); |  | ||||||
| 
 |  | ||||||
|     // Open GUI and register view_port
 |  | ||||||
|     Gui* gui = furi_record_open("gui"); |  | ||||||
|     gui_add_view_port(gui, view_port, GuiLayerFullscreen); |  | ||||||
| 
 |  | ||||||
|     AppEvent event; |  | ||||||
|     while(1) { |  | ||||||
|         osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, osWaitForever); |  | ||||||
|         State* state = (State*)acquire_mutex_block(&state_mutex); |  | ||||||
| 
 |  | ||||||
|         if(event_status == osOK) { |  | ||||||
|             if(event.type == EventTypeKey) { |  | ||||||
|                 if(event.value.input.type == InputTypeLong && |  | ||||||
|                    event.value.input.key == InputKeyBack) { |  | ||||||
|                     printf("[keypad test] bye!\r\n"); |  | ||||||
|                     release_mutex(&state_mutex, state); |  | ||||||
|                     break; |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 if(event.value.input.type == InputTypeShort && |  | ||||||
|                    event.value.input.key == InputKeyBack) { |  | ||||||
|                     reset_state(state); |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 if(event.value.input.key == InputKeyRight) { |  | ||||||
|                     if(event.value.input.type == InputTypePress) { |  | ||||||
|                         state->press[0] = true; |  | ||||||
|                     } else if(event.value.input.type == InputTypeRelease) { |  | ||||||
|                         state->press[0] = false; |  | ||||||
|                     } |  | ||||||
| 
 |  | ||||||
|                     if(event.value.input.type == InputTypeShort) { |  | ||||||
|                         ++state->right; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 if(event.value.input.key == InputKeyLeft) { |  | ||||||
|                     if(event.value.input.type == InputTypePress) { |  | ||||||
|                         state->press[1] = true; |  | ||||||
|                     } else if(event.value.input.type == InputTypeRelease) { |  | ||||||
|                         state->press[1] = false; |  | ||||||
|                     } |  | ||||||
| 
 |  | ||||||
|                     if(event.value.input.type == InputTypeShort) { |  | ||||||
|                         ++state->left; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 if(event.value.input.key == InputKeyUp) { |  | ||||||
|                     if(event.value.input.type == InputTypePress) { |  | ||||||
|                         state->press[2] = true; |  | ||||||
|                     } else if(event.value.input.type == InputTypeRelease) { |  | ||||||
|                         state->press[2] = false; |  | ||||||
|                     } |  | ||||||
| 
 |  | ||||||
|                     if(event.value.input.type == InputTypeShort) { |  | ||||||
|                         ++state->up; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 if(event.value.input.key == InputKeyDown) { |  | ||||||
|                     if(event.value.input.type == InputTypePress) { |  | ||||||
|                         state->press[3] = true; |  | ||||||
|                     } else if(event.value.input.type == InputTypeRelease) { |  | ||||||
|                         state->press[3] = false; |  | ||||||
|                     } |  | ||||||
| 
 |  | ||||||
|                     if(event.value.input.type == InputTypeShort) { |  | ||||||
|                         ++state->down; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 if(event.value.input.key == InputKeyOk) { |  | ||||||
|                     if(event.value.input.type == InputTypePress) { |  | ||||||
|                         state->press[4] = true; |  | ||||||
|                     } else if(event.value.input.type == InputTypeRelease) { |  | ||||||
|                         state->press[4] = false; |  | ||||||
|                     } |  | ||||||
| 
 |  | ||||||
|                     if(event.value.input.type == InputTypeShort) { |  | ||||||
|                         ++state->ok; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         view_port_update(view_port); |  | ||||||
|         release_mutex(&state_mutex, state); |  | ||||||
|     } |  | ||||||
|     // remove & free all stuff created by app
 |  | ||||||
|     gui_remove_view_port(gui, view_port); |  | ||||||
|     view_port_free(view_port); |  | ||||||
|     osMessageQueueDelete(event_queue); |  | ||||||
|     delete_mutex(&state_mutex); |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| @ -1,14 +0,0 @@ | |||||||
| #include "u8g2/u8g2.h" |  | ||||||
| #include <furi.h> |  | ||||||
| 
 |  | ||||||
| int32_t u8g2_example(void* p) { |  | ||||||
|     // open record
 |  | ||||||
|     u8g2_t* fb = furi_record_open("u8g2_fb"); |  | ||||||
|     u8g2_SetFont(fb, u8g2_font_6x10_mf); |  | ||||||
|     u8g2_SetDrawColor(fb, 1); |  | ||||||
|     u8g2_SetFontMode(fb, 1); |  | ||||||
|     u8g2_DrawStr(fb, 2, 12, "hello world!"); |  | ||||||
|     furi_record_close("u8g2_fb"); |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| @ -1,76 +0,0 @@ | |||||||
| #include "u8g2/u8g2.h" |  | ||||||
| #include "qrcode/qrcode.h" |  | ||||||
| #include <furi.h> |  | ||||||
| 
 |  | ||||||
| /*
 |  | ||||||
| TODO: rework with new app api |  | ||||||
| 
 |  | ||||||
| void u8g2_DrawPixelSize(u8g2_t* u8g2, uint8_t x, uint8_t y, uint8_t size) { |  | ||||||
|     for(uint8_t px = 0; px < size; px++) { |  | ||||||
|         for(uint8_t py = 0; py < size; py++) { |  | ||||||
|             u8g2_DrawPixel(u8g2, x + px, y + py); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int32_t u8g2_qrcode(void* p) { |  | ||||||
|     // open record
 |  | ||||||
|     FuriRecordSubscriber* fb_record = |  | ||||||
|         furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL); |  | ||||||
| 
 |  | ||||||
|     // Allocate a chunk of memory to store the QR code
 |  | ||||||
|     // https://github.com/ricmoo/QRCode
 |  | ||||||
|     // we init version 1, 21x21 px, 16 alphanumeric chars with
 |  | ||||||
|     // QUARTILE error correction
 |  | ||||||
|     const uint8_t qr_version = 1; |  | ||||||
|     const uint8_t qr_error_correction = ECC_QUARTILE; |  | ||||||
| 
 |  | ||||||
|     const uint8_t qr_x = 32; |  | ||||||
|     const uint8_t qr_y = 0; |  | ||||||
|     const uint8_t qr_size = 3; |  | ||||||
| 
 |  | ||||||
|     // The structure to manage the QR code
 |  | ||||||
|     QRCode qrcode; |  | ||||||
| 
 |  | ||||||
|     // QR Code init
 |  | ||||||
|     uint8_t qrcodeBytes[qrcode_getBufferSize(qr_version)]; |  | ||||||
|     qrcode_initText(&qrcode, qrcodeBytes, qr_version, qr_error_correction, "HELLO FLIPPER"); |  | ||||||
| 
 |  | ||||||
|     if(fb_record == NULL) { |  | ||||||
|         printf("[view_port] cannot create fb record\r\n"); |  | ||||||
|         return 255; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     u8g2_t* fb = furi_take(fb_record); |  | ||||||
| 
 |  | ||||||
|     // clear display
 |  | ||||||
|     if(fb != NULL) { |  | ||||||
|         u8g2_ClearBuffer(fb); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     while(1) { |  | ||||||
|         if(fb != NULL) { |  | ||||||
|             // draw qr code
 |  | ||||||
|             for(uint8_t y = 0; y < qrcode.size; y++) { |  | ||||||
|                 for(uint8_t x = 0; x < qrcode.size; x++) { |  | ||||||
|                     if(qrcode_getModule(&qrcode, x, y)) { |  | ||||||
|                         u8g2_SetDrawColor(fb, 1); |  | ||||||
|                         u8g2_DrawPixelSize(fb, qr_x + x * qr_size, qr_y + y * qr_size, qr_size); |  | ||||||
|                     } else { |  | ||||||
|                         u8g2_SetDrawColor(fb, 0); |  | ||||||
|                         u8g2_DrawPixelSize(fb, qr_x + x * qr_size, qr_y + y * qr_size, qr_size); |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } else { |  | ||||||
|             return 255; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         furi_commit(fb_record); |  | ||||||
| 
 |  | ||||||
|         delay(1); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| */ |  | ||||||
| @ -1,35 +0,0 @@ | |||||||
| #include <furi.h> |  | ||||||
| #include <api-hal.h> |  | ||||||
| #include <string.h> |  | ||||||
| 
 |  | ||||||
| int32_t application_uart_write(void* p) { |  | ||||||
|     // Red led for showing progress
 |  | ||||||
|     GpioPin led = {.pin = GPIO_PIN_8, .port = GPIOA}; |  | ||||||
|     // TODO open record
 |  | ||||||
|     GpioPin* led_record = &led; |  | ||||||
| 
 |  | ||||||
|     hal_gpio_init(led_record, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); |  | ||||||
| 
 |  | ||||||
|     // create buffer
 |  | ||||||
|     const char test_string[] = "test\n"; |  | ||||||
|     printf(test_string); |  | ||||||
| 
 |  | ||||||
|     // for example, create counter and show its value
 |  | ||||||
|     uint8_t counter = 0; |  | ||||||
| 
 |  | ||||||
|     while(1) { |  | ||||||
|         // continously write it to UART
 |  | ||||||
|         printf("counter: %d\n", counter); |  | ||||||
|         counter++; |  | ||||||
| 
 |  | ||||||
|         // flash at every send
 |  | ||||||
|         hal_gpio_write(led_record, false); |  | ||||||
|         delay(50); |  | ||||||
|         hal_gpio_write(led_record, true); |  | ||||||
| 
 |  | ||||||
|         // delay with overall perion of 1s
 |  | ||||||
|         delay(950); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| @ -1,103 +0,0 @@ | |||||||
| #include <furi.h> |  | ||||||
| #include <gui/gui.h> |  | ||||||
| #include <gui/view_dispatcher.h> |  | ||||||
| #include <gui/modules/submenu.h> |  | ||||||
| 
 |  | ||||||
| static ViewDispatcher* view_dispatcher; |  | ||||||
| static osMessageQueueId_t event_queue; |  | ||||||
| 
 |  | ||||||
| typedef enum { |  | ||||||
|     EventTypeGoAway, |  | ||||||
|     EventTypeGoToMainMenu, |  | ||||||
|     EventTypeSwitchToVertical, |  | ||||||
|     EventTypeSwitchToHorizontal, |  | ||||||
| } EventType; |  | ||||||
| 
 |  | ||||||
| // Nothing dangerous in settings some vars and flags inside callback
 |  | ||||||
| static void submenu_callback(void* context, uint32_t index) { |  | ||||||
|     EventType event = EventTypeGoAway; |  | ||||||
|     switch(index) { |  | ||||||
|     case 1: |  | ||||||
|         event = EventTypeSwitchToVertical; |  | ||||||
|         break; |  | ||||||
|     case 2: |  | ||||||
|         event = EventTypeSwitchToHorizontal; |  | ||||||
|         break; |  | ||||||
|     default: |  | ||||||
|         break; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| uint32_t previous_exit_callback(void* context) { |  | ||||||
|     EventType event = EventTypeGoAway; |  | ||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |  | ||||||
|     return VIEW_IGNORE; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| uint32_t previous_callback(void* context) { |  | ||||||
|     EventType event = EventTypeGoToMainMenu; |  | ||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |  | ||||||
|     return VIEW_IGNORE; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int32_t application_vertical_screen(void* p) { |  | ||||||
|     event_queue = osMessageQueueNew(8, sizeof(EventType), NULL); |  | ||||||
| 
 |  | ||||||
|     view_dispatcher = view_dispatcher_alloc(); |  | ||||||
|     Gui* gui = furi_record_open("gui"); |  | ||||||
|     view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen); |  | ||||||
| 
 |  | ||||||
|     Submenu* submenu = submenu_alloc(); |  | ||||||
|     View* submenu_view = submenu_get_view(submenu); |  | ||||||
|     view_set_previous_callback(submenu_view, previous_exit_callback); |  | ||||||
|     view_set_orientation(submenu_view, ViewOrientationVertical); |  | ||||||
|     submenu_add_item(submenu, "VerSubm", 1, submenu_callback, view_dispatcher); |  | ||||||
|     submenu_add_item(submenu, "HorSubm", 2, submenu_callback, view_dispatcher); |  | ||||||
|     view_dispatcher_add_view(view_dispatcher, 1, submenu_view); |  | ||||||
| 
 |  | ||||||
|     Submenu* submenu_vertical = submenu_alloc(); |  | ||||||
|     View* submenu_vertical_view = submenu_get_view(submenu_vertical); |  | ||||||
|     view_set_previous_callback(submenu_vertical_view, previous_callback); |  | ||||||
|     view_set_orientation(submenu_vertical_view, ViewOrientationVertical); |  | ||||||
|     submenu_add_item(submenu_vertical, "Vert1", 1, NULL, view_dispatcher); |  | ||||||
|     submenu_add_item(submenu_vertical, "Vert2", 2, NULL, view_dispatcher); |  | ||||||
|     view_dispatcher_add_view(view_dispatcher, 2, submenu_vertical_view); |  | ||||||
| 
 |  | ||||||
|     Submenu* submenu_horizontal = submenu_alloc(); |  | ||||||
|     View* submenu_horizontal_view = submenu_get_view(submenu_horizontal); |  | ||||||
|     view_set_previous_callback(submenu_horizontal_view, previous_callback); |  | ||||||
|     view_set_orientation(submenu_horizontal_view, ViewOrientationHorizontal); |  | ||||||
|     submenu_add_item(submenu_horizontal, "Horiz1", 1, NULL, view_dispatcher); |  | ||||||
|     submenu_add_item(submenu_horizontal, "Horiz2", 2, NULL, view_dispatcher); |  | ||||||
|     view_dispatcher_add_view(view_dispatcher, 3, submenu_horizontal_view); |  | ||||||
| 
 |  | ||||||
|     view_dispatcher_switch_to_view(view_dispatcher, 1); |  | ||||||
| 
 |  | ||||||
|     while(1) { |  | ||||||
|         EventType event; |  | ||||||
|         furi_check(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK); |  | ||||||
|         if(event == EventTypeGoAway) { |  | ||||||
|             break; |  | ||||||
|         } else if(event == EventTypeGoToMainMenu) { |  | ||||||
|             view_dispatcher_switch_to_view(view_dispatcher, 1); |  | ||||||
|         } else if(event == EventTypeSwitchToVertical) { |  | ||||||
|             view_dispatcher_switch_to_view(view_dispatcher, 2); |  | ||||||
|         } else if(event == EventTypeSwitchToHorizontal) { |  | ||||||
|             view_dispatcher_switch_to_view(view_dispatcher, 3); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     view_dispatcher_remove_view(view_dispatcher, 1); |  | ||||||
|     view_dispatcher_remove_view(view_dispatcher, 2); |  | ||||||
|     view_dispatcher_remove_view(view_dispatcher, 3); |  | ||||||
|     submenu_free(submenu); |  | ||||||
|     submenu_free(submenu_vertical); |  | ||||||
|     submenu_free(submenu_horizontal); |  | ||||||
|     view_dispatcher_free(view_dispatcher); |  | ||||||
|     osMessageQueueDelete(event_queue); |  | ||||||
|     furi_record_close("gui"); |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| @ -1,5 +1,5 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| #include <input/input.h> | #include <input/input.h> | ||||||
| @ -44,7 +44,7 @@ static void render_callback(Canvas* canvas, void* ctx) { | |||||||
|     canvas_clear(canvas); |     canvas_clear(canvas); | ||||||
|     canvas_set_color(canvas, ColorBlack); |     canvas_set_color(canvas, ColorBlack); | ||||||
|     canvas_set_font(canvas, FontPrimary); |     canvas_set_font(canvas, FontPrimary); | ||||||
|     canvas_draw_str(canvas, 2, 10, "GPIO demo"); |     canvas_draw_str(canvas, 2, 10, "GPIO Control"); | ||||||
|     canvas_set_font(canvas, FontSecondary); |     canvas_set_font(canvas, FontSecondary); | ||||||
|     canvas_draw_str(canvas, 2, 25, GPIO_PINS[state->gpio_index].name); |     canvas_draw_str(canvas, 2, 25, GPIO_PINS[state->gpio_index].name); | ||||||
| 
 | 
 | ||||||
| @ -60,7 +60,7 @@ static void input_callback(InputEvent* input_event, void* ctx) { | |||||||
|     osMessageQueuePut(event_queue, &event, 0, 0); |     osMessageQueuePut(event_queue, &event, 0, 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t app_gpio_test(void* p) { | int32_t gpio_test_app(void* p) { | ||||||
|     osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(AppEvent), NULL); |     osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(AppEvent), NULL); | ||||||
|     furi_check(event_queue); |     furi_check(event_queue); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,239 +0,0 @@ | |||||||
| #include <furi.h> |  | ||||||
| #include <gui/gui.h> |  | ||||||
| #include <gui/view_port.h> |  | ||||||
| #include <gui/view.h> |  | ||||||
| #include <gui/view_dispatcher.h> |  | ||||||
| #include <gui/modules/dialog.h> |  | ||||||
| #include <gui/modules/dialog_ex.h> |  | ||||||
| #include <gui/modules/submenu.h> |  | ||||||
| #include <gui/modules/text_input.h> |  | ||||||
| #include <gui/modules/byte_input.h> |  | ||||||
| #include <gui/modules/popup.h> |  | ||||||
| 
 |  | ||||||
| #define GUI_TEST_FLAG_EXIT 0x00000001U |  | ||||||
| 
 |  | ||||||
| typedef enum { |  | ||||||
|     GuiTesterViewTextInput = 0, |  | ||||||
|     GuiTesterViewSubmenu, |  | ||||||
|     GuiTesterViewDialog, |  | ||||||
|     GuiTesterViewDialogEx, |  | ||||||
|     GuiTesterViewPopup, |  | ||||||
|     GuiTesterViewByteInput, |  | ||||||
|     GuiTesterViewLast |  | ||||||
| } GuiTesterView; |  | ||||||
| 
 |  | ||||||
| typedef struct { |  | ||||||
|     ViewDispatcher* view_dispatcher; |  | ||||||
|     Dialog* dialog; |  | ||||||
|     DialogEx* dialog_ex; |  | ||||||
|     Submenu* submenu; |  | ||||||
|     TextInput* text_input; |  | ||||||
|     Popup* popup; |  | ||||||
|     ByteInput* byte_input; |  | ||||||
|     GuiTesterView view_index; |  | ||||||
| } GuiTester; |  | ||||||
| 
 |  | ||||||
| static GuiTester* gui_test_alloc(void) { |  | ||||||
|     GuiTester* gui_tester = furi_alloc(sizeof(GuiTester)); |  | ||||||
|     gui_tester->view_dispatcher = view_dispatcher_alloc(); |  | ||||||
|     gui_tester->view_index = GuiTesterViewByteInput; |  | ||||||
| 
 |  | ||||||
|     gui_tester->dialog = dialog_alloc(); |  | ||||||
|     view_dispatcher_add_view( |  | ||||||
|         gui_tester->view_dispatcher, GuiTesterViewDialog, dialog_get_view(gui_tester->dialog)); |  | ||||||
| 
 |  | ||||||
|     gui_tester->dialog_ex = dialog_ex_alloc(); |  | ||||||
|     view_dispatcher_add_view( |  | ||||||
|         gui_tester->view_dispatcher, |  | ||||||
|         GuiTesterViewDialogEx, |  | ||||||
|         dialog_ex_get_view(gui_tester->dialog_ex)); |  | ||||||
| 
 |  | ||||||
|     gui_tester->submenu = submenu_alloc(); |  | ||||||
|     view_dispatcher_add_view( |  | ||||||
|         gui_tester->view_dispatcher, GuiTesterViewSubmenu, submenu_get_view(gui_tester->submenu)); |  | ||||||
| 
 |  | ||||||
|     gui_tester->text_input = text_input_alloc(); |  | ||||||
|     view_dispatcher_add_view( |  | ||||||
|         gui_tester->view_dispatcher, |  | ||||||
|         GuiTesterViewTextInput, |  | ||||||
|         text_input_get_view(gui_tester->text_input)); |  | ||||||
| 
 |  | ||||||
|     gui_tester->popup = popup_alloc(); |  | ||||||
|     view_dispatcher_add_view( |  | ||||||
|         gui_tester->view_dispatcher, GuiTesterViewPopup, popup_get_view(gui_tester->popup)); |  | ||||||
| 
 |  | ||||||
|     gui_tester->byte_input = byte_input_alloc(); |  | ||||||
|     view_dispatcher_add_view( |  | ||||||
|         gui_tester->view_dispatcher, |  | ||||||
|         GuiTesterViewByteInput, |  | ||||||
|         byte_input_get_view(gui_tester->byte_input)); |  | ||||||
| 
 |  | ||||||
|     return gui_tester; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void gui_test_free(GuiTester* gui_tester) { |  | ||||||
|     furi_assert(gui_tester); |  | ||||||
|     view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewDialog); |  | ||||||
|     dialog_free(gui_tester->dialog); |  | ||||||
|     view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewDialogEx); |  | ||||||
|     dialog_ex_free(gui_tester->dialog_ex); |  | ||||||
|     view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewSubmenu); |  | ||||||
|     submenu_free(gui_tester->submenu); |  | ||||||
|     view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewTextInput); |  | ||||||
|     text_input_free(gui_tester->text_input); |  | ||||||
|     view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewPopup); |  | ||||||
|     popup_free(gui_tester->popup); |  | ||||||
|     view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewByteInput); |  | ||||||
|     byte_input_free(gui_tester->byte_input); |  | ||||||
| 
 |  | ||||||
|     view_dispatcher_free(gui_tester->view_dispatcher); |  | ||||||
|     free(gui_tester); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void next_view(void* context) { |  | ||||||
|     furi_assert(context); |  | ||||||
|     GuiTester* gui_tester = context; |  | ||||||
| 
 |  | ||||||
|     gui_tester->view_index++; |  | ||||||
|     if(gui_tester->view_index >= GuiTesterViewLast) { |  | ||||||
|         gui_tester->view_index = 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     view_dispatcher_switch_to_view(gui_tester->view_dispatcher, gui_tester->view_index); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void popup_callback(void* context) { |  | ||||||
|     next_view(context); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void submenu_callback(void* context, uint32_t index) { |  | ||||||
|     next_view(context); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void dialog_callback(DialogResult result, void* context) { |  | ||||||
|     next_view(context); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void dialog_ex_callback(DialogExResult result, void* context) { |  | ||||||
|     next_view(context); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void text_input_callback(void* context) { |  | ||||||
|     next_view(context); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void byte_input_callback(void* context) { |  | ||||||
|     next_view(context); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void event_cb(const void* value, void* ctx) { |  | ||||||
|     furi_assert(value); |  | ||||||
|     furi_assert(ctx); |  | ||||||
|     const InputEvent* event = value; |  | ||||||
|     if(event->key == InputKeyBack && event->type == InputTypeLong) { |  | ||||||
|         osThreadFlagsSet((osThreadId_t)ctx, GUI_TEST_FLAG_EXIT); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int32_t gui_test(void* param) { |  | ||||||
|     (void)param; |  | ||||||
|     PubSub* event_record = furi_record_open("input_events"); |  | ||||||
|     PubSubItem* event_pubsub = subscribe_pubsub(event_record, event_cb, (void*)osThreadGetId()); |  | ||||||
|     GuiTester* gui_tester = gui_test_alloc(); |  | ||||||
| 
 |  | ||||||
|     Gui* gui = furi_record_open("gui"); |  | ||||||
|     view_dispatcher_attach_to_gui(gui_tester->view_dispatcher, gui, ViewDispatcherTypeFullscreen); |  | ||||||
| 
 |  | ||||||
|     // Submenu
 |  | ||||||
|     submenu_add_item(gui_tester->submenu, "Read", 0, submenu_callback, gui_tester); |  | ||||||
|     submenu_add_item(gui_tester->submenu, "Saved", 0, submenu_callback, gui_tester); |  | ||||||
|     submenu_add_item(gui_tester->submenu, "Emulate", 0, submenu_callback, gui_tester); |  | ||||||
|     submenu_add_item(gui_tester->submenu, "Enter manually", 0, submenu_callback, gui_tester); |  | ||||||
|     submenu_add_item(gui_tester->submenu, "Blah blah", 0, submenu_callback, gui_tester); |  | ||||||
|     submenu_add_item(gui_tester->submenu, "Set time", 0, submenu_callback, gui_tester); |  | ||||||
|     submenu_add_item(gui_tester->submenu, "Gender-bender", 0, submenu_callback, gui_tester); |  | ||||||
|     submenu_add_item( |  | ||||||
|         gui_tester->submenu, "Hack American Elections", 0, submenu_callback, gui_tester); |  | ||||||
|     submenu_add_item(gui_tester->submenu, "Hack the White House", 0, submenu_callback, gui_tester); |  | ||||||
| 
 |  | ||||||
|     // Dialog
 |  | ||||||
|     dialog_set_result_callback(gui_tester->dialog, dialog_callback); |  | ||||||
|     dialog_set_context(gui_tester->dialog, gui_tester); |  | ||||||
|     dialog_set_header_text(gui_tester->dialog, "Delete Abc123?"); |  | ||||||
|     dialog_set_text(gui_tester->dialog, "ID: F0 00 01 02 03 04\nAre you shure?"); |  | ||||||
|     dialog_set_left_button_text(gui_tester->dialog, "Yes"); |  | ||||||
|     dialog_set_right_button_text(gui_tester->dialog, "No"); |  | ||||||
| 
 |  | ||||||
|     // Dialog extended
 |  | ||||||
|     dialog_ex_set_result_callback(gui_tester->dialog_ex, dialog_ex_callback); |  | ||||||
|     dialog_ex_set_context(gui_tester->dialog_ex, gui_tester); |  | ||||||
|     dialog_ex_set_header(gui_tester->dialog_ex, "Dallas", 95, 12, AlignCenter, AlignCenter); |  | ||||||
|     dialog_ex_set_text( |  | ||||||
|         gui_tester->dialog_ex, "F6 E5 D4\nC3 B2 A1", 95, 32, AlignCenter, AlignCenter); |  | ||||||
|     dialog_ex_set_icon(gui_tester->dialog_ex, 0, 1, &I_DolphinExcited_64x63); |  | ||||||
|     dialog_ex_set_left_button_text(gui_tester->dialog_ex, "More"); |  | ||||||
|     dialog_ex_set_right_button_text(gui_tester->dialog_ex, "Save"); |  | ||||||
| 
 |  | ||||||
|     // Popup
 |  | ||||||
|     popup_set_callback(gui_tester->popup, popup_callback); |  | ||||||
|     popup_set_context(gui_tester->popup, gui_tester); |  | ||||||
|     popup_set_icon(gui_tester->popup, 0, 2, &I_DolphinMafia_115x62); |  | ||||||
|     popup_set_text(gui_tester->popup, "Deleted", 83, 19, AlignLeft, AlignBottom); |  | ||||||
|     popup_set_timeout(gui_tester->popup, 5000); |  | ||||||
|     popup_enable_timeout(gui_tester->popup); |  | ||||||
| 
 |  | ||||||
|     // Text input
 |  | ||||||
|     const uint8_t text_input_text_len = 64; |  | ||||||
|     char* text_input_text = calloc(text_input_text_len + 1, 1); |  | ||||||
|     memcpy(text_input_text, "New_ke", strlen("New_ke")); |  | ||||||
| 
 |  | ||||||
|     text_input_set_result_callback( |  | ||||||
|         gui_tester->text_input, |  | ||||||
|         text_input_callback, |  | ||||||
|         gui_tester, |  | ||||||
|         text_input_text, |  | ||||||
|         text_input_text_len, |  | ||||||
|         false); |  | ||||||
|     text_input_set_header_text(gui_tester->text_input, "Name the key"); |  | ||||||
| 
 |  | ||||||
|     const uint8_t byte_input_bytes_len = 16; |  | ||||||
|     uint8_t byte_input_bytes[16] = { |  | ||||||
|         0x00, |  | ||||||
|         0x01, |  | ||||||
|         0x02, |  | ||||||
|         0x03, |  | ||||||
|         0x04, |  | ||||||
|         0x05, |  | ||||||
|         0x06, |  | ||||||
|         0x07, |  | ||||||
|         0x08, |  | ||||||
|         0x09, |  | ||||||
|         0x0A, |  | ||||||
|         0x0B, |  | ||||||
|         0x0C, |  | ||||||
|         0x0D, |  | ||||||
|         0x0E, |  | ||||||
|         0x0F}; |  | ||||||
| 
 |  | ||||||
|     byte_input_set_result_callback( |  | ||||||
|         gui_tester->byte_input, |  | ||||||
|         byte_input_callback, |  | ||||||
|         NULL, |  | ||||||
|         gui_tester, |  | ||||||
|         byte_input_bytes, |  | ||||||
|         byte_input_bytes_len); |  | ||||||
|     byte_input_set_header_text(gui_tester->byte_input, "Enter the key"); |  | ||||||
| 
 |  | ||||||
|     view_dispatcher_switch_to_view(gui_tester->view_dispatcher, gui_tester->view_index); |  | ||||||
| 
 |  | ||||||
|     while(1) { |  | ||||||
|         if(osThreadFlagsWait(GUI_TEST_FLAG_EXIT, osFlagsWaitAny, osWaitForever)) { |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     unsubscribe_pubsub(event_pubsub); |  | ||||||
|     free(text_input_text); |  | ||||||
|     gui_test_free(gui_tester); |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| @ -3,7 +3,7 @@ | |||||||
| #include "icon_animation_i.h" | #include "icon_animation_i.h" | ||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr); | uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr); | ||||||
| uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr); | uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr); | ||||||
| @ -11,7 +11,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ | |||||||
| Canvas* canvas_init() { | Canvas* canvas_init() { | ||||||
|     Canvas* canvas = furi_alloc(sizeof(Canvas)); |     Canvas* canvas = furi_alloc(sizeof(Canvas)); | ||||||
| 
 | 
 | ||||||
|     api_hal_power_insomnia_enter(); |     furi_hal_power_insomnia_enter(); | ||||||
| 
 | 
 | ||||||
|     canvas->orientation = CanvasOrientationHorizontal; |     canvas->orientation = CanvasOrientationHorizontal; | ||||||
|     u8g2_Setup_st7565_erc12864_alt_f( |     u8g2_Setup_st7565_erc12864_alt_f( | ||||||
| @ -21,10 +21,11 @@ Canvas* canvas_init() { | |||||||
|     u8g2_InitDisplay(&canvas->fb); |     u8g2_InitDisplay(&canvas->fb); | ||||||
|     u8g2_SetContrast(&canvas->fb, 36); |     u8g2_SetContrast(&canvas->fb, 36); | ||||||
|     // wake up display
 |     // wake up display
 | ||||||
|  |     u8g2_ClearBuffer(&canvas->fb); | ||||||
|     u8g2_SetPowerSave(&canvas->fb, 0); |     u8g2_SetPowerSave(&canvas->fb, 0); | ||||||
|     u8g2_SendBuffer(&canvas->fb); |     u8g2_SendBuffer(&canvas->fb); | ||||||
| 
 | 
 | ||||||
|     api_hal_power_insomnia_exit(); |     furi_hal_power_insomnia_exit(); | ||||||
| 
 | 
 | ||||||
|     return canvas; |     return canvas; | ||||||
| } | } | ||||||
|  | |||||||
| @ -420,7 +420,7 @@ Gui* gui_alloc() { | |||||||
|     return gui; |     return gui; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t gui_task(void* p) { | int32_t gui_srv(void* p) { | ||||||
|     Gui* gui = gui_alloc(); |     Gui* gui = gui_alloc(); | ||||||
| 
 | 
 | ||||||
|     furi_record_create("gui", gui); |     furi_record_create("gui", gui); | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| #include "button_menu.h" | #include "button_menu.h" | ||||||
| #include "gui/canvas.h" | #include "gui/canvas.h" | ||||||
| #include "gui/elements.h" | #include "gui/elements.h" | ||||||
|  | #include "input/input.h" | ||||||
| #include <m-array.h> | #include <m-array.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| @ -23,6 +24,7 @@ ARRAY_DEF(ButtonMenuItemArray, ButtonMenuItem, M_POD_OPLIST); | |||||||
| 
 | 
 | ||||||
| struct ButtonMenu { | struct ButtonMenu { | ||||||
|     View* view; |     View* view; | ||||||
|  |     bool freeze_input; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
| @ -158,7 +160,7 @@ static void button_menu_process_down(ButtonMenu* button_menu) { | |||||||
|         }); |         }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void button_menu_process_ok(ButtonMenu* button_menu) { | static void button_menu_process_ok(ButtonMenu* button_menu, InputType type) { | ||||||
|     furi_assert(button_menu); |     furi_assert(button_menu); | ||||||
| 
 | 
 | ||||||
|     ButtonMenuItem* item = NULL; |     ButtonMenuItem* item = NULL; | ||||||
| @ -168,11 +170,22 @@ static void button_menu_process_ok(ButtonMenu* button_menu) { | |||||||
|             if(model->position < (ButtonMenuItemArray_size(model->items))) { |             if(model->position < (ButtonMenuItemArray_size(model->items))) { | ||||||
|                 item = ButtonMenuItemArray_get(model->items, model->position); |                 item = ButtonMenuItemArray_get(model->items, model->position); | ||||||
|             } |             } | ||||||
|             return true; |             return false; | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|     if(item && item->callback) { |     if(item->type == ButtonMenuItemTypeControl) { | ||||||
|         item->callback(item->callback_context, item->index); |         if(type == InputTypeShort) { | ||||||
|  |             if(item && item->callback) { | ||||||
|  |                 item->callback(item->callback_context, item->index, type); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     if(item->type == ButtonMenuItemTypeCommon) { | ||||||
|  |         if((type == InputTypePress) || (type == InputTypeRelease)) { | ||||||
|  |             if(item && item->callback) { | ||||||
|  |                 item->callback(item->callback_context, item->index, type); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -182,7 +195,19 @@ static bool button_menu_view_input_callback(InputEvent* event, void* context) { | |||||||
|     ButtonMenu* button_menu = context; |     ButtonMenu* button_menu = context; | ||||||
|     bool consumed = false; |     bool consumed = false; | ||||||
| 
 | 
 | ||||||
|     if(event->type == InputTypeShort) { |     if(event->key == InputKeyOk) { | ||||||
|  |         if((event->type == InputTypeRelease) || (event->type == InputTypePress)) { | ||||||
|  |             consumed = true; | ||||||
|  |             button_menu->freeze_input = (event->type == InputTypePress); | ||||||
|  |             button_menu_process_ok(button_menu, event->type); | ||||||
|  |         } else if(event->type == InputTypeShort) { | ||||||
|  |             consumed = true; | ||||||
|  |             button_menu_process_ok(button_menu, event->type); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if(!button_menu->freeze_input && | ||||||
|  |        ((event->type == InputTypeRepeat) || (event->type == InputTypeShort))) { | ||||||
|         switch(event->key) { |         switch(event->key) { | ||||||
|         case InputKeyUp: |         case InputKeyUp: | ||||||
|             consumed = true; |             consumed = true; | ||||||
| @ -192,10 +217,6 @@ static bool button_menu_view_input_callback(InputEvent* event, void* context) { | |||||||
|             consumed = true; |             consumed = true; | ||||||
|             button_menu_process_down(button_menu); |             button_menu_process_down(button_menu); | ||||||
|             break; |             break; | ||||||
|         case InputKeyOk: |  | ||||||
|             consumed = true; |  | ||||||
|             button_menu_process_ok(button_menu); |  | ||||||
|             break; |  | ||||||
|         default: |         default: | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| @ -272,6 +293,7 @@ ButtonMenu* button_menu_alloc(void) { | |||||||
|             return true; |             return true; | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  |     button_menu->freeze_input = false; | ||||||
|     return button_menu; |     return button_menu; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -11,7 +11,7 @@ typedef struct ButtonMenu ButtonMenu; | |||||||
| typedef struct ButtonMenuItem ButtonMenuItem; | typedef struct ButtonMenuItem ButtonMenuItem; | ||||||
| 
 | 
 | ||||||
| /* Callback for any button menu actions */ | /* Callback for any button menu actions */ | ||||||
| typedef void (*ButtonMenuItemCallback)(void* context, int32_t index); | 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 { | typedef enum { | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| #include "button_panel.h" | #include "button_panel.h" | ||||||
| #include "api-hal-resources.h" | #include "furi-hal-resources.h" | ||||||
| #include "gui/canvas.h" | #include "gui/canvas.h" | ||||||
| #include <m-array.h> | #include <m-array.h> | ||||||
| #include <m-i-list.h> | #include <m-i-list.h> | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| #include "u8g2/u8g2.h" | #include "u8g2/u8g2.h" | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
| static ApiHalSpiDevice* u8g2_periphery_display = NULL; | static FuriHalSpiDevice* u8g2_periphery_display = NULL; | ||||||
| 
 | 
 | ||||||
| uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { | uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { | ||||||
|     switch(msg) { |     switch(msg) { | ||||||
| @ -36,7 +36,7 @@ uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, vo | |||||||
| uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { | uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { | ||||||
|     switch(msg) { |     switch(msg) { | ||||||
|     case U8X8_MSG_BYTE_SEND: |     case U8X8_MSG_BYTE_SEND: | ||||||
|         api_hal_spi_bus_tx(u8g2_periphery_display->bus, (uint8_t*)arg_ptr, arg_int, 10000); |         furi_hal_spi_bus_tx(u8g2_periphery_display->bus, (uint8_t*)arg_ptr, arg_int, 10000); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|     case U8X8_MSG_BYTE_SET_DC: |     case U8X8_MSG_BYTE_SET_DC: | ||||||
| @ -49,14 +49,14 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ | |||||||
|     case U8X8_MSG_BYTE_START_TRANSFER: |     case U8X8_MSG_BYTE_START_TRANSFER: | ||||||
|         furi_assert(u8g2_periphery_display == NULL); |         furi_assert(u8g2_periphery_display == NULL); | ||||||
|         u8g2_periphery_display = |         u8g2_periphery_display = | ||||||
|             (ApiHalSpiDevice*)api_hal_spi_device_get(ApiHalSpiDeviceIdDisplay); |             (FuriHalSpiDevice*)furi_hal_spi_device_get(FuriHalSpiDeviceIdDisplay); | ||||||
|         hal_gpio_write(u8g2_periphery_display->chip_select, false); |         hal_gpio_write(u8g2_periphery_display->chip_select, false); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|     case U8X8_MSG_BYTE_END_TRANSFER: |     case U8X8_MSG_BYTE_END_TRANSFER: | ||||||
|         furi_assert(u8g2_periphery_display); |         furi_assert(u8g2_periphery_display); | ||||||
|         hal_gpio_write(u8g2_periphery_display->chip_select, true); |         hal_gpio_write(u8g2_periphery_display->chip_select, true); | ||||||
|         api_hal_spi_device_return(u8g2_periphery_display); |         furi_hal_spi_device_return(u8g2_periphery_display); | ||||||
|         u8g2_periphery_display = NULL; |         u8g2_periphery_display = NULL; | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -183,12 +183,12 @@ void KeyReader::switch_mode_if_needed() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void KeyReader::start() { | void KeyReader::start() { | ||||||
|     api_hal_power_enable_otg(); |     furi_hal_power_enable_otg(); | ||||||
|     switch_to(ReadMode::CYFRAL_METAKOM); |     switch_to(ReadMode::CYFRAL_METAKOM); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void KeyReader::stop() { | void KeyReader::stop() { | ||||||
|     api_hal_power_disable_otg(); |     furi_hal_power_disable_otg(); | ||||||
|     onewire_master->stop(); |     onewire_master->stop(); | ||||||
|     stop_comaparator(); |     stop_comaparator(); | ||||||
| } | } | ||||||
|  | |||||||
| @ -14,12 +14,12 @@ KeyWriter::Error KeyWriter::write(iButtonKey* key) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void KeyWriter::start() { | void KeyWriter::start() { | ||||||
|     api_hal_power_enable_otg(); |     furi_hal_power_enable_otg(); | ||||||
|     onewire_master->start(); |     onewire_master->start(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void KeyWriter::stop() { | void KeyWriter::stop() { | ||||||
|     api_hal_power_disable_otg(); |     furi_hal_power_disable_otg(); | ||||||
|     onewire_master->stop(); |     onewire_master->stop(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #include "pulse-sequencer.h" | #include "pulse-sequencer.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <callback-connector.h> | #include <callback-connector.h> | ||||||
| #include <api-hal-resources.h> | #include <furi-hal-resources.h> | ||||||
| 
 | 
 | ||||||
| void PulseSequencer::set_periods( | void PulseSequencer::set_periods( | ||||||
|     uint32_t* _periods, |     uint32_t* _periods, | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ void iButtonApp::run(void* args) { | |||||||
| 
 | 
 | ||||||
| iButtonApp::iButtonApp() | iButtonApp::iButtonApp() | ||||||
|     : notification{"notification"} { |     : notification{"notification"} { | ||||||
|     api_hal_power_insomnia_enter(); |     furi_hal_power_insomnia_enter(); | ||||||
|     key_worker = new KeyWorker(&ibutton_gpio); |     key_worker = new KeyWorker(&ibutton_gpio); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -49,7 +49,7 @@ iButtonApp::~iButtonApp() { | |||||||
|     } |     } | ||||||
|     delete key_worker; |     delete key_worker; | ||||||
| 
 | 
 | ||||||
|     api_hal_power_insomnia_exit(); |     furi_hal_power_insomnia_exit(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| iButtonAppViewManager* iButtonApp::get_view_manager() { | iButtonAppViewManager* iButtonApp::get_view_manager() { | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include <stdarg.h> | #include <stdarg.h> | ||||||
| #include <cli/cli.h> | #include <cli/cli.h> | ||||||
| #include <lib/toolbox/args.h> | #include <lib/toolbox/args.h> | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #include "ibutton-app.h" | #include "ibutton-app.h" | ||||||
| 
 | 
 | ||||||
| // app enter function
 | // app enter function
 | ||||||
| extern "C" int32_t app_ibutton(void* p) { | extern "C" int32_t ibutton_app(void* p) { | ||||||
|     iButtonApp* app = new iButtonApp(); |     iButtonApp* app = new iButtonApp(); | ||||||
|     app->run(p); |     app->run(p); | ||||||
|     delete app; |     delete app; | ||||||
|  | |||||||
| @ -91,7 +91,7 @@ void input_cli_send(Cli* cli, string_t args, void* context) { | |||||||
|     notify_pubsub(&input->event_pubsub, &event); |     notify_pubsub(&input->event_pubsub, &event); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t input_task() { | int32_t input_srv() { | ||||||
|     input = furi_alloc(sizeof(Input)); |     input = furi_alloc(sizeof(Input)); | ||||||
|     input->thread = osThreadGetId(); |     input->thread = osThreadGetId(); | ||||||
|     init_pubsub(&input->event_pubsub); |     init_pubsub(&input->event_pubsub); | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <api-hal-resources.h> | #include <furi-hal-resources.h> | ||||||
| 
 | 
 | ||||||
| /* Input Types
 | /* Input Types
 | ||||||
|  * Some of them are physical events and some logical |  * Some of them are physical events and some logical | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <cli/cli.h> | #include <cli/cli.h> | ||||||
| #include <m-string.h> | #include <m-string.h> | ||||||
| #include <api-hal-gpio.h> | #include <furi-hal-gpio.h> | ||||||
| 
 | 
 | ||||||
| #define INPUT_DEBOUNCE_TICKS_HALF (INPUT_DEBOUNCE_TICKS / 2) | #define INPUT_DEBOUNCE_TICKS_HALF (INPUT_DEBOUNCE_TICKS / 2) | ||||||
| #define INPUT_PRESS_TICKS 150 | #define INPUT_PRESS_TICKS 150 | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| #include <api-hal-delay.h> | #include <furi-hal-delay.h> | ||||||
| #include <irda.h> | #include <irda.h> | ||||||
| #include <app-template.h> | #include <app-template.h> | ||||||
| #include <cli/cli.h> | #include <cli/cli.h> | ||||||
| #include <cmsis_os2.h> | #include <cmsis_os2.h> | ||||||
| #include <irda_worker.h> | #include <irda_worker.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal-irda.h> | #include <furi-hal-irda.h> | ||||||
| #include <sstream> | #include <sstream> | ||||||
| #include <string> | #include <string> | ||||||
| #include <m-string.h> | #include <m-string.h> | ||||||
| @ -19,7 +19,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s | |||||||
|     Cli* cli = (Cli*)context; |     Cli* cli = (Cli*)context; | ||||||
| 
 | 
 | ||||||
|     if(irda_worker_signal_is_decoded(received_signal)) { |     if(irda_worker_signal_is_decoded(received_signal)) { | ||||||
|         const IrdaMessage* message = irda_worker_get_decoded_message(received_signal); |         const IrdaMessage* message = irda_worker_get_decoded_signal(received_signal); | ||||||
|         buf_cnt = sniprintf( |         buf_cnt = sniprintf( | ||||||
|             buf, |             buf, | ||||||
|             sizeof(buf), |             sizeof(buf), | ||||||
| @ -48,22 +48,21 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void irda_cli_start_ir_rx(Cli* cli, string_t args, void* context) { | static void irda_cli_start_ir_rx(Cli* cli, string_t args, void* context) { | ||||||
|     if(api_hal_irda_is_busy()) { |     if(furi_hal_irda_is_busy()) { | ||||||
|         printf("IRDA is busy. Exit."); |         printf("IRDA is busy. Exit."); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     IrdaWorker* worker = irda_worker_alloc(); |     IrdaWorker* worker = irda_worker_alloc(); | ||||||
|     irda_worker_set_context(worker, cli); |     irda_worker_rx_start(worker); | ||||||
|     irda_worker_start(worker); |     irda_worker_rx_set_received_signal_callback(worker, signal_received_callback, cli); | ||||||
|     irda_worker_set_received_signal_callback(worker, signal_received_callback); |  | ||||||
| 
 | 
 | ||||||
|     printf("Receiving IRDA...\r\nPress Ctrl+C to abort\r\n"); |     printf("Receiving IRDA...\r\nPress Ctrl+C to abort\r\n"); | ||||||
|     while(!cli_cmd_interrupt_received(cli)) { |     while(!cli_cmd_interrupt_received(cli)) { | ||||||
|         delay(50); |         delay(50); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     irda_worker_stop(worker); |     irda_worker_rx_stop(worker); | ||||||
|     irda_worker_free(worker); |     irda_worker_free(worker); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -142,7 +141,7 @@ static bool parse_signal_raw( | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void irda_cli_start_ir_tx(Cli* cli, string_t args, void* context) { | static void irda_cli_start_ir_tx(Cli* cli, string_t args, void* context) { | ||||||
|     if(api_hal_irda_is_busy()) { |     if(furi_hal_irda_is_busy()) { | ||||||
|         printf("IRDA is busy. Exit."); |         printf("IRDA is busy. Exit."); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| #include "irda-app-brute-force.hpp" | #include "irda-app-brute-force.h" | ||||||
| #include "irda/irda-app-file-parser.hpp" | #include "irda/irda-app-file-parser.h" | ||||||
| #include "m-string.h" | #include "m-string.h" | ||||||
| #include <file-worker-cpp.h> | #include <file-worker-cpp.h> | ||||||
| #include <memory> | #include <memory> | ||||||
| @ -47,7 +47,6 @@ void IrdaAppBruteForce::stop_bruteforce() { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // TODO: [FL-1418] replace with timer-chained consequence of messages.
 |  | ||||||
| bool IrdaAppBruteForce::send_next_bruteforce(void) { | bool IrdaAppBruteForce::send_next_bruteforce(void) { | ||||||
|     furi_assert(current_record.size()); |     furi_assert(current_record.size()); | ||||||
|     furi_assert(file_parser); |     furi_assert(file_parser); | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "furi/check.h" | #include "furi/check.h" | ||||||
| #include <unordered_map> | #include <unordered_map> | ||||||
| #include "irda-app-file-parser.hpp" | #include "irda-app-file-parser.h" | ||||||
| #include <memory> | #include <memory> | ||||||
| 
 | 
 | ||||||
| class IrdaAppBruteForce { | class IrdaAppBruteForce { | ||||||
| @ -28,7 +28,9 @@ public: | |||||||
|     bool start_bruteforce(int index, int& record_amount); |     bool start_bruteforce(int index, int& record_amount); | ||||||
|     void add_record(int index, const char* name); |     void add_record(int index, const char* name); | ||||||
| 
 | 
 | ||||||
|     IrdaAppBruteForce(const char* filename) : universal_db_filename (filename) {} |     IrdaAppBruteForce(const char* filename) | ||||||
|     ~IrdaAppBruteForce() {} |         : universal_db_filename(filename) { | ||||||
|  |     } | ||||||
|  |     ~IrdaAppBruteForce() { | ||||||
|  |     } | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| @ -9,6 +9,8 @@ public: | |||||||
|         Exit, |         Exit, | ||||||
|         Back, |         Back, | ||||||
|         MenuSelected, |         MenuSelected, | ||||||
|  |         MenuSelectedPress, | ||||||
|  |         MenuSelectedRelease, | ||||||
|         DialogExSelected, |         DialogExSelected, | ||||||
|         NextScene, |         NextScene, | ||||||
|         IrdaMessageReceived, |         IrdaMessageReceived, | ||||||
| @ -24,4 +26,3 @@ public: | |||||||
| 
 | 
 | ||||||
|     Type type; |     Type type; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "irda-app-file-parser.hpp" | #include "irda-app-file-parser.h" | ||||||
| #include "furi/check.h" | #include "furi/check.h" | ||||||
| #include "irda-app-remote-manager.hpp" | #include "irda-app-remote-manager.h" | ||||||
| #include "irda-app-signal.h" | #include "irda-app-signal.h" | ||||||
| #include "m-string.h" | #include "m-string.h" | ||||||
| #include <text-store.h> | #include <text-store.h> | ||||||
|  | |||||||
| @ -26,8 +26,16 @@ public: | |||||||
|     std::string make_name(const std::string& full_name) const; |     std::string make_name(const std::string& full_name) const; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     size_t stringify_message(const IrdaAppSignal& signal, const char* name, char* content, size_t content_len); |     size_t stringify_message( | ||||||
|     size_t stringify_raw_signal(const IrdaAppSignal& signal, const char* name, char* content, size_t content_len); |         const IrdaAppSignal& signal, | ||||||
|  |         const char* name, | ||||||
|  |         char* content, | ||||||
|  |         size_t content_len); | ||||||
|  |     size_t stringify_raw_signal( | ||||||
|  |         const IrdaAppSignal& signal, | ||||||
|  |         const char* name, | ||||||
|  |         char* content, | ||||||
|  |         size_t content_len); | ||||||
|     std::unique_ptr<IrdaFileSignal> parse_signal(const std::string& str) const; |     std::unique_ptr<IrdaFileSignal> parse_signal(const std::string& str) const; | ||||||
|     std::unique_ptr<IrdaFileSignal> parse_signal_raw(const std::string& str) const; |     std::unique_ptr<IrdaFileSignal> parse_signal_raw(const std::string& str) const; | ||||||
|     std::string make_full_name(const std::string& name) const; |     std::string make_full_name(const std::string& name) const; | ||||||
| @ -41,4 +49,3 @@ private: | |||||||
|     char file_buf[128]; |     char file_buf[128]; | ||||||
|     size_t file_buf_cnt = 0; |     size_t file_buf_cnt = 0; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "irda-app-remote-manager.hpp" | #include "irda-app-remote-manager.h" | ||||||
| #include <storage/storage.h> | #include <storage/storage.h> | ||||||
| #include "furi.h" | #include "furi.h" | ||||||
| #include "furi/check.h" | #include "furi/check.h" | ||||||
| @ -8,7 +8,7 @@ | |||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| #include <string> | #include <string> | ||||||
| #include <utility> | #include <utility> | ||||||
| #include "irda-app-file-parser.hpp" | #include "irda-app-file-parser.h" | ||||||
| 
 | 
 | ||||||
| static const std::string default_remote_name = "remote"; | static const std::string default_remote_name = "remote"; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -12,21 +12,27 @@ class IrdaAppRemoteButton { | |||||||
|     friend class IrdaAppRemoteManager; |     friend class IrdaAppRemoteManager; | ||||||
|     std::string name; |     std::string name; | ||||||
|     IrdaAppSignal signal; |     IrdaAppSignal signal; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     IrdaAppRemoteButton(const char* name, const IrdaAppSignal& signal) |     IrdaAppRemoteButton(const char* name, const IrdaAppSignal& signal) | ||||||
|         : name(name), signal (signal) {} |         : name(name) | ||||||
|     ~IrdaAppRemoteButton() {} |         , signal(signal) { | ||||||
|  |     } | ||||||
|  |     ~IrdaAppRemoteButton() { | ||||||
|  |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class IrdaAppRemote { | class IrdaAppRemote { | ||||||
|     friend class IrdaAppRemoteManager; |     friend class IrdaAppRemoteManager; | ||||||
|     std::vector<IrdaAppRemoteButton> buttons; |     std::vector<IrdaAppRemoteButton> buttons; | ||||||
|     std::string name; |     std::string name; | ||||||
| public: |  | ||||||
|     IrdaAppRemote(const std::string& name) : name(name) {} |  | ||||||
| 
 | 
 | ||||||
|     IrdaAppRemote& operator=(std::string& new_name) noexcept | public: | ||||||
|     { |     IrdaAppRemote(const std::string& name) | ||||||
|  |         : name(name) { | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     IrdaAppRemote& operator=(std::string& new_name) noexcept { | ||||||
|         name = new_name; |         name = new_name; | ||||||
|         buttons.clear(); |         buttons.clear(); | ||||||
|         return *this; |         return *this; | ||||||
| @ -61,4 +67,3 @@ public: | |||||||
|     bool store(); |     bool store(); | ||||||
|     bool load(const std::string& name); |     bool load(const std::string& name); | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| @ -1,7 +1,7 @@ | |||||||
| #include "furi.h" | #include "furi.h" | ||||||
| #include "gui/modules/button_panel.h" | #include "gui/modules/button_panel.h" | ||||||
| #include "irda-app.hpp" | #include "irda-app.h" | ||||||
| #include "irda/irda-app-event.hpp" | #include "irda/irda-app-event.h" | ||||||
| #include <callback-connector.h> | #include <callback-connector.h> | ||||||
| 
 | 
 | ||||||
| IrdaAppViewManager::IrdaAppViewManager() { | IrdaAppViewManager::IrdaAppViewManager() { | ||||||
| @ -112,8 +112,14 @@ void IrdaAppViewManager::receive_event(IrdaAppEvent* event) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IrdaAppViewManager::send_event(IrdaAppEvent* event) { | void IrdaAppViewManager::send_event(IrdaAppEvent* event) { | ||||||
|     osStatus_t result = osMessageQueuePut(event_queue, event, 0, 0); |     uint32_t timeout = 0; | ||||||
|     furi_check(result == osOK); |     /* Rapid button hammering on Remote Scene causes queue overflow - ignore it,
 | ||||||
|  |      * but try to keep button release event - it switches off IRDA DMA sending. */ | ||||||
|  |     if(event->type == IrdaAppEvent::Type::MenuSelectedRelease) { | ||||||
|  |         timeout = 200; | ||||||
|  |     } | ||||||
|  |     osMessageQueuePut(event_queue, event, 0, timeout); | ||||||
|  |     /* furi_check(result == osOK); */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint32_t IrdaAppViewManager::previous_view_callback(void* context) { | uint32_t IrdaAppViewManager::previous_view_callback(void* context) { | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ | |||||||
| #include <gui/modules/dialog_ex.h> | #include <gui/modules/dialog_ex.h> | ||||||
| #include <gui/modules/submenu.h> | #include <gui/modules/submenu.h> | ||||||
| #include <gui/modules/popup.h> | #include <gui/modules/popup.h> | ||||||
| #include "irda-app.hpp" | #include "irda-app.h" | ||||||
| #include "view/irda-app-brut-view.h" | #include "view/irda-app-brut-view.h" | ||||||
| #include "gui/modules/button_panel.h" | #include "gui/modules/button_panel.h" | ||||||
| 
 | 
 | ||||||
| @ -57,4 +57,3 @@ private: | |||||||
| 
 | 
 | ||||||
|     void add_view(ViewType view_type, View* view); |     void add_view(ViewType view_type, View* view); | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| @ -1,5 +1,5 @@ | |||||||
| #include "irda-app.hpp" | #include "irda-app.h" | ||||||
| #include "irda/irda-app-file-parser.hpp" | #include "irda/irda-app-file-parser.h" | ||||||
| #include <irda_worker.h> | #include <irda_worker.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| @ -222,22 +222,33 @@ void IrdaApp::notify_click() { | |||||||
|     notification_message_block(notification, &sequence); |     notification_message_block(notification, &sequence); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IrdaApp::notify_click_and_blink() { | void IrdaApp::notify_click_and_green_blink() { | ||||||
|     static const NotificationSequence sequence = { |     static const NotificationSequence sequence = { | ||||||
|         &message_click, |         &message_click, | ||||||
|         &message_delay_1, |         &message_delay_1, | ||||||
|         &message_sound_off, |         &message_sound_off, | ||||||
|         &message_red_0, |  | ||||||
|         &message_green_255, |         &message_green_255, | ||||||
|         &message_blue_0, |  | ||||||
|         &message_delay_10, |         &message_delay_10, | ||||||
|         &message_green_0, |         &message_green_0, | ||||||
|  |         &message_do_not_reset, | ||||||
|         NULL, |         NULL, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     notification_message_block(notification, &sequence); |     notification_message_block(notification, &sequence); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void IrdaApp::notify_blink_green() { | ||||||
|  |     static const NotificationSequence sequence = { | ||||||
|  |         &message_green_255, | ||||||
|  |         &message_delay_10, | ||||||
|  |         &message_green_0, | ||||||
|  |         &message_do_not_reset, | ||||||
|  |         NULL, | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     notification_message(notification, &sequence); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void IrdaApp::notify_double_vibro() { | void IrdaApp::notify_double_vibro() { | ||||||
|     notification_message(notification, &sequence_double_vibro); |     notification_message(notification, &sequence_double_vibro); | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,17 +2,16 @@ | |||||||
| #include <map> | #include <map> | ||||||
| #include <irda.h> | #include <irda.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include "scene/irda-app-scene.hpp" | #include "scene/irda-app-scene.h" | ||||||
| #include "irda-app-event.hpp" | #include "irda-app-event.h" | ||||||
| #include "scene/irda-app-scene.hpp" | #include "scene/irda-app-scene.h" | ||||||
| #include "irda-app-view-manager.hpp" | #include "irda-app-view-manager.h" | ||||||
| #include "irda-app-remote-manager.hpp" | #include "irda-app-remote-manager.h" | ||||||
| #include <forward_list> | #include <forward_list> | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| #include <notification/notification-messages.h> | #include <notification/notification-messages.h> | ||||||
| #include <irda_worker.h> | #include <irda_worker.h> | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class IrdaApp { | class IrdaApp { | ||||||
| public: | public: | ||||||
|     enum class EditElement : uint8_t { |     enum class EditElement : uint8_t { | ||||||
| @ -71,7 +70,7 @@ public: | |||||||
|     void set_learn_new_remote(bool value); |     void set_learn_new_remote(bool value); | ||||||
| 
 | 
 | ||||||
|     enum : int { |     enum : int { | ||||||
|            ButtonNA = -1, |         ButtonNA = -1, | ||||||
|     }; |     }; | ||||||
|     int get_current_button(); |     int get_current_button(); | ||||||
|     void set_current_button(int value); |     void set_current_button(int value); | ||||||
| @ -83,7 +82,8 @@ public: | |||||||
|     void notify_green_on(); |     void notify_green_on(); | ||||||
|     void notify_green_off(); |     void notify_green_off(); | ||||||
|     void notify_click(); |     void notify_click(); | ||||||
|     void notify_click_and_blink(); |     void notify_click_and_green_blink(); | ||||||
|  |     void notify_blink_green(); | ||||||
| 
 | 
 | ||||||
|     static void text_input_callback(void* context); |     static void text_input_callback(void* context); | ||||||
|     static void popup_callback(void* context); |     static void popup_callback(void* context); | ||||||
| @ -95,9 +95,9 @@ public: | |||||||
|     ~IrdaApp() { |     ~IrdaApp() { | ||||||
|         irda_worker_free(irda_worker); |         irda_worker_free(irda_worker); | ||||||
|         furi_record_close("notification"); |         furi_record_close("notification"); | ||||||
|         for (auto &it : scenes) |         for(auto& it : scenes) delete it.second; | ||||||
|             delete it.second; |  | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     static const uint8_t text_store_size = 128; |     static const uint8_t text_store_size = 128; | ||||||
|     static const uint8_t text_store_max = 2; |     static const uint8_t text_store_max = 2; | ||||||
| @ -120,7 +120,7 @@ private: | |||||||
|         {Scene::Start, new IrdaAppSceneStart()}, |         {Scene::Start, new IrdaAppSceneStart()}, | ||||||
|         {Scene::Universal, new IrdaAppSceneUniversal()}, |         {Scene::Universal, new IrdaAppSceneUniversal()}, | ||||||
|         {Scene::UniversalTV, new IrdaAppSceneUniversalTV()}, |         {Scene::UniversalTV, new IrdaAppSceneUniversalTV()}, | ||||||
| //        {Scene::UniversalAudio, new IrdaAppSceneUniversalAudio()},
 |         //        {Scene::UniversalAudio, new IrdaAppSceneUniversalAudio()},
 | ||||||
|         {Scene::Learn, new IrdaAppSceneLearn()}, |         {Scene::Learn, new IrdaAppSceneLearn()}, | ||||||
|         {Scene::LearnSuccess, new IrdaAppSceneLearnSuccess()}, |         {Scene::LearnSuccess, new IrdaAppSceneLearnSuccess()}, | ||||||
|         {Scene::LearnEnterName, new IrdaAppSceneLearnEnterName()}, |         {Scene::LearnEnterName, new IrdaAppSceneLearnEnterName()}, | ||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "irda-app.hpp" | #include "irda-app.h" | ||||||
| 
 | 
 | ||||||
| extern "C" int32_t irda(void* p) { | extern "C" int32_t irda_app(void* p) { | ||||||
|     IrdaApp* app = new IrdaApp(); |     IrdaApp* app = new IrdaApp(); | ||||||
|     int32_t result = app->run(p); |     int32_t result = app->run(p); | ||||||
|     delete app; |     delete app; | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneEditDeleteDone::on_enter(IrdaApp* app) { | void IrdaAppSceneEditDeleteDone::on_enter(IrdaApp* app) { | ||||||
|     IrdaAppViewManager* view_manager = app->get_view_manager(); |     IrdaAppViewManager* view_manager = app->get_view_manager(); | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "irda.h" | #include "irda.h" | ||||||
| #include "irda/scene/irda-app-scene.hpp" | #include "irda/scene/irda-app-scene.h" | ||||||
| #include <string> | #include <string> | ||||||
| 
 | 
 | ||||||
| static void dialog_result_callback(DialogExResult result, void* context) { | static void dialog_result_callback(DialogExResult result, void* context) { | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "gui/modules/submenu.h" | #include "gui/modules/submenu.h" | ||||||
| 
 | 
 | ||||||
| static void submenu_callback(void* context, uint32_t index) { | static void submenu_callback(void* context, uint32_t index) { | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneEditRenameDone::on_enter(IrdaApp* app) { | void IrdaAppSceneEditRenameDone::on_enter(IrdaApp* app) { | ||||||
|     IrdaAppViewManager* view_manager = app->get_view_manager(); |     IrdaAppViewManager* view_manager = app->get_view_manager(); | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneEditRename::on_enter(IrdaApp* app) { | void IrdaAppSceneEditRename::on_enter(IrdaApp* app) { | ||||||
|     IrdaAppViewManager* view_manager = app->get_view_manager(); |     IrdaAppViewManager* view_manager = app->get_view_manager(); | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "gui/modules/submenu.h" | #include "gui/modules/submenu.h" | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneLearnDone::on_enter(IrdaApp* app) { | void IrdaAppSceneLearnDone::on_enter(IrdaApp* app) { | ||||||
|     IrdaAppViewManager* view_manager = app->get_view_manager(); |     IrdaAppViewManager* view_manager = app->get_view_manager(); | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "gui/modules/text_input.h" | #include "gui/modules/text_input.h" | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneLearnEnterName::on_enter(IrdaApp* app) { | void IrdaAppSceneLearnEnterName::on_enter(IrdaApp* app) { | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "irda.h" | #include "irda.h" | ||||||
| #include "../irda-app-file-parser.hpp" | #include "../irda-app-file-parser.h" | ||||||
| #include <memory> | #include <memory> | ||||||
| 
 | 
 | ||||||
| static void dialog_result_callback(DialogExResult result, void* context) { | static void dialog_result_callback(DialogExResult result, void* context) { | ||||||
| @ -51,6 +51,10 @@ void IrdaAppSceneLearnSuccess::on_enter(IrdaApp* app) { | |||||||
| 
 | 
 | ||||||
| bool IrdaAppSceneLearnSuccess::on_event(IrdaApp* app, IrdaAppEvent* event) { | bool IrdaAppSceneLearnSuccess::on_event(IrdaApp* app, IrdaAppEvent* event) { | ||||||
|     bool consumed = false; |     bool consumed = false; | ||||||
|  |     if(event->type == IrdaAppEvent::Type::Tick) { | ||||||
|  |         /* Send event every tick to suppress any switching off green light */ | ||||||
|  |         app->notify_green_on(); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     if(event->type == IrdaAppEvent::Type::DialogExSelected) { |     if(event->type == IrdaAppEvent::Type::DialogExSelected) { | ||||||
|         switch(event->payload.dialog_ex_result) { |         switch(event->payload.dialog_ex_result) { | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "../irda-app-event.hpp" | #include "../irda-app-event.h" | ||||||
| #include <irda_worker.h> | #include <irda_worker.h> | ||||||
| 
 | 
 | ||||||
| static void signal_received_callback(void* context, IrdaWorkerSignal* received_signal) { | static void signal_received_callback(void* context, IrdaWorkerSignal* received_signal) { | ||||||
| @ -9,7 +9,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s | |||||||
|     IrdaApp* app = static_cast<IrdaApp*>(context); |     IrdaApp* app = static_cast<IrdaApp*>(context); | ||||||
| 
 | 
 | ||||||
|     if(irda_worker_signal_is_decoded(received_signal)) { |     if(irda_worker_signal_is_decoded(received_signal)) { | ||||||
|         IrdaAppSignal signal(irda_worker_get_decoded_message(received_signal)); |         IrdaAppSignal signal(irda_worker_get_decoded_signal(received_signal)); | ||||||
|         app->set_received_signal(signal); |         app->set_received_signal(signal); | ||||||
|     } else { |     } else { | ||||||
|         const uint32_t* timings; |         const uint32_t* timings; | ||||||
| @ -19,7 +19,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s | |||||||
|         app->set_received_signal(signal); |         app->set_received_signal(signal); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     irda_worker_set_received_signal_callback(app->get_irda_worker(), NULL); |     irda_worker_rx_set_received_signal_callback(app->get_irda_worker(), NULL, NULL); | ||||||
|     IrdaAppEvent event; |     IrdaAppEvent event; | ||||||
|     event.type = IrdaAppEvent::Type::IrdaMessageReceived; |     event.type = IrdaAppEvent::Type::IrdaMessageReceived; | ||||||
|     auto view_manager = app->get_view_manager(); |     auto view_manager = app->get_view_manager(); | ||||||
| @ -31,9 +31,8 @@ void IrdaAppSceneLearn::on_enter(IrdaApp* app) { | |||||||
|     auto popup = view_manager->get_popup(); |     auto popup = view_manager->get_popup(); | ||||||
| 
 | 
 | ||||||
|     auto worker = app->get_irda_worker(); |     auto worker = app->get_irda_worker(); | ||||||
|     irda_worker_set_context(worker, app); |     irda_worker_rx_set_received_signal_callback(worker, signal_received_callback, app); | ||||||
|     irda_worker_set_received_signal_callback(worker, signal_received_callback); |     irda_worker_rx_start(worker); | ||||||
|     irda_worker_start(worker); |  | ||||||
| 
 | 
 | ||||||
|     popup_set_icon(popup, 0, 32, &I_IrdaLearnShort_128x31); |     popup_set_icon(popup, 0, 32, &I_IrdaLearnShort_128x31); | ||||||
|     popup_set_text( |     popup_set_text( | ||||||
| @ -58,11 +57,9 @@ bool IrdaAppSceneLearn::on_event(IrdaApp* app, IrdaAppEvent* event) { | |||||||
|     case IrdaAppEvent::Type::IrdaMessageReceived: |     case IrdaAppEvent::Type::IrdaMessageReceived: | ||||||
|         app->notify_success(); |         app->notify_success(); | ||||||
|         app->switch_to_next_scene_without_saving(IrdaApp::Scene::LearnSuccess); |         app->switch_to_next_scene_without_saving(IrdaApp::Scene::LearnSuccess); | ||||||
|         irda_worker_stop(app->get_irda_worker()); |  | ||||||
|         break; |         break; | ||||||
|     case IrdaAppEvent::Type::Back: |     case IrdaAppEvent::Type::Back: | ||||||
|         consumed = true; |         consumed = true; | ||||||
|         irda_worker_stop(app->get_irda_worker()); |  | ||||||
|         app->switch_to_previous_scene(); |         app->switch_to_previous_scene(); | ||||||
|         break; |         break; | ||||||
|     default: |     default: | ||||||
| @ -73,4 +70,5 @@ bool IrdaAppSceneLearn::on_event(IrdaApp* app, IrdaAppEvent* event) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneLearn::on_exit(IrdaApp* app) { | void IrdaAppSceneLearn::on_exit(IrdaApp* app) { | ||||||
|  |     irda_worker_rx_stop(app->get_irda_worker()); | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "irda/irda-app-event.hpp" | #include "irda/irda-app-event.h" | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneRemoteList::on_enter(IrdaApp* app) { | void IrdaAppSceneRemoteList::on_enter(IrdaApp* app) { | ||||||
|     IrdaAppFileParser file_parser; |     IrdaAppFileParser file_parser; | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "gui/modules/button_menu.h" | #include "gui/modules/button_menu.h" | ||||||
|  | #include "input/input.h" | ||||||
|  | #include "irda_worker.h" | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
|     ButtonIndexPlus = -2, |     ButtonIndexPlus = -2, | ||||||
| @ -7,22 +9,41 @@ typedef enum { | |||||||
|     ButtonIndexNA = 0, |     ButtonIndexNA = 0, | ||||||
| } ButtonIndex; | } ButtonIndex; | ||||||
| 
 | 
 | ||||||
| static void button_menu_callback(void* context, int32_t index) { | static void button_menu_callback(void* context, int32_t index, InputType type) { | ||||||
|     IrdaApp* app = static_cast<IrdaApp*>(context); |     IrdaApp* app = static_cast<IrdaApp*>(context); | ||||||
|     IrdaAppEvent event; |     IrdaAppEvent event; | ||||||
| 
 | 
 | ||||||
|     event.type = IrdaAppEvent::Type::MenuSelected; |     if(type == InputTypePress) { | ||||||
|  |         event.type = IrdaAppEvent::Type::MenuSelectedPress; | ||||||
|  |     } else if(type == InputTypeRelease) { | ||||||
|  |         event.type = IrdaAppEvent::Type::MenuSelectedRelease; | ||||||
|  |     } else if(type == InputTypeShort) { | ||||||
|  |         event.type = IrdaAppEvent::Type::MenuSelected; | ||||||
|  |     } else { | ||||||
|  |         furi_assert(0); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     event.payload.menu_index = index; |     event.payload.menu_index = index; | ||||||
| 
 | 
 | ||||||
|     app->get_view_manager()->send_event(&event); |     app->get_view_manager()->send_event(&event); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void irda_app_message_sent_callback(void* context) { | ||||||
|  |     IrdaApp* app = static_cast<IrdaApp*>(context); | ||||||
|  |     app->notify_blink_green(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void IrdaAppSceneRemote::on_enter(IrdaApp* app) { | void IrdaAppSceneRemote::on_enter(IrdaApp* app) { | ||||||
|     IrdaAppViewManager* view_manager = app->get_view_manager(); |     IrdaAppViewManager* view_manager = app->get_view_manager(); | ||||||
|     ButtonMenu* button_menu = view_manager->get_button_menu(); |     ButtonMenu* button_menu = view_manager->get_button_menu(); | ||||||
|     auto remote_manager = app->get_remote_manager(); |     auto remote_manager = app->get_remote_manager(); | ||||||
|     int i = 0; |     int i = 0; | ||||||
|  |     button_pressed = false; | ||||||
| 
 | 
 | ||||||
|  |     irda_worker_tx_set_get_signal_callback( | ||||||
|  |         app->get_irda_worker(), irda_worker_tx_get_signal_steady_callback, app); | ||||||
|  |     irda_worker_tx_set_signal_sent_callback( | ||||||
|  |         app->get_irda_worker(), irda_app_message_sent_callback, app); | ||||||
|     buttons_names = remote_manager->get_button_list(); |     buttons_names = remote_manager->get_button_list(); | ||||||
| 
 | 
 | ||||||
|     i = 0; |     i = 0; | ||||||
| @ -48,24 +69,49 @@ void IrdaAppSceneRemote::on_enter(IrdaApp* app) { | |||||||
| bool IrdaAppSceneRemote::on_event(IrdaApp* app, IrdaAppEvent* event) { | bool IrdaAppSceneRemote::on_event(IrdaApp* app, IrdaAppEvent* event) { | ||||||
|     bool consumed = true; |     bool consumed = true; | ||||||
| 
 | 
 | ||||||
|     if(event->type == IrdaAppEvent::Type::MenuSelected) { |     if((event->type == IrdaAppEvent::Type::MenuSelected) || | ||||||
|  |        (event->type == IrdaAppEvent::Type::MenuSelectedPress) || | ||||||
|  |        (event->type == IrdaAppEvent::Type::MenuSelectedRelease)) { | ||||||
|         switch(event->payload.menu_index) { |         switch(event->payload.menu_index) { | ||||||
|         case ButtonIndexPlus: |         case ButtonIndexPlus: | ||||||
|  |             furi_assert(event->type == IrdaAppEvent::Type::MenuSelected); | ||||||
|             app->notify_click(); |             app->notify_click(); | ||||||
|             buttonmenu_item_selected = event->payload.menu_index; |             buttonmenu_item_selected = event->payload.menu_index; | ||||||
|             app->set_learn_new_remote(false); |             app->set_learn_new_remote(false); | ||||||
|             app->switch_to_next_scene(IrdaApp::Scene::Learn); |             app->switch_to_next_scene(IrdaApp::Scene::Learn); | ||||||
|             break; |             break; | ||||||
|         case ButtonIndexEdit: |         case ButtonIndexEdit: | ||||||
|  |             furi_assert(event->type == IrdaAppEvent::Type::MenuSelected); | ||||||
|             app->notify_click(); |             app->notify_click(); | ||||||
|             buttonmenu_item_selected = event->payload.menu_index; |             buttonmenu_item_selected = event->payload.menu_index; | ||||||
|             app->switch_to_next_scene(IrdaApp::Scene::Edit); |             app->switch_to_next_scene(IrdaApp::Scene::Edit); | ||||||
|             break; |             break; | ||||||
|         default: |         default: | ||||||
|             app->notify_click_and_blink(); |             furi_assert(event->type != IrdaAppEvent::Type::MenuSelected); | ||||||
|             auto remote_manager = app->get_remote_manager(); |             bool pressed = (event->type == IrdaAppEvent::Type::MenuSelectedPress); | ||||||
|             auto signal = remote_manager->get_button_data(event->payload.menu_index); | 
 | ||||||
|             signal.transmit(); |             if(pressed && !button_pressed) { | ||||||
|  |                 button_pressed = true; | ||||||
|  |                 app->notify_click_and_green_blink(); | ||||||
|  | 
 | ||||||
|  |                 auto button_signal = | ||||||
|  |                     app->get_remote_manager()->get_button_data(event->payload.menu_index); | ||||||
|  |                 if(button_signal.is_raw()) { | ||||||
|  |                     irda_worker_set_raw_signal( | ||||||
|  |                         app->get_irda_worker(), | ||||||
|  |                         button_signal.get_raw_signal().timings, | ||||||
|  |                         button_signal.get_raw_signal().timings_cnt); | ||||||
|  |                 } else { | ||||||
|  |                     irda_worker_set_decoded_signal( | ||||||
|  |                         app->get_irda_worker(), &button_signal.get_message()); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 irda_worker_tx_start(app->get_irda_worker()); | ||||||
|  |             } else if(!pressed && button_pressed) { | ||||||
|  |                 button_pressed = false; | ||||||
|  |                 irda_worker_tx_stop(app->get_irda_worker()); | ||||||
|  |                 app->notify_green_off(); | ||||||
|  |             } | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|     } else if(event->type == IrdaAppEvent::Type::Back) { |     } else if(event->type == IrdaAppEvent::Type::Back) { | ||||||
| @ -79,6 +125,8 @@ bool IrdaAppSceneRemote::on_event(IrdaApp* app, IrdaAppEvent* event) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneRemote::on_exit(IrdaApp* app) { | void IrdaAppSceneRemote::on_exit(IrdaApp* app) { | ||||||
|  |     irda_worker_tx_set_get_signal_callback(app->get_irda_worker(), nullptr, nullptr); | ||||||
|  |     irda_worker_tx_set_signal_sent_callback(app->get_irda_worker(), nullptr, nullptr); | ||||||
|     IrdaAppViewManager* view_manager = app->get_view_manager(); |     IrdaAppViewManager* view_manager = app->get_view_manager(); | ||||||
|     ButtonMenu* button_menu = view_manager->get_button_menu(); |     ButtonMenu* button_menu = view_manager->get_button_menu(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
|     SubmenuIndexUniversalLibrary, |     SubmenuIndexUniversalLibrary, | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| #include "assets_icons.h" | #include "assets_icons.h" | ||||||
| #include "gui/modules/button_menu.h" | #include "gui/modules/button_menu.h" | ||||||
| #include "gui/modules/button_panel.h" | #include "gui/modules/button_panel.h" | ||||||
| #include "../view/irda-app-brut-view.h" | #include "../view/irda-app-brut-view.h" | ||||||
| #include "gui/view.h" | #include "gui/view.h" | ||||||
| #include "irda/irda-app-event.hpp" | #include "irda/irda-app-event.h" | ||||||
| #include "irda/irda-app-view-manager.hpp" | #include "irda/irda-app-view-manager.h" | ||||||
| #include "irda/scene/irda-app-scene.hpp" | #include "irda/scene/irda-app-scene.h" | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneUniversalCommon::irda_app_item_callback(void* context, uint32_t index) { | void IrdaAppSceneUniversalCommon::irda_app_item_callback(void* context, uint32_t index) { | ||||||
|     IrdaApp* app = static_cast<IrdaApp*>(context); |     IrdaApp* app = static_cast<IrdaApp*>(context); | ||||||
| @ -49,10 +49,11 @@ void IrdaAppSceneUniversalCommon::show_popup(IrdaApp* app, int record_amount) { | |||||||
|     button_panel_set_popup_input_callback(button_panel, irda_popup_brut_input_callback, app); |     button_panel_set_popup_input_callback(button_panel, irda_popup_brut_input_callback, app); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneUniversalCommon::progress_popup(IrdaApp* app) { | bool IrdaAppSceneUniversalCommon::progress_popup(IrdaApp* app) { | ||||||
|     popup_brut_increase_progress(app->get_view_manager()->get_popup_brut()); |     bool result = popup_brut_increase_progress(app->get_view_manager()->get_popup_brut()); | ||||||
|     auto button_panel = app->get_view_manager()->get_button_panel(); |     auto button_panel = app->get_view_manager()->get_button_panel(); | ||||||
|     with_view_model_cpp(button_panel_get_view(button_panel), void*, model, { return true; }); |     with_view_model_cpp(button_panel_get_view(button_panel), void*, model, { return true; }); | ||||||
|  |     return result; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool IrdaAppSceneUniversalCommon::on_event(IrdaApp* app, IrdaAppEvent* event) { | bool IrdaAppSceneUniversalCommon::on_event(IrdaApp* app, IrdaAppEvent* event) { | ||||||
| @ -63,9 +64,11 @@ bool IrdaAppSceneUniversalCommon::on_event(IrdaApp* app, IrdaAppEvent* event) { | |||||||
|             auto view_manager = app->get_view_manager(); |             auto view_manager = app->get_view_manager(); | ||||||
|             IrdaAppEvent tick_event = {.type = IrdaAppEvent::Type::Tick}; |             IrdaAppEvent tick_event = {.type = IrdaAppEvent::Type::Tick}; | ||||||
|             view_manager->send_event(&tick_event); |             view_manager->send_event(&tick_event); | ||||||
|             if(brute_force.send_next_bruteforce()) { |             bool result = brute_force.send_next_bruteforce(); | ||||||
|                 progress_popup(app); |             if(result) { | ||||||
|             } else { |                 result = progress_popup(app); | ||||||
|  |             } | ||||||
|  |             if(!result) { | ||||||
|                 brute_force.stop_bruteforce(); |                 brute_force.stop_bruteforce(); | ||||||
|                 brute_force_started = false; |                 brute_force_started = false; | ||||||
|                 remove_popup(app); |                 remove_popup(app); | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| #include "irda/scene/irda-app-scene.hpp" | #include "irda/scene/irda-app-scene.h" | ||||||
| #include "irda/irda-app.hpp" | #include "irda/irda-app.h" | ||||||
| 
 | 
 | ||||||
| void IrdaAppSceneUniversalTV::on_enter(IrdaApp* app) { | void IrdaAppSceneUniversalTV::on_enter(IrdaApp* app) { | ||||||
|     IrdaAppViewManager* view_manager = app->get_view_manager(); |     IrdaAppViewManager* view_manager = app->get_view_manager(); | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../irda-app.hpp" | #include "../irda-app.h" | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
|     SubmenuIndexUniversalTV, |     SubmenuIndexUniversalTV, | ||||||
|  | |||||||
| @ -1,11 +1,10 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "../irda-app-event.hpp" | #include "../irda-app-event.h" | ||||||
| #include <api-hal-irda.h> | #include <furi-hal-irda.h> | ||||||
| #include "irda.h" | #include "irda.h" | ||||||
| #include <vector> | #include <vector> | ||||||
| #include <string> | #include <string> | ||||||
| #include "../irda-app-brute-force.hpp" | #include "../irda-app-brute-force.h" | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| class IrdaApp; | class IrdaApp; | ||||||
| 
 | 
 | ||||||
| @ -24,6 +23,7 @@ public: | |||||||
|     void on_enter(IrdaApp* app) final; |     void on_enter(IrdaApp* app) final; | ||||||
|     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; |     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; | ||||||
|     void on_exit(IrdaApp* app) final; |     void on_exit(IrdaApp* app) final; | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     uint32_t submenu_item_selected = 0; |     uint32_t submenu_item_selected = 0; | ||||||
| }; | }; | ||||||
| @ -33,6 +33,7 @@ public: | |||||||
|     void on_enter(IrdaApp* app) final; |     void on_enter(IrdaApp* app) final; | ||||||
|     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; |     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; | ||||||
|     void on_exit(IrdaApp* app) final; |     void on_exit(IrdaApp* app) final; | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     uint32_t submenu_item_selected = 0; |     uint32_t submenu_item_selected = 0; | ||||||
| }; | }; | ||||||
| @ -70,9 +71,11 @@ public: | |||||||
|     void on_enter(IrdaApp* app) final; |     void on_enter(IrdaApp* app) final; | ||||||
|     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; |     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; | ||||||
|     void on_exit(IrdaApp* app) final; |     void on_exit(IrdaApp* app) final; | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     std::vector<std::string> buttons_names; |     std::vector<std::string> buttons_names; | ||||||
|     uint32_t buttonmenu_item_selected = 0; |     uint32_t buttonmenu_item_selected = 0; | ||||||
|  |     bool button_pressed = false; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class IrdaAppSceneRemoteList : public IrdaAppScene { | class IrdaAppSceneRemoteList : public IrdaAppScene { | ||||||
| @ -80,6 +83,7 @@ public: | |||||||
|     void on_enter(IrdaApp* app) final; |     void on_enter(IrdaApp* app) final; | ||||||
|     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; |     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; | ||||||
|     void on_exit(IrdaApp* app) final; |     void on_exit(IrdaApp* app) final; | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     uint32_t submenu_item_selected = 0; |     uint32_t submenu_item_selected = 0; | ||||||
|     std::vector<std::string> remote_names; |     std::vector<std::string> remote_names; | ||||||
| @ -90,6 +94,7 @@ public: | |||||||
|     void on_enter(IrdaApp* app) final; |     void on_enter(IrdaApp* app) final; | ||||||
|     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; |     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; | ||||||
|     void on_exit(IrdaApp* app) final; |     void on_exit(IrdaApp* app) final; | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     uint32_t submenu_item_selected = 0; |     uint32_t submenu_item_selected = 0; | ||||||
| }; | }; | ||||||
| @ -99,6 +104,7 @@ public: | |||||||
|     void on_enter(IrdaApp* app) final; |     void on_enter(IrdaApp* app) final; | ||||||
|     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; |     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; | ||||||
|     void on_exit(IrdaApp* app) final; |     void on_exit(IrdaApp* app) final; | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     std::vector<std::string> buttons_names; |     std::vector<std::string> buttons_names; | ||||||
| }; | }; | ||||||
| @ -133,16 +139,20 @@ public: | |||||||
| 
 | 
 | ||||||
| class IrdaAppSceneUniversalCommon : public IrdaAppScene { | class IrdaAppSceneUniversalCommon : public IrdaAppScene { | ||||||
|     bool brute_force_started = false; |     bool brute_force_started = false; | ||||||
|  | 
 | ||||||
| protected: | protected: | ||||||
|     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; |     bool on_event(IrdaApp* app, IrdaAppEvent* event) final; | ||||||
|     void on_exit(IrdaApp* app) final; |     void on_exit(IrdaApp* app) final; | ||||||
|     IrdaAppBruteForce brute_force; |     IrdaAppBruteForce brute_force; | ||||||
|     void remove_popup(IrdaApp* app); |     void remove_popup(IrdaApp* app); | ||||||
|     void show_popup(IrdaApp* app, int record_amount); |     void show_popup(IrdaApp* app, int record_amount); | ||||||
|     void progress_popup(IrdaApp* app); |     bool progress_popup(IrdaApp* app); | ||||||
|     static void irda_app_item_callback(void* context, uint32_t index); |     static void irda_app_item_callback(void* context, uint32_t index); | ||||||
|     IrdaAppSceneUniversalCommon(const char* filename) : brute_force(filename) {} |     IrdaAppSceneUniversalCommon(const char* filename) | ||||||
|     ~IrdaAppSceneUniversalCommon() {} |         : brute_force(filename) { | ||||||
|  |     } | ||||||
|  |     ~IrdaAppSceneUniversalCommon() { | ||||||
|  |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class IrdaAppSceneUniversalTV : public IrdaAppSceneUniversalCommon { | class IrdaAppSceneUniversalTV : public IrdaAppSceneUniversalCommon { | ||||||
| @ -151,13 +161,16 @@ public: | |||||||
|     IrdaAppSceneUniversalTV() |     IrdaAppSceneUniversalTV() | ||||||
|         : IrdaAppSceneUniversalCommon("/ext/irda/universal/tv.ir") { |         : IrdaAppSceneUniversalCommon("/ext/irda/universal/tv.ir") { | ||||||
|     } |     } | ||||||
|     ~IrdaAppSceneUniversalTV() {} |     ~IrdaAppSceneUniversalTV() { | ||||||
|  |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class IrdaAppSceneUniversalAudio : public IrdaAppSceneUniversalCommon { | class IrdaAppSceneUniversalAudio : public IrdaAppSceneUniversalCommon { | ||||||
| public: | public: | ||||||
|     void on_enter(IrdaApp* app) final; |     void on_enter(IrdaApp* app) final; | ||||||
|     IrdaAppSceneUniversalAudio() : IrdaAppSceneUniversalCommon("/ext/irda/universal/audio.ir") {} |     IrdaAppSceneUniversalAudio() | ||||||
|     ~IrdaAppSceneUniversalAudio() {} |         : IrdaAppSceneUniversalCommon("/ext/irda/universal/audio.ir") { | ||||||
|  |     } | ||||||
|  |     ~IrdaAppSceneUniversalAudio() { | ||||||
|  |     } | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "api-hal-resources.h" | #include "furi-hal-resources.h" | ||||||
| #include "assets_icons.h" | #include "assets_icons.h" | ||||||
| #include "gui/canvas.h" | #include "gui/canvas.h" | ||||||
| #include "gui/view.h" | #include "gui/view.h" | ||||||
| @ -15,13 +15,15 @@ struct IrdaAppPopupBrut { | |||||||
|     char percents_string_storage[8]; |     char percents_string_storage[8]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| void popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut) { | bool popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut) { | ||||||
|     furi_assert(popup_brut); |     furi_assert(popup_brut); | ||||||
| 
 | 
 | ||||||
|     if(popup_brut->progress < popup_brut->progress_max) |     if(popup_brut->progress < popup_brut->progress_max) | ||||||
|         ++popup_brut->progress; |         ++popup_brut->progress; | ||||||
|     else |     else | ||||||
|         furi_assert(0); |         furi_assert(0); | ||||||
|  | 
 | ||||||
|  |     return popup_brut->progress < popup_brut->progress_max; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void popup_brut_draw_callback(Canvas* canvas, void* context) { | void popup_brut_draw_callback(Canvas* canvas, void* context) { | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ extern "C" { | |||||||
| 
 | 
 | ||||||
| typedef struct IrdaAppPopupBrut IrdaAppPopupBrut; | typedef struct IrdaAppPopupBrut IrdaAppPopupBrut; | ||||||
| 
 | 
 | ||||||
| void popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut); | bool popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut); | ||||||
| IrdaAppPopupBrut* popup_brut_alloc(); | IrdaAppPopupBrut* popup_brut_alloc(); | ||||||
| void popup_brut_free(IrdaAppPopupBrut* popup_brut); | void popup_brut_free(IrdaAppPopupBrut* popup_brut); | ||||||
| void popup_brut_draw_callback(Canvas* canvas, void* model); | void popup_brut_draw_callback(Canvas* canvas, void* model); | ||||||
|  | |||||||
| @ -4,8 +4,8 @@ | |||||||
| #include <irda_worker.h> | #include <irda_worker.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal-irda.h> | #include <furi-hal-irda.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include <gui/view_port.h> | #include <gui/view_port.h> | ||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| #include <gui/elements.h> | #include <gui/elements.h> | ||||||
| @ -58,7 +58,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s | |||||||
|     IrdaMonitor* irda_monitor = context; |     IrdaMonitor* irda_monitor = context; | ||||||
| 
 | 
 | ||||||
|     if(irda_worker_signal_is_decoded(received_signal)) { |     if(irda_worker_signal_is_decoded(received_signal)) { | ||||||
|         const IrdaMessage* message = irda_worker_get_decoded_message(received_signal); |         const IrdaMessage* message = irda_worker_get_decoded_signal(received_signal); | ||||||
|         snprintf( |         snprintf( | ||||||
|             irda_monitor->display_text, |             irda_monitor->display_text, | ||||||
|             sizeof(irda_monitor->display_text), |             sizeof(irda_monitor->display_text), | ||||||
| @ -112,10 +112,10 @@ int32_t irda_monitor_app(void* p) { | |||||||
|     gui_add_view_port(gui, irda_monitor->view_port, GuiLayerFullscreen); |     gui_add_view_port(gui, irda_monitor->view_port, GuiLayerFullscreen); | ||||||
| 
 | 
 | ||||||
|     irda_monitor->worker = irda_worker_alloc(); |     irda_monitor->worker = irda_worker_alloc(); | ||||||
|     irda_worker_set_context(irda_monitor->worker, irda_monitor); |     irda_worker_rx_start(irda_monitor->worker); | ||||||
|     irda_worker_start(irda_monitor->worker); |     irda_worker_rx_set_received_signal_callback( | ||||||
|     irda_worker_set_received_signal_callback(irda_monitor->worker, signal_received_callback); |         irda_monitor->worker, signal_received_callback, irda_monitor); | ||||||
|     irda_worker_enable_blink_on_receiving(irda_monitor->worker, true); |     irda_worker_rx_enable_blink_on_receiving(irda_monitor->worker, true); | ||||||
| 
 | 
 | ||||||
|     while(1) { |     while(1) { | ||||||
|         InputEvent event; |         InputEvent event; | ||||||
| @ -126,7 +126,7 @@ int32_t irda_monitor_app(void* p) { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     irda_worker_stop(irda_monitor->worker); |     irda_worker_rx_stop(irda_monitor->worker); | ||||||
|     irda_worker_free(irda_monitor->worker); |     irda_worker_free(irda_monitor->worker); | ||||||
|     osMessageQueueDelete(irda_monitor->event_queue); |     osMessageQueueDelete(irda_monitor->event_queue); | ||||||
|     view_port_enabled_set(irda_monitor->view_port, false); |     view_port_enabled_set(irda_monitor->view_port, false); | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #include <generic-scene.hpp> | #include <generic-scene.hpp> | ||||||
| #include <scene-controller.hpp> | #include <scene-controller.hpp> | ||||||
|  | |||||||
| @ -3,9 +3,9 @@ | |||||||
| void LfRfidDebugAppSceneTune::on_enter(LfRfidDebugApp* app, bool need_restore) { | void LfRfidDebugAppSceneTune::on_enter(LfRfidDebugApp* app, bool need_restore) { | ||||||
|     app->view_controller.switch_to<LfRfidViewTuneVM>(); |     app->view_controller.switch_to<LfRfidViewTuneVM>(); | ||||||
| 
 | 
 | ||||||
|     api_hal_rfid_pins_read(); |     furi_hal_rfid_pins_read(); | ||||||
|     api_hal_rfid_tim_read(125000, 0.5); |     furi_hal_rfid_tim_read(125000, 0.5); | ||||||
|     api_hal_rfid_tim_read_start(); |     furi_hal_rfid_tim_read_start(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) { | bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) { | ||||||
| @ -14,15 +14,15 @@ bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Even | |||||||
|     LfRfidViewTuneVM* tune = app->view_controller; |     LfRfidViewTuneVM* tune = app->view_controller; | ||||||
| 
 | 
 | ||||||
|     if(tune->is_dirty()) { |     if(tune->is_dirty()) { | ||||||
|         api_hal_rfid_set_read_period(tune->get_ARR()); |         furi_hal_rfid_set_read_period(tune->get_ARR()); | ||||||
|         api_hal_rfid_set_read_pulse(tune->get_CCR()); |         furi_hal_rfid_set_read_pulse(tune->get_CCR()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return consumed; |     return consumed; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LfRfidDebugAppSceneTune::on_exit(LfRfidDebugApp* app) { | void LfRfidDebugAppSceneTune::on_exit(LfRfidDebugApp* app) { | ||||||
|     api_hal_rfid_tim_read_stop(); |     furi_hal_rfid_tim_read_stop(); | ||||||
|     api_hal_rfid_tim_reset(); |     furi_hal_rfid_tim_reset(); | ||||||
|     api_hal_rfid_pins_reset(); |     furi_hal_rfid_pins_reset(); | ||||||
| } | } | ||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "decoder-analyzer.h" | #include "decoder-analyzer.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| bool DecoderAnalyzer::read(uint8_t* _data, uint8_t _data_size) { | bool DecoderAnalyzer::read(uint8_t* _data, uint8_t _data_size) { | ||||||
|     bool result = false; |     bool result = false; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #include "emmarine.h" | #include "emmarin.h" | ||||||
| #include "decoder-emmarine.h" | #include "decoder-emmarin.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| constexpr uint32_t clocks_in_us = 64; | constexpr uint32_t clocks_in_us = 64; | ||||||
| constexpr uint32_t short_time = 255 * clocks_in_us; | constexpr uint32_t short_time = 255 * clocks_in_us; | ||||||
| @ -13,19 +13,19 @@ constexpr uint32_t short_time_high = short_time + jitter_time; | |||||||
| constexpr uint32_t long_time_low = long_time - jitter_time; | constexpr uint32_t long_time_low = long_time - jitter_time; | ||||||
| constexpr uint32_t long_time_high = long_time + jitter_time; | constexpr uint32_t long_time_high = long_time + jitter_time; | ||||||
| 
 | 
 | ||||||
| void DecoderEMMarine::reset_state() { | void DecoderEMMarin::reset_state() { | ||||||
|     ready = false; |     ready = false; | ||||||
|     readed_data = 0; |     readed_data = 0; | ||||||
|     manchester_advance( |     manchester_advance( | ||||||
|         manchester_saved_state, ManchesterEventReset, &manchester_saved_state, nullptr); |         manchester_saved_state, ManchesterEventReset, &manchester_saved_state, nullptr); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool DecoderEMMarine::read(uint8_t* data, uint8_t data_size) { | bool DecoderEMMarin::read(uint8_t* data, uint8_t data_size) { | ||||||
|     bool result = false; |     bool result = false; | ||||||
| 
 | 
 | ||||||
|     if(ready) { |     if(ready) { | ||||||
|         result = true; |         result = true; | ||||||
|         em_marine.decode( |         em_marin.decode( | ||||||
|             reinterpret_cast<const uint8_t*>(&readed_data), sizeof(uint64_t), data, data_size); |             reinterpret_cast<const uint8_t*>(&readed_data), sizeof(uint64_t), data, data_size); | ||||||
|         ready = false; |         ready = false; | ||||||
|     } |     } | ||||||
| @ -33,7 +33,7 @@ bool DecoderEMMarine::read(uint8_t* data, uint8_t data_size) { | |||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DecoderEMMarine::process_front(bool polarity, uint32_t time) { | void DecoderEMMarin::process_front(bool polarity, uint32_t time) { | ||||||
|     if(ready) return; |     if(ready) return; | ||||||
|     if(time < short_time_low) return; |     if(time < short_time_low) return; | ||||||
| 
 | 
 | ||||||
| @ -61,12 +61,12 @@ void DecoderEMMarine::process_front(bool polarity, uint32_t time) { | |||||||
|         if(data_ok) { |         if(data_ok) { | ||||||
|             readed_data = (readed_data << 1) | data; |             readed_data = (readed_data << 1) | data; | ||||||
| 
 | 
 | ||||||
|             ready = em_marine.can_be_decoded( |             ready = em_marin.can_be_decoded( | ||||||
|                 reinterpret_cast<const uint8_t*>(&readed_data), sizeof(uint64_t)); |                 reinterpret_cast<const uint8_t*>(&readed_data), sizeof(uint64_t)); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| DecoderEMMarine::DecoderEMMarine() { | DecoderEMMarin::DecoderEMMarin() { | ||||||
|     reset_state(); |     reset_state(); | ||||||
| } | } | ||||||
| @ -3,12 +3,12 @@ | |||||||
| #include <atomic> | #include <atomic> | ||||||
| #include "manchester-decoder.h" | #include "manchester-decoder.h" | ||||||
| #include "protocols/protocol-emmarin.h" | #include "protocols/protocol-emmarin.h" | ||||||
| class DecoderEMMarine { | class DecoderEMMarin { | ||||||
| public: | public: | ||||||
|     bool read(uint8_t* data, uint8_t data_size); |     bool read(uint8_t* data, uint8_t data_size); | ||||||
|     void process_front(bool polarity, uint32_t time); |     void process_front(bool polarity, uint32_t time); | ||||||
| 
 | 
 | ||||||
|     DecoderEMMarine(); |     DecoderEMMarin(); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     void reset_state(); |     void reset_state(); | ||||||
| @ -17,5 +17,5 @@ private: | |||||||
|     std::atomic<bool> ready; |     std::atomic<bool> ready; | ||||||
| 
 | 
 | ||||||
|     ManchesterState manchester_saved_state; |     ManchesterState manchester_saved_state; | ||||||
|     ProtocolEMMarin em_marine; |     ProtocolEMMarin em_marin; | ||||||
| }; | }; | ||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "decoder-gpio-out.h" | #include "decoder-gpio-out.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| void DecoderGpioOut::process_front(bool polarity, uint32_t time) { | void DecoderGpioOut::process_front(bool polarity, uint32_t time) { | ||||||
|     hal_gpio_write(&gpio_ext_pa7, polarity); |     hal_gpio_write(&gpio_ext_pa7, polarity); | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| #include "decoder-hid26.h" | #include "decoder-hid26.h" | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| constexpr uint32_t clocks_in_us = 64; | constexpr uint32_t clocks_in_us = 64; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| #include "decoder-indala.h" | #include "decoder-indala.h" | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| constexpr uint32_t clocks_in_us = 64; | constexpr uint32_t clocks_in_us = 64; | ||||||
| constexpr uint32_t us_per_bit = 255; | constexpr uint32_t us_per_bit = 255; | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "encoder-emmarine.h" | #include "encoder-emmarin.h" | ||||||
| #include "protocols/protocol-emmarin.h" | #include "protocols/protocol-emmarin.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
| @ -20,7 +20,7 @@ const char* lfrfid_key_get_type_string(LfrfidKeyType type) { | |||||||
| const char* lfrfid_key_get_manufacturer_string(LfrfidKeyType type) { | const char* lfrfid_key_get_manufacturer_string(LfrfidKeyType type) { | ||||||
|     switch(type) { |     switch(type) { | ||||||
|     case LfrfidKeyType::KeyEM4100: |     case LfrfidKeyType::KeyEM4100: | ||||||
|         return "Em-Marine"; |         return "EM-Marin"; | ||||||
|         break; |         break; | ||||||
|     case LfrfidKeyType::KeyH10301: |     case LfrfidKeyType::KeyH10301: | ||||||
|         return "HID"; |         return "HID"; | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #include "rfid-reader.h" | #include "rfid-reader.h" | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <api-hal.h> | #include <furi-hal.h> | ||||||
| #include <stm32wbxx_ll_cortex.h> | #include <stm32wbxx_ll_cortex.h> | ||||||
| #include <tim.h> | #include <tim.h> | ||||||
| 
 | 
 | ||||||
| @ -20,7 +20,10 @@ void RfidReader::decode(bool polarity) { | |||||||
|     uint32_t period = current_dwt_value - last_dwt_value; |     uint32_t period = current_dwt_value - last_dwt_value; | ||||||
|     last_dwt_value = current_dwt_value; |     last_dwt_value = current_dwt_value; | ||||||
| 
 | 
 | ||||||
|     //decoder_gpio_out.process_front(polarity, period);
 | #ifdef RFID_GPIO_DEBUG | ||||||
|  |     decoder_gpio_out.process_front(polarity, period); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|     switch(type) { |     switch(type) { | ||||||
|     case Type::Normal: |     case Type::Normal: | ||||||
|         decoder_em.process_front(polarity, period); |         decoder_em.process_front(polarity, period); | ||||||
| @ -49,11 +52,11 @@ void RfidReader::switch_mode() { | |||||||
|     switch(type) { |     switch(type) { | ||||||
|     case Type::Normal: |     case Type::Normal: | ||||||
|         type = Type::Indala; |         type = Type::Indala; | ||||||
|         api_hal_rfid_change_read_config(62500.0f, 0.25f); |         furi_hal_rfid_change_read_config(62500.0f, 0.25f); | ||||||
|         break; |         break; | ||||||
|     case Type::Indala: |     case Type::Indala: | ||||||
|         type = Type::Normal; |         type = Type::Normal; | ||||||
|         api_hal_rfid_change_read_config(125000.0f, 0.5f); |         furi_hal_rfid_change_read_config(125000.0f, 0.5f); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -76,9 +79,9 @@ RfidReader::RfidReader() { | |||||||
| void RfidReader::start() { | void RfidReader::start() { | ||||||
|     type = Type::Normal; |     type = Type::Normal; | ||||||
| 
 | 
 | ||||||
|     api_hal_rfid_pins_read(); |     furi_hal_rfid_pins_read(); | ||||||
|     api_hal_rfid_tim_read(125000, 0.5); |     furi_hal_rfid_tim_read(125000, 0.5); | ||||||
|     api_hal_rfid_tim_read_start(); |     furi_hal_rfid_tim_read_start(); | ||||||
|     start_comparator(); |     start_comparator(); | ||||||
| 
 | 
 | ||||||
|     switch_timer_reset(); |     switch_timer_reset(); | ||||||
| @ -86,27 +89,16 @@ void RfidReader::start() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RfidReader::start_forced(RfidReader::Type _type) { | void RfidReader::start_forced(RfidReader::Type _type) { | ||||||
|     type = _type; |     start(); | ||||||
|     switch(type) { |     if(_type == Type::Indala) { | ||||||
|     case Type::Normal: |         switch_mode(); | ||||||
|         start(); |  | ||||||
|         break; |  | ||||||
|     case Type::Indala: |  | ||||||
|         api_hal_rfid_pins_read(); |  | ||||||
|         api_hal_rfid_tim_read(62500.0f, 0.25f); |  | ||||||
|         api_hal_rfid_tim_read_start(); |  | ||||||
|         start_comparator(); |  | ||||||
| 
 |  | ||||||
|         switch_timer_reset(); |  | ||||||
|         last_readed_count = 0; |  | ||||||
|         break; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RfidReader::stop() { | void RfidReader::stop() { | ||||||
|     api_hal_rfid_pins_reset(); |     furi_hal_rfid_pins_reset(); | ||||||
|     api_hal_rfid_tim_read_stop(); |     furi_hal_rfid_tim_read_stop(); | ||||||
|     api_hal_rfid_tim_reset(); |     furi_hal_rfid_tim_reset(); | ||||||
|     stop_comparator(); |     stop_comparator(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Aleksandr Kutuzov
						Aleksandr Kutuzov