MX vor 2 Jahren
Ursprung
Commit
1126bf860c
93 geänderte Dateien mit 2468 neuen und 1568 gelöschten Zeilen
  1. 8 0
      apps_source_code/dice/CHANGELOG.md
  2. 674 0
      apps_source_code/dice/LICENSE.md
  3. 21 8
      apps_source_code/dice/README.md
  4. 6 6
      apps_source_code/dice/application.fam
  5. BIN
      apps_source_code/dice/assets/ui_button_exit.png
  6. BIN
      apps_source_code/dice/assets/ui_button_history.png
  7. BIN
      apps_source_code/dice/assets/ui_result_1.png
  8. BIN
      apps_source_code/dice/assets/ui_result_2.png
  9. BIN
      apps_source_code/dice/assets/ui_result_3.png
  10. BIN
      apps_source_code/dice/assets/ui_result_border.png
  11. 89 3
      apps_source_code/dice/constants.h
  12. 191 59
      apps_source_code/dice/dice_app.c
  13. BIN
      apps_source_code/dice/sources/flipper-screen.png
  14. BIN
      apps_source_code/dice/sources/main-screen.png
  15. 0 0
      apps_source_code/dice/sources/result_border.pixil
  16. BIN
      apps_source_code/dice/sources/roll-screen.png
  17. 1 1
      apps_source_code/flipper_geiger/application.fam
  18. 178 95
      apps_source_code/flipper_geiger/flipper_geiger.c
  19. 2 3
      apps_source_code/t-rex-runner/README.md
  20. 17 8
      apps_source_code/t-rex-runner/trexrunner.c
  21. 1 0
      non_catalog_apps/FlipBIP/README.md
  22. 2 4
      non_catalog_apps/FlipBIP/application.fam
  23. 23 24
      non_catalog_apps/FlipBIP/flipbip.c
  24. 6 17
      non_catalog_apps/FlipBIP/flipbip.h
  25. 0 6
      non_catalog_apps/FlipBIP/helpers/flipbip_custom_event.h
  26. 0 35
      non_catalog_apps/FlipBIP/helpers/flipbip_haptic.c
  27. 0 7
      non_catalog_apps/FlipBIP/helpers/flipbip_haptic.h
  28. 0 39
      non_catalog_apps/FlipBIP/helpers/flipbip_led.c
  29. 0 2
      non_catalog_apps/FlipBIP/helpers/flipbip_led.h
  30. 0 27
      non_catalog_apps/FlipBIP/helpers/flipbip_speaker.c
  31. 0 4
      non_catalog_apps/FlipBIP/helpers/flipbip_speaker.h
  32. 1 0
      non_catalog_apps/FlipBIP/lib/crypto/CONTRIBUTORS
  33. 2 0
      non_catalog_apps/FlipBIP/lib/crypto/bip32.c
  34. 1 0
      non_catalog_apps/FlipBIP/lib/crypto/memzero.c
  35. 6 1
      non_catalog_apps/FlipBIP/lib/crypto/options.h
  36. 5 5
      non_catalog_apps/FlipBIP/lib/crypto/rand.c
  37. 1 0
      non_catalog_apps/FlipBIP/lib/crypto/rand.h
  38. 0 1
      non_catalog_apps/FlipBIP/scenes/flipbip_scene_config.h
  39. 32 4
      non_catalog_apps/FlipBIP/scenes/flipbip_scene_menu.c
  40. 21 11
      non_catalog_apps/FlipBIP/scenes/flipbip_scene_scene_1.c
  41. 0 46
      non_catalog_apps/FlipBIP/scenes/flipbip_scene_settings.c
  42. 0 55
      non_catalog_apps/FlipBIP/scenes/flipbip_scene_startscreen.c
  43. 27 18
      non_catalog_apps/FlipBIP/views/flipbip_scene_1.c
  44. 0 130
      non_catalog_apps/FlipBIP/views/flipbip_startscreen.c
  45. 0 19
      non_catalog_apps/FlipBIP/views/flipbip_startscreen.h
  46. 1 1
      non_catalog_apps/airmouse/application.fam
  47. 173 132
      non_catalog_apps/airmouse/tracking/main_loop.cc
  48. 1 1
      non_catalog_apps/airmouse/tracking/orientation_tracker.cc
  49. 8 5
      non_catalog_apps/airmouse/tracking/sensors/sensor_fusion_ekf.cc
  50. 49 45
      non_catalog_apps/airmouse/views/bt_mouse.c
  51. 3 3
      non_catalog_apps/esp32_gravity/application.fam
  52. 24 20
      non_catalog_apps/esp32_gravity/esp_flip_const.h
  53. 12 3
      non_catalog_apps/esp32_gravity/esp_flip_struct.h
  54. BIN
      non_catalog_apps/esp32_gravity/gravity-icon.png
  55. 18 8
      non_catalog_apps/esp32_gravity/scenes/uart_terminal_scene_console_output.c
  56. 176 146
      non_catalog_apps/esp32_gravity/scenes/uart_terminal_scene_start.c
  57. 68 59
      non_catalog_apps/esp32_gravity/scenes/uart_terminal_scene_text_input.c
  58. 4 2
      non_catalog_apps/esp32_gravity/uart_terminal_app_i.h
  59. 39 1
      non_catalog_apps/esubghz_chat/crypto_wrapper.c
  60. 10 0
      non_catalog_apps/esubghz_chat/crypto_wrapper.h
  61. 18 0
      non_catalog_apps/esubghz_chat/nfc_helpers.h
  62. 46 1
      non_catalog_apps/esubghz_chat/scenes/esubghz_chat_key_read_popup.c
  63. 43 2
      non_catalog_apps/esubghz_chat/scenes/esubghz_chat_key_share_popup.c
  64. 22 12
      non_catalog_apps/flipper_chronometer/flipper_chronometer.c
  65. 1 1
      non_catalog_apps/flipperscope/README.md
  66. 1 0
      non_catalog_apps/flipperscope/application.fam
  67. BIN
      non_catalog_apps/flipperscope/icons/pause_10x10.png
  68. BIN
      non_catalog_apps/flipperscope/icons/play_10x10.png
  69. 3 1
      non_catalog_apps/flipperscope/scenes/scope_scene_about.c
  70. 14 0
      non_catalog_apps/flipperscope/scenes/scope_scene_run.c
  71. 2 2
      non_catalog_apps/flipperscope/scope_app_i.h
  72. 6 5
      non_catalog_apps/ublox/README.md
  73. 5 1
      non_catalog_apps/ublox/application.fam
  74. 3 0
      non_catalog_apps/ublox/changelog.md
  75. 43 56
      non_catalog_apps/ublox/helpers/kml.c
  76. 0 2
      non_catalog_apps/ublox/helpers/kml.h
  77. 0 2
      non_catalog_apps/ublox/helpers/ublox_types.h
  78. 12 10
      non_catalog_apps/ublox/scenes/ublox_scene_about.c
  79. 25 25
      non_catalog_apps/ublox/scenes/ublox_scene_data_display.c
  80. 11 70
      non_catalog_apps/ublox/scenes/ublox_scene_data_display_config.c
  81. 25 34
      non_catalog_apps/ublox/scenes/ublox_scene_enter_file_name.c
  82. 7 3
      non_catalog_apps/ublox/scenes/ublox_scene_start.c
  83. 50 62
      non_catalog_apps/ublox/scenes/ublox_scene_sync_time.c
  84. BIN
      non_catalog_apps/ublox/screenshots/data_display_car.png
  85. BIN
      non_catalog_apps/ublox/screenshots/data_display_handheld.png
  86. BIN
      non_catalog_apps/ublox/screenshots/menu.png
  87. BIN
      non_catalog_apps/ublox/screenshots/sync_time.png
  88. 9 8
      non_catalog_apps/ublox/ublox.c
  89. 2 2
      non_catalog_apps/ublox/ublox_i.h
  90. 161 152
      non_catalog_apps/ublox/ublox_worker.c
  91. 1 1
      non_catalog_apps/ublox/ublox_worker.h
  92. 55 52
      non_catalog_apps/ublox/views/data_display_view.c
  93. 2 0
      non_catalog_apps/ublox/views/data_display_view.h

+ 8 - 0
apps_source_code/dice/CHANGELOG.md

@@ -0,0 +1,8 @@
+# Changelog
+
+## 1.1
+- Add history of dice rolls
+- UI fixes
+
+## 1
+- Initial release

+ 674 - 0
apps_source_code/dice/LICENSE.md

@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 21 - 8
apps_source_code/dice/README.md

@@ -1,16 +1,29 @@
-# Flipper Zero Dice App
+# Flipper Zero DnD Dice 
+Version: 1.1 ([Changelog](https://github.com/Ka3u6y6a/flipper-zero-dice/blob/main/CHANGELOG.md))
 
-<div style="text-align:center"><img src="sources/flipper-screen.png"/></div>
+<div style="text-align:center"><img src=".flipcorg/banner.png"/></div>
+<br />
+
+**DnD Dice** is a dice rolling application for your **Flipper Zero**.
+
+Dice types: Coin, d4, d6, d8, d10, d12, d20, d100
 
 ## Screenshots
 
-<div style="text-align:center"><img src="sources/main-screen.png"/></div>
- <br />
-<div style="text-align:center"><img src="sources/roll-screen.png"/></div>
+<div style="text-align:center"><img src=".flipcorg/gallery/1-main-screen.png"/></div>
+<br />
+<div style="text-align:center"><img src=".flipcorg/gallery/2-roll-screen.png"/></div>
+<br />
+<div style="text-align:center"><img src=".flipcorg/gallery/3-history-screen.png"/></div>
 
 ## Compiling
 
-1. Clone the [flipperzero-firmware](https://github.com/flipperdevices/flipperzero-firmware) repository or another firmware that you use.
+1. Go to [https://flipc.org/Ka3u6y6a/flipper-zero-dice](https://flipc.org/Ka3u6y6a/flipper-zero-dice?branch=main)
+2. Click **Install** or **Download** button
+
+OR
+
+1. Clone the [flipperzero-firmware](https://github.com/flipperdevices/flipperzero-firmware) repository or another firmware that you use (for example [unleashed-firmware](https://github.com/DarkFlippers/unleashed-firmware)).
 2. Create a symbolic link in `applications_user` named **dice**, pointing to this repository.
-3. Compile by command `./fbt fap_dice_app`
-4. Copy `build/f7-firmware-D/.extapps/dice_app.fap` to **apps/Tools** on the SD card  or by [qFlipper](https://flipperzero.one/update) app.
+3. Compile by command `./fbt fap_dice_dnd_app`
+4. Copy `build/f7-firmware-D/.extapps/dice_dnd_app.fap` to **apps/Games** on the SD card or by [qFlipper](https://flipperzero.one/update) app.

+ 6 - 6
apps_source_code/dice/application.fam

@@ -1,17 +1,17 @@
 App(
     appid="dice_app",
-    name="Dice",
+    name="Dice D&D",
     apptype=FlipperAppType.EXTERNAL,
-    entry_point="dice_tool_app",
-    cdefines=["APP_DICE"],
+    entry_point="dice_dnd_app",
+    cdefines=["APP_DICE_DND"],
     requires=["gui"],
     stack_size=1 * 1024,
     order=90,
-    fap_icon="icon.png",
+	fap_icon="icon.png",
     fap_category="Games",
     fap_icon_assets="assets",
     fap_author="@Ka3u6y6a",
     fap_weburl="https://github.com/Ka3u6y6a/flipper-zero-dice",
-    fap_version="1.0",
+    fap_version="1.1",
     fap_description="Dice rolling, types: Coin, d4, d6, d8, d10, d12, d20, d100",
-)
+)

BIN
apps_source_code/dice/assets/ui_button_exit.png


BIN
apps_source_code/dice/assets/ui_button_history.png


BIN
apps_source_code/dice/assets/ui_result_1.png


BIN
apps_source_code/dice/assets/ui_result_2.png


BIN
apps_source_code/dice/assets/ui_result_3.png


BIN
apps_source_code/dice/assets/ui_result_border.png


+ 89 - 3
apps_source_code/dice/constants.h

@@ -5,6 +5,14 @@
 
 #define DICE_TYPES 8
 
+#define HISTORY_SIZE 10
+#define HISTORY_COL HISTORY_SIZE / 2
+#define HISTORY_START_POST_X 2
+#define HISTORY_START_POST_Y 10
+#define HISTORY_STEP_X 66
+#define HISTORY_STEP_Y 10
+#define HISTORY_X_GAP 11
+
 #define MAX_DICE_COUNT 10
 #define MAX_COIN_FRAMES 9
 #define MAX_DICE_FRAMES 4
@@ -15,6 +23,9 @@
 
 #define DICE_GAP 44
 
+#define RESULT_BORDER_X 44
+#define RESULT_OFFSET 20
+
 #define SWIPE_DIST 11
 
 const Icon* coin_heads_start[] = {&I_coin_1, &I_coin_2};
@@ -33,6 +44,7 @@ const Icon* coin_frames[] = {
     &I_coin_1,
 };
 
+const int8_t result_frame_pos_y[] = {-30, -20, -10, 0};
 const Icon* dice_frames[] = {
     &I_d4_1,   &I_d4_2,   &I_d4_3,   &I_d4_1, // d4
     &I_d6_1,   &I_d6_2,   &I_d6_3,   &I_d6_4, // d6
@@ -43,6 +55,8 @@ const Icon* dice_frames[] = {
     &I_d100_1, &I_d100_2, &I_d100_3, &I_d100_4, // d100
 };
 
+const uint8_t screen_pos[] = {};
+
 typedef struct {
     uint8_t type;
     int x;
@@ -50,7 +64,11 @@ typedef struct {
     char* name;
 } Dice;
 
-const uint8_t screen_pos[] = {};
+typedef struct {
+    int8_t index;
+    uint8_t count;
+    uint8_t result;
+} History;
 
 static const Dice dice_types[] = {
     {2, 0, 0, "Coin"},
@@ -64,7 +82,15 @@ static const Dice dice_types[] = {
 };
 
 typedef enum { EventTypeTick, EventTypeKey } EventType;
-typedef enum { SelectState, SwipeLeftState, SwipeRightState, AnimState, ResultState } AppState;
+typedef enum {
+    SelectState,
+    SwipeLeftState,
+    SwipeRightState,
+    AnimState,
+    AnimResultState,
+    ResultState,
+    HistoryState,
+} AppState;
 
 typedef struct {
     EventType type;
@@ -72,14 +98,16 @@ typedef struct {
 } AppEvent;
 
 typedef struct {
-    FuriMutex* mutex;
     AppState app_state;
     uint16_t roll_result;
     uint8_t rolled_dices[MAX_DICE_COUNT];
     uint8_t anim_frame;
     uint8_t dice_index;
     uint8_t dice_count;
+    int8_t result_pos;
     Dice dices[DICE_TYPES];
+    History history[HISTORY_SIZE];
+    FuriMutex* mutex;
 } State;
 
 void init(State* const state) {
@@ -94,6 +122,33 @@ void init(State* const state) {
         state->dices[i].x = DICE_X + (i * DICE_GAP);
         state->dices[i].y = i == 0 ? DICE_Y_T : DICE_Y;
     }
+
+    for(uint8_t i = 0; i < HISTORY_SIZE; i++) {
+        state->history[i].index = -1;
+    }
+}
+
+void add_to_history(State* const state, uint8_t index, uint8_t count, uint8_t result) {
+    uint8_t last = HISTORY_SIZE - 1;
+    if(state->history[last].index >= 0) {
+        for(uint8_t i = 1; i < HISTORY_SIZE; i++) {
+            state->history[i - 1] = state->history[i];
+        }
+
+        state->history[last].index = index;
+        state->history[last].count = count;
+        state->history[last].result = result;
+        return;
+    }
+
+    for(uint8_t i = 0; i < HISTORY_SIZE; i++) {
+        if(state->history[i].index < 0) {
+            state->history[i].index = index;
+            state->history[i].count = count;
+            state->history[i].result = result;
+            return;
+        }
+    }
 }
 
 void coin_set_start(uint16_t type) {
@@ -114,4 +169,35 @@ void coin_set_end(uint16_t type) {
         coin_frames[MAX_COIN_FRAMES - 2] = coin_tails_end[0];
         coin_frames[MAX_COIN_FRAMES - 1] = coin_tails_end[1];
     }
+}
+
+bool isResultVisible(AppState state, uint8_t dice_index) {
+    return (state == ResultState || state == AnimResultState) && dice_index != 0;
+}
+
+bool isDiceNameVisible(AppState state) {
+    return state != SwipeLeftState && state != SwipeRightState;
+}
+
+bool isDiceButtonsVisible(AppState state) {
+    return isDiceNameVisible(state) && state != AnimResultState && state != ResultState &&
+           state != AnimState && state != HistoryState;
+}
+
+bool isOneDice(uint8_t dice_index) {
+    return dice_index == 0 || dice_index == 7;
+}
+
+bool isDiceSettingsDisabled(AppState state, uint8_t dice_index) {
+    return isOneDice(dice_index) || state == ResultState || state == AnimResultState ||
+           state == AnimState || state == HistoryState;
+}
+
+bool isAnimState(AppState state) {
+    return state == SwipeLeftState || state == SwipeRightState || state == AnimResultState ||
+           state == AnimState;
+}
+
+bool isMenuState(AppState state) {
+    return state == SwipeLeftState || state == SwipeRightState || state == SelectState;
 }

+ 191 - 59
apps_source_code/dice/dice_app.c

@@ -35,19 +35,35 @@ static void update(State* const state) {
 
             if(state->anim_frame >= MAX_COIN_FRAMES) {
                 state->anim_frame = 0;
-                state->app_state = ResultState;
+                state->app_state = AnimResultState;
             }
         } else {
             if(state->anim_frame >= MAX_DICE_FRAMES) {
                 state->anim_frame = 0;
-                state->app_state = ResultState;
+                state->app_state = AnimResultState;
             }
         }
+    } else if(state->app_state == AnimResultState) {
+        if(state->dice_index == 0) { // no extra animations for coin
+            state->anim_frame = 0;
+            state->app_state = ResultState;
+            return;
+        }
+
+        state->result_pos = result_frame_pos_y[state->anim_frame];
+        state->anim_frame += 1;
+
+        // end animation
+        if(state->result_pos == 0) {
+            state->anim_frame = 0;
+            state->app_state = ResultState;
+        }
     }
 }
 
 static void roll(State* const state) {
     state->roll_result = 0;
+    state->result_pos = result_frame_pos_y[0];
 
     for(uint8_t i = 0; i < MAX_DICE_COUNT; i++) {
         if(i < state->dice_count) {
@@ -60,57 +76,118 @@ static void roll(State* const state) {
 
     if(state->dice_index == 0) coin_set_end(state->roll_result); // change coin anim
 
+    add_to_history(state, state->dice_index, state->dice_count, state->roll_result);
     state->app_state = AnimState;
 }
 
-static void draw_ui(const State* state, Canvas* canvas) {
+static void draw_main_menu(const State* state, Canvas* canvas) {
     canvas_set_font(canvas, FontSecondary);
 
     FuriString* count = furi_string_alloc();
     furi_string_printf(count, "%01d", state->dice_count);
 
-    // dice name and arrows
-    if(state->app_state != SwipeLeftState && state->app_state != SwipeRightState) {
+    // dice name
+    if(isDiceNameVisible(state->app_state)) {
         canvas_draw_str_aligned(
             canvas, 63, 50, AlignCenter, AlignBottom, dice_types[state->dice_index].name);
-
-        if(state->dice_index > 0) canvas_draw_icon(canvas, 45, 44, &I_ui_button_left);
+    }
+    // dice arrow buttons
+    if(isDiceButtonsVisible(state->app_state)) {
+        if(state->dice_index > 0) canvas_draw_icon(canvas, 44, 44, &I_ui_button_left);
         if(state->dice_index < DICE_TYPES - 1)
             canvas_draw_icon(canvas, 78, 44, &I_ui_button_right);
     }
 
-    // dice settings
-    if(state->dice_index == 0)
+    // dice count settings
+    if(isDiceSettingsDisabled(state->app_state, state->dice_index))
         canvas_draw_icon(canvas, 48, 51, &I_ui_count_1);
     else
         canvas_draw_icon(canvas, 48, 51, &I_ui_count);
     canvas_draw_str_aligned(canvas, 58, 61, AlignCenter, AlignBottom, furi_string_get_cstr(count));
 
     // buttons
-    canvas_draw_icon(canvas, 92, 54, &I_ui_button_roll);
-    canvas_draw_icon(canvas, 0, 54, &I_ui_button_exit);
+    if(isAnimState(state->app_state) == false) {
+        canvas_draw_icon(canvas, 92, 54, &I_ui_button_roll);
+        canvas_draw_icon(canvas, 0, 54, &I_ui_button_history);
+    }
+
+    if(state->app_state == AnimResultState || state->app_state == ResultState) {
+        canvas_draw_icon(canvas, 0, 54, &I_ui_button_back);
+    }
 
     furi_string_free(count);
 }
 
+static void draw_history(const State* state, Canvas* canvas) {
+    canvas_set_font(canvas, FontSecondary);
+    FuriString* hist = furi_string_alloc();
+
+    uint8_t x = HISTORY_START_POST_X;
+    uint8_t y = HISTORY_START_POST_Y;
+    for(uint8_t i = 0; i < HISTORY_COL; i++) {
+        // left side
+        furi_string_printf(hist, "%01d.", i + 1);
+        canvas_draw_str_aligned(canvas, x, y, AlignLeft, AlignBottom, furi_string_get_cstr(hist));
+        if (state->history[i].index < 0) {
+            furi_string_printf(hist, "--------");
+        } else {
+            if (state->history[i].index == 0){
+                furi_string_printf(hist, state->history[i].result == 1 ? "Heads" : "Tails");
+            } else {
+                furi_string_printf(hist, "%01d%s: %01d", state->history[i].count, dice_types[state->history[i].index].name, state->history[i].result);
+            }
+        }
+        canvas_draw_str_aligned(canvas, x + HISTORY_X_GAP, y, AlignLeft, AlignBottom, furi_string_get_cstr(hist));
+
+        // right side
+        uint8_t r_index = i + HISTORY_COL;
+        furi_string_printf(hist, "%01d.", r_index + 1);
+        canvas_draw_str_aligned(canvas, x + HISTORY_STEP_X, y, AlignLeft, AlignBottom, furi_string_get_cstr(hist));
+        if (state->history[r_index].index < 0){
+            furi_string_printf(hist, "--------");
+        } else {
+            if (state->history[r_index].index == 0){
+                furi_string_printf(hist, state->history[r_index].result == 1 ? "Heads" : "Tails");
+            } else {
+                furi_string_printf(hist, "%01d%s: %01d", state->history[r_index].count, dice_types[state->history[r_index].index].name, state->history[r_index].result);
+            }
+        }
+        canvas_draw_str_aligned(canvas, x + HISTORY_STEP_X + HISTORY_X_GAP, y, AlignLeft, AlignBottom, furi_string_get_cstr(hist));
+
+        y += HISTORY_STEP_Y;
+    }
+
+    canvas_draw_icon(canvas, 0, 54, &I_ui_button_back);
+    canvas_draw_icon(canvas, 75, 54, &I_ui_button_exit);
+    furi_string_free(hist);
+}
+
 static void draw_dice(const State* state, Canvas* canvas) {
+    if(isMenuState(state->app_state) == false) { // draw only selected dice
+        if(state->dice_index == 0) { // coin
+            draw_dice_frame = coin_frames[state->anim_frame];
+        } else { // dices
+            draw_dice_frame =
+                dice_frames[(state->dice_index - 1) * MAX_DICE_FRAMES + state->anim_frame];
+        }
+
+        canvas_draw_icon(
+            canvas,
+            state->dices[state->dice_index].x,
+            state->dices[state->dice_index].y,
+            draw_dice_frame);
+        return;
+    }
+
     for(uint8_t i = 0; i < DICE_TYPES; i++) {
         if(state->app_state == ResultState && state->dice_index == i && state->dice_index != 0)
             continue; // draw results except coin
         if(state->dices[i].x > 128 || state->dices[i].x < -35) continue; // outside the screen
 
-        if(i == state->dice_index) { // draw dice with animation
-            if(i == 0) { // coin
-                draw_dice_frame = coin_frames[state->anim_frame];
-            } else { // dices
-                draw_dice_frame = dice_frames[(i - 1) * MAX_DICE_FRAMES + state->anim_frame];
-            }
-        } else { // draw first dice frame
-            if(i == 0) { // coin
-                draw_dice_frame = coin_frames[0];
-            } else { // dices
-                draw_dice_frame = dice_frames[(i - 1) * MAX_DICE_FRAMES];
-            }
+        if(i == 0) { // coin
+            draw_dice_frame = coin_frames[0];
+        } else { // dices
+            draw_dice_frame = dice_frames[(i - 1) * MAX_DICE_FRAMES];
         }
 
         canvas_draw_icon(canvas, state->dices[i].x, state->dices[i].y, draw_dice_frame);
@@ -118,37 +195,68 @@ static void draw_dice(const State* state, Canvas* canvas) {
 }
 
 static void draw_results(const State* state, Canvas* canvas) {
-    if(state->app_state != ResultState) return;
-    if(state->dice_index == 0) return; // skip for coin
-
     canvas_set_font(canvas, FontPrimary);
 
     FuriString* sum = furi_string_alloc();
     furi_string_printf(sum, "%01d", state->roll_result);
 
-    // result text
-    canvas_draw_str_aligned(canvas, 64, 20, AlignCenter, AlignCenter, furi_string_get_cstr(sum));
     // ui frame
-    if(state->roll_result > 99)
-        canvas_draw_icon(canvas, 52, 26, &I_ui_result_3);
-    else if(state->roll_result > 9)
-        canvas_draw_icon(canvas, 56, 26, &I_ui_result_2);
+    if(state->app_state == AnimResultState)
+        canvas_draw_icon(canvas, RESULT_BORDER_X, state->result_pos, &I_ui_result_border);
     else
-        canvas_draw_icon(canvas, 58, 26, &I_ui_result_1);
+        canvas_draw_icon(
+            canvas, RESULT_BORDER_X, result_frame_pos_y[MAX_DICE_FRAMES - 1], &I_ui_result_border);
+
+    // result text
+    canvas_draw_str_aligned(
+        canvas,
+        64,
+        state->result_pos + RESULT_OFFSET,
+        AlignCenter,
+        AlignCenter,
+        furi_string_get_cstr(sum));
+
+    if(state->app_state == ResultState && isOneDice(state->dice_index) == false) {
+        canvas_set_font(canvas, FontSecondary);
+
+        FuriString* dices = furi_string_alloc();
+        for(uint8_t i = 0; i < state->dice_count; i++) {
+            furi_string_cat_printf(dices, "%01d", state->rolled_dices[i]);
+
+            if(i != state->dice_count - 1) furi_string_cat_printf(dices, "%s", ", ");
+        }
+
+        canvas_draw_str_aligned(
+            canvas, 63, 37, AlignCenter, AlignCenter, furi_string_get_cstr(dices));
+        furi_string_free(dices);
+    }
 
     furi_string_free(sum);
 }
 
 static void draw_callback(Canvas* canvas, void* ctx) {
     furi_assert(ctx);
+
     const State* state = ctx;
     furi_mutex_acquire(state->mutex, FuriWaitForever);
 
+    if(state == NULL) {
+        return;
+    }
+
     canvas_clear(canvas);
 
-    draw_ui(state, canvas);
-    draw_dice(state, canvas);
-    draw_results(state, canvas);
+    if (state->app_state == HistoryState) {
+        draw_history(state, canvas);
+    } else {
+        draw_main_menu(state, canvas);
+
+        if(isResultVisible(state->app_state, state->dice_index)) {
+            draw_results(state, canvas);
+        } else {
+            draw_dice(state, canvas);
+        }
+    }
 
     furi_mutex_release(state->mutex);
 }
@@ -167,16 +275,16 @@ static void timer_callback(FuriMessageQueue* event_queue) {
     furi_message_queue_put(event_queue, &event, 0);
 }
 
-int32_t dice_tool_app(void* p) {
+int32_t dice_dnd_app(void* p) {
     UNUSED(p);
 
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(AppEvent));
 
-    FURI_LOG_E(TAG, ">>> Started...\r\n");
     State* state = malloc(sizeof(State));
     init(state);
 
     state->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
+
     if(!state->mutex) {
         FURI_LOG_E(TAG, "cannot create mutex\r\n");
         free(state);
@@ -208,41 +316,65 @@ int32_t dice_tool_app(void* p) {
             // button events
             if(event.type == EventTypeKey) {
                 if(event.input.type == InputTypePress) {
-                    // lock input while animations
-                    if(state->app_state == SelectState || state->app_state == ResultState) {
-                        // input
+                    // dice type
+                    if(isDiceButtonsVisible(state->app_state)) {
+                        if(event.input.key == InputKeyRight) {
+                            if(state->dice_index < DICE_TYPES - 1) {
+                                state->dice_index += 1;
+                                state->app_state = SwipeLeftState;
+                            }
+                        } else if(event.input.key == InputKeyLeft) {
+                            if(state->dice_index > 0) {
+                                state->dice_index -= 1;
+                                state->app_state = SwipeRightState;
+                            }
+                        }
+
+                        if(isOneDice(state->dice_index)) state->dice_count = 1;
+                    }
+                    // dice count
+                    if(isDiceSettingsDisabled(state->app_state, state->dice_index) == false &&
+                       isAnimState(state->app_state) == false) {
                         if(event.input.key == InputKeyUp) {
                             if(state->dice_index != 0) {
                                 state->dice_count += 1;
                                 if(state->dice_count > MAX_DICE_COUNT) {
-                                    state->dice_count = MAX_DICE_COUNT;
+                                    state->dice_count = 1;
                                 }
                             }
                         } else if(event.input.key == InputKeyDown) {
                             state->dice_count -= 1;
                             if(state->dice_count < 1) {
-                                state->dice_count = 1;
-                            }
-                        } else if(event.input.key == InputKeyRight) {
-                            if(state->dice_index < DICE_TYPES - 1) {
-                                state->dice_index += 1;
-                                state->app_state = SwipeLeftState;
-                            }
-                        } else if(event.input.key == InputKeyLeft) {
-                            if(state->dice_index > 0) {
-                                state->dice_index -= 1;
-                                state->app_state = SwipeRightState;
-                                if(state->dice_index == 0) state->dice_count = 1;
+                                state->dice_count = MAX_DICE_COUNT;
                             }
-                        } else if(event.input.key == InputKeyOk) {
-                            roll(state);
                         }
                     }
-                    // quit from app
-                    if(event.input.key == InputKeyBack) {
-                        processing = false;
+                    // roll
+                    if(event.input.key == InputKeyOk && isAnimState(state->app_state) == false) {
+                        roll(state);
                     }
                 }
+                
+                // back button handlers
+                if(event.input.key == InputKeyBack){
+                    // switch states
+                    if(event.input.type == InputTypeShort) {
+                        if(state->app_state == SelectState){
+                            state->app_state = HistoryState;
+                        }
+                        else if(state->app_state == HistoryState) {
+                            state->app_state = SelectState;
+                        }
+                        else if(state->app_state == ResultState || state->app_state == AnimResultState) {
+                            state->anim_frame = 0;
+                            state->app_state = SelectState;
+                        }
+                    }
+                    // exit
+                    else if(event.input.type == InputTypeLong) {
+                        processing = false;
+                    }
+                }                
             }
         }
 

BIN
apps_source_code/dice/sources/flipper-screen.png


BIN
apps_source_code/dice/sources/main-screen.png


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
apps_source_code/dice/sources/result_border.pixil


BIN
apps_source_code/dice/sources/roll-screen.png


+ 1 - 1
apps_source_code/flipper_geiger/application.fam

@@ -1,6 +1,6 @@
 App(
     appid="flipper_geiger",
-    name="Geiger counter",
+    name="Geiger Counter",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="flipper_geiger_app",
     cdefines=["APP_GEIGER"],

+ 178 - 95
apps_source_code/flipper_geiger/flipper_geiger.c

@@ -10,6 +10,7 @@
 #include <furi_hal_random.h>
 #include <furi_hal_pwm.h>
 #include <furi_hal_power.h>
+
 #include <storage/storage.h>
 #include <stream/buffered_file_stream.h>
 
@@ -35,51 +36,95 @@ typedef struct {
 typedef struct {
     FuriMutex* mutex;
     uint32_t cps, cpm;
-    uint32_t line[SCREEN_SIZE_X / 2];
+    uint32_t line[SCREEN_SIZE_X];
     float coef;
     uint8_t data;
+    uint8_t zoom;
+    uint8_t newLinePosition;
+    uint8_t version;
 } mutexStruct;
 
-static void draw_callback(Canvas* canvas, void* ctx) {
+static void draw_callback(Canvas* canvas, void* ctx) 
+{
     furi_assert(ctx);
 
-    mutexStruct displayStruct;
-    mutexStruct* geigerMutex = ctx;
-    furi_mutex_acquire(geigerMutex->mutex, FuriWaitForever);
-    memcpy(&displayStruct, geigerMutex, sizeof(mutexStruct));
-    furi_mutex_release(geigerMutex->mutex);
-
-    char buffer[32];
-    if(displayStruct.data == 0)
-        snprintf(
-            buffer, sizeof(buffer), "%ld cps - %ld cpm", displayStruct.cps, displayStruct.cpm);
-    else if(displayStruct.data == 1)
-        snprintf(
-            buffer,
-            sizeof(buffer),
-            "%ld cps - %.2f uSv/h",
-            displayStruct.cps,
-            ((double)displayStruct.cpm * (double)CONVERSION_FACTOR));
+    mutexStruct* mutexVal = ctx;
+    mutexStruct mutexDraw;
+    furi_mutex_acquire(mutexVal->mutex, FuriWaitForever);
+    memcpy(&mutexDraw, mutexVal, sizeof(mutexStruct));
+    furi_mutex_release(mutexVal->mutex);
+
+    if (mutexDraw.version == 0)
+    {
+        char buffer[32];
+        if (mutexDraw.data == 0) snprintf(buffer, sizeof(buffer), "%ld cps - %ld cpm", mutexDraw.cps, mutexDraw.cpm);
+        else if (mutexDraw.data == 1) snprintf(buffer, sizeof(buffer), "%ld cps - %.2f uSv/h", mutexDraw.cps, ((double)mutexDraw.cpm*(double)CONVERSION_FACTOR));
+        else if (mutexDraw.data == 2) snprintf(buffer, sizeof(buffer), "%ld cps - %.2f mSv/y", mutexDraw.cps, (((double)mutexDraw.cpm*(double)CONVERSION_FACTOR))*(double)8.76);
+        else if (mutexDraw.data == 3) snprintf(buffer, sizeof(buffer), "%ld cps - %.4f Rad/h", mutexDraw.cps, ((double)mutexDraw.cpm*(double)CONVERSION_FACTOR)/(double)10000);
+        else if (mutexDraw.data == 4) snprintf(buffer, sizeof(buffer), "%ld cps - %.2f mR/h", mutexDraw.cps, ((double)mutexDraw.cpm*(double)CONVERSION_FACTOR)/(double)10);
+        else snprintf(buffer, sizeof(buffer), "%ld cps - %.2f uR/h", mutexDraw.cps, ((double)mutexDraw.cpm*(double)CONVERSION_FACTOR)*(double)100);
+
+        canvas_set_font(canvas, FontPrimary);
+        canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignBottom, buffer);
+
+        uint8_t linePosition = mutexDraw.newLinePosition;
+
+        if (mutexDraw.zoom == 0)
+        {
+            for (int i=0;i<SCREEN_SIZE_X;i+=8)
+            {
+                if (linePosition != 0) linePosition--;
+                else linePosition = SCREEN_SIZE_X - 1;
+
+                float Y = SCREEN_SIZE_Y-(mutexDraw.line[linePosition]*mutexDraw.coef);
+                for (int j=0;j<8;j++)canvas_draw_line(canvas, i+j, Y, i+j, SCREEN_SIZE_Y);
+            }
+        }
+        else if (mutexDraw.zoom == 1)
+        {
+            for (int i=0;i<SCREEN_SIZE_X;i+=4)
+            {
+                if (linePosition != 0) linePosition--;
+                else linePosition = SCREEN_SIZE_X - 1;
+
+                float Y = SCREEN_SIZE_Y-(mutexDraw.line[linePosition]*mutexDraw.coef);
+                for (int j=0;j<4;j++)canvas_draw_line(canvas, i+j, Y, i+j, SCREEN_SIZE_Y);
+            }
+        }
+        else if (mutexDraw.zoom == 2)
+        {
+            for (int i=0;i<SCREEN_SIZE_X;i+=2)
+            {
+                if (linePosition != 0) linePosition--;
+                else linePosition = SCREEN_SIZE_X - 1;
+
+                float Y = SCREEN_SIZE_Y-(mutexDraw.line[linePosition]*mutexDraw.coef);
+                for (int j=0;j<2;j++)canvas_draw_line(canvas, i+j, Y, i+j, SCREEN_SIZE_Y);
+            }
+        }
+        else if (mutexDraw.zoom == 3)
+        {
+            for (int i=0;i<SCREEN_SIZE_X;i++)
+            {
+                if (linePosition != 0) linePosition--;
+                else linePosition = SCREEN_SIZE_X - 1;
+
+                float Y = SCREEN_SIZE_Y-(mutexDraw.line[linePosition]*mutexDraw.coef);
+                canvas_draw_line(canvas, i, Y, i, SCREEN_SIZE_Y);
+            }
+        }
+    }
     else
-        snprintf(
-            buffer,
-            sizeof(buffer),
-            "%ld cps - %.2f mSv/y",
-            displayStruct.cps,
-            (((double)displayStruct.cpm * (double)CONVERSION_FACTOR)) * (double)8.76);
-
-    for(int i = 0; i < SCREEN_SIZE_X; i += 2) {
-        float Y = SCREEN_SIZE_Y - (displayStruct.line[i / 2] * displayStruct.coef);
-
-        canvas_draw_line(canvas, i, Y, i, SCREEN_SIZE_Y);
-        canvas_draw_line(canvas, i + 1, Y, i + 1, SCREEN_SIZE_Y);
+    {
+        canvas_set_font(canvas, FontPrimary);
+        canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignBottom, "Geiger Counter");
+        canvas_draw_str_aligned(canvas, 64, 20, AlignCenter, AlignBottom, "Version 20230806");
+        canvas_draw_str_aligned(canvas, 64, 40, AlignCenter, AlignBottom, "github.com/nmrr");
     }
-
-    canvas_set_font(canvas, FontPrimary);
-    canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignBottom, buffer);
 }
 
-static void input_callback(InputEvent* input_event, void* ctx) {
+static void input_callback(InputEvent* input_event, void* ctx) 
+{
     furi_assert(ctx);
     FuriMessageQueue* event_queue = ctx;
     EventApp event = {.type = EventTypeInput, .input = *input_event};
@@ -91,7 +136,7 @@ static void clock_tick(void* ctx) {
 
     uint32_t randomNumber = furi_hal_random_get();
     randomNumber &= 0xFFF;
-    if(randomNumber == 0) randomNumber = 1;
+    if (randomNumber == 0) randomNumber = 1;
 
     furi_hal_pwm_set_params(FuriHalPwmOutputIdLptim2PA4, randomNumber, 50);
 
@@ -107,8 +152,8 @@ static void gpiocallback(void* ctx) {
     furi_message_queue_put(queue, &event, 0);
 }
 
-int32_t flipper_geiger_app(void* p) {
-    UNUSED(p);
+int32_t flipper_geiger_app() 
+{
     EventApp event;
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(EventApp));
 
@@ -118,20 +163,23 @@ int32_t flipper_geiger_app(void* p) {
     mutexStruct mutexVal;
     mutexVal.cps = 0;
     mutexVal.cpm = 0;
-    for(int i = 0; i < SCREEN_SIZE_X / 2; i++) mutexVal.line[i] = 0;
+    for (int i=0;i<SCREEN_SIZE_X;i++) mutexVal.line[i] = 0;
     mutexVal.coef = 1;
     mutexVal.data = 0;
+    mutexVal.zoom = 2;
+    mutexVal.newLinePosition = 0;
+    mutexVal.version = 0;
 
     uint32_t counter = 0;
 
-    mutexVal.mutex = furi_mutex_alloc(FuriMutexTypeNormal);
+    mutexVal.mutex= furi_mutex_alloc(FuriMutexTypeNormal);
     if(!mutexVal.mutex) {
         furi_message_queue_free(event_queue);
         return 255;
     }
 
     ViewPort* view_port = view_port_alloc();
-    view_port_draw_callback_set(view_port, draw_callback, &mutexVal);
+    view_port_draw_callback_set(view_port, draw_callback, &mutexVal.mutex);
     view_port_input_callback_set(view_port, input_callback, event_queue);
 
     furi_hal_gpio_add_int_callback(&gpio_ext_pa7, gpiocallback, event_queue);
@@ -159,117 +207,152 @@ int32_t flipper_geiger_app(void* p) {
 
     NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
 
-    while(1) {
+    while(1) 
+    {
         FuriStatus event_status = furi_message_queue_get(event_queue, &event, FuriWaitForever);
-
+        
         uint8_t screenRefresh = 0;
 
-        if(event_status == FuriStatusOk) {
-            if(event.type == EventTypeInput) {
-                if(event.input.key == InputKeyBack) {
+        if (event_status == FuriStatusOk)
+        {   
+            if(event.type == EventTypeInput) 
+            {
+                if(event.input.key == InputKeyBack && event.input.type == InputTypeLong) 
+                {
                     break;
-                } else if(event.input.key == InputKeyOk && event.input.type == InputTypeShort) {
+                }
+                else if(event.input.key == InputKeyOk && event.input.type == InputTypeLong)
+                {
                     counter = 0;
                     furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
 
                     mutexVal.cps = 0;
                     mutexVal.cpm = 0;
-                    for(int i = 0; i < SCREEN_SIZE_X / 2; i++) mutexVal.line[i] = 0;
+                    for (uint8_t i=0;i<SCREEN_SIZE_X;i++) mutexVal.line[i] = 0;
+                    mutexVal.newLinePosition = 0;
 
                     screenRefresh = 1;
                     furi_mutex_release(mutexVal.mutex);
-                } else if(event.input.key == InputKeyUp && event.input.type == InputTypeLong) {
-                    if(recordData == 0) {
+                }
+                else if(event.input.key == InputKeyUp && event.input.type == InputTypeLong)
+                {
+                    if (recordData == 0) 
+                    {
                         notification_message(notification, &sequence_set_only_red_255);
 
                         FuriHalRtcDateTime datetime;
                         furi_hal_rtc_get_datetime(&datetime);
 
                         char path[64];
-                        snprintf(
-                            path,
-                            sizeof(path),
-                            EXT_PATH("/geiger-%.4d-%.2d-%.2d--%.2d-%.2d-%.2d.csv"),
-                            datetime.year,
-                            datetime.month,
-                            datetime.day,
-                            datetime.hour,
-                            datetime.minute,
-                            datetime.second);
-
-                        buffered_file_stream_open(
-                            file_stream, path, FSAM_WRITE, FSOM_CREATE_ALWAYS);
+                        snprintf(path, sizeof(path), EXT_PATH("/geiger-%.4d-%.2d-%.2d--%.2d-%.2d-%.2d.csv"), datetime.year, datetime.month, datetime.day, datetime.hour, datetime.minute, datetime.second);
+
+                        buffered_file_stream_open(file_stream, path, FSAM_WRITE, FSOM_CREATE_ALWAYS);
                         furi_string_printf(dataString, "epoch,cps\n");
                         stream_write_string(file_stream, dataString);
                         epoch = 0;
                         recordData = 1;
-                    } else {
+                    }
+                    else
+                    {
                         buffered_file_stream_close(file_stream);
                         notification_message(notification, &sequence_reset_red);
                         recordData = 0;
                     }
-                } else if((event.input.key == InputKeyLeft &&
-                           event.input.type == InputTypeShort)) {
+                }
+                else if((event.input.key == InputKeyLeft && event.input.type == InputTypeShort))
+                {
                     furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
 
-                    if(mutexVal.data != 0)
-                        mutexVal.data--;
-                    else
-                        mutexVal.data = 2;
+                    if (mutexVal.data != 0) mutexVal.data--;
+                    else mutexVal.data = 5;
 
                     screenRefresh = 1;
                     furi_mutex_release(mutexVal.mutex);
-                } else if((event.input.key == InputKeyRight &&
-                           event.input.type == InputTypeShort)) {
+                }
+                else if((event.input.key == InputKeyRight && event.input.type == InputTypeShort))
+                {
                     furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
 
-                    if(mutexVal.data != 2)
-                        mutexVal.data++;
-                    else
-                        mutexVal.data = 0;
+                    if (mutexVal.data != 5) mutexVal.data++;
+                    else mutexVal.data = 0;
 
                     screenRefresh = 1;
                     furi_mutex_release(mutexVal.mutex);
                 }
-            } else if(event.type == ClockEventTypeTick) {
-                furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
+                else if((event.input.key == InputKeyUp && event.input.type == InputTypeShort))
+                {
+                    furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
+                    if (mutexVal.zoom != 0) mutexVal.zoom--;
+
+                    screenRefresh = 1;
+                    furi_mutex_release(mutexVal.mutex);
 
-                if(recordData == 1) {
+                }
+                else if((event.input.key == InputKeyDown && event.input.type == InputTypeShort))
+                {
+                    furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
+                    if (mutexVal.zoom != 3) mutexVal.zoom++;
+
+                    screenRefresh = 1;
+                    furi_mutex_release(mutexVal.mutex);
+                }
+                else if((event.input.key == InputKeyDown && event.input.type == InputTypeLong))
+                {
+                    furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
+                    if (mutexVal.version == 0) mutexVal.version = 1;
+                    else mutexVal.version = 0;
+
+                    screenRefresh = 1;
+                    furi_mutex_release(mutexVal.mutex);
+                }
+            }
+            else if (event.type == ClockEventTypeTick)
+            {
+                if (recordData == 1)
+                {
                     furi_string_printf(dataString, "%lu,%lu\n", epoch++, counter);
                     stream_write_string(file_stream, dataString);
                 }
 
-                for(int i = 0; i < SCREEN_SIZE_X / 2 - 1; i++)
-                    mutexVal.line[SCREEN_SIZE_X / 2 - 1 - i] =
-                        mutexVal.line[SCREEN_SIZE_X / 2 - 2 - i];
+                furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
 
-                mutexVal.line[0] = counter;
+                mutexVal.line[mutexVal.newLinePosition] = counter;
                 mutexVal.cps = counter;
                 counter = 0;
 
-                mutexVal.cpm = mutexVal.line[0];
-                uint32_t max = mutexVal.line[0];
-                for(int i = 1; i < SCREEN_SIZE_X / 2; i++) {
-                    if(i < 60) mutexVal.cpm += mutexVal.line[i];
-                    if(mutexVal.line[i] > max) max = mutexVal.line[i];
+                mutexVal.cpm = mutexVal.line[mutexVal.newLinePosition];
+                uint32_t max = mutexVal.line[mutexVal.newLinePosition];
+                uint8_t linePosition = mutexVal.newLinePosition;
+
+                for (int i=1;i<SCREEN_SIZE_X;i++)
+                {
+                    if (linePosition != 0) linePosition--;
+                    else linePosition = SCREEN_SIZE_X - 1;
+
+                    if (i < 60) mutexVal.cpm += mutexVal.line[linePosition];
+                    if (mutexVal.line[linePosition] > max) max = mutexVal.line[linePosition];
                 }
 
-                if(max > 0)
-                    mutexVal.coef = ((float)(SCREEN_SIZE_Y - 15)) / ((float)max);
-                else
-                    mutexVal.coef = 1;
+                if (max > 0) mutexVal.coef = ((float)(SCREEN_SIZE_Y-15))/((float)max);
+                else mutexVal.coef = 1;
+
+                if (mutexVal.newLinePosition != SCREEN_SIZE_X - 1) mutexVal.newLinePosition++;
+                else mutexVal.newLinePosition = 0;
 
                 screenRefresh = 1;
                 furi_mutex_release(mutexVal.mutex);
-            } else if(event.type == EventGPIO) {
+            }
+            else if (event.type == EventGPIO)
+            {
                 counter++;
             }
         }
 
-        if(screenRefresh == 1) view_port_update(view_port);
+        if (screenRefresh == 1) view_port_update(view_port);
     }
 
-    if(recordData == 1) {
+    if (recordData == 1) 
+    {
         buffered_file_stream_close(file_stream);
         notification_message(notification, &sequence_reset_red);
     }

+ 2 - 3
apps_source_code/t-rex-runner/README.md

@@ -4,14 +4,13 @@ Flipper Zero port of Chrome's running T-rex game
 ## Improvements
 - Added command to move DINO
 - Added gravity
-- Added (boring) cactus spawn
 - Added lose condition and lose screen
 - Added moving background
 - Added score system
+- Random cactus spawn
+- Increase cactus speed with time
 
 ## TODO
-- More random cactus spawn
-- Increase cactus speed with time
 - Fix background speed with cactus
 - Allow to play again without the need to close the game in the lose screen
 

+ 17 - 8
apps_source_code/t-rex-runner/trexrunner.c

@@ -1,5 +1,6 @@
 #include <furi.h>
 #include <furi_hal.h>
+#include <furi_hal_random.h>
 #include <gui/gui.h>
 #include <gui/icon_i.h>
 #include <gui/elements.h>
@@ -21,7 +22,8 @@
 
 #define CACTUS_W 10
 #define CACTUS_H 10
-#define START_x_speed 25
+#define START_x_speed 35
+#define X_INCREASE 3
 
 #define BACKGROUND_W 128
 #define BACKGROUND_H 12
@@ -100,16 +102,23 @@ static void timer_callback(void* ctx) {
     // Update Cactus state
     if(game_state->has_cactus) {
         game_state->cactus_position =
-            game_state->cactus_position - game_state->x_speed * delta_time_ms / 1000;
+            game_state->cactus_position - (game_state->x_speed - 15) * delta_time_ms / 1000;
         if(game_state->cactus_position <= 0) {
             game_state->has_cactus = 0;
             game_state->score = game_state->score + 1;
+
+            // Increase speed
+            game_state->x_speed = game_state->x_speed + X_INCREASE;
         }
     }
-    // Create cactus (not random)
+    // Create cactus (random frame in 1.5s)
     else {
-        game_state->has_cactus = 1;
-        game_state->cactus_position = 120;
+        uint8_t randomuint8[1];
+        furi_hal_random_fill_buf(randomuint8, 1);
+        if(randomuint8[0] % 30 == 0) {
+            game_state->has_cactus = 1;
+            game_state->cactus_position = 120;
+        }
     }
 
     // Move horizontal line
@@ -119,9 +128,9 @@ static void timer_callback(void* ctx) {
         game_state->background_position - game_state->x_speed * delta_time_ms / 1000;
 
     // Lose condition
-    if((game_state->y_position + 22 >= (64 - CACTUS_H)) &&
-       ((DINO_START_X + 20) >= game_state->cactus_position) &&
-       (DINO_START_X <= (game_state->cactus_position + CACTUS_W)))
+    if(game_state->has_cactus && ((game_state->y_position + 22 >= (64 - CACTUS_H)) &&
+                                  ((DINO_START_X + 20) >= game_state->cactus_position) &&
+                                  (DINO_START_X <= (game_state->cactus_position + CACTUS_W))))
         game_state->lost = 1;
 
     furi_mutex_release(game_state->mutex);

+ 1 - 0
non_catalog_apps/FlipBIP/README.md

@@ -22,6 +22,7 @@ The goal of this project is to see how much crypto functionality can be brought
   - Generation of offline `m/44'/0'/0'/0` BTC wallet
   - Generation of offline `m/44'/60'/0'/0` ETH wallet (coded from the $SPORK Castle of ETHDenver 2023!)
   - Generation of offline `m/44'/3'/0'/0` DOGE wallet
+  - Generation of offline `m/44'/133'/0'/0` ZEC transparent address wallet (by @wh00hw)
   - Similar features to: https://iancoleman.io/bip39/
 - Saving wallets to SD card
   - Wallets are saved to SD card upon creation in `apps_data/flipbip`

+ 2 - 4
non_catalog_apps/FlipBIP/application.fam

@@ -9,8 +9,6 @@ App(
     stack_size=3 * 1024,
     order=10,
     fap_icon="flipbip_10px.png",
-    fap_icon_assets="icons",
-    fap_icon_assets_symbol="flipbip",
     fap_private_libs=[
         Lib(
             name="crypto",
@@ -19,6 +17,6 @@ App(
     fap_category="Tools",
     fap_author="Struan Clark (xtruan)",
     fap_weburl="https://github.com/xtruan/FlipBIP",
-    fap_version=(1, 11),
-    fap_description="Crypto wallet tools for Flipper",
+    fap_version=(1, 13),
+    fap_description="Crypto wallet for Flipper",
 )

+ 23 - 24
non_catalog_apps/FlipBIP/flipbip.c

@@ -1,12 +1,13 @@
-#pragma GCC optimize("-Os")
-
 #include "flipbip.h"
 #include "helpers/flipbip_file.h"
-#include "helpers/flipbip_haptic.h"
 // From: lib/crypto
 #include <memzero.h>
 #include <bip39.h>
 
+#define MNEMONIC_MENU_DEFAULT "Import mnemonic seed"
+#define MNEMONIC_MENU_SUCCESS "Import seed (success)"
+#define MNEMONIC_MENU_FAILURE "Import seed (failed!)"
+
 bool flipbip_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
     FlipBip* app = context;
@@ -42,6 +43,7 @@ static void text_input_callback(void* context) {
             // reset input state
             app->input_state = FlipBipTextInputDefault;
             handled = true;
+            // switch back to settings view
             view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings);
         } else if(app->input_state == FlipBipTextInputMnemonic) {
             if(app->import_from_mnemonic == 1) {
@@ -56,11 +58,13 @@ static void text_input_callback(void* context) {
                     status = FlipBipStatusSaveError; // 12 = save error
 
                 if(status == FlipBipStatusSuccess) {
+                    app->mnemonic_menu_text = MNEMONIC_MENU_SUCCESS;
                     //notification_message(app->notification, &sequence_blink_cyan_100);
-                    flipbip_play_happy_bump(app);
+                    //flipbip_play_happy_bump(app);
                 } else {
+                    app->mnemonic_menu_text = MNEMONIC_MENU_FAILURE;
                     //notification_message(app->notification, &sequence_blink_red_100);
-                    flipbip_play_long_bump(app);
+                    //flipbip_play_long_bump(app);
                 }
 
                 memzero(app->import_mnemonic_text, TEXT_BUFFER_SIZE);
@@ -70,7 +74,9 @@ static void text_input_callback(void* context) {
             // reset input state
             app->input_state = FlipBipTextInputDefault;
             handled = true;
-            view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
+            // exit scene 1 instance that's being used for text input and go back to menu
+            scene_manager_previous_scene(app->scene_manager);
+            //view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
         }
     }
 
@@ -79,6 +85,7 @@ static void text_input_callback(void* context) {
         memzero(app->input_text, TEXT_BUFFER_SIZE);
         // reset input state
         app->input_state = FlipBipTextInputDefault;
+        // something went wrong, switch to menu view
         view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
     }
 }
@@ -86,12 +93,12 @@ static void text_input_callback(void* context) {
 FlipBip* flipbip_app_alloc() {
     FlipBip* app = malloc(sizeof(FlipBip));
     app->gui = furi_record_open(RECORD_GUI);
-    app->notification = furi_record_open(RECORD_NOTIFICATION);
+    //app->notification = furi_record_open(RECORD_NOTIFICATION);
 
-    //Turn backlight on, believe me this makes testing your app easier
-    notification_message(app->notification, &sequence_display_backlight_on);
+    // Turn backlight on, believe me this makes testing your app easier
+    //notification_message(app->notification, &sequence_display_backlight_on);
 
-    //Scene additions
+    // Scene additions
     app->view_dispatcher = view_dispatcher_alloc();
     view_dispatcher_enable_queue(app->view_dispatcher);
 
@@ -105,8 +112,6 @@ FlipBip* flipbip_app_alloc() {
     app->submenu = submenu_alloc();
 
     // Settings
-    app->haptic = FlipBipHapticOn;
-    app->led = FlipBipLedOn;
     app->bip39_strength = FlipBipStrength256; // 256 bits (24 words)
     app->passphrase = FlipBipPassphraseOff;
 
@@ -114,17 +119,13 @@ FlipBip* flipbip_app_alloc() {
     app->bip44_coin = FlipBipCoinBTC0; // 0 (BTC)
     app->overwrite_saved_seed = 0;
     app->import_from_mnemonic = 0;
+    app->mnemonic_menu_text = MNEMONIC_MENU_DEFAULT;
 
     // Text input
     app->input_state = FlipBipTextInputDefault;
 
     view_dispatcher_add_view(
         app->view_dispatcher, FlipBipViewIdMenu, submenu_get_view(app->submenu));
-    app->flipbip_startscreen = flipbip_startscreen_alloc();
-    view_dispatcher_add_view(
-        app->view_dispatcher,
-        FlipBipViewIdStartscreen,
-        flipbip_startscreen_get_view(app->flipbip_startscreen));
     app->flipbip_scene_1 = flipbip_scene_1_alloc();
     view_dispatcher_add_view(
         app->view_dispatcher, FlipBipViewIdScene1, flipbip_scene_1_get_view(app->flipbip_scene_1));
@@ -141,13 +142,13 @@ FlipBip* flipbip_app_alloc() {
         (void*)app,
         app->input_text,
         TEXT_BUFFER_SIZE,
-        //clear default text
+        // clear default text
         true);
-    text_input_set_header_text(app->text_input, "Input");
+    //text_input_set_header_text(app->text_input, "Input");
     view_dispatcher_add_view(
         app->view_dispatcher, FlipBipViewIdTextInput, text_input_get_view(app->text_input));
 
-    //End Scene Additions
+    // End Scene Additions
 
     return app;
 }
@@ -171,7 +172,7 @@ void flipbip_app_free(FlipBip* app) {
     furi_record_close(RECORD_GUI);
 
     app->gui = NULL;
-    app->notification = NULL;
+    //app->notification = NULL;
 
     //Remove whatever is left
     memzero(app, sizeof(FlipBip));
@@ -190,9 +191,7 @@ int32_t flipbip_app(void* p) {
 
     view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
 
-    scene_manager_next_scene(
-        app->scene_manager, FlipBipSceneStartscreen); //Start with start screen
-    //scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //if you want to directly start with Menu
+    scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //Start with menu
 
     furi_hal_power_suppress_charge_enter();
 

+ 6 - 17
non_catalog_apps/FlipBIP/flipbip.h

@@ -5,37 +5,35 @@
 #include <gui/gui.h>
 #include <input/input.h>
 #include <stdlib.h>
-#include <notification/notification_messages.h>
+//#include <notification/notification_messages.h>
 #include <gui/view_dispatcher.h>
 #include <gui/modules/submenu.h>
 #include <gui/scene_manager.h>
 #include <gui/modules/variable_item_list.h>
 #include <gui/modules/text_input.h>
 #include "scenes/flipbip_scene.h"
-#include "views/flipbip_startscreen.h"
 #include "views/flipbip_scene_1.h"
 
-#define FLIPBIP_VERSION "v1.11.0"
+#define FLIPBIP_VERSION "v1.13"
 
 #define COIN_BTC 0
 #define COIN_DOGE 3
 #define COIN_ETH 60
+#define COIN_ZEC 133
 
 #define TEXT_BUFFER_SIZE 256
 
 typedef struct {
     Gui* gui;
-    NotificationApp* notification;
+    // NotificationApp* notification;
     ViewDispatcher* view_dispatcher;
     Submenu* submenu;
     SceneManager* scene_manager;
     VariableItemList* variable_item_list;
     TextInput* text_input;
-    FlipBipStartscreen* flipbip_startscreen;
     FlipBipScene1* flipbip_scene_1;
+    char* mnemonic_menu_text;
     // Settings options
-    int haptic;
-    int led;
     int bip39_strength;
     int passphrase;
     // Main menu options
@@ -57,16 +55,6 @@ typedef enum {
     FlipBipViewIdTextInput,
 } FlipBipViewId;
 
-typedef enum {
-    FlipBipHapticOff,
-    FlipBipHapticOn,
-} FlipBipHapticState;
-
-typedef enum {
-    FlipBipLedOff,
-    FlipBipLedOn,
-} FlipBipLedState;
-
 typedef enum {
     FlipBipStrength128,
     FlipBipStrength192,
@@ -82,6 +70,7 @@ typedef enum {
     FlipBipCoinBTC0,
     FlipBipCoinETH60,
     FlipBipCoinDOGE3,
+    FlipBipCoinZEC133,
 } FlipBipCoin;
 
 typedef enum {

+ 0 - 6
non_catalog_apps/FlipBIP/helpers/flipbip_custom_event.h

@@ -1,12 +1,6 @@
 #pragma once
 
 typedef enum {
-    FlipBipCustomEventStartscreenUp,
-    FlipBipCustomEventStartscreenDown,
-    FlipBipCustomEventStartscreenLeft,
-    FlipBipCustomEventStartscreenRight,
-    FlipBipCustomEventStartscreenOk,
-    FlipBipCustomEventStartscreenBack,
     FlipBipCustomEventScene1Up,
     FlipBipCustomEventScene1Down,
     FlipBipCustomEventScene1Left,

+ 0 - 35
non_catalog_apps/FlipBIP/helpers/flipbip_haptic.c

@@ -1,35 +0,0 @@
-#include "flipbip_haptic.h"
-#include "../flipbip.h"
-
-void flipbip_play_happy_bump(void* context) {
-    FlipBip* app = context;
-    if(app->haptic != 1) {
-        return;
-    }
-    notification_message(app->notification, &sequence_set_vibro_on);
-    furi_thread_flags_wait(0, FuriFlagWaitAny, 20);
-    notification_message(app->notification, &sequence_reset_vibro);
-}
-
-void flipbip_play_bad_bump(void* context) {
-    FlipBip* app = context;
-    if(app->haptic != 1) {
-        return;
-    }
-    notification_message(app->notification, &sequence_set_vibro_on);
-    furi_thread_flags_wait(0, FuriFlagWaitAny, 100);
-    notification_message(app->notification, &sequence_reset_vibro);
-}
-
-void flipbip_play_long_bump(void* context) {
-    FlipBip* app = context;
-    if(app->haptic != 1) {
-        return;
-    }
-    for(int i = 0; i < 4; i++) {
-        notification_message(app->notification, &sequence_set_vibro_on);
-        furi_thread_flags_wait(0, FuriFlagWaitAny, 50);
-        notification_message(app->notification, &sequence_reset_vibro);
-        furi_thread_flags_wait(0, FuriFlagWaitAny, 100);
-    }
-}

+ 0 - 7
non_catalog_apps/FlipBIP/helpers/flipbip_haptic.h

@@ -1,7 +0,0 @@
-#include <notification/notification_messages.h>
-
-void flipbip_play_happy_bump(void* context);
-
-void flipbip_play_bad_bump(void* context);
-
-void flipbip_play_long_bump(void* context);

+ 0 - 39
non_catalog_apps/FlipBIP/helpers/flipbip_led.c

@@ -1,39 +0,0 @@
-#include "flipbip_led.h"
-#include "../flipbip.h"
-
-void flipbip_led_set_rgb(void* context, int red, int green, int blue) {
-    FlipBip* app = context;
-    if(app->led != 1) {
-        return;
-    }
-    NotificationMessage notification_led_message_1;
-    notification_led_message_1.type = NotificationMessageTypeLedRed;
-    NotificationMessage notification_led_message_2;
-    notification_led_message_2.type = NotificationMessageTypeLedGreen;
-    NotificationMessage notification_led_message_3;
-    notification_led_message_3.type = NotificationMessageTypeLedBlue;
-
-    notification_led_message_1.data.led.value = red;
-    notification_led_message_2.data.led.value = green;
-    notification_led_message_3.data.led.value = blue;
-    const NotificationSequence notification_sequence = {
-        &notification_led_message_1,
-        &notification_led_message_2,
-        &notification_led_message_3,
-        &message_do_not_reset,
-        NULL,
-    };
-    notification_message(app->notification, &notification_sequence);
-    furi_thread_flags_wait(
-        0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
-}
-
-void flipbip_led_reset(void* context) {
-    FlipBip* app = context;
-    notification_message(app->notification, &sequence_reset_red);
-    notification_message(app->notification, &sequence_reset_green);
-    notification_message(app->notification, &sequence_reset_blue);
-
-    furi_thread_flags_wait(
-        0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set
-}

+ 0 - 2
non_catalog_apps/FlipBIP/helpers/flipbip_led.h

@@ -1,2 +0,0 @@
-void flipbip_led_set_rgb(void* context, int red, int green, int blue);
-void flipbip_led_reset(void* context);

+ 0 - 27
non_catalog_apps/FlipBIP/helpers/flipbip_speaker.c

@@ -1,27 +0,0 @@
-// #include "flipbip_speaker.h"
-// #include "../flipbip.h"
-
-// #define NOTE_INPUT 587.33f
-
-// void flipbip_play_input_sound(void* context) {
-//     FlipBip* app = context;
-//     if (app->speaker != 1) {
-//         return;
-//     }
-//     float volume = 1.0f;
-//     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
-//         furi_hal_speaker_start(NOTE_INPUT, volume);
-//     }
-
-// }
-
-// void flipbip_stop_all_sound(void* context) {
-//     FlipBip* app = context;
-//     if (app->speaker != 1) {
-//         return;
-//     }
-//     if(furi_hal_speaker_is_mine()) {
-//         furi_hal_speaker_stop();
-//         furi_hal_speaker_release();
-//     }
-// }

+ 0 - 4
non_catalog_apps/FlipBIP/helpers/flipbip_speaker.h

@@ -1,4 +0,0 @@
-// #define NOTE_INPUT 587.33f
-
-// void flipbip_play_input_sound(void* context);
-// void flipbip_stop_all_sound(void* context);

+ 1 - 0
non_catalog_apps/FlipBIP/lib/crypto/CONTRIBUTORS

@@ -14,3 +14,4 @@ Oleg Andreev <oleganza@gmail.com>
 mog <mog@rush.rldn.net>
 John Dvorak <johndvorak26@gmail.com>
 Christian Reitter <invd@inhq.net>
+Struan Clark <xtruan@users.noreply.github.com>

+ 2 - 0
non_catalog_apps/FlipBIP/lib/crypto/bip32.c

@@ -26,7 +26,9 @@
 #include <string.h>
 
 #include "address.h"
+#if USE_NEM
 #include "aes/aes.h"
+#endif
 #include "base58.h"
 #include "bignum.h"
 #include "bip32.h"

+ 1 - 0
non_catalog_apps/FlipBIP/lib/crypto/memzero.c

@@ -50,6 +50,7 @@ void memzero(void* const pnt, const size_t len) {
     SecureZeroMemory(pnt, len);
 #elif defined(HAVE_MEMSET_S)
     memset_s(pnt, (rsize_t)len, 0, (rsize_t)len);
+// REMOVED - Flipper Zero does not have this function
 // #elif defined(HAVE_EXPLICIT_BZERO)
 //   explicit_bzero(pnt, len);
 #elif defined(HAVE_EXPLICIT_MEMSET)

+ 6 - 1
non_catalog_apps/FlipBIP/lib/crypto/options.h

@@ -86,9 +86,14 @@
 #define USE_KECCAK 1
 #endif
 
-// add way how to mark confidential data
+// add a way to mark confidential data
 #ifndef CONFIDENTIAL
 #define CONFIDENTIAL
 #endif
 
+// use Flipper Zero hardware random number generator
+#ifndef USE_FLIPPER_HAL_RANDOM
+#define USE_FLIPPER_HAL_RANDOM 1
+#endif
+
 #endif

+ 5 - 5
non_catalog_apps/FlipBIP/lib/crypto/rand.c

@@ -21,11 +21,9 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#define FLIPPER_HAL_RANDOM
-
 #include "rand.h"
 
-#ifdef FLIPPER_HAL_RANDOM
+#if USE_FLIPPER_HAL_RANDOM
 
 // NOTE:
 // random32() and random_buffer() have been replaced in this implementation
@@ -67,6 +65,8 @@ void random_buffer(uint8_t* buf, size_t len) {
 // The following code is platform independent
 //
 
+static uint32_t seed = 0;
+
 uint32_t random32(void) {
   // Linear congruential generator from Numerical Recipes
   // https://en.wikipedia.org/wiki/Linear_congruential_generator
@@ -74,7 +74,7 @@ uint32_t random32(void) {
   return seed;
 }
 
-void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) {
+void random_buffer(uint8_t *buf, size_t len) {
   uint32_t r = 0;
   for (size_t i = 0; i < len; i++) {
     if (i % 4 == 0) {
@@ -84,7 +84,7 @@ void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) {
   }
 }
 
-#endif /* FLIPPER_HAL_RANDOM */
+#endif /* USE_FLIPPER_HAL_RANDOM */
 
 uint32_t random_uniform(uint32_t n) {
     uint32_t x = 0, max = 0xFFFFFFFF - (0xFFFFFFFF % n);

+ 1 - 0
non_catalog_apps/FlipBIP/lib/crypto/rand.h

@@ -26,6 +26,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include "options.h"
 
 void random_reseed(const uint32_t value);
 uint32_t random32(void);

+ 0 - 1
non_catalog_apps/FlipBIP/scenes/flipbip_scene_config.h

@@ -1,4 +1,3 @@
-ADD_SCENE(flipbip, startscreen, Startscreen)
 ADD_SCENE(flipbip, menu, Menu)
 ADD_SCENE(flipbip, scene_1, Scene_1)
 ADD_SCENE(flipbip, settings, Settings)

+ 32 - 4
non_catalog_apps/FlipBIP/scenes/flipbip_scene_menu.c

@@ -1,13 +1,17 @@
 #include "../flipbip.h"
 #include "../helpers/flipbip_file.h"
 
+#define FLIPBIP_SUBMENU_TEXT "** FlipBIP wallet " FLIPBIP_VERSION " **"
+
 enum SubmenuIndex {
     SubmenuIndexScene1BTC = 10,
     SubmenuIndexScene1ETH,
     SubmenuIndexScene1DOGE,
+    SubmenuIndexScene1ZEC,
     SubmenuIndexScene1New,
     SubmenuIndexScene1Import,
     SubmenuIndexSettings,
+    SubmenuIndexNOP,
 };
 
 void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) {
@@ -18,6 +22,14 @@ void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) {
 void flipbip_scene_menu_on_enter(void* context) {
     FlipBip* app = context;
 
+    // FlipBIP header with version
+    submenu_add_item(
+        app->submenu,
+        FLIPBIP_SUBMENU_TEXT,
+        SubmenuIndexNOP,
+        flipbip_scene_menu_submenu_callback,
+        app);
+
     if(flipbip_has_file(FlipBipFileKey, NULL, false) &&
        flipbip_has_file(FlipBipFileDat, NULL, false)) {
         submenu_add_item(
@@ -38,6 +50,12 @@ void flipbip_scene_menu_on_enter(void* context) {
             SubmenuIndexScene1DOGE,
             flipbip_scene_menu_submenu_callback,
             app);
+        submenu_add_item(
+            app->submenu,
+            "View ZEC (t-addr) wallet",
+            SubmenuIndexScene1ZEC,
+            flipbip_scene_menu_submenu_callback,
+            app);
         submenu_add_item(
             app->submenu,
             "Regenerate wallet",
@@ -54,7 +72,7 @@ void flipbip_scene_menu_on_enter(void* context) {
     }
     submenu_add_item(
         app->submenu,
-        "Import from mnemonic",
+        app->mnemonic_menu_text,
         SubmenuIndexScene1Import,
         flipbip_scene_menu_submenu_callback,
         app);
@@ -101,6 +119,14 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
                 app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1DOGE);
             scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
             return true;
+        } else if(event.event == SubmenuIndexScene1ZEC) {
+            app->overwrite_saved_seed = 0;
+            app->import_from_mnemonic = 0;
+            app->bip44_coin = FlipBipCoinZEC133;
+            scene_manager_set_scene_state(
+                app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1ZEC);
+            scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
+            return true;
         } else if(event.event == SubmenuIndexScene1New) {
             app->overwrite_saved_seed = 1;
             app->import_from_mnemonic = 0;
@@ -110,15 +136,17 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
             return true;
         } else if(event.event == SubmenuIndexScene1Import) {
             app->import_from_mnemonic = 1;
-            app->input_state = FlipBipTextInputMnemonic;
-            text_input_set_header_text(app->text_input, "Enter mnemonic phrase");
-            view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdTextInput);
+            scene_manager_set_scene_state(
+                app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1Import);
+            scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
             return true;
         } else if(event.event == SubmenuIndexSettings) {
             scene_manager_set_scene_state(
                 app->scene_manager, FlipBipSceneMenu, SubmenuIndexSettings);
             scene_manager_next_scene(app->scene_manager, FlipBipSceneSettings);
             return true;
+        } else if(event.event == SubmenuIndexNOP) {
+            return true;
         }
     }
     return false;

+ 21 - 11
non_catalog_apps/FlipBIP/scenes/flipbip_scene_scene_1.c

@@ -11,8 +11,18 @@ void flipbip_scene_1_callback(FlipBipCustomEvent event, void* context) {
 void flipbip_scene_scene_1_on_enter(void* context) {
     furi_assert(context);
     FlipBip* app = context;
-    flipbip_scene_1_set_callback(app->flipbip_scene_1, flipbip_scene_1_callback, app);
-    view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdScene1);
+
+    if(app->import_from_mnemonic == 1) {
+        // handle mnemonic seed import mode with text input, this only
+        // uses this scene to have a correct stack of scenes
+        app->input_state = FlipBipTextInputMnemonic;
+        text_input_set_header_text(app->text_input, "Enter mnemonic phrase");
+        view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdTextInput);
+    } else {
+        // handle all other modes, these actually use this scene's logic
+        flipbip_scene_1_set_callback(app->flipbip_scene_1, flipbip_scene_1_callback, app);
+        view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdScene1);
+    }
 }
 
 bool flipbip_scene_scene_1_on_event(void* context, SceneManagerEvent event) {
@@ -21,16 +31,16 @@ bool flipbip_scene_scene_1_on_event(void* context, SceneManagerEvent event) {
 
     if(event.type == SceneManagerEventTypeCustom) {
         switch(event.event) {
-        case FlipBipCustomEventScene1Left:
-        case FlipBipCustomEventScene1Right:
-            break;
-        case FlipBipCustomEventScene1Up:
-        case FlipBipCustomEventScene1Down:
-            break;
+        // case FlipBipCustomEventScene1Left:
+        // case FlipBipCustomEventScene1Right:
+        //     break;
+        // case FlipBipCustomEventScene1Up:
+        // case FlipBipCustomEventScene1Down:
+        //     break;
         case FlipBipCustomEventScene1Back:
-            notification_message(app->notification, &sequence_reset_red);
-            notification_message(app->notification, &sequence_reset_green);
-            notification_message(app->notification, &sequence_reset_blue);
+            //notification_message(app->notification, &sequence_reset_red);
+            //notification_message(app->notification, &sequence_reset_green);
+            //notification_message(app->notification, &sequence_reset_blue);
             if(!scene_manager_search_and_switch_to_previous_scene(
                    app->scene_manager, FlipBipSceneMenu)) {
                 scene_manager_stop(app->scene_manager);

+ 0 - 46
non_catalog_apps/FlipBIP/scenes/flipbip_scene_settings.c

@@ -6,24 +6,6 @@
 #define TEXT_LABEL_ON "ON"
 #define TEXT_LABEL_OFF "OFF"
 
-const char* const haptic_text[2] = {
-    TEXT_LABEL_OFF,
-    TEXT_LABEL_ON,
-};
-const uint32_t haptic_value[2] = {
-    FlipBipHapticOff,
-    FlipBipHapticOn,
-};
-
-const char* const led_text[2] = {
-    TEXT_LABEL_OFF,
-    TEXT_LABEL_ON,
-};
-const uint32_t led_value[2] = {
-    FlipBipLedOff,
-    FlipBipLedOn,
-};
-
 const char* const bip39_strength_text[3] = {
     "12",
     "18",
@@ -44,20 +26,6 @@ const uint32_t passphrase_value[2] = {
     FlipBipPassphraseOn,
 };
 
-static void flipbip_scene_settings_set_haptic(VariableItem* item) {
-    FlipBip* app = variable_item_get_context(item);
-    uint8_t index = variable_item_get_current_value_index(item);
-    variable_item_set_current_value_text(item, haptic_text[index]);
-    app->haptic = haptic_value[index];
-}
-
-static void flipbip_scene_settings_set_led(VariableItem* item) {
-    FlipBip* app = variable_item_get_context(item);
-    uint8_t index = variable_item_get_current_value_index(item);
-    variable_item_set_current_value_text(item, led_text[index]);
-    app->led = led_value[index];
-}
-
 static void flipbip_scene_settings_set_bip39_strength(VariableItem* item) {
     FlipBip* app = variable_item_get_context(item);
     uint8_t index = variable_item_get_current_value_index(item);
@@ -108,20 +76,6 @@ void flipbip_scene_settings_on_enter(void* context) {
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, passphrase_text[value_index]);
 
-    // Vibro on/off
-    item = variable_item_list_add(
-        app->variable_item_list, "Vibro/Haptic:", 2, flipbip_scene_settings_set_haptic, app);
-    value_index = value_index_uint32(app->haptic, haptic_value, 2);
-    variable_item_set_current_value_index(item, value_index);
-    variable_item_set_current_value_text(item, haptic_text[value_index]);
-
-    // LED Effects on/off
-    item = variable_item_list_add(
-        app->variable_item_list, "LED FX:", 2, flipbip_scene_settings_set_led, app);
-    value_index = value_index_uint32(app->led, led_value, 2);
-    variable_item_set_current_value_index(item, value_index);
-    variable_item_set_current_value_text(item, led_text[value_index]);
-
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings);
 }
 

+ 0 - 55
non_catalog_apps/FlipBIP/scenes/flipbip_scene_startscreen.c

@@ -1,55 +0,0 @@
-#include "../flipbip.h"
-#include "../helpers/flipbip_custom_event.h"
-#include "../views/flipbip_startscreen.h"
-
-void flipbip_scene_startscreen_callback(FlipBipCustomEvent event, void* context) {
-    furi_assert(context);
-    FlipBip* app = context;
-    view_dispatcher_send_custom_event(app->view_dispatcher, event);
-}
-
-void flipbip_scene_startscreen_on_enter(void* context) {
-    furi_assert(context);
-    FlipBip* app = context;
-    flipbip_startscreen_set_callback(
-        app->flipbip_startscreen, flipbip_scene_startscreen_callback, app);
-    view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdStartscreen);
-}
-
-bool flipbip_scene_startscreen_on_event(void* context, SceneManagerEvent event) {
-    FlipBip* app = context;
-    bool consumed = false;
-
-    if(event.type == SceneManagerEventTypeCustom) {
-        switch(event.event) {
-        case FlipBipCustomEventStartscreenLeft:
-        case FlipBipCustomEventStartscreenRight:
-            break;
-        case FlipBipCustomEventStartscreenUp:
-        case FlipBipCustomEventStartscreenDown:
-            break;
-        case FlipBipCustomEventStartscreenOk:
-            scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu);
-            consumed = true;
-            break;
-        case FlipBipCustomEventStartscreenBack:
-            notification_message(app->notification, &sequence_reset_red);
-            notification_message(app->notification, &sequence_reset_green);
-            notification_message(app->notification, &sequence_reset_blue);
-            if(!scene_manager_search_and_switch_to_previous_scene(
-                   app->scene_manager, FlipBipSceneStartscreen)) {
-                scene_manager_stop(app->scene_manager);
-                view_dispatcher_stop(app->view_dispatcher);
-            }
-            consumed = true;
-            break;
-        }
-    }
-
-    return consumed;
-}
-
-void flipbip_scene_startscreen_on_exit(void* context) {
-    FlipBip* app = context;
-    UNUSED(app);
-}

+ 27 - 18
non_catalog_apps/FlipBIP/views/flipbip_scene_1.c

@@ -3,12 +3,9 @@
 #include <furi_hal.h>
 #include <input/input.h>
 #include <gui/elements.h>
-//#include <dolphin/dolphin.h>
 #include <storage/storage.h>
 #include <string.h>
-#include "flipbip_icons.h"
-#include "../helpers/flipbip_haptic.h"
-#include "../helpers/flipbip_led.h"
+//#include "flipbip_icons.h"
 #include "../helpers/flipbip_string.h"
 #include "../helpers/flipbip_file.h"
 // From: /lib/crypto
@@ -43,7 +40,7 @@
 #define TEXT_NEW_WALLET "New wallet"
 #define TEXT_DEFAULT_COIN "Coin"
 #define TEXT_RECEIVE_ADDRESS "receive address:"
-#define TEXT_DEFAULT_DERIV "m/44'/X'/0'/0"
+// #define TEXT_DEFAULT_DERIV "m/44'/X'/0'/0"
 const char* TEXT_INFO = "-Scroll pages with up/down-"
                         "p1,2)   BIP39 Mnemonic/Seed"
                         "p3)       BIP32 Root Key   "
@@ -55,16 +52,19 @@ const char* TEXT_INFO = "-Scroll pages with up/down-"
 #define TEXT_QRFILE_EXT ".qrcode" // 7 chars + 1 null
 
 // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
-const uint32_t COIN_INFO_ARRAY[3][6] = {
+const uint32_t COIN_INFO_ARRAY[4][6] = {
     {COIN_BTC, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinBTC0},
     {COIN_ETH, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinETH60},
-    {COIN_DOGE, 0x02fac398, 0x02facafd, 0x1e, 0x9e, FlipBipCoinBTC0}};
+    {COIN_DOGE, 0x02fac398, 0x02facafd, 0x1e, 0x9e, FlipBipCoinBTC0},
+    {COIN_ZEC, 0x0488ade4, 0x0488b21e, 0x1cb8, 0x80, FlipBipCoinZEC133},
+};
 
 // coin_name, derivation_path
-const char* COIN_TEXT_ARRAY[3][3] = {
+const char* COIN_TEXT_ARRAY[4][3] = {
     {"BTC", "m/44'/0'/0'/0", "bitcoin:"},
     {"ETH", "m/44'/60'/0'/0", "ethereum:"},
-    {"DOGE", "m/44'/3'/0'/0", "dogecoin:"}};
+    {"DOGE", "m/44'/3'/0'/0", "dogecoin:"},
+    {"ZEC", "m/44'/133'/0'/0", "zcash:"}};
 
 struct FlipBipScene1 {
     View* view;
@@ -98,7 +98,7 @@ static CONFIDENTIAL char* s_disp_text4 = NULL;
 static CONFIDENTIAL char* s_disp_text5 = NULL;
 static CONFIDENTIAL char* s_disp_text6 = NULL;
 // Derivation path text
-static const char* s_derivation_text = TEXT_DEFAULT_DERIV;
+static const char* s_derivation_text = TEXT_DEFAULT_COIN; // TEXT_DEFAULT_DERIV;
 // Warning text
 static bool s_warn_insecure = false;
 #define WARN_INSECURE_TEXT_1 "Recommendation:"
@@ -147,7 +147,6 @@ static void flipbip_scene_1_init_address(
         ecdsa_get_address(
             s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen);
         strcpy(addr_text, buf);
-
         //ecdsa_get_wif(addr_node->private_key, WIF_VERSION, HASHER_SHA2D, buf, buflen);
 
     } else if(coin_info[5] == FlipBipCoinETH60) { // ETH
@@ -157,6 +156,12 @@ static void flipbip_scene_1_init_address(
         addr_text[1] = 'x';
         // Convert the hash to a hex string
         flipbip_btox((uint8_t*)buf, 20, addr_text + 2);
+
+    } else if(coin_info[5] == FlipBipCoinZEC133) { // ZEC
+        ecdsa_get_address(
+            s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen);
+        addr_text[0] = 't';
+        strcpy(addr_text, buf);
     }
 
     // Clear the address node
@@ -311,7 +316,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {
         canvas_set_font(canvas, FontPrimary);
         canvas_draw_str(canvas, 2, 10, TEXT_LOADING);
         canvas_draw_str(canvas, 7, 30, s_derivation_text);
-        canvas_draw_icon(canvas, 86, 22, &I_Keychain_39x36);
+        // canvas_draw_icon(canvas, 86, 22, &I_Keychain_39x36);
         if(s_warn_insecure) {
             canvas_set_font(canvas, FontSecondary);
             canvas_draw_str(canvas, 2, 50, WARN_INSECURE_TEXT_1);
@@ -654,9 +659,12 @@ void flipbip_scene_1_enter(void* context) {
         s_derivation_text = TEXT_NEW_WALLET;
     }
 
-    flipbip_play_happy_bump(app);
+    // Wait a beat to allow the display time to update to the loading screen
+    furi_thread_flags_wait(0, FuriFlagWaitAny, 20);
+
+    //flipbip_play_happy_bump(app);
     //notification_message(app->notification, &sequence_blink_cyan_100);
-    flipbip_led_set_rgb(app, 255, 0, 0);
+    //flipbip_led_set_rgb(app, 255, 0, 0);
 
     with_view_model(
         instance->view,
@@ -669,7 +677,8 @@ void flipbip_scene_1_enter(void* context) {
 
             // nonzero status, free the mnemonic
             if(status != FlipBipStatusSuccess) {
-                memzero((void*)model->mnemonic, strlen(model->mnemonic));
+                // calling strlen on mnemonic here can cause a crash, don't.
+                // it wasn't loaded properly anyways, no need to zero the memory
                 free((void*)model->mnemonic);
             }
 
@@ -677,15 +686,15 @@ void flipbip_scene_1_enter(void* context) {
             if(status == FlipBipStatusSaveError) {
                 model->mnemonic = "ERROR:,Save error";
                 model->page = PAGE_MNEMONIC;
-                flipbip_play_long_bump(app);
+                //flipbip_play_long_bump(app);
             } else if(status == FlipBipStatusLoadError) {
                 model->mnemonic = "ERROR:,Load error";
                 model->page = PAGE_MNEMONIC;
-                flipbip_play_long_bump(app);
+                //flipbip_play_long_bump(app);
             } else if(status == FlipBipStatusMnemonicCheckError) {
                 model->mnemonic = "ERROR:,Mnemonic check error";
                 model->page = PAGE_MNEMONIC;
-                flipbip_play_long_bump(app);
+                //flipbip_play_long_bump(app);
             }
 
             // s_busy = false;

+ 0 - 130
non_catalog_apps/FlipBIP/views/flipbip_startscreen.c

@@ -1,130 +0,0 @@
-#include "../flipbip.h"
-#include <furi.h>
-#include <furi_hal.h>
-#include <input/input.h>
-#include <gui/elements.h>
-#include "flipbip_icons.h"
-
-struct FlipBipStartscreen {
-    View* view;
-    FlipBipStartscreenCallback callback;
-    void* context;
-};
-
-typedef struct {
-    int some_value;
-} FlipBipStartscreenModel;
-
-void flipbip_startscreen_set_callback(
-    FlipBipStartscreen* instance,
-    FlipBipStartscreenCallback callback,
-    void* context) {
-    furi_assert(instance);
-    furi_assert(callback);
-    instance->callback = callback;
-    instance->context = context;
-}
-
-void flipbip_startscreen_draw(Canvas* canvas, FlipBipStartscreenModel* model) {
-    UNUSED(model);
-    canvas_clear(canvas);
-    canvas_set_color(canvas, ColorBlack);
-
-    canvas_draw_icon(canvas, 1, 33, &I_Auth_62x31);
-
-    canvas_set_font(canvas, FontPrimary);
-    canvas_draw_str(canvas, 18, 11, "FlipBIP - BIP32/39/44");
-
-    canvas_set_font(canvas, FontSecondary);
-    canvas_draw_str(canvas, 23, 22, "Crypto toolkit for Flipper");
-    canvas_draw_str(canvas, 99, 34, FLIPBIP_VERSION);
-
-    elements_button_right(canvas, "Start");
-}
-
-static void flipbip_startscreen_model_init(FlipBipStartscreenModel* const model) {
-    model->some_value = 1;
-}
-
-bool flipbip_startscreen_input(InputEvent* event, void* context) {
-    furi_assert(context);
-    FlipBipStartscreen* instance = context;
-    if(event->type == InputTypeRelease) {
-        switch(event->key) {
-        case InputKeyBack:
-            with_view_model(
-                instance->view,
-                FlipBipStartscreenModel * model,
-                {
-                    UNUSED(model);
-                    instance->callback(FlipBipCustomEventStartscreenBack, instance->context);
-                },
-                true);
-            break;
-        case InputKeyLeft:
-        case InputKeyRight:
-        case InputKeyUp:
-        case InputKeyDown:
-        case InputKeyOk:
-            with_view_model(
-                instance->view,
-                FlipBipStartscreenModel * model,
-                {
-                    UNUSED(model);
-                    instance->callback(FlipBipCustomEventStartscreenOk, instance->context);
-                },
-                true);
-            break;
-        case InputKeyMAX:
-            break;
-        }
-    }
-    return true;
-}
-
-void flipbip_startscreen_exit(void* context) {
-    furi_assert(context);
-}
-
-void flipbip_startscreen_enter(void* context) {
-    furi_assert(context);
-    FlipBipStartscreen* instance = (FlipBipStartscreen*)context;
-    with_view_model(
-        instance->view,
-        FlipBipStartscreenModel * model,
-        { flipbip_startscreen_model_init(model); },
-        true);
-}
-
-FlipBipStartscreen* flipbip_startscreen_alloc() {
-    FlipBipStartscreen* instance = malloc(sizeof(FlipBipStartscreen));
-    instance->view = view_alloc();
-    view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(FlipBipStartscreenModel));
-    view_set_context(instance->view, instance); // furi_assert crashes in events without this
-    view_set_draw_callback(instance->view, (ViewDrawCallback)flipbip_startscreen_draw);
-    view_set_input_callback(instance->view, flipbip_startscreen_input);
-    //view_set_enter_callback(instance->view, flipbip_startscreen_enter);
-    //view_set_exit_callback(instance->view, flipbip_startscreen_exit);
-
-    with_view_model(
-        instance->view,
-        FlipBipStartscreenModel * model,
-        { flipbip_startscreen_model_init(model); },
-        true);
-
-    return instance;
-}
-
-void flipbip_startscreen_free(FlipBipStartscreen* instance) {
-    furi_assert(instance);
-
-    with_view_model(
-        instance->view, FlipBipStartscreenModel * model, { UNUSED(model); }, true);
-    view_free(instance->view);
-    free(instance);
-}
-
-View* flipbip_startscreen_get_view(FlipBipStartscreen* instance) {
-    furi_assert(instance);
-    return instance->view;
-}

+ 0 - 19
non_catalog_apps/FlipBIP/views/flipbip_startscreen.h

@@ -1,19 +0,0 @@
-#pragma once
-
-#include <gui/view.h>
-#include "../helpers/flipbip_custom_event.h"
-
-typedef struct FlipBipStartscreen FlipBipStartscreen;
-
-typedef void (*FlipBipStartscreenCallback)(FlipBipCustomEvent event, void* context);
-
-void flipbip_startscreen_set_callback(
-    FlipBipStartscreen* flipbip_startscreen,
-    FlipBipStartscreenCallback callback,
-    void* context);
-
-View* flipbip_startscreen_get_view(FlipBipStartscreen* flipbip_static);
-
-FlipBipStartscreen* flipbip_startscreen_alloc();
-
-void flipbip_startscreen_free(FlipBipStartscreen* flipbip_static);

+ 1 - 1
non_catalog_apps/airmouse/application.fam

@@ -6,6 +6,6 @@ App(
     stack_size=10 * 1024,
     fap_category="GPIO",
     fap_icon="mouse_10px.png",
-    fap_version="0.6",
+    fap_version="0.8",
     sources=["*.c", "*.cc"],
 )

+ 173 - 132
non_catalog_apps/airmouse/tracking/main_loop.cc

@@ -12,178 +12,219 @@
 static const float CURSOR_SPEED = 1024.0 / (M_PI / 4);
 static const float STABILIZE_BIAS = 16.0;
 
-float g_yaw = 0;
-float g_pitch = 0;
-float g_dYaw = 0;
-float g_dPitch = 0;
-bool firstRead = true;
-bool stabilize = true;
-CalibrationData calibration;
-cardboard::OrientationTracker tracker(10000000l); // 10 ms / 100 Hz
-uint64_t ippms, ippms2;
-
-static inline float clamp(float val)
-{
-    while (val <= -M_PI) {
-        val += 2 * M_PI;
-    }
-    while (val >= M_PI) {
-        val -= 2 * M_PI;
+class TrackingState {
+private:
+    float yaw;
+    float pitch;
+    float dYaw;
+    float dPitch;
+    bool firstRead;
+    bool stabilize;
+    CalibrationData calibration;
+    cardboard::OrientationTracker tracker;
+    uint64_t ippus, ippus2;
+
+private:
+    float clamp(float val) {
+        while (val <= -M_PI) {
+            val += 2 * M_PI;
+        }
+        while (val >= M_PI) {
+            val -= 2 * M_PI;
+        }
+        return val;
     }
-    return val;
-}
 
-static inline float highpass(float oldVal, float newVal)
-{
-    if (!stabilize) {
-        return newVal;
+    float highpass(float oldVal, float newVal) {
+        if (!stabilize) {
+            return newVal;
+        }
+        float delta = clamp(oldVal - newVal);
+        float alpha = (float) std::max(0.0, 1 - std::pow(std::fabs(delta) * CURSOR_SPEED / STABILIZE_BIAS, 3.0));
+        return newVal + alpha * delta;
     }
-    float delta = clamp(oldVal - newVal);
-    float alpha = (float) std::max(0.0, 1 - std::pow(std::fabs(delta) * CURSOR_SPEED / STABILIZE_BIAS, 3.0));
-    return newVal + alpha * delta;
-}
 
-void sendCurrentState(MouseMoveCallback mouse_move, void *context)
-{
-    float dX = g_dYaw * CURSOR_SPEED;
-    float dY = g_dPitch * CURSOR_SPEED;
+    void sendCurrentState(MouseMoveCallback mouse_move, void *context) {
+        float dX = dYaw * CURSOR_SPEED;
+        float dY = dPitch * CURSOR_SPEED;
+
+        // Scale the shift down to fit the protocol.
+        if (dX > 127) {
+            dY *= 127.0 / dX;
+            dX = 127;
+        }
+        if (dX < -127) {
+            dY *= -127.0 / dX;
+            dX = -127;
+        }
+        if (dY > 127) {
+            dX *= 127.0 / dY;
+            dY = 127;
+        }
+        if (dY < -127) {
+            dX *= -127.0 / dY;
+            dY = -127;
+        }
+
+        const int8_t x = (int8_t)std::floor(dX + 0.5);
+        const int8_t y = (int8_t)std::floor(dY + 0.5);
+
+        mouse_move(x, y, context);
 
-    // Scale the shift down to fit the protocol.
-    if (dX > 127) {
-        dY *= 127.0 / dX;
-        dX = 127;
+        // Only subtract the part of the error that was already sent.
+        if (x != 0) {
+            dYaw -= x / CURSOR_SPEED;
+        }
+        if (y != 0) {
+            dPitch -= y / CURSOR_SPEED;
+        }
     }
-    if (dX < -127) {
-        dY *= -127.0 / dX;
-        dX = -127;
+
+    void onOrientation(cardboard::Vector4& quaternion) {
+        float q1 = quaternion[0]; // X * sin(T/2)
+        float q2 = quaternion[1]; // Y * sin(T/2)
+        float q3 = quaternion[2]; // Z * sin(T/2)
+        float q0 = quaternion[3]; // cos(T/2)
+
+        float yaw = std::atan2(2 * (q0 * q3 - q1 * q2), (1 - 2 * (q1 * q1 + q3 * q3)));
+        float pitch = std::asin(2 * (q0 * q1 + q2 * q3));
+        // float roll = std::atan2(2 * (q0 * q2 - q1 * q3), (1 - 2 * (q1 * q1 + q2 * q2)));
+
+        if (yaw == NAN || pitch == NAN) {
+            // NaN case, skip it
+            return;
+        }
+
+        if (firstRead) {
+            this->yaw = yaw;
+            this->pitch = pitch;
+            firstRead = false;
+        } else {
+            const float newYaw = highpass(this->yaw, yaw);
+            const float newPitch = highpass(this->pitch, pitch);
+
+            float dYaw = clamp(this->yaw - newYaw);
+            float dPitch = this->pitch - newPitch;
+            this->yaw = newYaw;
+            this->pitch = newPitch;
+
+            // Accumulate the error locally.
+            this->dYaw += dYaw;
+            this->dPitch += dPitch;
+        }
     }
-    if (dY > 127) {
-        dX *= 127.0 / dY;
-        dY = 127;
+
+public:
+    TrackingState()
+        : yaw(0)
+        , pitch(0)
+        , dYaw(0)
+        , dPitch(0)
+        , firstRead(true)
+        , stabilize(true)
+        , tracker(10000000l) { // 10 ms / 100 Hz
+        ippus = furi_hal_cortex_instructions_per_microsecond();
+        ippus2 = ippus / 2;
     }
-    if (dY < -127) {
-        dX *= -127.0 / dY;
-        dY = -127;
+
+    void beginCalibration() {
+        calibration.reset();
     }
 
-    const int8_t x = (int8_t)std::floor(dX + 0.5);
-    const int8_t y = (int8_t)std::floor(dY + 0.5);
+    bool stepCalibration() {
+        if (calibration.isComplete())
+            return true;
 
-    mouse_move(x, y, context);
+        double vec[6];
+        if (imu_read(vec) & GYR_DATA_READY) {
+            cardboard::Vector3 data(vec[3], vec[4], vec[5]);
+            furi_delay_ms(9); // Artificially limit to ~100Hz
+            return calibration.add(data);
+        }
 
-    // Only subtract the part of the error that was already sent.
-    if (x != 0) {
-        g_dYaw -= x / CURSOR_SPEED;
+        return false;
     }
-    if (y != 0) {
-        g_dPitch -= y / CURSOR_SPEED;
+
+    void saveCalibration() {
+        CalibrationMedian store;
+        cardboard::Vector3 median = calibration.getMedian();
+        store.x = median[0];
+        store.y = median[1];
+        store.z = median[2];
+        CALIBRATION_DATA_SAVE(&store);
     }
-}
 
-void onOrientation(cardboard::Vector4& quaternion)
-{
-    float q1 = quaternion[0]; // X * sin(T/2)
-    float q2 = quaternion[1]; // Y * sin(T/2)
-    float q3 = quaternion[2]; // Z * sin(T/2)
-    float q0 = quaternion[3]; // cos(T/2)
+    void loadCalibration() {
+        CalibrationMedian store;
+        cardboard::Vector3 median = calibration.getMedian();
+        if (CALIBRATION_DATA_LOAD(&store)) {
+            median[0] = store.x;
+            median[1] = store.y;
+            median[2] = store.z;
+        }
 
-    float yaw = std::atan2(2 * (q0 * q3 - q1 * q2), (1 - 2 * (q1 * q1 + q3 * q3)));
-    float pitch = std::asin(2 * (q0 * q1 + q2 * q3));
-    // float roll = std::atan2(2 * (q0 * q2 - q1 * q3), (1 - 2 * (q1 * q1 + q2 * q2)));
+        tracker.SetCalibration(median);
+    }
 
-    if (yaw == NAN || pitch == NAN) {
-        // NaN case, skip it
-        return;
+    void beginTracking() {
+        loadCalibration();
+        tracker.Resume();
     }
 
-    if (firstRead) {
-        g_yaw = yaw;
-        g_pitch = pitch;
-        firstRead = false;
-    } else {
-        const float newYaw = highpass(g_yaw, yaw);
-        const float newPitch = highpass(g_pitch, pitch);
-
-        float dYaw = clamp(g_yaw - newYaw);
-        float dPitch = g_pitch - newPitch;
-        g_yaw = newYaw;
-        g_pitch = newPitch;
-
-        // Accumulate the error locally.
-        g_dYaw += dYaw;
-        g_dPitch += dPitch;
+    void stepTracking(MouseMoveCallback mouse_move, void *context) {
+        double vec[6];
+        int ret = imu_read(vec);
+        if (ret != 0) {
+            uint64_t t = (DWT->CYCCNT * 1000llu + ippus2) / ippus;
+            if (ret & ACC_DATA_READY) {
+                cardboard::AccelerometerData adata
+                    = { .system_timestamp = t, .sensor_timestamp_ns = t,
+                        .data = cardboard::Vector3(vec[0], vec[1], vec[2]) };
+                tracker.OnAccelerometerData(adata);
+            }
+            if (ret & GYR_DATA_READY) {
+                cardboard::GyroscopeData gdata
+                    = { .system_timestamp = t, .sensor_timestamp_ns = t,
+                        .data = cardboard::Vector3(vec[3], vec[4], vec[5]) };
+                cardboard::Vector4 pose = tracker.OnGyroscopeData(gdata);
+                onOrientation(pose);
+                sendCurrentState(mouse_move, context);
+            }
+        }
     }
-}
+
+    void stopTracking() {
+        tracker.Pause();
+    }
+};
+
+static TrackingState g_state;
 
 extern "C" {
 
 void calibration_begin() {
-    calibration.reset();
+    g_state.beginCalibration();
     FURI_LOG_I(TAG, "Calibrating");
 }
 
 bool calibration_step() {
-    if (calibration.isComplete())
-        return true;
-
-    double vec[6];
-    if (imu_read(vec) & GYR_DATA_READY) {
-        cardboard::Vector3 data(vec[3], vec[4], vec[5]);
-        furi_delay_ms(9); // Artificially limit to ~100Hz
-        return calibration.add(data);
-    }
-
-    return false;
+    return g_state.stepCalibration();
 }
 
 void calibration_end() {
-    CalibrationMedian store;
-    cardboard::Vector3 median = calibration.getMedian();
-    store.x = median[0];
-    store.y = median[1];
-    store.z = median[2];
-    CALIBRATION_DATA_SAVE(&store);
+    g_state.saveCalibration();
 }
 
 void tracking_begin() {
-    CalibrationMedian store;
-    cardboard::Vector3 median = calibration.getMedian();
-    if (CALIBRATION_DATA_LOAD(&store)) {
-        median[0] = store.x;
-        median[1] = store.y;
-        median[2] = store.z;
-    }
-
-    ippms = furi_hal_cortex_instructions_per_microsecond();
-    ippms2 = ippms / 2;
-    tracker.SetCalibration(median);
-    tracker.Resume();
+    g_state.beginTracking();
 }
 
 void tracking_step(MouseMoveCallback mouse_move, void *context) {
-    double vec[6];
-    int ret = imu_read(vec);
-    if (ret != 0) {
-        uint64_t t = (DWT->CYCCNT * 1000llu + ippms2) / ippms;
-        if (ret & ACC_DATA_READY) {
-            cardboard::AccelerometerData adata
-                = { .system_timestamp = t, .sensor_timestamp_ns = t,
-                    .data = cardboard::Vector3(vec[0], vec[1], vec[2]) };
-            tracker.OnAccelerometerData(adata);
-        }
-        if (ret & GYR_DATA_READY) {
-            cardboard::GyroscopeData gdata
-                = { .system_timestamp = t, .sensor_timestamp_ns = t,
-                    .data = cardboard::Vector3(vec[3], vec[4], vec[5]) };
-            cardboard::Vector4 pose = tracker.OnGyroscopeData(gdata);
-            onOrientation(pose);
-            sendCurrentState(mouse_move, context);
-        }
-    }
+    g_state.stepTracking(mouse_move, context);
 }
 
 void tracking_end() {
-    tracker.Pause();
+    g_state.stopTracking();
 }
 
 }

+ 1 - 1
non_catalog_apps/airmouse/tracking/orientation_tracker.cc

@@ -89,7 +89,7 @@ Vector4 OrientationTracker::OnGyroscopeData(const GyroscopeData& event)
 
     sensor_fusion_->ProcessGyroscopeSample(data);
 
-    return OrientationTracker::GetPose(data.sensor_timestamp_ns + sampling_period_ns_);
+    return GetPose(data.sensor_timestamp_ns + sampling_period_ns_);
 }
 
 } // namespace cardboard

+ 8 - 5
non_catalog_apps/airmouse/tracking/sensors/sensor_fusion_ekf.cc

@@ -59,13 +59,14 @@ namespace {
     // angle = norm(a)
     // axis = a.normalized()
     // If norm(a) == 0, it returns an identity rotation.
-    static inline Rotation RotationFromVector(const Vector3& a)
+    static inline void RotationFromVector(const Vector3& a, Rotation& r)
     {
         const double norm_a = Length(a);
         if (norm_a < kEpsilon) {
-            return Rotation::Identity();
+            r = Rotation::Identity();
+            return;
         }
-        return Rotation::FromAxisAndAngle(a / norm_a, norm_a);
+        r = Rotation::FromAxisAndAngle(a / norm_a, norm_a);
     }
 
 } // namespace
@@ -199,7 +200,8 @@ void SensorFusionEkf::ComputeMeasurementJacobian()
         Vector3 delta = Vector3::Zero();
         delta[dof] = kFiniteDifferencingEpsilon;
 
-        const Rotation epsilon_rotation = RotationFromVector(delta);
+        Rotation epsilon_rotation;
+        RotationFromVector(delta, epsilon_rotation);
         const Vector3 delta_rotation
             = ComputeInnovation(epsilon_rotation * current_state_.sensor_from_start_rotation);
 
@@ -263,7 +265,8 @@ void SensorFusionEkf::ProcessAccelerometerSample(const AccelerometerData& sample
         * state_covariance_;
 
     // Updates pose and associate covariance matrix.
-    const Rotation rotation_from_state_update = RotationFromVector(state_update_);
+    Rotation rotation_from_state_update;
+    RotationFromVector(state_update_, rotation_from_state_update);
 
     current_state_.sensor_from_start_rotation
         = rotation_from_state_update * current_state_.sensor_from_start_rotation;

+ 49 - 45
non_catalog_apps/airmouse/views/bt_mouse.c

@@ -132,6 +132,11 @@ void bt_mouse_connection_status_changed_callback(BtStatus status, void* context)
     BtMouse* bt_mouse = context;
 
     bt_mouse->connected = (status == BtStatusConnected);
+    if(!bt_mouse->notifications) {
+        tracking_end();
+        return;
+    }
+
     if(bt_mouse->connected) {
         notification_internal_message(bt_mouse->notifications, &sequence_set_blue_255);
         tracking_begin();
@@ -140,9 +145,6 @@ void bt_mouse_connection_status_changed_callback(BtStatus status, void* context)
         tracking_end();
         notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
     }
-
-    //with_view_model(
-    //    bt_mouse->view, void * model, { model->connected = connected; }, true);
 }
 
 bool bt_mouse_move(int8_t dx, int8_t dy, void* context) {
@@ -160,46 +162,6 @@ bool bt_mouse_move(int8_t dx, int8_t dy, void* context) {
     return true;
 }
 
-void bt_mouse_enter_callback(void* context) {
-    furi_assert(context);
-    BtMouse* bt_mouse = context;
-
-    bt_mouse->bt = furi_record_open(RECORD_BT);
-    bt_mouse->notifications = furi_record_open(RECORD_NOTIFICATION);
-    bt_set_status_changed_callback(
-        bt_mouse->bt, bt_mouse_connection_status_changed_callback, bt_mouse);
-    furi_assert(bt_set_profile(bt_mouse->bt, BtProfileHidKeyboard));
-    furi_hal_bt_start_advertising();
-}
-
-bool bt_mouse_custom_callback(uint32_t event, void* context) {
-    UNUSED(event);
-    furi_assert(context);
-    BtMouse* bt_mouse = context;
-
-    tracking_step(bt_mouse_move, context);
-    furi_delay_ms(3); // Magic! Removing this will break the buttons
-
-    view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0);
-    return true;
-}
-
-void bt_mouse_exit_callback(void* context) {
-    furi_assert(context);
-    BtMouse* bt_mouse = context;
-
-    tracking_end();
-    notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
-
-    furi_hal_bt_stop_advertising();
-    bt_set_profile(bt_mouse->bt, BtProfileSerial);
-
-    furi_record_close(RECORD_NOTIFICATION);
-    bt_mouse->notifications = NULL;
-    furi_record_close(RECORD_BT);
-    bt_mouse->bt = NULL;
-}
-
 static int8_t clamp(int t) {
     if(t < -128) {
         return -128;
@@ -279,6 +241,50 @@ void bt_mouse_thread_stop(BtMouse* bt_mouse) {
     furi_thread_join(bt_mouse->thread);
     furi_thread_free(bt_mouse->thread);
     furi_mutex_free(bt_mouse->mutex);
+    bt_mouse->mutex = NULL;
+    bt_mouse->thread = NULL;
+}
+
+void bt_mouse_enter_callback(void* context) {
+    furi_assert(context);
+    BtMouse* bt_mouse = context;
+
+    bt_mouse->bt = furi_record_open(RECORD_BT);
+    bt_mouse->notifications = furi_record_open(RECORD_NOTIFICATION);
+    bt_set_status_changed_callback(
+        bt_mouse->bt, bt_mouse_connection_status_changed_callback, bt_mouse);
+    furi_assert(bt_set_profile(bt_mouse->bt, BtProfileHidKeyboard));
+    furi_hal_bt_start_advertising();
+    bt_mouse_thread_start(bt_mouse);
+}
+
+bool bt_mouse_custom_callback(uint32_t event, void* context) {
+    UNUSED(event);
+    furi_assert(context);
+    BtMouse* bt_mouse = context;
+
+    tracking_step(bt_mouse_move, context);
+    furi_delay_ms(3); // Magic! Removing this will break the buttons
+
+    view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0);
+    return true;
+}
+
+void bt_mouse_exit_callback(void* context) {
+    furi_assert(context);
+    BtMouse* bt_mouse = context;
+
+    bt_mouse_thread_stop(bt_mouse);
+    tracking_end();
+    notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
+
+    furi_hal_bt_stop_advertising();
+    bt_set_profile(bt_mouse->bt, BtProfileSerial);
+
+    furi_record_close(RECORD_NOTIFICATION);
+    bt_mouse->notifications = NULL;
+    furi_record_close(RECORD_BT);
+    bt_mouse->bt = NULL;
 }
 
 BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher) {
@@ -293,13 +299,11 @@ BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher) {
     view_set_enter_callback(bt_mouse->view, bt_mouse_enter_callback);
     view_set_custom_callback(bt_mouse->view, bt_mouse_custom_callback);
     view_set_exit_callback(bt_mouse->view, bt_mouse_exit_callback);
-    bt_mouse_thread_start(bt_mouse);
     return bt_mouse;
 }
 
 void bt_mouse_free(BtMouse* bt_mouse) {
     furi_assert(bt_mouse);
-    bt_mouse_thread_stop(bt_mouse);
     view_free(bt_mouse->view);
     free(bt_mouse);
 }

+ 3 - 3
non_catalog_apps/esp32_gravity/application.fam

@@ -6,11 +6,11 @@ App(
     requires=["gui"],
     stack_size=1 * 1024,
     order=90,
-    fap_icon="uart_terminal.png",
+    fap_icon="gravity-icon.png",
     fap_category="GPIO",
     fap_icon_assets="assets",
     fap_icon_assets_symbol="uart_terminal",
     fap_author="https://github.com/chris-bc",
-    fap_version="1.0",
-    fap_description="App to control ESP32-C6 Gravity wireless exploration platform.",
+    fap_version="0.2.1",
+    fap_description="App to control ESP32 Gravity wireless exploration platform.",
 )

+ 24 - 20
non_catalog_apps/esp32_gravity/esp_flip_const.h

@@ -1,33 +1,33 @@
+#ifndef ESP_FLIP_CONST_H
+#define ESP_FLIP_CONST_H
+
 /* Command usage string - SHORT_* is compressed help text for Flipper */
-const char USAGE_BEACON[] =
-    "Beacon spam attack. Usage: beacon [ RICKROLL | RANDOM [ COUNT ] | INFINITE | USER | OFF ]";
-const char USAGE_TARGET_SSIDS[] =
-    "Manage SSID targets. Usage: target-ssids [ ( ADD | REMOVE ) <ssid_name> ]";
-const char USAGE_PROBE[] = "Probe flood attack. Usage: probe [ ANY | SSIDS | OFF ]";
+const char USAGE_BEACON[] = "Beacon spam attack. Usage: beacon [ RICKROLL | RANDOM [ COUNT ] | INFINITE | TARGET-SSIDs | APs | OFF ]";
+const char USAGE_TARGET_SSIDS[] = "Manage SSID targets. Usage: target-ssids [ ( ADD | REMOVE ) <ssid_name> ]";
+const char USAGE_PROBE[] = "Probe flood attack. Usage: probe [ ANY | TARGET-SSIDs | APs | OFF ]";
+const char USAGE_FUZZ[] = "Various invalid packets. Usage: fuzz OFF | ( ( BEACON | REQ | RESP )+ ( OVERFLOW | MALFORMED ) )";
 const char USAGE_SNIFF[] = "Display interesting packets. Usage: sniff [ ON | OFF ]";
-const char USAGE_DEAUTH[] =
-    "Deauth attack. Usage: deauth [ <millis> ] [ FRAME | DEVICE | SPOOF ] [ STA | BROADCAST | OFF ]";
-const char USAGE_MANA[] =
-    "Mana attack. Usage: mana ( CLEAR | ( [ VERBOSE ] [ ON | OFF ] ) | ( AUTH [ NONE | WEP | WPA ] ) | ( LOUD [ ON | OFF ] ) )";
+const char USAGE_DEAUTH[] = "Deauth attack. Usage: deauth [ <millis> ] [ FRAME | DEVICE | SPOOF ] [ STA | AP | BROADCAST | OFF ]";
+const char USAGE_MANA[] = "Mana attack. Usage: mana ( CLEAR | ( [ VERBOSE ] [ ON | OFF ] ) | ( AUTH [ NONE | WEP | WPA ] ) | ( LOUD [ ON | OFF ] ) )";
 const char USAGE_STALK[] = "Toggle target tracking/homing. Usage: stalk";
 const char USAGE_AP_DOS[] = "802.11 denial-of-service attack. Usage: ap-dos [ ON | OFF ]";
-const char USAGE_AP_CLONE[] =
-    "Clone and attempt takeover of the specified AP. Usage: ap-clone [ <AP MAC> | APs | OFF ]";
+const char USAGE_AP_CLONE[] = "Clone and attempt takeover of the specified AP. Usage: ap-clone [ <AP MAC> | APs | OFF ]";
 const char USAGE_SCAN[] = "Scan for wireless devices. Usage: scan [ <ssid> | ON | OFF ]";
-const char USAGE_HOP[] =
-    "Configure channel hopping. Usage: hop [ <millis> ] [ ON | OFF | DEFAULT | KILL ]";
+const char USAGE_HOP[] = "Configure channel hopping. Usage: hop [ <millis> ] [ ON | OFF | DEFAULT | KILL ]";
 const char USAGE_SET[] = "Set a variable. Usage: set <variable> <value>";
 const char USAGE_GET[] = "Get a variable. Usage: get <variable>";
-const char USAGE_VIEW[] = "List available targets. Usage: view ( AP | STA )+";
+const char USAGE_VIEW[] = "List available targets. Usage: view ( ( AP [ selectedSTA ] ) | ( STA [ selectedAP ] ) )+";
 const char USAGE_SELECT[] = "Select an element. Usage: select ( AP | STA ) <elementId>+";
+const char USAGE_SELECTED[] = "Display selected elements. Usage: selected ( AP | STA )";
 const char USAGE_CLEAR[] = "Clear stored APs or STAs. Usage: clear ( AP | STA | ALL )";
-const char USAGE_HANDSHAKE[] =
-    "Toggle monitoring for encryption material. Usage handshake [ ON | OFF ]";
+const char USAGE_HANDSHAKE[] = "Toggle monitoring for encryption material. Usage handshake [ ON | OFF ]";
 const char USAGE_COMMANDS[] = "Display a *brief* summary of Gravity commands";
+const char USAGE_INFO[] = "Provide help information for the specified command. Usage: info <cmd>";
 
 const char SHORT_BEACON[] = "beacon RANDOM <count>";
 const char SHORT_TARGET_SSIDS[] = "(ADD | REMOVE) <apName>";
-const char SHORT_PROBE[] = "probe ANY | SSIDS | OFF";
+const char SHORT_PROBE[] = "probe ANY | TARGET-SSIDs | APs | OFF";
+const char SHORT_FUZZ[] = "fuzz OFF | ( ( BEACON | REQ | RESP )+ ( OVERFLOW | MALFORMED ) )";
 const char SHORT_SNIFF[] = "sniff [ ON | OFF ]";
 const char SHORT_DEAUTH[] = "deauth <millis>";
 const char SHORT_MANA[] = "Mana attack";
@@ -38,8 +38,12 @@ const char SHORT_SCAN[] = "scan <SSID Name>";
 const char SHORT_HOP[] = "hop <millis>";
 const char SHORT_SET[] = "set <variable> <value>";
 const char SHORT_GET[] = "get <variable>";
-const char SHORT_VIEW[] = "VIEW ( AP | STA )+";
-const char SHORT_SELECT[] = "select ( AP | STA ) <id>+";
+const char SHORT_VIEW[] = "VIEW ( ( AP [ selectedSTA ] ) | ( STA [ selectedAP ] ) )+";
+const char SHORT_SELECT[] = "select ( AP | STA ) <id>+  sep. ^";
+const char SHORT_SELECTED[] = "selected ( AP | STA )";
 const char SHORT_CLEAR[] = "clear ( AP | STA | ALL )";
 const char SHORT_HANDSHAKE[] = "handshake [ ON | OFF ]";
-const char SHORT_COMMANDS[] = "Brief command summary";
+const char SHORT_COMMANDS[] = "Brief command summary";
+const char SHORT_INFO[] = "Command help. info <cmd>";
+
+#endif

+ 12 - 3
non_catalog_apps/esp32_gravity/esp_flip_struct.h

@@ -1,7 +1,11 @@
+#ifndef ESP_FLIP_STRUCT_H
+#define ESP_FLIP_STRUCT_H
+
 /*  Globals to track module status information */
 enum AttackMode {
     ATTACK_BEACON,
     ATTACK_PROBE,
+    ATTACK_FUZZ,
     ATTACK_SNIFF,
     ATTACK_DEAUTH,
     ATTACK_MANA,
@@ -17,10 +21,10 @@ enum AttackMode {
 typedef enum AttackMode AttackMode;
 
 enum GravityCommand {
-    GRAVITY_NONE,
-    GRAVITY_BEACON,
+    GRAVITY_BEACON = 0,
     GRAVITY_TARGET_SSIDS,
     GRAVITY_PROBE,
+    GRAVITY_FUZZ,
     GRAVITY_SNIFF,
     GRAVITY_DEAUTH,
     GRAVITY_MANA,
@@ -33,8 +37,13 @@ enum GravityCommand {
     GRAVITY_GET,
     GRAVITY_VIEW,
     GRAVITY_SELECT,
+    GRAVITY_SELECTED,
     GRAVITY_CLEAR,
     GRAVITY_HANDSHAKE,
-    GRAVITY_COMMANDS
+    GRAVITY_COMMANDS,
+    GRAVITY_INFO,
+    GRAVITY_NONE = 99
 };
 typedef enum GravityCommand GravityCommand;
+
+#endif

BIN
non_catalog_apps/esp32_gravity/gravity-icon.png


+ 18 - 8
non_catalog_apps/esp32_gravity/scenes/uart_terminal_scene_console_output.c

@@ -31,16 +31,26 @@ void uart_terminal_scene_console_output_on_enter(void* context) {
         text_box_set_focus(text_box, TextBoxFocusEnd);
     }
 
-    if(app->is_command) {
-        furi_string_reset(
-            app->text_box_store); /* GRAVITY If this callback is called each time the view is displayed, I think this will clear the screen */
+    if(app->is_command) {                       /* View console ensures this is false */
+        furi_string_reset(app->text_box_store);
         app->text_box_store_strlen = 0;
 
-        if(0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
-            const char* help_msg =
-                "ESP32 Gravity terminal for Flipper\n\nCopypasted from UART terminal by cool4uma\n\nThis app is a modified\nUART terminal,\nThanks cool4uma and 0xchocolate(github)\nfor great code and app.\n\n";
-            furi_string_cat_str(app->text_box_store, help_msg);
-            app->text_box_store_strlen += strlen(help_msg);
+        /* Handle Flipper commands here - set ap->is_command = false for commands that are consumed */
+        if (!strcmp(app->selected_tx_string, "GET_STARTED")) {
+            app->is_command = false;
+            /* Display detailed instructions on getting started */
+            uart_text_input_set_header_text(app->text_input, "Getting Started");
+            // TODO: See if the header works
+            char string[] = "             Flipper Gravity\nGETTING STARTED\nUnless you're doing a basic beacon spam or probe flood attack, or a Mana attack, the first thing to do is turn scanning on and let it run while you explore the menu. View found APs (you can leave scanning on or turn it off), select a few APs or STAs and run a DEAUTH attack against the selected APs or STAs. When an AP is specified for a DEAUTH attack Gravity will use all STAs it identifies as clients of the specified APs. Turn off scanning and deauth, and turn on MANA or LOUD MANA. This is still under development, but you can watch Wireshark to see if any devices send you an association request.\n";
+            furi_string_cat_str(app->text_box_store, string);
+            app->text_box_store_strlen += strlen(string);
+        } else if (!strcmp(app->selected_tx_string, "ABOUT")) {
+            app->is_command = false;
+            /* Display a basic about screen */
+            // TODO: See if the following works:
+            char aboutStr[] = "              Flipper Gravity\n                    v0.2.1\nBy Chris BC\n    https://github.com/chris-bc/flipper-gravity\n    https://github.com/esp32c6-gravity\n\n\nMost ideas and code stolen from ESP32 Marauder and UART Terminal.";
+            furi_string_cat_str(app->text_box_store, aboutStr);
+            app->text_box_store_strlen += strlen(aboutStr);
         }
 
         if(app->show_stopscan_tip) {

+ 176 - 146
non_catalog_apps/esp32_gravity/scenes/uart_terminal_scene_start.c

@@ -11,7 +11,7 @@ typedef enum { FOCUS_CONSOLE_END = 0, FOCUS_CONSOLE_START, FOCUS_CONSOLE_TOGGLE
 #define SHOW_STOPSCAN_TIP (true)
 #define NO_TIP (false)
 
-#define MAX_OPTIONS (9)
+#define MAX_OPTIONS (12)
 typedef struct {
     const char* item_string;
     const char* options_menu[MAX_OPTIONS];
@@ -28,150 +28,171 @@ typedef struct {
 */
 const UART_TerminalItem items[NUM_MENU_ITEMS] = {
     {"Console", {"View", "Clear"}, 2, {"", "cls"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
+    {"Bluetooth",
+    {"On", "Off"},
+    2,
+    {"bluetooth on", "bluetooth off"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Beacon",
-     {"Status", "RickRoll", "Random", "Infinite", "target-ssids", "Off"},
-     6,
-     {"beacon", "beacon rickroll", "beacon random ", "beacon infinite", "beacon user", "beacon off"},
-     TOGGLE_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Status", "target-ssids", "APs", "RickRoll", "Random", "Infinite", "Off"},
+    6,
+    {"beacon", "beacon target-ssids", "beacon aps", "beacon rickroll", "beacon random ", "beacon infinite", "beacon off"},
+    TOGGLE_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Probe",
-     {"Status", "Any", "target-ssids", "Off"},
-     4,
-     {"probe", "probe any", "probe ssids", "probe off"},
-     NO_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Status", "Any", "target-ssids", "APs", "Off"},
+    4,
+    {"probe", "probe any", "probe target-ssids", "probe aps", "probe off"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
+    {"Fuzz",
+    {"Status", "Off", "Overflow Beacon", "Overflow Request", "Overflow Response", "Malformed Beacon", "Malformed Request", "Malformed Response"},
+    8,
+    {"fuzz", "fuzz off", "fuzz beacon overflow", "fuzz req overflow", "fuzz resp overflow", "fuzz beacon malformed", "fuzz req malformed", "fuzz resp malformed"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Sniff",
-     {"Status", "On", "Off"},
-     3,
-     {"sniff", "sniff on", "sniff off"},
-     NO_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Status", "On", "Off"},
+    3,
+    {"sniff", "sniff on", "sniff off"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"target-ssids",
-     {"Add", "Remove", "List"},
-     3,
-     {"target-ssids add ", "target-ssids remove ", "target-ssids"},
-     TOGGLE_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Add", "Remove", "List"},
+    3,
+    {"target-ssids add ", "target-ssids remove ", "target-ssids"},
+    TOGGLE_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Scan",
-     {"Status", "On", "Off", "<ssid>"},
-     4,
-     {"scan", "scan on", "scan off", "scan "},
-     TOGGLE_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Status", "On", "Off", "<ssid>"},
+    4,
+    {"scan", "scan on", "scan off", "scan "},
+    TOGGLE_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Hop",
-     {"Status", "On", "Off", "Default", "Set "},
-     5,
-     {"hop", "hop on", "hop off", "hop default", "hop "},
-     TOGGLE_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Status", "On", "Off", "Sequential", "Random", "Default", "Set "},
+    7,
+    {"hop", "hop on", "hop off", "hop sequential", "hop random", "hop default", "hop "},
+    TOGGLE_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"View",
-     {"STA", "AP", "STA+AP"},
-     3,
-     {"view sta", "view ap", "view sta ap"},
-     NO_ARGS,
-     FOCUS_CONSOLE_START,
-     NO_TIP},
+    {"STA", "AP", "STA+AP"},
+    3,
+    {"view sta", "view ap", "view sta ap"},
+    NO_ARGS,
+    FOCUS_CONSOLE_START,
+    NO_TIP},
     {"Select",
-     {"STA", "AP"},
-     2,
-     {"select sta ", "select ap "},
-     INPUT_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
-    {"Clear", {"STA", "AP"}, 2, {"clear sta", "clear ap"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
+    {"STA", "AP"},
+    2,
+    {"select sta ", "select ap "},
+    INPUT_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
+    {"Selected",
+    {"STA", "AP", "STA+AP"},
+    3,
+    {"selected sta", "selected ap", "selected"},
+    NO_ARGS,
+    FOCUS_CONSOLE_START,
+    NO_TIP},
+    {"Clear",
+    {"STA", "AP", "ALL"},
+    3,
+    {"clear sta", "clear ap", "clear all"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Get",
-     {"SSID_LEN_MIN", "SSID_LEN_MAX", "DEFAULT_SSID_COUNT", "Channel", "MAC", "MAC_RAND"},
-     6,
-     {"get ssid_len_min",
-      "get ssid_len_max",
-      "get default_ssid_count",
-      "get channel",
-      "get mac",
-      "get mac_rand"},
-     NO_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"pkt expiry", "SSID rnd chars", "Attack millis", "SSID min len", "SSID max len", "default SSID count", "Channel", "MAC", "MAC Randomisation"},
+    9,
+    {"get expiry", "get scramble_words", "get attack_millis", "get ssid_len_min", "get ssid_len_max", "get default_ssid_count", "get channel", "get mac", "get mac_rand"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Set",
-     {"SSID_LEN_MIN", "SSID_LEN_MAX", "DEFAULT_SSID_COUNT", "Channel", "MAC", "MAC_RAND"},
-     6,
-     {"set ssid_len_min ",
-      "set ssid_len_max ",
-      "set default_ssid_count ",
-      "set channel ",
-      "set mac ",
-      "set mac_rand "},
-     INPUT_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"pkt expiry", "SSID rnd chars", "Attack millis", "SSID min len", "SSID max len", "default SSID count", "Channel", "MAC", "MAC Randomisation"},
+    8,
+    {"set expiry ", "set scramble_words ", "set attack_millis ", "set ssid_len_min ", "set ssid_len_max ", "set default_ssid_count ", "set channel ", "set mac ", "set mac_rand "},
+    INPUT_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Deauth",
-     {"Status",
-      "Set Delay",
-      "Off",
-      "Frame STA",
-      "Device STA",
-      "Spoof STA",
-      "Frame B'Cast",
-      "Device B'Cast",
-      "Spoof B'Cast"},
-     9,
-     {"deauth",
-      "deauth ",
-      "deauth off",
-      "deauth frame sta",
-      "deauth device sta",
-      "deauth spoof sta",
-      "deauth frame broadcast",
-      "deauth device broadcast",
-      "deauth spoof broadcast"},
-     TOGGLE_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Status", "Set Delay", "Off", "Frame STA", "Device STA", "Spoof STA", "Frame APs", "Device APs", "Spoof APs", "Frame B'Cast", "Device B'Cast", "Spoof B'Cast"},
+    12,
+    {"deauth", "deauth ", "deauth off", "deauth frame sta", "deauth device sta", "deauth spoof sta", "deauth frame ap", "deauth device ap", "deauth spoof ap", "deauth frame broadcast", "deauth device broadcast", "deauth spoof broadcast"},
+    TOGGLE_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Mana",
-     {"Status", "On", "Off", "Clear"},
-     4,
-     {"mana", "mana on", "mana off", "mana clear"},
-     NO_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Status", "On", "Off", "Clear"},
+    4,
+    {"mana", "mana on", "mana off", "mana clear"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Mana Verbose",
-     {"Status", "On", "Off"},
-     3,
-     {"mana verbose", "mana verbose on", "mana verbose off"},
-     NO_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
+    {"Status", "On", "Off"},
+    3,
+    {"mana verbose", "mana verbose on", "mana verbose off"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
     {"Mana Loud",
-     {"Status", "On", "Off"},
-     3,
-     {"mana loud", "mana loud on", "mana loud off"},
-     NO_ARGS,
-     FOCUS_CONSOLE_END,
-     NO_TIP},
-    {"Help", {"Commands", "Help"}, 2, {"commands", "help"}, NO_ARGS, FOCUS_CONSOLE_START, NO_TIP},
+    {"Status", "On", "Off"},
+    3,
+    {"mana loud", "mana loud on", "mana loud off"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
+    {"selectedAP DOS",
+    {"Status", "On", "Off"},
+    3,
+    {"ap-dos", "ap-dos on", "ap-dos off"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
+    {"AP Clone Attack",
+    {"Status", "On", "Off"},
+    3,
+    {"ap-clone", "ap-clone on", "ap-clone off"},
+    NO_ARGS,
+    FOCUS_CONSOLE_END,
+    NO_TIP},
+    {"Help",
+    {"Info <cmd>", "Get Started", "Commands", "About", "Help"},
+    5,
+    {"info ", "GET_STARTED", "commands", "ABOUT", "help"},
+    TOGGLE_ARGS,
+    FOCUS_CONSOLE_START,
+    NO_TIP},
 };
 
-char* strToken(char* cmdLine, char sep, int tokenNum) {
-    size_t i;
+
+char *strToken(char *cmdLine, char sep, int tokenNum) {
+    int i;
     int tokenCount = 0;
-    for(i = 0; i < strlen(cmdLine) && tokenCount != tokenNum; ++i) {
-        if(cmdLine[i] == sep) {
+    for (i = 0; i < (int)strlen(cmdLine) && tokenCount != tokenNum; ++i) {
+        if (cmdLine[i] == sep) {
             ++tokenCount;
         }
     }
-    if(cmdLine[i - 1] == sep || cmdLine[i - 1] == '\0') {
+    if (cmdLine[i - 1] == sep || cmdLine[i - 1] == '\0') {
         /* Found the end of the token, now find the beginning */
         int j;
-        for(j = (i - 2); j > 0 && cmdLine[j] != sep; --j) {
-        }
+        for (j = (i - 2); j > 0 && cmdLine[j] != sep; --j) { }
         /* Token runs from index j to (i - 2) */
-        char* retVal = malloc(sizeof(char) * (i - j));
-        if(retVal == NULL) {
+        char *retVal = malloc(sizeof(char) * (i - j));
+        if (retVal == NULL) {
             printf("GRAVITY: Failed to malloc token\n");
             return NULL;
         }
@@ -180,7 +201,7 @@ char* strToken(char* cmdLine, char sep, int tokenNum) {
         return retVal;
     } else {
         /* No token */
-        if(tokenNum == 1) {
+        if (tokenNum == 1) {
             return cmdLine;
         } else {
             return NULL;
@@ -212,46 +233,52 @@ static void uart_terminal_scene_start_var_list_enter_callback(void* context, uin
     app->show_stopscan_tip = item->show_stopscan_tip;
 
     /* GRAVITY: Set app->gravityMode based on first word in command */
-
+    
     //char *cmd = strsep(&origCmd, " ");
     /* GRAVITY: strsep is disabled by Flipper's SDK. RYO */
-    char* cmd = strToken((char*)app->selected_tx_string, ' ', 1);
-    if(!strcmp(cmd, "beacon")) {
+    char *cmd = strToken((char *)app->selected_tx_string, ' ', 1);
+    if (!strcmp(cmd, "beacon")) {
         app->gravityCommand = GRAVITY_BEACON;
-    } else if(!strcmp(cmd, "target-ssids")) {
+    } else if (!strcmp(cmd, "target-ssids")) {
         app->gravityCommand = GRAVITY_TARGET_SSIDS;
-    } else if(!strcmp(cmd, "probe")) {
+    } else if (!strcmp(cmd, "probe")) {
         app->gravityCommand = GRAVITY_PROBE;
-    } else if(!strcmp(cmd, "sniff")) {
+    } else if (!strcmp(cmd, "fuzz")) {
+        app->gravityCommand = GRAVITY_FUZZ;
+    } else if (!strcmp(cmd, "sniff")) {
         app->gravityCommand = GRAVITY_SNIFF;
-    } else if(!strcmp(cmd, "deauth")) {
+    } else if (!strcmp(cmd, "deauth")) {
         app->gravityCommand = GRAVITY_DEAUTH;
-    } else if(!strcmp(cmd, "mana")) {
+    } else if (!strcmp(cmd, "mana")) {
         app->gravityCommand = GRAVITY_MANA;
-    } else if(!strcmp(cmd, "stalk")) {
+    } else if (!strcmp(cmd, "stalk")) {
         app->gravityCommand = GRAVITY_STALK;
-    } else if(!strcmp(cmd, "ap-dos")) {
+    } else if (!strcmp(cmd, "ap-dos")) {
         app->gravityCommand = GRAVITY_AP_DOS;
-    } else if(!strcmp(cmd, "ap-clone")) {
+    } else if (!strcmp(cmd, "ap-clone")) {
         app->gravityCommand = GRAVITY_AP_CLONE;
-    } else if(!strcmp(cmd, "scan")) {
+    } else if (!strcmp(cmd, "scan")) {
         app->gravityCommand = GRAVITY_SCAN;
-    } else if(!strcmp(cmd, "hop")) {
+    } else if (!strcmp(cmd, "hop")) {
         app->gravityCommand = GRAVITY_HOP;
-    } else if(!strcmp(cmd, "set")) {
+    } else if (!strcmp(cmd, "set")) {
         app->gravityCommand = GRAVITY_SET;
-    } else if(!strcmp(cmd, "get")) {
+    } else if (!strcmp(cmd, "get")) {
         app->gravityCommand = GRAVITY_GET;
-    } else if(!strcmp(cmd, "view")) {
+    } else if (!strcmp(cmd, "view")) {
         app->gravityCommand = GRAVITY_VIEW;
-    } else if(!strcmp(cmd, "select")) {
+    } else if (!strcmp(cmd, "select")) {
         app->gravityCommand = GRAVITY_SELECT;
-    } else if(!strcmp(cmd, "clear")) {
+    } else if (!strcmp(cmd, "selected")) {
+        app->gravityCommand = GRAVITY_SELECTED;
+    } else if (!strcmp(cmd, "clear")) {
         app->gravityCommand = GRAVITY_CLEAR;
-    } else if(!strcmp(cmd, "handshake")) {
+    } else if (!strcmp(cmd, "handshake")) {
         app->gravityCommand = GRAVITY_HANDSHAKE;
-    } else if(!strcmp(cmd, "commands")) {
+    } else if (!strcmp(cmd, "commands")) {
         app->gravityCommand = GRAVITY_COMMANDS;
+    } else if (!strcmp(cmd, "info")) {
+        app->gravityCommand = GRAVITY_INFO;
     } else {
         app->gravityCommand = GRAVITY_NONE;
     }
@@ -260,9 +287,12 @@ static void uart_terminal_scene_start_var_list_enter_callback(void* context, uin
 
     /* GRAVITY: For TOGGLE_ARGS display a keyboard if actual_command ends with ' ' */
     int cmdLen = strlen(app->selected_tx_string);
-    bool needs_keyboard =
-        ((item->needs_keyboard == INPUT_ARGS) ||
-         (item->needs_keyboard == TOGGLE_ARGS && (app->selected_tx_string[cmdLen - 1] == ' ')));
+    bool needs_keyboard = ((item->needs_keyboard == INPUT_ARGS) ||
+                            (item->needs_keyboard == TOGGLE_ARGS &&
+                                (app->selected_tx_string[cmdLen-1] == ' ')));
+    /* Initialise the serial console */
+    uart_terminal_uart_tx((uint8_t*)("\n"), 1);
+
     if(needs_keyboard) {
         view_dispatcher_send_custom_event(app->view_dispatcher, UART_TerminalEventStartKeyboard);
     } else {

+ 68 - 59
non_catalog_apps/esp32_gravity/scenes/uart_terminal_scene_text_input.c

@@ -28,65 +28,74 @@ void uart_terminal_scene_text_input_on_enter(void* context) {
     // Setup view
     UART_TextInput* text_input = app->text_input;
     // Add help message to header
-    char* helpStr = NULL;
-    switch(app->gravityCommand) {
-    case GRAVITY_BEACON:
-        helpStr = (char*)SHORT_BEACON;
-        break;
-    case GRAVITY_TARGET_SSIDS:
-        helpStr = (char*)SHORT_TARGET_SSIDS;
-        break;
-    case GRAVITY_PROBE:
-        helpStr = (char*)SHORT_PROBE;
-        break;
-    case GRAVITY_SNIFF:
-        helpStr = (char*)SHORT_SNIFF;
-        break;
-    case GRAVITY_DEAUTH:
-        helpStr = (char*)SHORT_DEAUTH;
-        break;
-    case GRAVITY_MANA:
-        helpStr = (char*)SHORT_MANA;
-        break;
-    case GRAVITY_STALK:
-        helpStr = (char*)SHORT_STALK;
-        break;
-    case GRAVITY_AP_DOS:
-        helpStr = (char*)SHORT_AP_DOS;
-        break;
-    case GRAVITY_AP_CLONE:
-        helpStr = (char*)SHORT_AP_CLONE;
-        break;
-    case GRAVITY_SCAN:
-        helpStr = (char*)SHORT_SCAN;
-        break;
-    case GRAVITY_HOP:
-        helpStr = (char*)SHORT_HOP;
-        break;
-    case GRAVITY_SET:
-        helpStr = (char*)SHORT_SET;
-        break;
-    case GRAVITY_GET:
-        helpStr = (char*)SHORT_GET;
-        break;
-    case GRAVITY_VIEW:
-        helpStr = (char*)SHORT_VIEW;
-        break;
-    case GRAVITY_SELECT:
-        helpStr = (char*)SHORT_SELECT;
-        break;
-    case GRAVITY_CLEAR:
-        helpStr = (char*)SHORT_CLEAR;
-        break;
-    case GRAVITY_HANDSHAKE:
-        helpStr = (char*)SHORT_HANDSHAKE;
-        break;
-    case GRAVITY_COMMANDS:
-        helpStr = (char*)SHORT_COMMANDS;
-        break;
-    default:
-        helpStr = "Send command to UART";
-        break;
+    char *helpStr = NULL;
+    switch (app->gravityCommand) {
+        case GRAVITY_BEACON:
+            helpStr = (char *)SHORT_BEACON;
+            break;
+        case GRAVITY_TARGET_SSIDS:
+            helpStr = (char*)SHORT_TARGET_SSIDS;
+            break;
+        case GRAVITY_PROBE:
+            helpStr = (char *)SHORT_PROBE;
+            break;
+        case GRAVITY_FUZZ:
+            helpStr = (char *)SHORT_FUZZ;
+            break;
+        case GRAVITY_SNIFF:
+            helpStr = (char *)SHORT_SNIFF;
+            break;
+        case GRAVITY_DEAUTH:
+            helpStr = (char *)SHORT_DEAUTH;
+            break;
+        case GRAVITY_MANA:
+            helpStr = (char *)SHORT_MANA;
+            break;
+        case GRAVITY_STALK:
+            helpStr = (char *)SHORT_STALK;
+            break;
+        case GRAVITY_AP_DOS:
+            helpStr = (char *)SHORT_AP_DOS;
+            break;
+        case GRAVITY_AP_CLONE:
+            helpStr = (char *)SHORT_AP_CLONE;
+            break;
+        case GRAVITY_SCAN:
+            helpStr = (char *)SHORT_SCAN;
+            break;
+        case GRAVITY_HOP:
+            helpStr = (char *)SHORT_HOP;
+            break;
+        case GRAVITY_SET:
+            helpStr = (char *)SHORT_SET;
+            break;
+        case GRAVITY_GET:
+            helpStr = (char *)SHORT_GET;
+            break;
+        case GRAVITY_VIEW:
+            helpStr = (char *)SHORT_VIEW;
+            break;
+        case GRAVITY_SELECT:
+            helpStr = (char *)SHORT_SELECT;
+            break;
+        case GRAVITY_SELECTED:
+            helpStr = (char *)SHORT_SELECTED;
+            break;
+        case GRAVITY_CLEAR:
+            helpStr = (char *)SHORT_CLEAR;
+            break;
+        case GRAVITY_HANDSHAKE:
+            helpStr = (char *)SHORT_HANDSHAKE;
+            break;
+        case GRAVITY_COMMANDS:
+            helpStr = (char *)SHORT_COMMANDS;
+            break;
+        case GRAVITY_INFO:
+            helpStr = (char *)SHORT_INFO;
+            break;
+        default:
+            helpStr = "Send command to UART";
+            break;
     }
 
     uart_text_input_set_header_text(text_input, helpStr);

+ 4 - 2
non_catalog_apps/esp32_gravity/uart_terminal_app_i.h

@@ -12,9 +12,11 @@
 #include <gui/modules/variable_item_list.h>
 #include "uart_text_input.h"
 
-#define NUM_MENU_ITEMS (17)
+#define GRAVITY_VERSION "0.2.1"
 
-#define UART_TERMINAL_TEXT_BOX_STORE_SIZE (8192)
+#define NUM_MENU_ITEMS (22)
+
+#define UART_TERMINAL_TEXT_BOX_STORE_SIZE (1024)
 #define UART_TERMINAL_TEXT_INPUT_STORE_SIZE (512)
 #define UART_CH (FuriHalUartIdUSART1)
 

+ 39 - 1
non_catalog_apps/esubghz_chat/crypto_wrapper.c

@@ -182,10 +182,48 @@ bool crypto_ctx_encrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
 			msg->tag, TAG_BYTES) == 0);
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 
-	// increase internal counter
+	// update replay dict and increase internal counter
 	if (ret) {
+		ESubGhzChatReplayDict_set_at(ctx->replay_dict, ctx->run_id,
+				ctx->counter);
 		ctx->counter++;
 	}
 
 	return ret;
 }
+
+size_t crypto_ctx_dump_replay_dict(ESubGhzChatCryptoCtx *ctx,
+		CryptoCtxReplayDictWriter writer, void *writer_ctx)
+{
+	size_t ret = 0;
+	ESubGhzChatReplayDict_it_t i;
+
+	for (ESubGhzChatReplayDict_it(i, ctx->replay_dict);
+			!ESubGhzChatReplayDict_end_p(i);
+			ESubGhzChatReplayDict_next(i), ret++) {
+		ESubGhzChatReplayDict_itref_t *ref =
+			ESubGhzChatReplayDict_ref(i);
+		if (!writer(ref->key, ref->value, writer_ctx)) {
+			break;
+		}
+	}
+
+	return ret;
+}
+
+size_t crypto_ctx_read_replay_dict(ESubGhzChatCryptoCtx *ctx,
+		CryptoCtxReplayDictReader reader, void *reader_ctx)
+{
+	size_t ret = 0;
+
+	uint64_t run_id;
+	uint32_t counter;
+
+	while (reader(&run_id, &counter, reader_ctx)) {
+		ESubGhzChatReplayDict_set_at(ctx->replay_dict, run_id,
+				counter);
+		ret++;
+	}
+
+	return ret;
+}

+ 10 - 0
non_catalog_apps/esubghz_chat/crypto_wrapper.h

@@ -33,6 +33,16 @@ bool crypto_ctx_decrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
 bool crypto_ctx_encrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
 		uint8_t *out);
 
+typedef bool (*CryptoCtxReplayDictWriter)(uint64_t run_id, uint32_t counter,
+		void *context);
+typedef bool (*CryptoCtxReplayDictReader)(uint64_t *run_id, uint32_t *counter,
+		void *context);
+
+size_t crypto_ctx_dump_replay_dict(ESubGhzChatCryptoCtx *ctx,
+		CryptoCtxReplayDictWriter writer, void *writer_ctx);
+size_t crypto_ctx_read_replay_dict(ESubGhzChatCryptoCtx *ctx,
+		CryptoCtxReplayDictReader reader, void *reader_ctx);
+
 #ifdef __cplusplus
 }
 #endif

+ 18 - 0
non_catalog_apps/esubghz_chat/nfc_helpers.h

@@ -0,0 +1,18 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NFC_MAX_BYTES 256
+#define NFC_CONFIG_PAGES 4
+
+struct ReplayDictNfcEntry {
+	uint64_t run_id;
+	uint32_t counter;
+	uint32_t unused;
+} __attribute__ ((packed));
+
+#ifdef __cplusplus
+}
+#endif

+ 46 - 1
non_catalog_apps/esubghz_chat/scenes/esubghz_chat_key_read_popup.c

@@ -1,4 +1,5 @@
 #include "../esubghz_chat_i.h"
+#include "../nfc_helpers.h"
 
 typedef enum {
 	KeyReadPopupState_Idle,
@@ -38,11 +39,45 @@ static void key_read_popup_timeout_cb(void* context)
 	}
 }
 
+struct ReplayDictNfcReaderContext {
+	uint8_t *cur;
+	uint8_t *max;
+};
+
+static bool replay_dict_nfc_reader(uint64_t *run_id, uint32_t *counter, void
+		*context)
+{
+	struct ReplayDictNfcReaderContext *ctx = (struct
+			ReplayDictNfcReaderContext *) context;
+
+	if (ctx->cur + sizeof(struct ReplayDictNfcEntry) > ctx->max) {
+		return false;
+	}
+
+	struct ReplayDictNfcEntry *entry = (struct ReplayDictNfcEntry *)
+		ctx->cur;
+	*run_id = entry->run_id;
+	*counter = __ntohl(entry->counter);
+
+	ctx->cur += sizeof(struct ReplayDictNfcEntry);
+
+	return true;
+}
+
 static bool key_read_popup_handle_key_read(ESubGhzChatState *state)
 {
 	NfcDeviceData *dev_data = state->nfc_dev_data;
 
-	if (dev_data->mf_ul_data.data_read < KEY_BITS / 8) {
+	/* check for config pages */
+	if (dev_data->mf_ul_data.data_read < NFC_CONFIG_PAGES * 4) {
+		return false;
+	}
+
+	size_t data_read = dev_data->mf_ul_data.data_read - (NFC_CONFIG_PAGES *
+			4);
+
+	/* check if key was transmitted */
+	if (data_read < KEY_BITS / 8) {
 		return false;
 	}
 
@@ -59,6 +94,16 @@ static bool key_read_popup_handle_key_read(ESubGhzChatState *state)
 		return false;
 	}
 
+	/* read the replay dict */
+	struct ReplayDictNfcReaderContext rd_ctx = {
+		.cur = dev_data->mf_ul_data.data + (KEY_BITS / 8),
+		.max = dev_data->mf_ul_data.data + (data_read < NFC_MAX_BYTES ?
+				data_read : NFC_MAX_BYTES)
+	};
+
+	crypto_ctx_read_replay_dict(state->crypto_ctx, replay_dict_nfc_reader,
+			&rd_ctx);
+
 	/* set encrypted flag */
 	state->encrypted = true;
 

+ 43 - 2
non_catalog_apps/esubghz_chat/scenes/esubghz_chat_key_share_popup.c

@@ -1,4 +1,32 @@
 #include "../esubghz_chat_i.h"
+#include "../nfc_helpers.h"
+
+struct ReplayDictNfcWriterContext {
+	uint8_t *cur;
+	uint8_t *max;
+};
+
+static bool replay_dict_nfc_writer(uint64_t run_id, uint32_t counter, void
+		*context)
+{
+	struct ReplayDictNfcWriterContext *ctx = (struct
+			ReplayDictNfcWriterContext *) context;
+
+	struct ReplayDictNfcEntry entry = {
+		.run_id = run_id,
+		.counter = __htonl(counter),
+		.unused = 0
+	};
+
+	if (ctx->cur + sizeof(entry) > ctx->max) {
+		return false;
+	}
+
+	memcpy(ctx->cur, &entry, sizeof(entry));
+	ctx->cur += sizeof(entry);
+
+	return true;
+}
 
 static void prepare_nfc_dev_data(ESubGhzChatState *state)
 {
@@ -21,9 +49,22 @@ static void prepare_nfc_dev_data(ESubGhzChatState *state)
 	dev_data->mf_ul_data.version.storage_size = 0x11;
 	dev_data->mf_ul_data.version.protocol_type = 0x03;
 
-	/* Add 16 to the size for config pages */
-	dev_data->mf_ul_data.data_size = (KEY_BITS / 8) + 16;
+	/* write key */
 	crypto_ctx_get_key(state->crypto_ctx, dev_data->mf_ul_data.data);
+
+	/* write the replay dict */
+	struct ReplayDictNfcWriterContext wr_ctx = {
+		.cur = dev_data->mf_ul_data.data + (KEY_BITS / 8),
+		.max = dev_data->mf_ul_data.data + NFC_MAX_BYTES
+	};
+
+	size_t n_entries = crypto_ctx_dump_replay_dict(state->crypto_ctx,
+			replay_dict_nfc_writer, &wr_ctx);
+
+	/* calculate size of data, add 16 for config pages */
+	dev_data->mf_ul_data.data_size = (KEY_BITS / 8) + (n_entries *
+			sizeof(struct ReplayDictNfcEntry)) + (NFC_CONFIG_PAGES
+			* 4);
 }
 
 /* Prepares the key share popup scene. */

+ 22 - 12
non_catalog_apps/flipper_chronometer/flipper_chronometer.c

@@ -7,10 +7,8 @@
 #include <gui/gui.h>
 #include <input/input.h>
 #include <notification/notification_messages.h>
-#include <furi_hal_pwm.h>
 #include <furi_hal_power.h>
 #include <locale/locale.h>
-#include <lib/toolbox/md5.h>
 
 #define SCREEN_SIZE_X 128
 #define SCREEN_SIZE_Y 64
@@ -18,7 +16,6 @@
 typedef enum {
     EventTypeInput,
     ClockEventTypeTick,
-    EventGPIO,
 } EventType;
 
 typedef struct {
@@ -26,12 +23,11 @@ typedef struct {
     InputEvent input;
 } EventApp;
 
-#define lineArraySize 128
-
 typedef struct {
     FuriMutex* mutex;
     uint32_t timer;
     uint8_t minute;
+    uint8_t hour;
 } mutexStruct;
 
 static void draw_callback(Canvas* canvas, void* ctx) 
@@ -43,9 +39,13 @@ static void draw_callback(Canvas* canvas, void* ctx)
     furi_mutex_release(mutexVal->mutex);
 
     char buffer[16];
-    snprintf(buffer, sizeof(buffer), "%02u:%02lu:%03lu", mutexDraw.minute, mutexDraw.timer / 64000000, (mutexDraw.timer % 64000000) / 64000);
     canvas_set_font(canvas, FontBigNumbers);
-    canvas_draw_str_aligned(canvas, SCREEN_SIZE_X/2, SCREEN_SIZE_Y/2 + 5, AlignCenter, AlignBottom, buffer);
+    snprintf(buffer, sizeof(buffer), "%02u:%02u:%02lu", mutexDraw.hour, mutexDraw.minute, mutexDraw.timer / 64000000);
+    canvas_draw_str_aligned(canvas, 5, SCREEN_SIZE_Y/2 + 5, AlignLeft, AlignBottom, buffer);
+
+    canvas_set_font(canvas, FontPrimary);
+    snprintf(buffer, sizeof(buffer), "%03lu", (mutexDraw.timer % 64000000) / 64000);
+    canvas_draw_str_aligned(canvas, SCREEN_SIZE_X - 5, SCREEN_SIZE_Y/2, AlignRight, AlignBottom, buffer);
 }
 
 static void input_callback(InputEvent* input_event, void* ctx) 
@@ -81,6 +81,7 @@ int32_t flipper_chronometer_app()
     mutexStruct mutexVal;
     mutexVal.minute = 0;
     mutexVal.timer = 0;
+    mutexVal.hour = 0;
 
     uint32_t previousTimer = 0;
 
@@ -137,6 +138,7 @@ int32_t flipper_chronometer_app()
                     LL_TIM_SetCounter(TIM2, 0);
                     furi_mutex_acquire(mutexVal.mutex, FuriWaitForever);
                     mutexVal.minute = 0;
+                    mutexVal.hour = 0;
                     mutexVal.timer = 0;
                     furi_mutex_release(mutexVal.mutex);
 
@@ -157,12 +159,20 @@ int32_t flipper_chronometer_app()
             if (mutexVal.timer < previousTimer)
             {
                 if (mutexVal.minute < 59) mutexVal.minute++;
-                else 
+                else
                 {
-                    LL_TIM_DisableCounter(TIM2);
-                    mutexVal.timer = 3839999999;
-                    furi_timer_stop(timer);
-                    enableChrono = 0;
+                    if (mutexVal.hour < 99)
+                    {
+                        mutexVal.hour++;
+                        mutexVal.minute = 0;
+                    }
+                    else
+                    {
+                        LL_TIM_DisableCounter(TIM2);
+                        mutexVal.timer = 3839999999;
+                        furi_timer_stop(timer);
+                        enableChrono = 0;
+                    }
                 }
             }
             furi_mutex_release(mutexVal.mutex);

+ 1 - 1
non_catalog_apps/flipperscope/README.md

@@ -10,7 +10,7 @@ cd ..
 ./fbt launch_app APPSRC=applications_user/flipperscope
 ```
 
-Alternatively upload the **scope.fap** file in the binary folder of this repository to your flipper zero.
+Alternatively the binary can now be installed from https://lab.flipper.net/apps/flipperscope or the Flipper Mobile App.
 
 Provide signal to **pin 16/PC0**, with a voltage ranging from 0V to 2.5V and ground to **pin 18/GND**.
 

+ 1 - 0
non_catalog_apps/flipperscope/application.fam

@@ -8,6 +8,7 @@ App(
     stack_size=1 * 1024,
     fap_category="GPIO",
     fap_icon="scope_10px.png",
+    fap_icon_assets="icons",
     fap_version="0.1",
     fap_description="Oscilloscope application - apply signal to pin 16/PC0, with a voltage ranging from 0V to 2.5V and ground to pin 18/GND",
 )

BIN
non_catalog_apps/flipperscope/icons/pause_10x10.png


BIN
non_catalog_apps/flipperscope/icons/play_10x10.png


+ 3 - 1
non_catalog_apps/flipperscope/scenes/scope_scene_about.c

@@ -13,7 +13,9 @@ void scope_scene_about_on_enter(void* context) {
     FuriString* temp_str;
     temp_str = furi_string_alloc();
     furi_string_printf(temp_str, "\e#%s\n", "Information");
-    furi_string_cat_printf(temp_str, "Provide signal to pin 16/PC0, with a voltage ranging from 0V to 2.5V and ground to pin 18/GND.\n\n");
+    furi_string_cat_printf(
+        temp_str,
+        "Provide signal to pin 16/PC0, with a voltage ranging from 0V to 2.5V and ground to pin 18/GND.\n\n");
     furi_string_cat_printf(temp_str, "Developed by: %s\n", S_DEVELOPED);
     furi_string_cat_printf(temp_str, "Github: %s\n\n", S_GITHUB);
 

+ 14 - 0
non_catalog_apps/flipperscope/scenes/scope_scene_run.c

@@ -24,6 +24,7 @@
 #include "stm32wbxx_ll_gpio.h"
 
 #include "../scope_app_i.h"
+#include "flipperscope_icons.h"
 
 #define DIGITAL_SCALE_12BITS ((uint32_t)0xFFF)
 #define ADC_CONVERTED_DATA_BUFFER_SIZE ((uint32_t)128)
@@ -352,6 +353,11 @@ static void app_draw_callback(Canvas* canvas, void* ctx) {
     float min = FLT_MAX;
     int count = 0;
 
+    if(pause)
+        canvas_draw_icon(canvas, 115, 0, &I_pause_10x10);
+    else
+        canvas_draw_icon(canvas, 115, 0, &I_play_10x10);
+
     // Calculate voltage measurements
     for(uint32_t x = 0; x < ADC_CONVERTED_DATA_BUFFER_SIZE; x++) {
         if(mvoltDisplay[x] < min) min = mvoltDisplay[x];
@@ -454,6 +460,10 @@ void scope_scene_run_on_enter(void* context) {
     // What type of measurement are we performing
     type = app->measurement;
 
+    // Pause capture, when first started, if capturing
+    if(type == m_capture)
+        pause = 1;
+
     // Copy vector table, modify to use our own IRQ handlers
     __disable_irq();
     memcpy(ramVector, (uint32_t*)(FLASH_BASE | SCB->VTOR), sizeof(uint32_t) * TABLE_SIZE);
@@ -534,6 +544,10 @@ void scope_scene_run_on_enter(void* context) {
 
     furi_hal_bus_disable(FuriHalBusTIM2);
 
+    // Disable ADC interrupt and timer
+    LL_ADC_DisableIT_OVR(ADC1);
+    LL_TIM_DisableCounter(TIM2);
+
     // Stop DMA and switch back to original vector table
     LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_1);
 

+ 2 - 2
non_catalog_apps/flipperscope/scope_app_i.h

@@ -21,14 +21,14 @@ typedef struct {
 static const timeperiod time_list[] =
     {{1.0, "1s"}, {0.1, "0.1s"}, {1e-3, "1ms"}, {0.1e-3, "0.1ms"}, {1e-6, "1us"}};
 
-enum measureenum { m_time, m_voltage };
+enum measureenum { m_time, m_voltage, m_capture };
 
 typedef struct {
     enum measureenum type;
     char* str;
 } measurement;
 
-static const measurement measurement_list[] = {{m_time, "Time"}, {m_voltage, "Voltage"}};
+static const measurement measurement_list[] = {{m_time, "Time"}, {m_voltage, "Voltage"}, {m_capture, "Capture"}};
 
 struct ScopeApp {
     Gui* gui;

+ 6 - 5
non_catalog_apps/ublox/README.md

@@ -1,6 +1,7 @@
 # ublox
-Flipper Zero app to read from a u-blox GPS over I2C. This used to be
-in my repository `flipped`, but got to be both large and good enough
-to merit its own repo. Furthermore, I really, truly fixed the awful
-memory leak that had been plaguing this app for months, so now feature
-development can continue.
+Flipper Zero app to read from a u-blox GPS over I2C. This app can
+display data, log a path to a KML file, and sync the Flipper's time to
+GPS time.
+
+This app used to reside in my "flipped" GitHub repository, but I made
+it much better and moved it here.

+ 5 - 1
non_catalog_apps/ublox/application.fam

@@ -12,7 +12,11 @@ App(
     ],
     stack_size=2 * 1024,
     order=20,
+    fap_version=(0, 1), # major, minor
+    fap_description="App to display and log data from u-blox GPS modules over I2C",
+    fap_author="liamur",
     fap_icon="ublox_app_icon.png",
-    fap_category="GPIO", 
+    fap_category="GPIO",
     fap_icon_assets="images",
+    fap_weburl="https://github.com/liamhays/ublox",
 )

+ 3 - 0
non_catalog_apps/ublox/changelog.md

@@ -0,0 +1,3 @@
+0.1:
+- Initial release with data display, two view modes, time syncing, GPS
+  configuration, and KML logging.

+ 43 - 56
non_catalog_apps/ublox/helpers/kml.c

@@ -4,46 +4,40 @@
 
 bool kml_open_file(Storage* storage, KMLFile* kml, const char* path) {
     kml->file = storage_file_alloc(storage);
-    if (!storage_file_open(kml->file,
-			   path,
-			   FSAM_WRITE,
-			   FSOM_CREATE_ALWAYS)) {
-	FURI_LOG_E(TAG, "failed to open KML file %s", path);
-	storage_file_free(kml->file);
-	return false;
+    if(!storage_file_open(kml->file, path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
+        FURI_LOG_E(TAG, "failed to open KML file %s", path);
+        storage_file_free(kml->file);
+        return false;
     }
 
     // with the file opened, we need to write the intro KML tags
-    const char* kml_intro =
-	"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-	"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
-	"  <Document>\n"
-	"    <name>Paths</name>\n"
-	"    <Style id=\"yellowLineGreenPoly\">\n"
-	"      <LineStyle>\n"
-	"        <color>7f00ffff</color>\n"
-	"        <width>4</width>\n"
-	"      </LineStyle>\n"
-	"      <PolyStyle>\n"
-	"        <color>7f00ff00</color>\n"
-	"      </PolyStyle>\n"
-	"    </Style>\n"
-	"    <Placemark>\n"
-	"      <name>Path 1</name>\n"
-	"      <description>Path 1</description>\n"
-	"      <styleUrl>#yellowLineGreenPoly</styleUrl>\n"
-	"      <LineString>\n"
-	"        <tessellate>1</tessellate>\n"
-	"        <extrude>1</extrude>\n"
-	"        <altitudeMode>absolute</altitudeMode>\n"
-	"        <coordinates>\n";
+    const char* kml_intro = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+                            "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
+                            "  <Document>\n"
+                            "    <name>Paths</name>\n"
+                            "    <Style id=\"yellowLineGreenPoly\">\n"
+                            "      <LineStyle>\n"
+                            "        <color>7f00ffff</color>\n"
+                            "        <width>4</width>\n"
+                            "      </LineStyle>\n"
+                            "      <PolyStyle>\n"
+                            "        <color>7f00ff00</color>\n"
+                            "      </PolyStyle>\n"
+                            "    </Style>\n"
+                            "    <Placemark>\n"
+                            "      <name>Path 1</name>\n"
+                            "      <description>Path 1</description>\n"
+                            "      <styleUrl>#yellowLineGreenPoly</styleUrl>\n"
+                            "      <LineString>\n"
+                            "        <tessellate>1</tessellate>\n"
+                            "        <extrude>1</extrude>\n"
+                            "        <altitudeMode>absolute</altitudeMode>\n"
+                            "        <coordinates>\n";
 
-    if (!storage_file_write(kml->file,
-			    kml_intro,
-			    strlen(kml_intro))) {
-	storage_file_close(kml->file);
-	storage_file_free(kml->file);
-	return false;
+    if(!storage_file_write(kml->file, kml_intro, strlen(kml_intro))) {
+        storage_file_close(kml->file);
+        storage_file_free(kml->file);
+        return false;
     }
 
     return true;
@@ -52,35 +46,28 @@ bool kml_open_file(Storage* storage, KMLFile* kml, const char* path) {
 bool kml_add_path_point(KMLFile* kml, double lat, double lon, uint32_t alt) {
     // KML is longitude then latitude for some reason
     FuriString* point = furi_string_alloc_printf("          %f,%f,%lu\n", lon, lat, alt);
-    if (!storage_file_write(kml->file,
-			    furi_string_get_cstr(point),
-			    furi_string_size(point))) {
-	return false;
+    if(!storage_file_write(kml->file, furi_string_get_cstr(point), furi_string_size(point))) {
+        return false;
     }
 
     return true;
 }
 
 bool kml_close_file(KMLFile* kml) {
-    const char* kml_outro =
-	"        </coordinates>\n"
-	"      </LineString>\n"
-	"    </Placemark>\n"
-	"  </Document>\n"
-	"</kml>";
+    const char* kml_outro = "        </coordinates>\n"
+                            "      </LineString>\n"
+                            "    </Placemark>\n"
+                            "  </Document>\n"
+                            "</kml>";
 
-    if (!storage_file_write(kml->file,
-			    kml_outro,
-			    strlen(kml_outro))) {
-	storage_file_close(kml->file);
-	storage_file_free(kml->file);
-	return false;
+    if(!storage_file_write(kml->file, kml_outro, strlen(kml_outro))) {
+        storage_file_close(kml->file);
+        storage_file_free(kml->file);
+        return false;
     }
 
     storage_file_close(kml->file);
     storage_file_free(kml->file);
-    
-    return true;
-}	
-
 
+    return true;
+}

+ 0 - 2
non_catalog_apps/ublox/helpers/kml.h

@@ -18,5 +18,3 @@ bool kml_open_file(Storage* storage, KMLFile* kml, const char* path);
 bool kml_add_path_point(KMLFile* kml, double lat, double lon, uint32_t alt);
 
 bool kml_close_file(KMLFile* kml);
-
-

+ 0 - 2
non_catalog_apps/ublox/helpers/ublox_types.h

@@ -48,7 +48,6 @@ typedef enum {
 
 typedef struct UbloxDataDisplayState {
     UbloxDataDisplayViewMode view_mode;
-    UbloxDataDisplayBacklightMode backlight_mode;
     UbloxDataDisplayRefreshRate refresh_rate;
     UbloxDataDisplayNotifyMode notify_mode;
 } UbloxDataDisplayState;
@@ -57,4 +56,3 @@ typedef struct UbloxDeviceState {
     UbloxOdometerMode odometer_mode;
     UbloxPlatformModel platform_model;
 } UbloxDeviceState;
-

+ 12 - 10
non_catalog_apps/ublox/scenes/ublox_scene_about.c

@@ -31,18 +31,20 @@ void ublox_scene_about_on_enter(void* context) {
     furi_string_cat_printf(s, "GitHub: %s\n", UBLOX_GITHUB);
 
     furi_string_cat_printf(s, "\e#%s\n", "Description");
-    furi_string_cat_printf(s,
-			   "This app is a multi-purpose tool for u-blox GPS modules connected over I2C."
-			   " It is compatible with 8 and 9 series GPS units, and probably other models,"
-			   " sold by Sparkfun and other vendors.\n");
+    furi_string_cat_printf(
+        s,
+        "This app is a multi-purpose tool for u-blox GPS modules connected over I2C."
+        " It is compatible with 8 and 9 series GPS units, and probably other models,"
+        " sold by Sparkfun and other vendors.\n");
 
     furi_string_cat_printf(s, "\e#%s\n", "Usage");
-    furi_string_cat_printf(s,
-			   "Data Display shows GPS data. You can enable logging to a KML file to be"
-			   " viewed in a map program.\n"
-			   "Sync Time to GPS will sync the Flipper's RTC to the GPS. Note that this"
-			   " may be up to one second off, because there is no PPS signal connected.");
-			   
+    furi_string_cat_printf(
+        s,
+        "Data Display shows GPS data. You can enable logging to a KML file to be"
+        " viewed in a map program.\n"
+        "Sync Time to GPS will sync the Flipper's RTC to the GPS. Note that this"
+        " may be up to one second off, because there is no PPS signal connected.");
+
     widget_add_text_scroll_element(ublox->widget, 0, 16, 128, 50, furi_string_get_cstr(s));
 
     furi_string_free(s);

+ 25 - 25
non_catalog_apps/ublox/scenes/ublox_scene_data_display.c

@@ -18,7 +18,7 @@ void ublox_scene_data_display_view_callback(void* context, InputKey key) {
     } else if(key == InputKeyOk) {
         view_dispatcher_send_custom_event(ublox->view_dispatcher, GuiButtonTypeCenter);
     } else if(key == InputKeyRight) {
-	view_dispatcher_send_custom_event(ublox->view_dispatcher, GuiButtonTypeRight);
+        view_dispatcher_send_custom_event(ublox->view_dispatcher, GuiButtonTypeRight);
     }
 }
 
@@ -27,9 +27,9 @@ void ublox_scene_data_display_on_enter(void* context) {
 
     // Use any existing data
     data_display_set_nav_messages(ublox->data_display, ublox->nav_pvt, ublox->nav_odo);
-    
+
     data_display_set_callback(ublox->data_display, ublox_scene_data_display_view_callback, ublox);
-    
+
     if((ublox->data_display_state).view_mode == UbloxDataDisplayViewModeHandheld) {
         data_display_set_state(ublox->data_display, DataDisplayHandheldMode);
     } else if((ublox->data_display_state).view_mode == UbloxDataDisplayViewModeCar) {
@@ -38,7 +38,8 @@ void ublox_scene_data_display_on_enter(void* context) {
 
     view_dispatcher_switch_to_view(ublox->view_dispatcher, UbloxViewDataDisplay);
 
-    ublox_worker_start(ublox->worker, UbloxWorkerStateRead, ublox_scene_data_display_worker_callback, ublox);
+    ublox_worker_start(
+        ublox->worker, UbloxWorkerStateRead, ublox_scene_data_display_worker_callback, ublox);
 }
 
 bool ublox_scene_data_display_on_event(void* context, SceneManagerEvent event) {
@@ -47,23 +48,24 @@ bool ublox_scene_data_display_on_event(void* context, SceneManagerEvent event) {
 
     if(event.type == SceneManagerEventTypeCustom) {
         if(event.event == GuiButtonTypeLeft) {
-	    ublox_worker_stop(ublox->worker);
+            ublox_worker_stop(ublox->worker);
             scene_manager_next_scene(ublox->scene_manager, UbloxSceneDataDisplayConfig);
             consumed = true;
-        
-	} else if(event.event == GuiButtonTypeRight) {
-	    // TODO: only allow if GPS is detected?
-	    FURI_LOG_I(TAG, "right button");
-	    if (ublox->log_state == UbloxLogStateNone) {
-		// start logging
-		ublox_worker_stop(ublox->worker);
-		scene_manager_next_scene(ublox->scene_manager, UbloxSceneEnterFileName);
-		consumed = true;
-	    } else if(ublox->log_state == UbloxLogStateLogging) {
-		FURI_LOG_I(TAG, "stop logging from scene");
-		ublox->log_state = UbloxLogStateStopLogging;
-	    }
-	    
+
+        } else if(event.event == GuiButtonTypeRight) {
+            if(data_display_get_state(ublox->data_display) != DataDisplayGPSNotFound) {
+                FURI_LOG_I(TAG, "right button");
+                if(ublox->log_state == UbloxLogStateNone) {
+                    // start logging
+                    ublox_worker_stop(ublox->worker);
+                    scene_manager_next_scene(ublox->scene_manager, UbloxSceneEnterFileName);
+                    consumed = true;
+                } else if(ublox->log_state == UbloxLogStateLogging) {
+                    FURI_LOG_I(TAG, "stop logging from scene");
+                    ublox->log_state = UbloxLogStateStopLogging;
+                }
+            }
+
         } else if(event.event == UbloxWorkerEventDataReady) {
             if((ublox->data_display_state).notify_mode == UbloxDataDisplayNotifyOn) {
                 notification_message(ublox->notifications, &sequence_new_reading);
@@ -77,11 +79,10 @@ bool ublox_scene_data_display_on_event(void* context, SceneManagerEvent event) {
 
             data_display_set_nav_messages(ublox->data_display, ublox->nav_pvt, ublox->nav_odo);
 
+        } else if(event.event == UbloxWorkerEventLogStateChanged) {
+            data_display_set_log_state(ublox->data_display, ublox->log_state);
 
-	} else if(event.event == UbloxWorkerEventLogStateChanged) {
-	    data_display_set_log_state(ublox->data_display, ublox->log_state);
-
-	} else if(event.event == UbloxWorkerEventFailed) {
+        } else if(event.event == UbloxWorkerEventFailed) {
             FURI_LOG_I(TAG, "UbloxWorkerEventFailed");
             data_display_set_state(ublox->data_display, DataDisplayGPSNotFound);
         }
@@ -98,9 +99,8 @@ void ublox_scene_data_display_on_exit(void* context) {
 	//while (ublox->log_state != UbloxLogStateNone);
 	//furi_delay_ms(500);
 	}*/
-    
+
     ublox_worker_stop(ublox->worker);
 
     data_display_reset(ublox->data_display);
-
 }

+ 11 - 70
non_catalog_apps/ublox/scenes/ublox_scene_data_display_config.c

@@ -4,7 +4,6 @@
 
 enum UbloxSettingIndex {
     UbloxSettingIndexRefreshRate,
-    UbloxSettingIndexBacklightMode,
     UbloxSettingIndexDisplayMode,
     UbloxSettingIndexNotify,
     UbloxSettingIndexPlatformModel,
@@ -15,7 +14,6 @@ enum UbloxSettingIndex {
 enum UbloxDataDisplayConfigIndex {
     UbloxDataDisplayConfigIndexDisplayMode,
     UbloxDataDisplayConfigIndexRefreshRate,
-    UbloxDataDisplayConfigIndexBacklightMode,
 };
 
 #define DISPLAY_VIEW_MODE_COUNT 2
@@ -29,17 +27,6 @@ const UbloxDataDisplayViewMode display_view_mode_value[DISPLAY_VIEW_MODE_COUNT]
     UbloxDataDisplayViewModeCar,
 };
 
-#define BACKLIGHT_MODE_COUNT 2
-const char* const backlight_mode_text[BACKLIGHT_MODE_COUNT] = {
-    "Default",
-    "On",
-};
-
-const UbloxDataDisplayBacklightMode backlight_mode_value[BACKLIGHT_MODE_COUNT] = {
-    UbloxDataDisplayBacklightDefault,
-    UbloxDataDisplayBacklightOn,
-};
-
 #define REFRESH_RATE_COUNT 8
 // double const means that the data is constant and that the pointer
 // is constant.
@@ -137,37 +124,6 @@ static void ublox_scene_data_display_config_set_refresh_rate(VariableItem* item)
     FURI_LOG_I(TAG, "set refresh rate to %lds", (ublox->data_display_state).refresh_rate);
 }
 
-static uint8_t ublox_scene_data_display_config_next_backlight_mode(
-    const UbloxDataDisplayBacklightMode value,
-    void* context) {
-    furi_assert(context);
-
-    uint8_t index = 0;
-    for(int i = 0; i < BACKLIGHT_MODE_COUNT; i++) {
-        if(value == backlight_mode_value[i]) {
-            index = i;
-            break;
-        } else {
-            index = 0;
-        }
-    }
-    return index;
-}
-
-static void ublox_scene_data_display_config_set_backlight_mode(VariableItem* item) {
-    Ublox* ublox = variable_item_get_context(item);
-    uint8_t index = variable_item_get_current_value_index(item);
-
-    variable_item_set_current_value_text(item, backlight_mode_text[index]);
-    (ublox->data_display_state).backlight_mode = backlight_mode_value[index];
-
-    if((ublox->data_display_state).backlight_mode == UbloxDataDisplayBacklightOn) {
-        notification_message_block(ublox->notifications, &sequence_display_backlight_enforce_on);
-    } else if((ublox->data_display_state).backlight_mode == UbloxDataDisplayBacklightDefault) {
-        notification_message_block(ublox->notifications, &sequence_display_backlight_enforce_auto);
-    }
-}
-
 static uint8_t ublox_scene_data_display_config_next_display_view_mode(
     const UbloxDataDisplayViewMode value,
     void* context) {
@@ -275,7 +231,7 @@ static void ublox_scene_data_display_config_set_platform_model(VariableItem* ite
 static void ublox_scene_data_display_config_enter_callback(void* context, uint32_t index) {
     Ublox* ublox = context;
     if(index == UbloxSettingIndexResetOdometer) {
-	view_dispatcher_send_custom_event(ublox->view_dispatcher, UbloxCustomEventResetOdometer);
+        view_dispatcher_send_custom_event(ublox->view_dispatcher, UbloxCustomEventResetOdometer);
     }
 }
 
@@ -296,17 +252,6 @@ void ublox_scene_data_display_config_on_enter(void* context) {
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, refresh_rate_text[value_index]);
 
-    item = variable_item_list_add(
-        ublox->variable_item_list,
-        "Backlight:",
-        BACKLIGHT_MODE_COUNT,
-        ublox_scene_data_display_config_set_backlight_mode,
-        ublox);
-    value_index = ublox_scene_data_display_config_next_backlight_mode(
-        (ublox->data_display_state).backlight_mode, ublox);
-    variable_item_set_current_value_index(item, value_index);
-    variable_item_set_current_value_text(item, backlight_mode_text[value_index]);
-
     item = variable_item_list_add(
         ublox->variable_item_list,
         "Display Mode:",
@@ -351,13 +296,9 @@ void ublox_scene_data_display_config_on_enter(void* context) {
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, odometer_mode_text[value_index]);
 
-    item = variable_item_list_add(
-				  ublox->variable_item_list,
-				  "Reset Odometer",
-				  1, NULL, NULL);
-    variable_item_list_set_enter_callback(ublox->variable_item_list,
-					  ublox_scene_data_display_config_enter_callback,
-					  ublox);
+    item = variable_item_list_add(ublox->variable_item_list, "Reset Odometer", 1, NULL, NULL);
+    variable_item_list_set_enter_callback(
+        ublox->variable_item_list, ublox_scene_data_display_config_enter_callback, ublox);
     view_dispatcher_switch_to_view(ublox->view_dispatcher, UbloxViewVariableItemList);
 }
 
@@ -372,19 +313,19 @@ bool ublox_scene_data_display_config_on_event(void* context, SceneManagerEvent e
     bool consumed = false;
 
     if(event.type == SceneManagerEventTypeCustom) {
-	if(event.event == UbloxCustomEventResetOdometer) {
-	    ublox_worker_start(
+        if(event.event == UbloxCustomEventResetOdometer) {
+            ublox_worker_start(
                 ublox->worker,
                 UbloxWorkerStateResetOdometer,
                 ublox_scene_data_display_config_worker_callback,
                 ublox);
-	    // don't consume, we want to stay here
-	} else if(event.event == UbloxWorkerEventOdoReset) {
-	    if((ublox->data_display_state).notify_mode == UbloxDataDisplayNotifyOn) {
+            // don't consume, we want to stay here
+        } else if(event.event == UbloxWorkerEventOdoReset) {
+            if((ublox->data_display_state).notify_mode == UbloxDataDisplayNotifyOn) {
                 notification_message(ublox->notifications, &sequence_new_reading);
             }
-	    FURI_LOG_I(TAG, "odometer reset done");
-	}
+            FURI_LOG_I(TAG, "odometer reset done");
+        }
     }
 
     return consumed;

+ 25 - 34
non_catalog_apps/ublox/scenes/ublox_scene_enter_file_name.c

@@ -14,16 +14,17 @@ FuriString* ublox_scene_enter_file_name_get_timename() {
     FuriHalRtcDateTime datetime;
     furi_hal_rtc_get_datetime(&datetime);
     FuriString* s = furi_string_alloc();
-    
+
     // YMD sorts better
-    furi_string_printf(s,
-		       "gps-%.4d%.2d%.2d-%.2d%.2d%.2d.kml",
-		       datetime.year,
-		       datetime.month,
-		       datetime.day,
-		       datetime.hour,
-		       datetime.minute,
-		       datetime.second);
+    furi_string_printf(
+        s,
+        "gps-%.4d%.2d%.2d-%.2d%.2d%.2d.kml",
+        datetime.year,
+        datetime.month,
+        datetime.day,
+        datetime.hour,
+        datetime.minute,
+        datetime.second);
     return s;
 }
 
@@ -32,30 +33,23 @@ void ublox_scene_enter_file_name_on_enter(void* context) {
     TextInput* text_input = ublox->text_input;
 
     text_input_set_header_text(text_input, "Enter KML log file name");
-    text_input_set_result_callback(text_input,
-				   ublox_text_input_callback,
-				   context,
-				   ublox->text_store,
-				   100,
-				   false);
+    text_input_set_result_callback(
+        text_input, ublox_text_input_callback, context, ublox->text_store, 100, false);
 
     FuriString* fname = ublox_scene_enter_file_name_get_timename();
     strcpy(ublox->text_store, furi_string_get_cstr(fname));
 
-
     //FuriString* full_fname = furi_string_alloc_set(folder_path);
 
     ValidatorIsFile* validator_is_file =
-	// app path folder, app extension, current file name
-	validator_is_file_alloc_init(furi_string_get_cstr(ublox->logfile_folder),
-				     UBLOX_KML_EXTENSION,
-				     "");
+        // app path folder, app extension, current file name
+        validator_is_file_alloc_init(
+            furi_string_get_cstr(ublox->logfile_folder), UBLOX_KML_EXTENSION, "");
 
     text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
-    
+
     furi_string_free(fname);
     view_dispatcher_switch_to_view(ublox->view_dispatcher, UbloxViewTextInput);
-    
 }
 
 bool ublox_scene_enter_file_name_on_event(void* context, SceneManagerEvent event) {
@@ -63,15 +57,15 @@ bool ublox_scene_enter_file_name_on_event(void* context, SceneManagerEvent event
     bool consumed = false;
 
     if(event.type == SceneManagerEventTypeCustom) {
-	if(event.event == UbloxCustomEventTextInputDone) {
-	    //FuriString* fullname;
-	    FURI_LOG_I(TAG, "text: %s", ublox->text_store);
-	    ublox->log_state = UbloxLogStateStartLogging;
-	    //scene_manager_next_scene(ublox->scene_manager, UbloxSceneDataDisplay);
-	    // don't add data_display as the next scene, instead go back to the last scene
-	    scene_manager_previous_scene(ublox->scene_manager);
-	    consumed = true;
-	}
+        if(event.event == UbloxCustomEventTextInputDone) {
+            //FuriString* fullname;
+            FURI_LOG_I(TAG, "text: %s", ublox->text_store);
+            ublox->log_state = UbloxLogStateStartLogging;
+            //scene_manager_next_scene(ublox->scene_manager, UbloxSceneDataDisplay);
+            // don't add data_display as the next scene, instead go back to the last scene
+            scene_manager_previous_scene(ublox->scene_manager);
+            consumed = true;
+        }
     }
 
     return consumed;
@@ -80,6 +74,3 @@ bool ublox_scene_enter_file_name_on_event(void* context, SceneManagerEvent event
 void ublox_scene_enter_file_name_on_exit(void* context) {
     UNUSED(context);
 }
-
-
-										  

+ 7 - 3
non_catalog_apps/ublox/scenes/ublox_scene_start.c

@@ -24,7 +24,11 @@ void ublox_scene_start_on_enter(void* context) {
         ublox_scene_start_submenu_callback,
         ublox);
     submenu_add_item(
-        submenu, "Sync Time to GPS", SubmenuIndexSyncTime, ublox_scene_start_submenu_callback, ublox);
+        submenu,
+        "Sync Time to GPS",
+        SubmenuIndexSyncTime,
+        ublox_scene_start_submenu_callback,
+        ublox);
     submenu_add_item(
         submenu, "Wiring", SubmenuIndexWiring, ublox_scene_start_submenu_callback, ublox);
     submenu_add_item(
@@ -52,8 +56,8 @@ bool ublox_scene_start_on_event(void* context, SceneManagerEvent event) {
                 ublox->scene_manager, UbloxSceneStart, SubmenuIndexWiring);
             scene_manager_next_scene(ublox->scene_manager, UbloxSceneWiring);
             consumed = true;
-	} else if(event.event == SubmenuIndexSyncTime) {
-	    scene_manager_set_scene_state(
+        } else if(event.event == SubmenuIndexSyncTime) {
+            scene_manager_set_scene_state(
                 ublox->scene_manager, UbloxSceneStart, SubmenuIndexSyncTime);
             scene_manager_next_scene(ublox->scene_manager, UbloxSceneSyncTime);
             consumed = true;

+ 50 - 62
non_catalog_apps/ublox/scenes/ublox_scene_sync_time.c

@@ -14,13 +14,11 @@ void ublox_scene_sync_time_on_enter(void* context) {
 
     view_dispatcher_switch_to_view(ublox->view_dispatcher, UbloxViewWidget);
 
-    widget_add_string_element(ublox->widget,
-			      3, 5,
-			      AlignLeft, AlignCenter,
-			      FontPrimary,
-			      "Syncing time...");
-    
-    ublox_worker_start(ublox->worker, UbloxWorkerStateSyncTime, ublox_scene_sync_time_worker_callback, ublox);
+    widget_add_string_element(
+        ublox->widget, 3, 5, AlignLeft, AlignCenter, FontPrimary, "Syncing time...");
+
+    ublox_worker_start(
+        ublox->worker, UbloxWorkerStateSyncTime, ublox_scene_sync_time_worker_callback, ublox);
 }
 
 bool ublox_scene_sync_time_on_event(void* context, SceneManagerEvent event) {
@@ -28,60 +26,50 @@ bool ublox_scene_sync_time_on_event(void* context, SceneManagerEvent event) {
     bool consumed = false;
 
     if(event.type == SceneManagerEventTypeCustom) {
-	if(event.event == UbloxWorkerEventDataReady) {
-	    widget_reset(ublox->widget);
-	    // We don't have a timezone (or even UTC offset) in the
-	    // RTC, so we can only update the minute and second---not
-	    // even the date.
-	    FuriHalRtcDateTime datetime;
-	    furi_hal_rtc_get_datetime(&datetime);
-	    datetime.minute = (ublox->nav_timeutc).min;
-	    datetime.second = (ublox->nav_timeutc).sec;
-	    furi_hal_rtc_set_datetime(&datetime);
-
-	    widget_add_string_element(ublox->widget,
-				      3, 5,
-				      AlignLeft, AlignCenter,
-				      FontPrimary,
-				      "Updated min/sec to GPS");
-	    
-	    FuriString* s = furi_string_alloc();
-	    furi_string_cat_printf(s, "New date/time: ");
-
-	    FuriString* date = furi_string_alloc();
-	    locale_format_date(date, &datetime, locale_get_date_format(), "/");
-	    furi_string_cat_printf(date, " ");
-	    FuriString* time = furi_string_alloc();
-	    locale_format_time(time, &datetime, locale_get_time_format(), ":");
-
-	    furi_string_cat(date, time);
-	    widget_add_string_element(ublox->widget,
-				      3, 25,
-				      AlignLeft, AlignTop,
-				      FontSecondary,
-				      furi_string_get_cstr(s));
-	    widget_add_string_element(ublox->widget,
-				      3, 35,
-				      AlignLeft, AlignTop,
-				      FontSecondary,
-				      furi_string_get_cstr(date));
-	    furi_string_free(time);
-	    furi_string_free(date);
-	    furi_string_free(s);
-	} else if(event.event == UbloxWorkerEventFailed) {
-	    widget_reset(ublox->widget);
-	    widget_add_string_element(ublox->widget,
-				      3, 5,
-				      AlignLeft, AlignCenter,
-				      FontPrimary,
-				      "Syncing time...failed!");
-	    widget_add_string_element(ublox->widget,
-				      3, 20,
-				      AlignLeft, AlignCenter,
-				      FontSecondary,
-				      "No GPS found!");
-	}
-	    
+        if(event.event == UbloxWorkerEventDataReady) {
+            widget_reset(ublox->widget);
+            // We don't have a timezone (or even UTC offset) in the
+            // RTC, so we can only update the minute and second---not
+            // even the date.
+            FuriHalRtcDateTime datetime;
+            furi_hal_rtc_get_datetime(&datetime);
+            datetime.minute = (ublox->nav_timeutc).min;
+            datetime.second = (ublox->nav_timeutc).sec;
+            furi_hal_rtc_set_datetime(&datetime);
+
+            widget_add_string_element(
+                ublox->widget, 3, 5, AlignLeft, AlignCenter, FontPrimary, "Updated min/sec to GPS");
+
+            FuriString* s = furi_string_alloc();
+            furi_string_cat_printf(s, "New date/time: ");
+
+            FuriString* date = furi_string_alloc();
+            locale_format_date(date, &datetime, locale_get_date_format(), "/");
+            furi_string_cat_printf(date, " ");
+            FuriString* time = furi_string_alloc();
+            locale_format_time(time, &datetime, locale_get_time_format(), ":");
+
+            furi_string_cat(date, time);
+            widget_add_string_element(
+                ublox->widget, 3, 25, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(s));
+            widget_add_string_element(
+                ublox->widget,
+                3,
+                35,
+                AlignLeft,
+                AlignTop,
+                FontSecondary,
+                furi_string_get_cstr(date));
+            furi_string_free(time);
+            furi_string_free(date);
+            furi_string_free(s);
+        } else if(event.event == UbloxWorkerEventFailed) {
+            widget_reset(ublox->widget);
+            widget_add_string_element(
+                ublox->widget, 3, 5, AlignLeft, AlignCenter, FontPrimary, "Syncing time...failed!");
+            widget_add_string_element(
+                ublox->widget, 3, 20, AlignLeft, AlignCenter, FontSecondary, "No GPS found!");
+        }
     }
 
     return consumed;
@@ -89,7 +77,7 @@ bool ublox_scene_sync_time_on_event(void* context, SceneManagerEvent event) {
 
 void ublox_scene_sync_time_on_exit(void* context) {
     Ublox* ublox = context;
-    
+
     ublox_worker_stop(ublox->worker);
 
     widget_reset(ublox->widget);

BIN
non_catalog_apps/ublox/screenshots/data_display_car.png


BIN
non_catalog_apps/ublox/screenshots/data_display_handheld.png


BIN
non_catalog_apps/ublox/screenshots/menu.png


BIN
non_catalog_apps/ublox/screenshots/sync_time.png


+ 9 - 8
non_catalog_apps/ublox/ublox.c

@@ -9,7 +9,6 @@ const NotificationSequence sequence_new_reading = {
     NULL,
 };
 
-
 bool ublox_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
     Ublox* ublox = context;
@@ -56,7 +55,7 @@ Ublox* ublox_alloc() {
     ublox->text_input = text_input_alloc();
     view_dispatcher_add_view(
         ublox->view_dispatcher, UbloxViewTextInput, text_input_get_view(ublox->text_input));
-    
+
     ublox->data_display = data_display_alloc();
     view_dispatcher_add_view(
         ublox->view_dispatcher, UbloxViewDataDisplay, data_display_get_view(ublox->data_display));
@@ -67,10 +66,9 @@ Ublox* ublox_alloc() {
     ublox->log_state = UbloxLogStateNone;
     // default to "/data", which maps to "/ext/apps_data/ublox"
     ublox->logfile_folder = furi_string_alloc_set(STORAGE_APP_DATA_PATH_PREFIX);
-    
+
     // Establish default data display state
     (ublox->data_display_state).view_mode = UbloxDataDisplayViewModeHandheld;
-    (ublox->data_display_state).backlight_mode = UbloxDataDisplayBacklightDefault;
     (ublox->data_display_state).refresh_rate = 2;
     (ublox->data_display_state).notify_mode = UbloxDataDisplayNotifyOn;
 
@@ -79,7 +77,6 @@ Ublox* ublox_alloc() {
     (ublox->device_state).platform_model = UbloxPlatformModelPortable;
     ublox->gps_initted = false;
 
-    
     return ublox;
 }
 
@@ -90,7 +87,7 @@ void ublox_free(Ublox* ublox) {
 
     // no need to stop the worker, plus it causes the app to crash by NULL
     // pointer dereference from context in the worker struct
-    
+
     //FURI_LOG_I(TAG, "stop worker");
     //ublox_worker_stop(ublox->worker);
     //FURI_LOG_I(TAG, "%p", ublox->worker->context);
@@ -111,7 +108,7 @@ void ublox_free(Ublox* ublox) {
 
     view_dispatcher_remove_view(ublox->view_dispatcher, UbloxViewTextInput);
     text_input_free(ublox->text_input);
-    
+
     view_dispatcher_free(ublox->view_dispatcher);
 
     scene_manager_free(ublox->scene_manager);
@@ -124,7 +121,7 @@ void ublox_free(Ublox* ublox) {
     ublox->storage = NULL;
 
     if(ublox->logfile_folder != NULL) {
-	furi_string_free(ublox->logfile_folder);
+        furi_string_free(ublox->logfile_folder);
     }
     free(ublox);
 }
@@ -139,6 +136,10 @@ int32_t ublox_app(void* p) {
     view_dispatcher_run(ublox->view_dispatcher);
 
     // force restore the default backlight on exit
+
+    // TODO: this is breaking the backlight timeout for everything
+    // else: test by opening ublox, then leaving and opening DAP
+    // Link. DAP Link should force the backlight on but doesn't.
     notification_message_block(ublox->notifications, &sequence_display_backlight_enforce_auto);
 
     ublox_free(ublox);

+ 2 - 2
non_catalog_apps/ublox/ublox_i.h

@@ -42,7 +42,7 @@ struct Ublox {
     VariableItemList* variable_item_list;
     TextInput* text_input;
     DataDisplayView* data_display;
-    
+
     Storage* storage;
     NotificationApp* notifications;
 
@@ -56,7 +56,7 @@ struct Ublox {
     Ublox_NAV_PVT_Message nav_pvt;
     Ublox_NAV_ODO_Message nav_odo;
     Ublox_NAV_TIMEUTC_Message nav_timeutc;
-    
+
     UbloxDataDisplayState data_display_state;
     UbloxDeviceState device_state;
     bool gps_initted;

+ 161 - 152
non_catalog_apps/ublox/ublox_worker.c

@@ -61,11 +61,11 @@ void ublox_worker_stop(UbloxWorker* ublox_worker) {
     // close the logfile if currently logging
     //FURI_LOG_I(TAG, "log state: %d", ublox->log_state);
     if(ublox->log_state == UbloxLogStateLogging) {
-	FURI_LOG_I(TAG, "closing log file on worker stop");
-	ublox->log_state = UbloxLogStateNone;
-	if (!kml_close_file(&(ublox->kmlfile))) {
-	    FURI_LOG_E(TAG, "failed to close KML file!");
-	}
+        FURI_LOG_I(TAG, "closing log file on worker stop");
+        ublox->log_state = UbloxLogStateNone;
+        if(!kml_close_file(&(ublox->kmlfile))) {
+            FURI_LOG_E(TAG, "failed to close KML file!");
+        }
     }
     if(furi_thread_get_state(ublox_worker->thread) != FuriThreadStateStopped) {
         ublox_worker_change_state(ublox_worker, UbloxWorkerStateStop);
@@ -79,48 +79,48 @@ void ublox_worker_change_state(UbloxWorker* ublox_worker, UbloxWorkerState state
 
 void clear_ublox_data() {
     int fails = 0;
-    
-    if (!furi_hal_i2c_is_device_ready(
-	    &furi_hal_i2c_handle_external,
-	    UBLOX_I2C_ADDRESS << 1,
-	    furi_ms_to_ticks(I2C_TIMEOUT_MS))) {
-	FURI_LOG_E(TAG, "clear_ublox_data(): device not ready");
-	return;
+
+    if(!furi_hal_i2c_is_device_ready(
+           &furi_hal_i2c_handle_external,
+           UBLOX_I2C_ADDRESS << 1,
+           furi_ms_to_ticks(I2C_TIMEOUT_MS))) {
+        FURI_LOG_E(TAG, "clear_ublox_data(): device not ready");
+        return;
     }
-    
+
     uint8_t tx[] = {0xff};
     uint8_t response = 0;
-    
+
     while(response != 0xff && fails < 30) {
         if(!furi_hal_i2c_trx(
                &furi_hal_i2c_handle_external,
                UBLOX_I2C_ADDRESS << 1,
-               tx, 1,
-               &response, 1,
+               tx,
+               1,
+               &response,
+               1,
                furi_ms_to_ticks(I2C_TIMEOUT_MS))) {
-	    // if the GPS is disconnected during this loop, this will
-	    // loop forever, we must make that not happen. 30 loops is
-	    // plenty, and if the clearing doesn't work, the requisite
-	    // error will be generated by the caller on the next
-	    // actual attempt to reach the GPS.
-	    fails++;
+            // if the GPS is disconnected during this loop, this will
+            // loop forever, we must make that not happen. 30 loops is
+            // plenty, and if the clearing doesn't work, the requisite
+            // error will be generated by the caller on the next
+            // actual attempt to reach the GPS.
+            fails++;
             FURI_LOG_E(TAG, "clear_ublox_data(): error clearing ublox data");
         }
     }
 }
 
-
 int32_t ublox_worker_task(void* context) {
-
     UbloxWorker* ublox_worker = context;
 
     furi_hal_i2c_acquire(&furi_hal_i2c_handle_external);
-    
+
     if(ublox_worker->state == UbloxWorkerStateRead) {
-	ublox_worker_read_nav_messages(context);
-    } else if (ublox_worker->state == UbloxWorkerStateSyncTime) {
-	FURI_LOG_I(TAG, "sync time");
-	ublox_worker_sync_to_gps_time(ublox_worker);
+        ublox_worker_read_nav_messages(context);
+    } else if(ublox_worker->state == UbloxWorkerStateSyncTime) {
+        FURI_LOG_I(TAG, "sync time");
+        ublox_worker_sync_to_gps_time(ublox_worker);
     } else if(ublox_worker->state == UbloxWorkerStateResetOdometer) {
         ublox_worker_reset_odo(ublox_worker);
     } else if(ublox_worker->state == UbloxWorkerStateStop) {
@@ -138,7 +138,7 @@ void ublox_worker_read_nav_messages(void* context) {
     // this function is fairly complicated: it inits the GPS, handles
     // logging states, and reads data from the GPS to push it to the
     // main app struct.
-    
+
     // IMPORTANT NOTE: we don't use a timer that continually respawns
     // the thread because that causes a memory leak.
     UbloxWorker* ublox_worker = context;
@@ -146,89 +146,97 @@ void ublox_worker_read_nav_messages(void* context) {
 
     // We only start logging at the same time we restart the worker.
     if(ublox->log_state == UbloxLogStateStartLogging) {
-	FURI_LOG_I(TAG, "start logging");
-	// assemble full logfile pathname
-	FuriString* fullname = furi_string_alloc();
-	path_concat(furi_string_get_cstr(ublox->logfile_folder), ublox->text_store, fullname);
-	FURI_LOG_I(TAG, "fullname is %s", furi_string_get_cstr(fullname));
-	
-	if (!kml_open_file(ublox->storage, &(ublox->kmlfile), furi_string_get_cstr(fullname))) {
-	    FURI_LOG_E(TAG, "failed to open KML file %s!", furi_string_get_cstr(fullname));
-	    ublox->log_state = UbloxLogStateNone;
-	}
-	ublox->log_state = UbloxLogStateLogging;
-	furi_string_free(fullname);
-
-	ublox_worker->callback(UbloxWorkerEventLogStateChanged, ublox_worker->context);
-           
+        FURI_LOG_I(TAG, "start logging");
+        // assemble full logfile pathname
+        FuriString* fullname = furi_string_alloc();
+        path_concat(furi_string_get_cstr(ublox->logfile_folder), ublox->text_store, fullname);
+        FURI_LOG_I(TAG, "fullname is %s", furi_string_get_cstr(fullname));
+
+        if(!kml_open_file(ublox->storage, &(ublox->kmlfile), furi_string_get_cstr(fullname))) {
+            FURI_LOG_E(TAG, "failed to open KML file %s!", furi_string_get_cstr(fullname));
+            ublox->log_state = UbloxLogStateNone;
+        }
+        ublox->log_state = UbloxLogStateLogging;
+        furi_string_free(fullname);
+
+        ublox_worker->callback(UbloxWorkerEventLogStateChanged, ublox_worker->context);
     }
-    
+
     while(!ublox->gps_initted) {
-	if(ublox_worker->state != UbloxWorkerStateRead) {
-	    return;
-	}
-
-	// have to clear right before init to make retrying init work
-	clear_ublox_data();
-	if(ublox_worker_init_gps(ublox_worker)) {
-	    ublox->gps_initted = true;
-	    break;
-	} else {
-	    ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
-	    FURI_LOG_E(TAG, "init GPS failed, try again");
-	}
-	// don't try constantly, no reason to
-	furi_delay_ms(500);
+        if(ublox_worker->state != UbloxWorkerStateRead) {
+            return;
+        }
+
+        // have to clear right before init to make retrying init work
+        clear_ublox_data();
+        if(ublox_worker_init_gps(ublox_worker)) {
+            ublox->gps_initted = true;
+            break;
+        } else {
+            ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
+            FURI_LOG_E(TAG, "init GPS failed, try again");
+        }
+        uint32_t ticks = furi_get_tick();
+        // don't try constantly, no reason to
+        while(furi_get_tick() - ticks < furi_ms_to_ticks(500)) {
+            if(ublox_worker->state != UbloxWorkerStateRead) {
+                return;
+            }
+        }
+        //furi_delay_ms(500);
     }
 
     // clear data so we don't an error on startup
     clear_ublox_data();
-    
+
     // break the loop when the thread state changes
     while(ublox_worker->state == UbloxWorkerStateRead) {
-	// we interrupt with checking the state to help reduce
-	// lag. it's not perfect, but it does overall improve things.
-	bool pvt = ublox_worker_read_pvt(ublox_worker);
-	
-	if (ublox_worker->state != UbloxWorkerStateRead) break;
-	// clearing makes the second read much faster
-	clear_ublox_data();
-	
-	if (ublox_worker->state != UbloxWorkerStateRead) break;
-	
-	bool odo = ublox_worker_read_odo(ublox_worker);
-	
-	if (pvt && odo) {
-	    ublox_worker->callback(UbloxWorkerEventDataReady, ublox_worker->context);
-	    
-	    if (ublox->log_state == UbloxLogStateLogging) {
-		if (!kml_add_path_point(&(ublox->kmlfile),
-					// ublox returns values as floats * 1e7 in int form
-					(double)(ublox->nav_pvt.lat) / (double)1e7,
-					(double)(ublox->nav_pvt.lon) / (double)1e7,
-					ublox->nav_pvt.hMSL / 1e3)) { // convert altitude to meters
-		    FURI_LOG_E(TAG, "failed to write line to file");
-		}
-	    }
-	} else {
-	    ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
-	}
-
-	uint32_t ticks = furi_get_tick();
-	while(furi_get_tick() - ticks < furi_ms_to_ticks(((ublox->data_display_state).refresh_rate * 1000))) {
-	    // putting this here (should) make the logging response faster
-	    if(ublox->log_state == UbloxLogStateStopLogging) {
-		FURI_LOG_I(TAG, "stop logging");
-		if (!kml_close_file(&(ublox->kmlfile))) {
-		    FURI_LOG_E(TAG, "failed to close KML file!");
-		}
-		ublox->log_state = UbloxLogStateNone;
-		ublox_worker->callback(UbloxWorkerEventLogStateChanged, ublox_worker->context);
-	    }
-	    if(ublox_worker->state != UbloxWorkerStateRead) {
-		return;
-	    }
-	}
+        // reading takes a little time, measure here
+        uint32_t ticks = furi_get_tick();
+        // we interrupt with checking the state to help reduce
+        // lag. it's not perfect, but it does overall improve things.
+        bool pvt = ublox_worker_read_pvt(ublox_worker);
+
+        if(ublox_worker->state != UbloxWorkerStateRead) break;
+        // clearing makes the second read much faster
+        clear_ublox_data();
+
+        if(ublox_worker->state != UbloxWorkerStateRead) break;
+
+        bool odo = ublox_worker_read_odo(ublox_worker);
+
+        if(pvt && odo) {
+            ublox_worker->callback(UbloxWorkerEventDataReady, ublox_worker->context);
+
+            if(ublox->log_state == UbloxLogStateLogging) {
+                if(!kml_add_path_point(
+                       &(ublox->kmlfile),
+                       // ublox returns values as floats * 1e7 in int form
+                       (double)(ublox->nav_pvt.lat) / (double)1e7,
+                       (double)(ublox->nav_pvt.lon) / (double)1e7,
+                       ublox->nav_pvt.hMSL / 1e3)) { // convert altitude to meters
+                    FURI_LOG_E(TAG, "failed to write line to file");
+                }
+            }
+        } else {
+            ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
+        }
+
+        while(furi_get_tick() - ticks <
+              furi_ms_to_ticks(((ublox->data_display_state).refresh_rate * 1000))) {
+            // putting this here (should) make the logging response faster
+            if(ublox->log_state == UbloxLogStateStopLogging) {
+                FURI_LOG_I(TAG, "stop logging");
+                if(!kml_close_file(&(ublox->kmlfile))) {
+                    FURI_LOG_E(TAG, "failed to close KML file!");
+                }
+                ublox->log_state = UbloxLogStateNone;
+                ublox_worker->callback(UbloxWorkerEventLogStateChanged, ublox_worker->context);
+            }
+            if(ublox_worker->state != UbloxWorkerStateRead) {
+                return;
+            }
+        }
     }
 }
 
@@ -243,30 +251,30 @@ void ublox_worker_sync_to_gps_time(void* context) {
     frame_tx.payload = NULL;
     UbloxMessage* message_tx = ublox_frame_to_bytes(&frame_tx);
 
-
-    UbloxMessage* message_rx = ublox_worker_i2c_transfer(message_tx, UBX_NAV_TIMEUTC_MESSAGE_LENGTH);
+    UbloxMessage* message_rx =
+        ublox_worker_i2c_transfer(message_tx, UBX_NAV_TIMEUTC_MESSAGE_LENGTH);
     if(message_rx == NULL) {
-	FURI_LOG_E(TAG, "get_gps_time transfer failed");
-	ublox_worker_change_state(ublox_worker, UbloxWorkerStateStop);
-	ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
-	return;
+        FURI_LOG_E(TAG, "get_gps_time transfer failed");
+        ublox_worker_change_state(ublox_worker, UbloxWorkerStateStop);
+        ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
+        return;
     }
     FURI_LOG_I(TAG, "got message");
     UbloxFrame* frame_rx = ublox_bytes_to_frame(message_rx);
     ublox_message_free(message_rx);
 
     if(frame_rx == NULL) {
-	FURI_LOG_E(TAG, "NULL pointer, something wrong with NAV-TIMEUTC message!");
-	ublox_worker_change_state(ublox_worker, UbloxWorkerStateStop);
-	ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
-	return;
+        FURI_LOG_E(TAG, "NULL pointer, something wrong with NAV-TIMEUTC message!");
+        ublox_worker_change_state(ublox_worker, UbloxWorkerStateStop);
+        ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
+        return;
     } else {
-	Ublox_NAV_TIMEUTC_Message nav_timeutc = {
-	    .iTOW = (frame_rx->payload[0]) | (frame_rx->payload[1] << 8) |
+        Ublox_NAV_TIMEUTC_Message nav_timeutc = {
+            .iTOW = (frame_rx->payload[0]) | (frame_rx->payload[1] << 8) |
                     (frame_rx->payload[2] << 16) | (frame_rx->payload[3] << 24),
-	    .tAcc = (frame_rx->payload[4]) | (frame_rx->payload[5] << 8) |
+            .tAcc = (frame_rx->payload[4]) | (frame_rx->payload[5] << 8) |
                     (frame_rx->payload[6] << 16) | (frame_rx->payload[7] << 24),
-	    .nano = (frame_rx->payload[8]) | (frame_rx->payload[9] << 8) |
+            .nano = (frame_rx->payload[8]) | (frame_rx->payload[9] << 8) |
                     (frame_rx->payload[10] << 16) | (frame_rx->payload[11] << 24),
             .year = (frame_rx->payload[12]) | (frame_rx->payload[13] << 8),
             .month = frame_rx->payload[14],
@@ -275,11 +283,11 @@ void ublox_worker_sync_to_gps_time(void* context) {
             .min = frame_rx->payload[17],
             .sec = frame_rx->payload[18],
             .valid = frame_rx->payload[19],
-	};
+        };
 
-	ublox->nav_timeutc = nav_timeutc;
-	ublox_frame_free(frame_rx);
-	ublox_worker->callback(UbloxWorkerEventDataReady, ublox_worker->context);
+        ublox->nav_timeutc = nav_timeutc;
+        ublox_frame_free(frame_rx);
+        ublox_worker->callback(UbloxWorkerEventDataReady, ublox_worker->context);
     }
 }
 
@@ -295,13 +303,12 @@ FuriString* print_uint8_array(uint8_t* array, int length) {
 }
 
 UbloxMessage* ublox_worker_i2c_transfer(UbloxMessage* message_tx, uint8_t read_length) {
-
-    if (!furi_hal_i2c_is_device_ready(
-	    &furi_hal_i2c_handle_external,
-	    UBLOX_I2C_ADDRESS << 1,
-	    furi_ms_to_ticks(I2C_TIMEOUT_MS))) {
-	FURI_LOG_E(TAG, "device not ready");
-	return NULL;
+    if(!furi_hal_i2c_is_device_ready(
+           &furi_hal_i2c_handle_external,
+           UBLOX_I2C_ADDRESS << 1,
+           furi_ms_to_ticks(I2C_TIMEOUT_MS))) {
+        FURI_LOG_E(TAG, "device not ready");
+        return NULL;
     }
 
     // Either our I2C implementation is broken or the GPS's is, so we
@@ -312,7 +319,8 @@ UbloxMessage* ublox_worker_i2c_transfer(UbloxMessage* message_tx, uint8_t read_l
     if(!furi_hal_i2c_tx(
            &furi_hal_i2c_handle_external,
            UBLOX_I2C_ADDRESS << 1,
-           message_tx->message, message_tx->length,
+           message_tx->message,
+           message_tx->length,
            furi_ms_to_ticks(I2C_TIMEOUT_MS))) {
         FURI_LOG_E(TAG, "error writing message to GPS");
         return NULL;
@@ -326,23 +334,25 @@ UbloxMessage* ublox_worker_i2c_transfer(UbloxMessage* message_tx, uint8_t read_l
 
     //FURI_LOG_I(TAG, "start ticks at %lu", furi_get_tick()); // returns ms
     while(true) {
-	if(!furi_hal_i2c_rx(
-	       &furi_hal_i2c_handle_external,
+        if(!furi_hal_i2c_rx(
+               &furi_hal_i2c_handle_external,
                UBLOX_I2C_ADDRESS << 1,
-               response, 1,
+               response,
+               1,
                furi_ms_to_ticks(I2C_TIMEOUT_MS))) {
-	    FURI_LOG_E(TAG, "error reading first byte of response");
+            FURI_LOG_E(TAG, "error reading first byte of response");
             free(response);
             return NULL;
-	}
-	
+        }
+
         // checking with 0xb5 prevents strange bursts of junk data from becoming an issue.
         if(response[0] != 0xff && response[0] == 0xb5) {
-	    //FURI_LOG_I(TAG, "read rest of message at %lu", furi_get_tick());
+            //FURI_LOG_I(TAG, "read rest of message at %lu", furi_get_tick());
             if(!furi_hal_i2c_rx(
                    &furi_hal_i2c_handle_external,
                    UBLOX_I2C_ADDRESS << 1,
-                   &(response[1]), read_length - 1, // first byte already read
+                   &(response[1]),
+                   read_length - 1, // first byte already read
                    furi_ms_to_ticks(I2C_TIMEOUT_MS))) {
                 FURI_LOG_E(TAG, "error reading rest of response");
                 free(response);
@@ -350,7 +360,7 @@ UbloxMessage* ublox_worker_i2c_transfer(UbloxMessage* message_tx, uint8_t read_l
             }
             break;
         }
-	furi_delay_ms(1);
+        furi_delay_ms(1);
     }
 
     UbloxMessage* message_rx = malloc(sizeof(UbloxMessage));
@@ -492,7 +502,7 @@ bool ublox_worker_read_odo(UbloxWorker* ublox_worker) {
             .distanceStd = (frame_rx->payload[16]) | (frame_rx->payload[17] << 8) |
                            (frame_rx->payload[18] << 16) | (frame_rx->payload[19] << 24),
         };
-	FURI_LOG_I(TAG, "odo (m): %lu", nav_odo.distance);
+        //FURI_LOG_I(TAG, "odo (m): %lu", nav_odo.distance);
         ublox->nav_odo = nav_odo;
         ublox_frame_free(frame_rx);
         return true;
@@ -596,7 +606,7 @@ bool ublox_worker_init_gps(UbloxWorker* ublox_worker) {
     UbloxMessage* nav5_message_rx =
         ublox_worker_i2c_transfer(nav5_message_tx, UBX_CFG_NAV5_MESSAGE_LENGTH);
     ublox_message_free(nav5_message_tx);
-    
+
     if(nav5_message_rx == NULL) {
         FURI_LOG_E(TAG, "CFG-NAV5 transfer failed");
         return false;
@@ -622,7 +632,6 @@ bool ublox_worker_init_gps(UbloxWorker* ublox_worker) {
     FURI_LOG_I(
         TAG, "CFG-NAV5 ack: id = %u, type = %s", ack->message[3], ack->message[3] ? "ACK" : "NAK");
 
-
     ublox_message_free(nav5_message_rx);
     ublox_message_free(ack);
     return true;
@@ -639,21 +648,21 @@ void ublox_worker_reset_odo(UbloxWorker* ublox_worker) {
     UbloxMessage* odo_message_tx = ublox_frame_to_bytes(&odo_frame_tx);
 
     UbloxMessage* ack = ublox_worker_i2c_transfer(odo_message_tx, UBX_ACK_ACK_MESSAGE_LENGTH);
-    
+
     ublox_message_free(odo_message_tx);
-    
+
     if(ack == NULL) {
         FURI_LOG_E(TAG, "ACK after NAV-RESETODO set transfer failed");
         ublox_worker->callback(UbloxWorkerEventFailed, ublox_worker->context);
         return;
     } else {
-	FURI_LOG_I(
-	    TAG,
-	    "NAV-RESETODO ack: id = %u, type = %s",
-	    ack->message[3],
-	    ack->message[3] ? "ACK" : "NAK");
-	
-	ublox_message_free(ack);
+        FURI_LOG_I(
+            TAG,
+            "NAV-RESETODO ack: id = %u, type = %s",
+            ack->message[3],
+            ack->message[3] ? "ACK" : "NAK");
+
+        ublox_message_free(ack);
     }
     ublox_worker->callback(UbloxWorkerEventOdoReset, ublox_worker->context);
     // no reason to trigger an event on success, the user will see that

+ 1 - 1
non_catalog_apps/ublox/ublox_worker.h

@@ -42,7 +42,7 @@ void ublox_worker_start(
 void ublox_worker_stop(UbloxWorker* ublox_worker);
 
 UbloxMessage* ublox_worker_i2c_transfer(UbloxMessage* message_tx, uint8_t read_length);
-    
+
 bool ublox_worker_init_gps();
 
 void ublox_worker_read_nav_messages(void* context);

+ 55 - 52
non_catalog_apps/ublox/views/data_display_view.c

@@ -21,12 +21,12 @@ static void draw_buttons(Canvas* canvas, void* model) {
     DataDisplayViewModel* m = model;
     elements_button_left(canvas, "Config");
     if(m->log_state == UbloxLogStateLogging) {
-	elements_button_right(canvas, "Stop Log");
+        elements_button_right(canvas, "Stop Log");
     } else {
-	elements_button_right(canvas, "Start Log");
+        elements_button_right(canvas, "Start Log");
     }
 }
-	
+
 static void data_display_draw_callback(Canvas* canvas, void* model) {
     DataDisplayViewModel* m = model;
     if(m->state == DataDisplayGPSNotFound) {
@@ -40,7 +40,7 @@ static void data_display_draw_callback(Canvas* canvas, void* model) {
         // TODO: check invalidLlh flag in flags3?
         Ublox_NAV_PVT_Message message = m->nav_pvt;
         Ublox_NAV_ODO_Message nav_odo = m->nav_odo;
-	draw_buttons(canvas, model);
+        draw_buttons(canvas, model);
         FuriString* s = furi_string_alloc();
 
         /*** Draw fix ***/
@@ -50,47 +50,47 @@ static void data_display_draw_callback(Canvas* canvas, void* model) {
         canvas_set_font(canvas, FontSecondary);
 
         if(message.fixType == 0) {
-	    furi_string_printf(s, "N");
+            furi_string_printf(s, "N");
         } else if(message.fixType == 1) {
-	    furi_string_printf(s, "R");
+            furi_string_printf(s, "R");
         } else if(message.fixType == 2) {
-	    furi_string_printf(s, "2D");
+            furi_string_printf(s, "2D");
         } else if(message.fixType == 3) {
-	    furi_string_printf(s, "3D");
+            furi_string_printf(s, "3D");
         } else if(message.fixType == 4) {
-	    furi_string_printf(s, "G+D");
+            furi_string_printf(s, "G+D");
         } else if(message.fixType == 5) {
-	    furi_string_printf(s, "TO");
+            furi_string_printf(s, "TO");
         }
 
         /*** Draw number of satellites ***/
-	furi_string_cat_printf(s, "/%u", message.numSV);
-	canvas_draw_str(canvas, 23, 9, furi_string_get_cstr(s));
+        furi_string_cat_printf(s, "/%u", message.numSV);
+        canvas_draw_str(canvas, 23, 9, furi_string_get_cstr(s));
 
         /*** Draw odometer ***/
         canvas_set_font(canvas, FontPrimary);
         canvas_draw_str(canvas, 58, 9, "Od:");
-	
+
         canvas_set_font(canvas, FontSecondary);
-	// distance values are in meters
-	if(locale_get_measurement_unit() == LocaleMeasurementUnitsMetric) {
-	    furi_string_printf(s, "%.1fkm", (double)(nav_odo.distance / 1e3)); // km
-	} else {
-	    furi_string_printf(s, "%.1fmi", (double)(nav_odo.distance / 1e3 * 0.6214)); // km to mi
-	}
+        // distance values are in meters
+        if(locale_get_measurement_unit() == LocaleMeasurementUnitsMetric) {
+            furi_string_printf(s, "%.1fkm", (double)(nav_odo.distance / 1e3)); // km
+        } else {
+            furi_string_printf(s, "%.1fmi", (double)(nav_odo.distance / 1e3 * 0.6214)); // km to mi
+        }
         canvas_draw_str(canvas, 77, 9, furi_string_get_cstr(s));
 
-	canvas_set_font(canvas, FontPrimary);
-	canvas_draw_str(canvas, 112, 9, "L:");
-
-	canvas_set_font(canvas, FontSecondary);
-	if (m->log_state == UbloxLogStateLogging) {
-	    canvas_draw_str(canvas, 122, 9, "Y"); // yes
-	} else {
-	    canvas_draw_str(canvas, 122, 9, "N"); // no
-	}
-	
-	/*** Draw latitude ***/
+        canvas_set_font(canvas, FontPrimary);
+        canvas_draw_str(canvas, 112, 9, "L:");
+
+        canvas_set_font(canvas, FontSecondary);
+        if(m->log_state == UbloxLogStateLogging) {
+            canvas_draw_str(canvas, 122, 9, "Y"); // yes
+        } else {
+            canvas_draw_str(canvas, 122, 9, "N"); // no
+        }
+
+        /*** Draw latitude ***/
         canvas_set_font(canvas, FontPrimary);
         canvas_draw_str(canvas, 0, 22, "Lat:");
 
@@ -158,7 +158,7 @@ static void data_display_draw_callback(Canvas* canvas, void* model) {
         Ublox_NAV_PVT_Message message = m->nav_pvt;
         Ublox_NAV_ODO_Message nav_odo = m->nav_odo;
         FuriString* s = furi_string_alloc();
-	draw_buttons(canvas, model);
+        draw_buttons(canvas, model);
         // TODO: imperial/metric
         canvas_set_font(canvas, FontPrimary);
         // gSpeed is in mm/s
@@ -194,12 +194,13 @@ static void data_display_draw_callback(Canvas* canvas, void* model) {
         canvas_draw_str(canvas, 60, 49, furi_string_get_cstr(s));
 
         furi_string_free(s);
-
     }
 }
 
 static bool data_display_input_callback(InputEvent* event, void* context) {
     DataDisplayView* data_display = context;
+    // this method of getting the model breaks the whole app
+    //DataDisplayViewModel* model = view_get_model(data_display->view);
     bool consumed = false;
 
     if(event->type == InputTypeShort) {
@@ -208,16 +209,12 @@ static bool data_display_input_callback(InputEvent* event, void* context) {
                 data_display->callback(data_display->context, event->key);
             }
             consumed = true;
-        } else if(event->key == InputKeyOk) {
+        } else if(event->key == InputKeyRight) { // && model->state != DataDisplayGPSNotFound) {
             if(data_display->callback) {
                 data_display->callback(data_display->context, event->key);
             }
-        } else if(event->key == InputKeyRight) {
-	    if(data_display->callback) {
-                data_display->callback(data_display->context, event->key);
-            }
-	    consumed = true;
-	}
+            consumed = true;
+        }
     }
     return consumed;
 }
@@ -286,25 +283,31 @@ void data_display_set_nav_messages(
         true);
 }
 
-void data_display_set_log_state(
-    DataDisplayView* data_display,
-    UbloxLogState log_state) {
+void data_display_set_log_state(DataDisplayView* data_display, UbloxLogState log_state) {
     furi_assert(data_display);
     with_view_model(
-	data_display->view,
-	DataDisplayViewModel * model,
-	{
-	    model->log_state = log_state;
-	},
-	true);
+        data_display->view, DataDisplayViewModel * model, { model->log_state = log_state; }, true);
 }
 
 void data_display_set_state(DataDisplayView* data_display, DataDisplayState state) {
     furi_assert(data_display);
     with_view_model(
         data_display->view,
-	DataDisplayViewModel * model,
-	{ model->state = state; },
-	// do refresh
-	true);
+        DataDisplayViewModel * model,
+        { model->state = state; },
+        // do refresh
+        true);
+}
+
+DataDisplayState data_display_get_state(DataDisplayView* data_display) {
+    DataDisplayState state;
+    furi_assert(data_display);
+    with_view_model(
+        data_display->view,
+        DataDisplayViewModel * model,
+        { state = model->state; },
+        // no refresh
+        false);
+
+    return state;
 }

+ 2 - 0
non_catalog_apps/ublox/views/data_display_view.h

@@ -40,3 +40,5 @@ void data_display_set_nav_messages(
 void data_display_set_state(DataDisplayView* data_display, DataDisplayState state);
 
 void data_display_set_log_state(DataDisplayView* data_display, UbloxLogState log_state);
+
+DataDisplayState data_display_get_state(DataDisplayView* data_display);

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.