Просмотр исходного кода

Squashed 'metronome/' changes from cf5342a83..4217eb68a

4217eb68a fixing some big bugs
7fa773cab combine 1
027185014 move base pack here
REVERT: cf5342a83 Update app category in README.
REVERT: a046973d8 Update application manifest.
REVERT: ace305f9e Run clang-format on sources.
REVERT: 94922f96e README improvements.
REVERT: 2b8707ea5 Add FAP build to GitHub actions.
REVERT: d668fd779 Use FuriString instead of mlib string_t.
REVERT: 472f80537 Add .gitignore.
REVERT: 17f54592c Update app type to EXTERNAL.
REVERT: 0a681eb72 Update to furi_mutex.
REVERT: 58c290196 update README
REVERT: 3003355eb fix speaker issues due to api change, fix switch statement, add icon in external folder
REVERT: dbbf14934 add graphics, update readme
REVERT: 6f5d70d53 add volume indicator
REVERT: a9fa5189d add 3 different output modes: silent, vibro, loud
REVERT: a294a57af fix indentation
REVERT: a59879bf1 refactor added elements stuff into own file
REVERT: 98e42712c readme
REVERT: 4c0d982eb add screenshot, appicon, readme
REVERT: 1c3f57129 blinking led
REVERT: 5c99c0932 working progress bar indicator
REVERT: f454a611d buttons up top
REVERT: 395fb1dc1 working note length selection
REVERT: e6927559d working beats per bar, note size fixed to 4
REVERT: 7460e50be beats per bar, settable, not implemented
REVERT: 7540797c2 center button prompt
REVERT: 06a16410e button prompt
REVERT: 0518c6e38 add long-press and repeating
REVERT: 664f8e724 code cleanup, fix timing offset due to delay
REVERT: 5aaca73b8 working beeps
REVERT: 1bfa25ed2 README
REVERT: a3cedfec4 set bpm with keys, play/pause with center

git-subtree-dir: metronome
git-subtree-split: 4217eb68a222ad5b040d3d368624bd3f529063d4
Willy-JL 2 лет назад
Родитель
Сommit
0ce1fff965
12 измененных файлов с 31 добавлено и 122 удалено
  1. 0 34
      .github/workflows/build.yml
  2. 0 57
      .gitignore
  3. 9 12
      README.md
  4. 8 3
      application.fam
  5. 1 1
      gui_extensions.c
  6. 0 0
      images/ButtonUp_7x4.png
  7. BIN
      img/1.png
  8. BIN
      img/2.png
  9. BIN
      img/screenshot.png
  10. 13 15
      metronome.c
  11. 0 0
      metronome_icon.png
  12. BIN
      ui.png

+ 0 - 34
.github/workflows/build.yml

@@ -1,34 +0,0 @@
-name: "FAP Build"
-on:
-  push:
-    branches:
-      - main 
-  pull_request:
-  schedule:
-    - cron: "1 1 * * *"
-jobs:
-  ufbt-build-action:
-    runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        include:
-          - name: dev channel
-            sdk-channel: dev
-          - name: release channel
-            sdk-channel: release
-    name: 'ufbt: Build for ${{ matrix.name }}'
-    steps:
-      - name: Checkout
-        uses: actions/checkout@v3
-        with:
-          submodules: recursive
-      - name: Build with ufbt
-        uses: flipperdevices/flipperzero-ufbt-action@v0.1.2
-        id: build-app
-        with:
-          sdk-channel: ${{ matrix.sdk-channel }}
-      - name: Upload app artifacts
-        uses: actions/upload-artifact@v3
-        with:
-          name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }}
-          path: ${{ steps.build-app.outputs.fap-artifacts }}

+ 0 - 57
.gitignore

@@ -1,57 +0,0 @@
-# Prerequisites
-*.d
-
-# Object files
-*.o
-*.ko
-*.obj
-*.elf
-
-# Linker output
-*.ilk
-*.map
-*.exp
-
-# Precompiled Headers
-*.gch
-*.pch
-
-# Libraries
-*.lib
-*.a
-*.la
-*.lo
-
-# Shared objects (inc. Windows DLLs)
-*.dll
-*.so
-*.so.*
-*.dylib
-
-# Executables
-*.exe
-*.out
-*.app
-*.i*86
-*.x86_64
-*.hex
-
-# Debug files
-*.dSYM/
-*.su
-*.idb
-*.pdb
-
-# Kernel Module Compile Results
-*.mod*
-*.cmd
-.tmp_versions/
-modules.order
-Module.symvers
-Mkfile.old
-dkms.conf
-
-# uFBT
-.vscode
-.clang-format
-dist/

+ 9 - 12
README.md

@@ -1,19 +1,10 @@
 # Metronome
 
-[![FAP Build](https://github.com/ezod/flipperzero-metronome/actions/workflows/build.yml/badge.svg)](https://github.com/ezod/flipperzero-metronome/actions/workflows/build.yml)
+[Original link](https://github.com/panki27/Metronome)
 
-A metronome for the Flipper Zero.
+A metronome for the [Flipper Zero](https://flipperzero.one/) device. Goes along perfectly with my [BPM tapper](https://github.com/panki27/bpm-tapper).
 
-![ui](ui.png)
-
-## Installation
-
-1. Navigate to the [FAP Build](https://github.com/ezod/flipperzero-metronome/actions/workflows/build.yml)
-   GitHub action workflow, and select the most recent run.
-2. The FAP is built for both the `dev` and `release` channels of the official
-   firmware. Download the artifact corresponding to your firmware version.
-3. Extract `metronome.fap` from the ZIP file to `apps/Media` on your Flipper
-   Zero SD card.
+![screenshot](img/screenshot.png)
 
 ## Features
 
@@ -24,3 +15,9 @@ A metronome for the Flipper Zero.
 - Progress indicator
 - LED flashes accordingly
 - 3 different settings: Beep, Vibrate, Silent (push Down to change)
+
+## Compiling
+
+```
+./fbt firmware_metronome
+```

+ 8 - 3
application.fam

@@ -3,10 +3,15 @@ App(
     name="Metronome",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="metronome_app",
-    requires=["gui"],
-    fap_icon="metronome_10x.png",
-    fap_icon_assets="icons",
+    requires=[
+        "gui",
+    ],
+    fap_icon="metronome_icon.png",
     fap_category="Media",
+    fap_icon_assets="images",
     stack_size=2 * 1024,
     order=20,
+    fap_author="@panki27 & @xMasterX",
+    fap_version="1.1",
+    fap_description="Metronome app",
 )

+ 1 - 1
gui_extensions.c

@@ -1,6 +1,6 @@
 #include <gui/canvas.h>
 #include <gui/icon_i.h>
-#include "metronome_icons.h"
+#include <metronome_icons.h>
 
 //lib can only do bottom left/right
 void elements_button_top_left(Canvas* canvas, const char* str) {

+ 0 - 0
icons/ButtonUp_7x4.png → images/ButtonUp_7x4.png




BIN
img/screenshot.png


+ 13 - 15
metronome.c

@@ -1,7 +1,6 @@
 #include <furi.h>
 #include <furi_hal.h>
 #include <input/input.h>
-#include <core/string.h>
 #include <stdlib.h>
 
 #include <gui/gui.h>
@@ -54,7 +53,8 @@ typedef struct {
 } MetronomeState;
 
 static void render_callback(Canvas* const canvas, void* ctx) {
-    const MetronomeState* metronome_state = (MetronomeState*)ctx;
+    furi_assert(ctx);
+    const MetronomeState* metronome_state = ctx;
     furi_mutex_acquire(metronome_state->mutex, FuriWaitForever);
 
     FuriString* tempStr = furi_string_alloc();
@@ -140,8 +140,10 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
 
 static void timer_callback(void* ctx) {
     // this is where we go BEEP!
-    MetronomeState* metronome_state = (MetronomeState*)ctx;
+    furi_assert(ctx);
+    MetronomeState* metronome_state = ctx;
     furi_mutex_acquire(metronome_state->mutex, FuriWaitForever);
+
     metronome_state->current_beat++;
     if(metronome_state->current_beat > metronome_state->beats_per_bar) {
         metronome_state->current_beat = 1;
@@ -267,7 +269,6 @@ static void metronome_state_init(MetronomeState* const metronome_state) {
     metronome_state->current_beat = 0;
     metronome_state->output_mode = Loud;
     metronome_state->notifications = furi_record_open(RECORD_NOTIFICATION);
-    metronome_state->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
 }
 
 int32_t metronome_app() {
@@ -276,6 +277,7 @@ int32_t metronome_app() {
     MetronomeState* metronome_state = malloc(sizeof(MetronomeState));
     metronome_state_init(metronome_state);
 
+    metronome_state->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
     if(!metronome_state->mutex) {
         FURI_LOG_E("Metronome", "cannot create mutex\r\n");
         free(metronome_state);
@@ -290,8 +292,7 @@ int32_t metronome_app() {
         furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, metronome_state);
 
     // Open GUI and register view_port
-    //
-    Gui* gui = furi_record_open("gui");
+    Gui* gui = furi_record_open(RECORD_GUI);
     gui_add_view_port(gui, view_port, GuiLayerFullscreen);
 
     PluginEvent event;
@@ -329,7 +330,7 @@ int32_t metronome_app() {
                     case InputKeyBack:
                         processing = false;
                         break;
-                    case InputKeyMAX:
+                    default:
                         break;
                     }
                 } else if(event.input.type == InputTypeLong) {
@@ -351,7 +352,7 @@ int32_t metronome_app() {
                     case InputKeyBack:
                         processing = false;
                         break;
-                    case InputKeyMAX:
+                    default:
                         break;
                     }
                 } else if(event.input.type == InputTypeRepeat) {
@@ -372,28 +373,25 @@ int32_t metronome_app() {
                     case InputKeyBack:
                         processing = false;
                         break;
-                    case InputKeyMAX:
+                    default:
                         break;
                     }
                 }
             }
-        } else {
-            FURI_LOG_D("Metronome", "FuriMessageQueue: event timeout");
-            // event timeout
         }
 
-        view_port_update(view_port);
         furi_mutex_release(metronome_state->mutex);
+        view_port_update(view_port);
     }
 
     view_port_enabled_set(view_port, false);
     gui_remove_view_port(gui, view_port);
-    furi_record_close("gui");
+    furi_record_close(RECORD_GUI);
     view_port_free(view_port);
     furi_message_queue_free(event_queue);
+    furi_mutex_free(metronome_state->mutex);
     furi_timer_free(metronome_state->timer);
     furi_record_close(RECORD_NOTIFICATION);
-    furi_mutex_free(metronome_state->mutex);
     free(metronome_state);
 
     return 0;

+ 0 - 0
metronome_10x.png → metronome_icon.png