diff --git a/applications/plugins/airmouse/views/bt_mouse.c b/applications/plugins/airmouse/views/bt_mouse.c deleted file mode 100644 index e6e0ae45a..000000000 --- a/applications/plugins/airmouse/views/bt_mouse.c +++ /dev/null @@ -1,303 +0,0 @@ -#include "bt_mouse.h" -#include "../tracking/main_loop.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct ButtonEvent { - int8_t button; - bool state; -} ButtonEvent; - -#define BTN_EVT_QUEUE_SIZE 32 - -struct BtMouse { - View* view; - ViewDispatcher* view_dispatcher; - Bt* bt; - NotificationApp* notifications; - FuriMutex* mutex; - FuriThread* thread; - bool connected; - - // Current mouse state - uint8_t btn; - int dx; - int dy; - int wheel; - - // Circular buffer; - // (qhead == qtail) means either empty or overflow. - // We'll ignore overflow and treat it as empty. - int qhead; - int qtail; - ButtonEvent queue[BTN_EVT_QUEUE_SIZE]; -}; - -#define BT_MOUSE_FLAG_INPUT_EVENT (1UL << 0) -#define BT_MOUSE_FLAG_KILL_THREAD (1UL << 1) -#define BT_MOUSE_FLAG_ALL (BT_MOUSE_FLAG_INPUT_EVENT | BT_MOUSE_FLAG_KILL_THREAD) - -#define MOUSE_MOVE_SHORT 5 -#define MOUSE_MOVE_LONG 20 - -static void bt_mouse_notify_event(BtMouse* bt_mouse) { - FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread); - furi_assert(thread_id); - furi_thread_flags_set(thread_id, BT_MOUSE_FLAG_INPUT_EVENT); -} - -static void bt_mouse_draw_callback(Canvas* canvas, void* context) { - UNUSED(context); - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 0, 10, "Bluetooth Mouse mode"); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 0, 63, "Hold [back] to exit"); -} - -static void bt_mouse_button_state(BtMouse* bt_mouse, int8_t button, bool state) { - ButtonEvent event; - event.button = button; - event.state = state; - - if(bt_mouse->connected) { - furi_mutex_acquire(bt_mouse->mutex, FuriWaitForever); - bt_mouse->queue[bt_mouse->qtail++] = event; - bt_mouse->qtail %= BTN_EVT_QUEUE_SIZE; - furi_mutex_release(bt_mouse->mutex); - bt_mouse_notify_event(bt_mouse); - } -} - -static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) { - with_view_model( - bt_mouse->view, - void* model, - { - UNUSED(model); - if(event->key == InputKeyUp) { - if(event->type == InputTypePress) { - bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_LEFT, true); - } else if(event->type == InputTypeRelease) { - bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_LEFT, false); - } - } else if(event->key == InputKeyDown) { - if(event->type == InputTypePress) { - bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_RIGHT, true); - } else if(event->type == InputTypeRelease) { - bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_RIGHT, false); - } - } else if(event->key == InputKeyOk) { - if(event->type == InputTypePress) { - bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_WHEEL, true); - } else if(event->type == InputTypeRelease) { - bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_WHEEL, false); - } - } - }, - true); -} - -static bool bt_mouse_input_callback(InputEvent* event, void* context) { - furi_assert(context); - BtMouse* bt_mouse = context; - bool consumed = false; - - if(event->type == InputTypeLong && event->key == InputKeyBack) { - furi_hal_bt_hid_mouse_release_all(); - } else { - bt_mouse_process(bt_mouse, event); - consumed = true; - } - - return consumed; -} - -void bt_mouse_connection_status_changed_callback(BtStatus status, void* context) { - furi_assert(context); - BtMouse* bt_mouse = context; - - bt_mouse->connected = (status == BtStatusConnected); - if(bt_mouse->connected) { - notification_internal_message(bt_mouse->notifications, &sequence_set_blue_255); - tracking_begin(); - view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0); - } else { - 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) { - furi_assert(context); - BtMouse* bt_mouse = context; - - if(bt_mouse->connected) { - furi_mutex_acquire(bt_mouse->mutex, FuriWaitForever); - bt_mouse->dx += dx; - bt_mouse->dy += dy; - furi_mutex_release(bt_mouse->mutex); - bt_mouse_notify_event(bt_mouse); - } - - 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; - } else if(t > 127) { - return 127; - } - return t; -} - -static int32_t bt_mouse_thread_callback(void* context) { - furi_assert(context); - BtMouse* bt_mouse = (BtMouse*)context; - - while(1) { - uint32_t flags = - furi_thread_flags_wait(BT_MOUSE_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever); - if(flags & BT_MOUSE_FLAG_KILL_THREAD) { - break; - } - if(flags & BT_MOUSE_FLAG_INPUT_EVENT) { - furi_mutex_acquire(bt_mouse->mutex, FuriWaitForever); - - ButtonEvent event; - bool send_buttons = false; - if(bt_mouse->qhead != bt_mouse->qtail) { - event = bt_mouse->queue[bt_mouse->qhead++]; - bt_mouse->qhead %= BTN_EVT_QUEUE_SIZE; - send_buttons = true; - } - - int8_t dx = clamp(bt_mouse->dx); - bt_mouse->dx -= dx; - int8_t dy = clamp(bt_mouse->dy); - bt_mouse->dy -= dy; - int8_t wheel = clamp(bt_mouse->wheel); - bt_mouse->wheel -= wheel; - - furi_mutex_release(bt_mouse->mutex); - - if(bt_mouse->connected && send_buttons) { - if(event.state) { - furi_hal_bt_hid_mouse_press(event.button); - } else { - furi_hal_bt_hid_mouse_release(event.button); - } - } - - if(bt_mouse->connected && (dx != 0 || dy != 0)) { - furi_hal_bt_hid_mouse_move(dx, dy); - } - - if(bt_mouse->connected && wheel != 0) { - furi_hal_bt_hid_mouse_scroll(wheel); - } - } - } - - return 0; -} - -void bt_mouse_thread_start(BtMouse* bt_mouse) { - furi_assert(bt_mouse); - bt_mouse->mutex = furi_mutex_alloc(FuriMutexTypeNormal); - bt_mouse->thread = furi_thread_alloc(); - furi_thread_set_name(bt_mouse->thread, "BtSender"); - furi_thread_set_stack_size(bt_mouse->thread, 1024); - furi_thread_set_context(bt_mouse->thread, bt_mouse); - furi_thread_set_callback(bt_mouse->thread, bt_mouse_thread_callback); - furi_thread_start(bt_mouse->thread); -} - -void bt_mouse_thread_stop(BtMouse* bt_mouse) { - furi_assert(bt_mouse); - FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread); - furi_assert(thread_id); - furi_thread_flags_set(thread_id, BT_MOUSE_FLAG_KILL_THREAD); - furi_thread_join(bt_mouse->thread); - furi_thread_free(bt_mouse->thread); - furi_mutex_free(bt_mouse->mutex); -} - -BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher) { - BtMouse* bt_mouse = malloc(sizeof(BtMouse)); - memset(bt_mouse, 0, sizeof(BtMouse)); - - bt_mouse->view = view_alloc(); - bt_mouse->view_dispatcher = view_dispatcher; - view_set_context(bt_mouse->view, bt_mouse); - view_set_draw_callback(bt_mouse->view, bt_mouse_draw_callback); - view_set_input_callback(bt_mouse->view, bt_mouse_input_callback); - 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); -} - -View* bt_mouse_get_view(BtMouse* bt_mouse) { - furi_assert(bt_mouse); - return bt_mouse->view; -} diff --git a/applications/plugins/counter/README.md b/applications/plugins/counter/README.md deleted file mode 100644 index 803c68634..000000000 --- a/applications/plugins/counter/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Dolphin counter -This is a simple plugin for the [Flipper Zero](https://www.flipperzero.one). -It gives you access to a counter which you can increment and decrement using the up and down buttons respectively. - -![preview](https://github.com/Krulknul/dolphin-counter/blob/main/media/preview.gif) - -# How to install this? -I'd recommend using [flipperzero-ufbt](https://github.com/flipperdevices/flipperzero-ufbt), which is a lightweight tool for quickly testing Flipper Zero applications. The app will stay present on your device so it is not necessary to flash the entire firmware. diff --git a/applications/plugins/counter/application.fam b/applications/plugins/counter/application.fam deleted file mode 100644 index bb2e58df1..000000000 --- a/applications/plugins/counter/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="Counter", - name="Counter", - apptype=FlipperAppType.EXTERNAL, - entry_point="counterapp", - requires=[ - "gui", - ], - fap_category="Misc", - fap_icon="icons/counter_icon.png", - fap_icon_assets="icons", -) \ No newline at end of file diff --git a/applications/plugins/counter/counter.c b/applications/plugins/counter/counter.c deleted file mode 100644 index 886ad3398..000000000 --- a/applications/plugins/counter/counter.c +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include -#include -#include - -#define MAX_COUNT 99 -#define BOXTIME 2 -#define BOXWIDTH 30 -#define MIDDLE_X 64 - BOXWIDTH / 2 -#define MIDDLE_Y 32 - BOXWIDTH / 2 -#define OFFSET_Y 9 - -typedef struct { - FuriMessageQueue* input_queue; - ViewPort* view_port; - Gui* gui; - FuriMutex** mutex; - - int count; - bool pressed; - int boxtimer; -} Counter; - -void state_free(Counter* c) { - gui_remove_view_port(c->gui, c->view_port); - furi_record_close(RECORD_GUI); - view_port_free(c->view_port); - furi_message_queue_free(c->input_queue); - furi_mutex_free(c->mutex); - free(c); -} - -static void input_callback(InputEvent* input_event, void* ctx) { - Counter* c = ctx; - if(input_event->type == InputTypeShort) { - furi_message_queue_put(c->input_queue, input_event, 0); - } -} - -static void render_callback(Canvas* canvas, void* ctx) { - Counter* c = ctx; - furi_check(furi_mutex_acquire(c->mutex, FuriWaitForever) == FuriStatusOk); - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignCenter, "Counter :)"); - canvas_set_font(canvas, FontBigNumbers); - - char scount[5]; - if(c->pressed == true || c->boxtimer > 0) { - canvas_draw_rframe(canvas, MIDDLE_X, MIDDLE_Y + OFFSET_Y, BOXWIDTH, BOXWIDTH, 5); - canvas_draw_rframe( - canvas, MIDDLE_X - 1, MIDDLE_Y + OFFSET_Y - 1, BOXWIDTH + 2, BOXWIDTH + 2, 5); - canvas_draw_rframe( - canvas, MIDDLE_X - 2, MIDDLE_Y + OFFSET_Y - 2, BOXWIDTH + 4, BOXWIDTH + 4, 5); - c->pressed = false; - c->boxtimer--; - } else { - canvas_draw_rframe(canvas, MIDDLE_X, MIDDLE_Y + OFFSET_Y, BOXWIDTH, BOXWIDTH, 5); - } - snprintf(scount, sizeof(scount), "%d", c->count); - canvas_draw_str_aligned(canvas, 64, 32 + OFFSET_Y, AlignCenter, AlignCenter, scount); - furi_mutex_release(c->mutex); -} - -Counter* state_init() { - Counter* c = malloc(sizeof(Counter)); - c->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - c->view_port = view_port_alloc(); - c->gui = furi_record_open(RECORD_GUI); - c->mutex = furi_mutex_alloc(FuriMutexTypeNormal); - c->count = 0; - c->boxtimer = 0; - view_port_input_callback_set(c->view_port, input_callback, c); - view_port_draw_callback_set(c->view_port, render_callback, c); - gui_add_view_port(c->gui, c->view_port, GuiLayerFullscreen); - return c; -} - -int32_t counterapp(void) { - Counter* c = state_init(); - - while(1) { - InputEvent input; - while(furi_message_queue_get(c->input_queue, &input, FuriWaitForever) == FuriStatusOk) { - furi_check(furi_mutex_acquire(c->mutex, FuriWaitForever) == FuriStatusOk); - - if(input.key == InputKeyBack) { - furi_mutex_release(c->mutex); - state_free(c); - return 0; - } else if((input.key == InputKeyUp || input.key == InputKeyOk) && c->count < MAX_COUNT) { - c->pressed = true; - c->boxtimer = BOXTIME; - c->count++; - } else if(input.key == InputKeyDown && c->count != 0) { - c->pressed = true; - c->boxtimer = BOXTIME; - c->count--; - } - furi_mutex_release(c->mutex); - view_port_update(c->view_port); - } - } - state_free(c); - return 0; -} diff --git a/applications/plugins/counter/icons/counter_icon.png b/applications/plugins/counter/icons/counter_icon.png deleted file mode 100644 index 4b8358b42..000000000 Binary files a/applications/plugins/counter/icons/counter_icon.png and /dev/null differ diff --git a/applications/plugins/counter/media/preview.gif b/applications/plugins/counter/media/preview.gif deleted file mode 100644 index 87098b733..000000000 Binary files a/applications/plugins/counter/media/preview.gif and /dev/null differ diff --git a/applications/plugins/flashlight/LICENSE b/applications/plugins/flashlight/LICENSE deleted file mode 100644 index 28d693a7c..000000000 --- a/applications/plugins/flashlight/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 MX - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/applications/plugins/flashlight/README.md b/applications/plugins/flashlight/README.md deleted file mode 100644 index a40cb2d5a..000000000 --- a/applications/plugins/flashlight/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Flashlight Plugin for Flipper Zero - -Simple Flashlight special for @Svaarich by @xMasterX - -Enables 3.3v on pin 7/C3 and leaves it on when you exit app - -**Connect LED to (+ -> 7/C3) | (GND -> GND)** diff --git a/applications/plugins/flashlight/application.fam b/applications/plugins/flashlight/application.fam deleted file mode 100644 index d6d5aa791..000000000 --- a/applications/plugins/flashlight/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="Flashlight", - name="Flashlight", - apptype=FlipperAppType.EXTERNAL, - entry_point="flashlight_app", - cdefines=["APP_FLASHLIGHT"], - requires=[ - "gui", - ], - stack_size=2 * 1024, - order=20, - fap_icon="flash10px.png", - fap_category="GPIO", -) \ No newline at end of file diff --git a/applications/plugins/flashlight/flash10px.png b/applications/plugins/flashlight/flash10px.png deleted file mode 100644 index 963a9ab5f..000000000 Binary files a/applications/plugins/flashlight/flash10px.png and /dev/null differ diff --git a/applications/plugins/flashlight/flashlight.c b/applications/plugins/flashlight/flashlight.c deleted file mode 100644 index 534d48fdb..000000000 --- a/applications/plugins/flashlight/flashlight.c +++ /dev/null @@ -1,130 +0,0 @@ -// by @xMasterX - -#include -#include -#include -#include -#include -#include - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef struct { - bool is_on; -} PluginState; - -static void render_callback(Canvas* const canvas, void* ctx) { - const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25); - if(plugin_state == NULL) { - return; - } - - canvas_set_font(canvas, FontPrimary); - elements_multiline_text_aligned(canvas, 64, 2, AlignCenter, AlignTop, "Flashlight"); - - canvas_set_font(canvas, FontSecondary); - - if(!plugin_state->is_on) { - elements_multiline_text_aligned( - canvas, 64, 28, AlignCenter, AlignTop, "Press OK button turn on"); - } else { - elements_multiline_text_aligned(canvas, 64, 28, AlignCenter, AlignTop, "Light is on!"); - elements_multiline_text_aligned( - canvas, 64, 40, AlignCenter, AlignTop, "Press OK button to off"); - } - - release_mutex((ValueMutex*)ctx, plugin_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void flash_toggle(PluginState* const plugin_state) { - furi_hal_gpio_write(&gpio_ext_pc3, false); - furi_hal_gpio_init(&gpio_ext_pc3, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - - if(plugin_state->is_on) { - furi_hal_gpio_write(&gpio_ext_pc3, false); - plugin_state->is_on = false; - } else { - furi_hal_gpio_write(&gpio_ext_pc3, true); - plugin_state->is_on = true; - } -} - -int32_t flashlight_app() { - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - PluginState* plugin_state = malloc(sizeof(PluginState)); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) { - FURI_LOG_E("flashlight", "cannot create mutex\r\n"); - furi_message_queue_free(event_queue); - free(plugin_state); - return 255; - } - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - - PluginState* plugin_state = (PluginState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - case InputKeyDown: - case InputKeyRight: - case InputKeyLeft: - break; - case InputKeyOk: - flash_toggle(plugin_state); - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } - } - } - - view_port_update(view_port); - release_mutex(&state_mutex, plugin_state); - } - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - - return 0; -} diff --git a/applications/plugins/music_beeper/music_beeper_worker.c b/applications/plugins/music_beeper/music_beeper_worker.c deleted file mode 100644 index 4523b806e..000000000 --- a/applications/plugins/music_beeper/music_beeper_worker.c +++ /dev/null @@ -1,507 +0,0 @@ -#include "music_beeper_worker.h" - -#include -#include - -#include -#include - -#include - -#define TAG "MusicBeeperWorker" - -#define MUSIC_BEEPER_FILETYPE "Flipper Music Format" -#define MUSIC_BEEPER_VERSION 0 - -#define SEMITONE_PAUSE 0xFF - -#define NOTE_C4 261.63f -#define NOTE_C4_SEMITONE (4.0f * 12.0f) -#define TWO_POW_TWELTH_ROOT 1.059463094359f - -typedef struct { - uint8_t semitone; - uint8_t duration; - uint8_t dots; -} NoteBlock; - -ARRAY_DEF(NoteBlockArray, NoteBlock, M_POD_OPLIST); - -struct MusicBeeperWorker { - FuriThread* thread; - bool should_work; - - MusicBeeperWorkerCallback callback; - void* callback_context; - - float volume; - uint32_t bpm; - uint32_t duration; - uint32_t octave; - NoteBlockArray_t notes; -}; - -static int32_t music_beeper_worker_thread_callback(void* context) { - furi_assert(context); - MusicBeeperWorker* instance = context; - - NoteBlockArray_it_t it; - NoteBlockArray_it(it, instance->notes); - if(furi_hal_speaker_acquire(1000)) { - while(instance->should_work) { - if(NoteBlockArray_end_p(it)) { - NoteBlockArray_it(it, instance->notes); - furi_delay_ms(10); - } else { - NoteBlock* note_block = NoteBlockArray_ref(it); - - float note_from_a4 = (float)note_block->semitone - NOTE_C4_SEMITONE; - float frequency = NOTE_C4 * powf(TWO_POW_TWELTH_ROOT, note_from_a4); - float duration = 60.0 * furi_kernel_get_tick_frequency() * 4 / instance->bpm / - note_block->duration; - uint32_t dots = note_block->dots; - while(dots > 0) { - duration += duration / 2; - dots--; - } - uint32_t next_tick = furi_get_tick() + duration; - float volume = instance->volume; - - if(instance->callback) { - instance->callback( - note_block->semitone, - note_block->dots, - note_block->duration, - 0.0, - instance->callback_context); - } - - furi_hal_speaker_stop(); - furi_hal_speaker_start(frequency, volume); - while(instance->should_work && furi_get_tick() < next_tick) { - volume *= 1; - furi_hal_speaker_set_volume(volume); - furi_delay_ms(2); - } - NoteBlockArray_next(it); - } - } - - furi_hal_speaker_stop(); - furi_hal_speaker_release(); - } else { - FURI_LOG_E(TAG, "Speaker system is busy with another process."); - } - - return 0; -} - -MusicBeeperWorker* music_beeper_worker_alloc() { - MusicBeeperWorker* instance = malloc(sizeof(MusicBeeperWorker)); - - NoteBlockArray_init(instance->notes); - - instance->thread = furi_thread_alloc_ex( - "MusicBeeperWorker", 1024, music_beeper_worker_thread_callback, instance); - - instance->volume = 1.0f; - - return instance; -} - -void music_beeper_worker_clear(MusicBeeperWorker* instance) { - NoteBlockArray_reset(instance->notes); -} - -void music_beeper_worker_free(MusicBeeperWorker* instance) { - furi_assert(instance); - furi_thread_free(instance->thread); - NoteBlockArray_clear(instance->notes); - free(instance); -} - -static bool is_digit(const char c) { - return isdigit(c) != 0; -} - -static bool is_letter(const char c) { - return islower(c) != 0 || isupper(c) != 0; -} - -static bool is_space(const char c) { - return c == ' ' || c == '\t'; -} - -static size_t extract_number(const char* string, uint32_t* number) { - size_t ret = 0; - *number = 0; - while(is_digit(*string)) { - *number *= 10; - *number += (*string - '0'); - string++; - ret++; - } - return ret; -} - -static size_t extract_dots(const char* string, uint32_t* number) { - size_t ret = 0; - *number = 0; - while(*string == '.') { - *number += 1; - string++; - ret++; - } - return ret; -} - -static size_t extract_char(const char* string, char* symbol) { - if(is_letter(*string)) { - *symbol = *string; - return 1; - } else { - return 0; - } -} - -static size_t extract_sharp(const char* string, char* symbol) { - if(*string == '#' || *string == '_') { - *symbol = '#'; - return 1; - } else { - return 0; - } -} - -static size_t skip_till(const char* string, const char symbol) { - size_t ret = 0; - while(*string != '\0' && *string != symbol) { - string++; - ret++; - } - if(*string != symbol) { - ret = 0; - } - return ret; -} - -static bool music_beeper_worker_add_note( - MusicBeeperWorker* instance, - uint8_t semitone, - uint8_t duration, - uint8_t dots) { - NoteBlock note_block; - - note_block.semitone = semitone; - note_block.duration = duration; - note_block.dots = dots; - - NoteBlockArray_push_back(instance->notes, note_block); - - return true; -} - -static int8_t note_to_semitone(const char note) { - switch(note) { - case 'C': - return 0; - // C# - case 'D': - return 2; - // D# - case 'E': - return 4; - case 'F': - return 5; - // F# - case 'G': - return 7; - // G# - case 'A': - return 9; - // A# - case 'B': - return 11; - default: - return 0; - } -} - -static bool music_beeper_worker_parse_notes(MusicBeeperWorker* instance, const char* string) { - const char* cursor = string; - bool result = true; - - while(*cursor != '\0') { - if(!is_space(*cursor)) { - uint32_t duration = 0; - char note_char = '\0'; - char sharp_char = '\0'; - uint32_t octave = 0; - uint32_t dots = 0; - - // Parsing - cursor += extract_number(cursor, &duration); - cursor += extract_char(cursor, ¬e_char); - cursor += extract_sharp(cursor, &sharp_char); - cursor += extract_number(cursor, &octave); - cursor += extract_dots(cursor, &dots); - - // Post processing - note_char = toupper(note_char); - if(!duration) { - duration = instance->duration; - } - if(!octave) { - octave = instance->octave; - } - - // Validation - bool is_valid = true; - is_valid &= (duration >= 1 && duration <= 128); - is_valid &= ((note_char >= 'A' && note_char <= 'G') || note_char == 'P'); - is_valid &= (sharp_char == '#' || sharp_char == '\0'); - is_valid &= (octave <= 16); - is_valid &= (dots <= 16); - if(!is_valid) { - FURI_LOG_E( - TAG, - "Invalid note: %lu%c%c%lu.%lu", - duration, - note_char == '\0' ? '_' : note_char, - sharp_char == '\0' ? '_' : sharp_char, - octave, - dots); - result = false; - break; - } - - // Note to semitones - uint8_t semitone = 0; - if(note_char == 'P') { - semitone = SEMITONE_PAUSE; - } else { - semitone += octave * 12; - semitone += note_to_semitone(note_char); - semitone += sharp_char == '#' ? 1 : 0; - } - - if(music_beeper_worker_add_note(instance, semitone, duration, dots)) { - FURI_LOG_D( - TAG, - "Added note: %c%c%lu.%lu = %u %lu", - note_char == '\0' ? '_' : note_char, - sharp_char == '\0' ? '_' : sharp_char, - octave, - dots, - semitone, - duration); - } else { - FURI_LOG_E( - TAG, - "Invalid note: %c%c%lu.%lu = %u %lu", - note_char == '\0' ? '_' : note_char, - sharp_char == '\0' ? '_' : sharp_char, - octave, - dots, - semitone, - duration); - } - cursor += skip_till(cursor, ','); - } - - if(*cursor != '\0') cursor++; - } - - return result; -} - -bool music_beeper_worker_load(MusicBeeperWorker* instance, const char* file_path) { - furi_assert(instance); - furi_assert(file_path); - - bool ret = false; - if(strcasestr(file_path, ".fmf")) { - ret = music_beeper_worker_load_fmf_from_file(instance, file_path); - } else { - ret = music_beeper_worker_load_rtttl_from_file(instance, file_path); - } - return ret; -} - -bool music_beeper_worker_load_fmf_from_file(MusicBeeperWorker* instance, const char* file_path) { - furi_assert(instance); - furi_assert(file_path); - - bool result = false; - FuriString* temp_str; - temp_str = furi_string_alloc(); - - Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* file = flipper_format_file_alloc(storage); - - do { - if(!flipper_format_file_open_existing(file, file_path)) break; - - uint32_t version = 0; - if(!flipper_format_read_header(file, temp_str, &version)) break; - if(furi_string_cmp_str(temp_str, MUSIC_BEEPER_FILETYPE) || - (version != MUSIC_BEEPER_VERSION)) { - FURI_LOG_E(TAG, "Incorrect file format or version"); - break; - } - - if(!flipper_format_read_uint32(file, "BPM", &instance->bpm, 1)) { - FURI_LOG_E(TAG, "BPM is missing"); - break; - } - if(!flipper_format_read_uint32(file, "Duration", &instance->duration, 1)) { - FURI_LOG_E(TAG, "Duration is missing"); - break; - } - if(!flipper_format_read_uint32(file, "Octave", &instance->octave, 1)) { - FURI_LOG_E(TAG, "Octave is missing"); - break; - } - - if(!flipper_format_read_string(file, "Notes", temp_str)) { - FURI_LOG_E(TAG, "Notes is missing"); - break; - } - - if(!music_beeper_worker_parse_notes(instance, furi_string_get_cstr(temp_str))) { - break; - } - - result = true; - } while(false); - - furi_record_close(RECORD_STORAGE); - flipper_format_free(file); - furi_string_free(temp_str); - - return result; -} - -bool music_beeper_worker_load_rtttl_from_file(MusicBeeperWorker* instance, const char* file_path) { - furi_assert(instance); - furi_assert(file_path); - - bool result = false; - FuriString* content; - content = furi_string_alloc(); - Storage* storage = furi_record_open(RECORD_STORAGE); - File* file = storage_file_alloc(storage); - - do { - if(!storage_file_open(file, file_path, FSAM_READ, FSOM_OPEN_EXISTING)) { - FURI_LOG_E(TAG, "Unable to open file"); - break; - }; - - uint16_t ret = 0; - do { - uint8_t buffer[65] = {0}; - ret = storage_file_read(file, buffer, sizeof(buffer) - 1); - for(size_t i = 0; i < ret; i++) { - furi_string_push_back(content, buffer[i]); - } - } while(ret > 0); - - furi_string_trim(content); - if(!furi_string_size(content)) { - FURI_LOG_E(TAG, "Empty file"); - break; - } - - if(!music_beeper_worker_load_rtttl_from_string(instance, furi_string_get_cstr(content))) { - FURI_LOG_E(TAG, "Invalid file content"); - break; - } - - result = true; - } while(0); - - storage_file_free(file); - furi_record_close(RECORD_STORAGE); - furi_string_free(content); - - return result; -} - -bool music_beeper_worker_load_rtttl_from_string(MusicBeeperWorker* instance, const char* string) { - furi_assert(instance); - - const char* cursor = string; - - // Skip name - cursor += skip_till(cursor, ':'); - if(*cursor != ':') { - return false; - } - - // Duration - cursor += skip_till(cursor, '='); - if(*cursor != '=') { - return false; - } - cursor++; - cursor += extract_number(cursor, &instance->duration); - - // Octave - cursor += skip_till(cursor, '='); - if(*cursor != '=') { - return false; - } - cursor++; - cursor += extract_number(cursor, &instance->octave); - - // BPM - cursor += skip_till(cursor, '='); - if(*cursor != '=') { - return false; - } - cursor++; - cursor += extract_number(cursor, &instance->bpm); - - // Notes - cursor += skip_till(cursor, ':'); - if(*cursor != ':') { - return false; - } - cursor++; - if(!music_beeper_worker_parse_notes(instance, cursor)) { - return false; - } - - return true; -} - -void music_beeper_worker_set_callback( - MusicBeeperWorker* instance, - MusicBeeperWorkerCallback callback, - void* context) { - furi_assert(instance); - instance->callback = callback; - instance->callback_context = context; -} - -void music_beeper_worker_set_volume(MusicBeeperWorker* instance, float volume) { - furi_assert(instance); - instance->volume = volume; -} - -void music_beeper_worker_start(MusicBeeperWorker* instance) { - furi_assert(instance); - furi_assert(instance->should_work == false); - - instance->should_work = true; - furi_thread_start(instance->thread); -} - -void music_beeper_worker_stop(MusicBeeperWorker* instance) { - furi_assert(instance); - furi_assert(instance->should_work == true); - - instance->should_work = false; - furi_thread_join(instance->thread); -} diff --git a/applications/plugins/musictracker/tracker_engine/speaker_hal.c b/applications/plugins/musictracker/tracker_engine/speaker_hal.c deleted file mode 100644 index 14a9c4f85..000000000 --- a/applications/plugins/musictracker/tracker_engine/speaker_hal.c +++ /dev/null @@ -1,107 +0,0 @@ -#include "speaker_hal.h" - -#define FURI_HAL_SPEAKER_TIMER TIM16 -#define FURI_HAL_SPEAKER_CHANNEL LL_TIM_CHANNEL_CH1 -#define FURI_HAL_SPEAKER_PRESCALER 500 - -void tracker_speaker_play(float frequency, float pwm) { - uint32_t autoreload = (SystemCoreClock / FURI_HAL_SPEAKER_PRESCALER / frequency) - 1; - if(autoreload < 2) { - autoreload = 2; - } else if(autoreload > UINT16_MAX) { - autoreload = UINT16_MAX; - } - - if(pwm < 0) pwm = 0; - if(pwm > 1) pwm = 1; - - uint32_t compare_value = pwm * autoreload; - - if(compare_value == 0) { - compare_value = 1; - } - - if(LL_TIM_OC_GetCompareCH1(FURI_HAL_SPEAKER_TIMER) != compare_value) { - LL_TIM_OC_SetCompareCH1(FURI_HAL_SPEAKER_TIMER, compare_value); - } - - if(LL_TIM_GetAutoReload(FURI_HAL_SPEAKER_TIMER) != autoreload) { - LL_TIM_SetAutoReload(FURI_HAL_SPEAKER_TIMER, autoreload); - if(LL_TIM_GetCounter(FURI_HAL_SPEAKER_TIMER) > autoreload) { - LL_TIM_SetCounter(FURI_HAL_SPEAKER_TIMER, 0); - } - } - - LL_TIM_EnableAllOutputs(FURI_HAL_SPEAKER_TIMER); -} - -void tracker_speaker_stop() { - LL_TIM_DisableAllOutputs(FURI_HAL_SPEAKER_TIMER); -} - -void tracker_speaker_init() { - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start(200.0f, 0.01f); - tracker_speaker_stop(); - } -} - -void tracker_speaker_deinit() { - if(furi_hal_speaker_is_mine()) { - furi_hal_speaker_stop(); - furi_hal_speaker_release(); - } -} - -static FuriHalInterruptISR tracker_isr; -static void* tracker_isr_context; -static void tracker_interrupt_cb(void* context) { - UNUSED(context); - - if(LL_TIM_IsActiveFlag_UPDATE(TIM2)) { - LL_TIM_ClearFlag_UPDATE(TIM2); - - if(tracker_isr) { - tracker_isr(tracker_isr_context); - } - } -} - -void tracker_interrupt_init(float freq, FuriHalInterruptISR isr, void* context) { - tracker_isr = isr; - tracker_isr_context = context; - - furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, tracker_interrupt_cb, NULL); - - LL_TIM_InitTypeDef TIM_InitStruct = {0}; - // Prescaler to get 1kHz clock - TIM_InitStruct.Prescaler = SystemCoreClock / 1000000 - 1; - TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; - // Auto reload to get freq Hz interrupt - TIM_InitStruct.Autoreload = (1000000 / freq) - 1; - TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; - LL_TIM_Init(TIM2, &TIM_InitStruct); - LL_TIM_EnableIT_UPDATE(TIM2); - LL_TIM_EnableAllOutputs(TIM2); - LL_TIM_EnableCounter(TIM2); -} - -void tracker_interrupt_deinit() { - FURI_CRITICAL_ENTER(); - LL_TIM_DeInit(TIM2); - FURI_CRITICAL_EXIT(); - - furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, NULL, NULL); -} - -void tracker_debug_init() { - furi_hal_gpio_init(&gpio_ext_pc3, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); -} - -void tracker_debug_set(bool value) { - furi_hal_gpio_write(&gpio_ext_pc3, value); -} - -void tracker_debug_deinit() { - furi_hal_gpio_init(&gpio_ext_pc3, GpioModeAnalog, GpioPullNo, GpioSpeedLow); -} \ No newline at end of file diff --git a/applications/plugins/ocarina/ocarina.c b/applications/plugins/ocarina/ocarina.c deleted file mode 100644 index 80dc1fddc..000000000 --- a/applications/plugins/ocarina/ocarina.c +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include -#include -#include -#include - -#define NOTE_UP 587.33f -#define NOTE_LEFT 493.88f -#define NOTE_RIGHT 440.00f -#define NOTE_DOWN 349.23 -#define NOTE_OK 293.66f - -typedef struct { - FuriMutex* model_mutex; - - FuriMessageQueue* event_queue; - - ViewPort* view_port; - Gui* gui; -} Ocarina; - -void draw_callback(Canvas* canvas, void* ctx) { - Ocarina* ocarina = ctx; - furi_check(furi_mutex_acquire(ocarina->model_mutex, FuriWaitForever) == FuriStatusOk); - - //canvas_draw_box(canvas, ocarina->model->x, ocarina->model->y, 4, 4); - canvas_draw_frame(canvas, 0, 0, 128, 64); - canvas_draw_str(canvas, 50, 10, "Ocarina"); - canvas_draw_str(canvas, 30, 20, "OK button for A"); - - furi_mutex_release(ocarina->model_mutex); -} - -void input_callback(InputEvent* input, void* ctx) { - Ocarina* ocarina = ctx; - // Puts input onto event queue with priority 0, and waits until completion. - furi_message_queue_put(ocarina->event_queue, input, FuriWaitForever); -} - -Ocarina* ocarina_alloc() { - Ocarina* instance = malloc(sizeof(Ocarina)); - - instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal); - - instance->event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, draw_callback, instance); - view_port_input_callback_set(instance->view_port, input_callback, instance); - - instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - return instance; -} - -void ocarina_free(Ocarina* instance) { - view_port_enabled_set(instance->view_port, false); // Disabsles our ViewPort - gui_remove_view_port(instance->gui, instance->view_port); // Removes our ViewPort from the Gui - furi_record_close("gui"); // Closes the gui record - view_port_free(instance->view_port); // Frees memory allocated by view_port_alloc - furi_message_queue_free(instance->event_queue); - - furi_mutex_free(instance->model_mutex); - - if(furi_hal_speaker_is_mine()) { - furi_hal_speaker_stop(); - furi_hal_speaker_release(); - } - - free(instance); -} - -int32_t ocarina_app(void* p) { - UNUSED(p); - - Ocarina* ocarina = ocarina_alloc(); - - InputEvent event; - for(bool processing = true; processing;) { - // Pops a message off the queue and stores it in `event`. - // No message priority denoted by NULL, and 100 ticks of timeout. - FuriStatus status = furi_message_queue_get(ocarina->event_queue, &event, 100); - furi_check(furi_mutex_acquire(ocarina->model_mutex, FuriWaitForever) == FuriStatusOk); - - float volume = 1.0f; - if(status == FuriStatusOk) { - if(event.type == InputTypePress) { - switch(event.key) { - case InputKeyUp: - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start(NOTE_UP, volume); - } - break; - case InputKeyDown: - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start(NOTE_DOWN, volume); - } - break; - case InputKeyLeft: - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start(NOTE_LEFT, volume); - } - break; - case InputKeyRight: - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start(NOTE_RIGHT, volume); - } - break; - case InputKeyOk: - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start(NOTE_OK, volume); - } - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } else if(event.type == InputTypeRelease) { - if(furi_hal_speaker_is_mine()) { - furi_hal_speaker_stop(); - furi_hal_speaker_release(); - } - } - } - - furi_mutex_release(ocarina->model_mutex); - view_port_update(ocarina->view_port); // signals our draw callback - } - ocarina_free(ocarina); - return 0; -} diff --git a/applications/plugins/tama_p1/hal.c b/applications/plugins/tama_p1/hal.c deleted file mode 100644 index b4638a84a..000000000 --- a/applications/plugins/tama_p1/hal.c +++ /dev/null @@ -1,143 +0,0 @@ -#include -#include -#include -#include -#include "tama.h" - -#define TAG_HAL "TamaLIB" - -static void* tama_p1_hal_malloc(u32_t size) { - return malloc(size); -} - -static void tama_p1_hal_free(void* ptr) { - free(ptr); -} - -static void tama_p1_hal_halt(void) { - g_ctx->halted = true; -} - -static bool_t tama_p1_hal_is_log_enabled(log_level_t level) { - switch(level) { - case LOG_ERROR: - return true; - case LOG_INFO: - return true; - case LOG_MEMORY: - return false; - case LOG_CPU: - return false; - default: - return false; - } -} - -static void tama_p1_hal_log(log_level_t level, char* buff, ...) { - if(!tama_p1_hal_is_log_enabled(level)) return; - - FuriString* string; - va_list args; - va_start(args, buff); - furi_string_cat_vprintf(string, buff, args); - va_end(args); - - switch(level) { - case LOG_ERROR: - FURI_LOG_E(TAG_HAL, "%s", furi_string_get_cstr(string)); - break; - case LOG_INFO: - FURI_LOG_I(TAG_HAL, "%s", furi_string_get_cstr(string)); - break; - case LOG_MEMORY: - case LOG_CPU: - default: - FURI_LOG_D(TAG_HAL, "%s", furi_string_get_cstr(string)); - break; - } - - furi_string_free(string); -} - -static void tama_p1_hal_sleep_until(timestamp_t ts) { - while(true) { - uint32_t count = LL_TIM_GetCounter(TIM2); - uint32_t delay = ts - count; - // FURI_LOG_D(TAG, "delay: %x", delay); - // Stolen from furi_delay_until_tick - if(delay != 0 && 0 == (delay >> (8 * sizeof(uint32_t) - 1))) { - // Not the best place to release mutex, but this is the only place we know whether - // we're ahead or behind, otherwise around the step call we'll always have to - // delay a tick and run more and more behind. - furi_mutex_release(g_state_mutex); - furi_delay_tick(1); - while(furi_mutex_acquire(g_state_mutex, FuriWaitForever) != FuriStatusOk) - furi_delay_tick(1); - } else { - break; - } - } -} - -static timestamp_t tama_p1_hal_get_timestamp(void) { - return LL_TIM_GetCounter(TIM2); -} - -static void tama_p1_hal_update_screen(void) { - // Do nothing, covered by main loop -} - -static void tama_p1_hal_set_lcd_matrix(u8_t x, u8_t y, bool_t val) { - if(val) - g_ctx->framebuffer[y] |= 1 << x; - else - g_ctx->framebuffer[y] &= ~(1 << x); -} - -static void tama_p1_hal_set_lcd_icon(u8_t icon, bool_t val) { - if(val) - g_ctx->icons |= 1 << icon; - else - g_ctx->icons &= ~(1 << icon); -} - -static void tama_p1_hal_play_frequency(bool_t en) { - if(en) { - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start(g_ctx->frequency, 0.5f); - } - } else { - if(furi_hal_speaker_is_mine()) { - furi_hal_speaker_stop(); - furi_hal_speaker_release(); - } - } - - g_ctx->buzzer_on = en; -} - -static void tama_p1_hal_set_frequency(u32_t freq) { - g_ctx->frequency = freq / 10.0F; - if(g_ctx->buzzer_on) tama_p1_hal_play_frequency(true); -} - -static int tama_p1_hal_handler(void) { - // Do nothing - return 0; -} - -void tama_p1_hal_init(hal_t* hal) { - hal->malloc = tama_p1_hal_malloc; - hal->free = tama_p1_hal_free; - hal->halt = tama_p1_hal_halt; - hal->is_log_enabled = tama_p1_hal_is_log_enabled; - hal->log = tama_p1_hal_log; - hal->sleep_until = tama_p1_hal_sleep_until; - hal->get_timestamp = tama_p1_hal_get_timestamp; - hal->update_screen = tama_p1_hal_update_screen; - hal->set_lcd_matrix = tama_p1_hal_set_lcd_matrix; - hal->set_lcd_icon = tama_p1_hal_set_lcd_icon; - hal->set_frequency = tama_p1_hal_set_frequency; - hal->play_frequency = tama_p1_hal_play_frequency; - hal->handler = tama_p1_hal_handler; -} \ No newline at end of file diff --git a/applications/plugins/tuning_fork/LICENSE b/applications/plugins/tuning_fork/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/tuning_fork/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - 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. - - - Copyright (C) - - 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 . - -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: - - Copyright (C) - 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 -. - - 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 -. diff --git a/applications/plugins/tuning_fork/README.md b/applications/plugins/tuning_fork/README.md deleted file mode 100644 index 5524eba3e..000000000 --- a/applications/plugins/tuning_fork/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Tuning Fork - -Inspired by [Metronome](https://github.com/panki27/Metronome) - -A tuning fork for the [Flipper Zero](https://flipperzero.one/) device. -Allows to play different notes in different pitches. - -![screenshot](img/tuning_fork.gif) - -## Features -- Tuning forks (440Hz, 432Hz, etc.) -- Scientific pitch (..., 256Hz, 512Hz, 1024Hz, ...) -- Guitar Standard (6 strings) -- Guitar Drop D (6 strings) -- Guitar D (6 strings) -- Guitar Drop C (6 strings) -- Guitar Standard (7 strings) -- Bass Standard (4 strings) -- Bass Standard Tenor (4 strings) -- Bass Standard (5 strings) -- Bass Standard Tenor (5 strings) -- Bass Drop D (4 strings) -- Bass D (4 strings) -- Bass Drop A (5 strings) - -## Compiling - -``` -./fbt firmware_tuning_fork -``` diff --git a/applications/plugins/tuning_fork/application.fam b/applications/plugins/tuning_fork/application.fam deleted file mode 100644 index 47cef5364..000000000 --- a/applications/plugins/tuning_fork/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="Tuning_Fork", - name="Tuning Fork", - apptype=FlipperAppType.EXTERNAL, - entry_point="tuning_fork_app", - cdefines=["APP_TUNING_FORM"], - requires=[ - "gui", - ], - fap_icon="tuning_fork_icon.png", - fap_category="Music", - stack_size=2 * 1024, - order=20, -) diff --git a/applications/plugins/tuning_fork/img/screenshot_1.png b/applications/plugins/tuning_fork/img/screenshot_1.png deleted file mode 100644 index 047279889..000000000 Binary files a/applications/plugins/tuning_fork/img/screenshot_1.png and /dev/null differ diff --git a/applications/plugins/tuning_fork/img/screenshot_2.png b/applications/plugins/tuning_fork/img/screenshot_2.png deleted file mode 100644 index c31f37744..000000000 Binary files a/applications/plugins/tuning_fork/img/screenshot_2.png and /dev/null differ diff --git a/applications/plugins/tuning_fork/img/tuning_fork.gif b/applications/plugins/tuning_fork/img/tuning_fork.gif deleted file mode 100644 index 27bfe8cbe..000000000 Binary files a/applications/plugins/tuning_fork/img/tuning_fork.gif and /dev/null differ diff --git a/applications/plugins/tuning_fork/notes.h b/applications/plugins/tuning_fork/notes.h deleted file mode 100644 index c00b4f8ed..000000000 --- a/applications/plugins/tuning_fork/notes.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef NOTES -#define NOTES - -#define C0 16.35f -#define Cs0 17.32f -#define Db0 17.32f -#define D0 18.35f -#define Ds0 19.45f -#define Eb0 19.45f -#define E0 20.60f -#define F0 21.83f -#define Fs0 23.12f -#define Gb0 23.12f -#define G0 24.50f -#define Gs0 25.96f -#define Ab0 25.96f -#define A0 27.50f -#define As0 29.14f -#define Bb0 29.14f -#define B0 30.868f -#define C1 32.70f -#define Cs1 34.65f -#define Db1 34.65f -#define D1 36.71f -#define Ds1 38.89f -#define Eb1 38.89f -#define E1 41.203f -#define F1 43.65f -#define Fs1 46.25f -#define Gb1 46.25f -#define G1 49.00f -#define Gs1 51.91f -#define Ab1 51.91f -#define A1 55.00f -#define As1 58.27f -#define Bb1 58.27f -#define B1 61.74f -#define C2 65.41f -#define Cs2 69.30f -#define Db2 69.30f -#define D2 73.416f -#define Ds2 77.78f -#define Eb2 77.78f -#define E2 82.41f -#define F2 87.31f -#define Fs2 92.50f -#define Gb2 92.50f -#define G2 97.999f -#define Gs2 103.83f -#define Ab2 103.83f -#define A2 110.00f -#define As2 116.54f -#define Bb2 116.54f -#define B2 123.47f -#define C3 130.813f -#define Cs3 138.59f -#define Db3 138.59f -#define D3 146.83f -#define Ds3 155.56f -#define Eb3 155.56f -#define E3 164.81f -#define F3 174.61f -#define Fs3 185.00f -#define Gb3 185.00f -#define G3 196.00f -#define Gs3 207.65f -#define Ab3 207.65f -#define A3 220.00f -#define As3 233.08f -#define Bb3 233.08f -#define B3 246.94f -#define C4 261.63f -#define Cs4 277.18f -#define Db4 277.18f -#define D4 293.66f -#define Ds4 311.13f -#define Eb4 311.13f -#define E4 329.63f -#define F4 349.23f -#define Fs4 369.99f -#define Gb4 369.99f -#define G4 392.00f -#define Gs4 415.30f -#define Ab4 415.30f -#define A4 440.00f -#define As4 466.16f -#define Bb4 466.16f -#define B4 493.88f -#define C5 523.25f -#define Cs5 554.37f -#define Db5 554.37f -#define D5 587.33f -#define Ds5 622.25f -#define Eb5 622.25f -#define E5 659.25f -#define F5 698.46f -#define Fs5 739.99f -#define Gb5 739.99f -#define G5 783.99f -#define Gs5 830.61f -#define Ab5 830.61f -#define A5 880.00f -#define As5 932.33f -#define Bb5 932.33f -#define B5 987.77f -#define C6 1046.50f -#define Cs6 1108.73f -#define Db6 1108.73f -#define D6 1174.66f -#define Ds6 1244.51f -#define Eb6 1244.51f -#define E6 1318.51f -#define F6 1396.91f -#define Fs6 1479.98f -#define Gb6 1479.98f -#define G6 1567.98f -#define Gs6 1661.22f -#define Ab6 1661.22f -#define A6 1760.00f -#define As6 1864.66f -#define Bb6 1864.66f -#define B6 1975.53f -#define C7 2093.00f -#define Cs7 2217.46f -#define Db7 2217.46f -#define D7 2349.32f -#define Ds7 2489.02f -#define Eb7 2489.02f -#define E7 2637.02f -#define F7 2793.83f -#define Fs7 2959.96f -#define Gb7 2959.96f -#define G7 3135.96f -#define Gs7 3322.44f -#define Ab7 3322.44f -#define A7 3520.00f -#define As7 3729.31f -#define Bb7 3729.31f -#define B7 3951.07f -#define C8 4186.01f -#define Cs8 4434.92f -#define Db8 4434.92f -#define D8 4698.63f -#define Ds8 4978.03f -#define Eb8 4978.03f -#define E8 5274.04f -#define F8 5587.65f -#define Fs8 5919.91f -#define Gb8 5919.91f -#define G8 6271.93f -#define Gs8 6644.88f -#define Ab8 6644.88f -#define A8 7040.00f -#define As8 7458.62f -#define Bb8 7458.62f -#define B8 7902.13f - -#endif //NOTES diff --git a/applications/plugins/tuning_fork/tuning_fork.c b/applications/plugins/tuning_fork/tuning_fork.c deleted file mode 100644 index 69a76029f..000000000 --- a/applications/plugins/tuning_fork/tuning_fork.c +++ /dev/null @@ -1,408 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "notes.h" -#include "tunings.h" - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -enum Page { Tunings, Notes }; - -typedef struct { - bool playing; - enum Page page; - int current_tuning_note_index; - int current_tuning_index; - float volume; - TUNING tuning; -} TuningForkState; - -static TUNING current_tuning(TuningForkState* tuningForkState) { - return tuningForkState->tuning; -} - -static NOTE current_tuning_note(TuningForkState* tuningForkState) { - return current_tuning(tuningForkState).notes[tuningForkState->current_tuning_note_index]; -} - -static float current_tuning_note_freq(TuningForkState* tuningForkState) { - return current_tuning_note(tuningForkState).frequency; -} - -static void current_tuning_note_label(TuningForkState* tuningForkState, char* outNoteLabel) { - for(int i = 0; i < 20; ++i) { - outNoteLabel[i] = current_tuning_note(tuningForkState).label[i]; - } -} - -static void current_tuning_label(TuningForkState* tuningForkState, char* outTuningLabel) { - for(int i = 0; i < 20; ++i) { - outTuningLabel[i] = current_tuning(tuningForkState).label[i]; - } -} - -static void updateTuning(TuningForkState* tuning_fork_state) { - tuning_fork_state->tuning = TuningList[tuning_fork_state->current_tuning_index]; - tuning_fork_state->current_tuning_note_index = 0; -} - -static void next_tuning(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->current_tuning_index == TUNINGS_COUNT - 1) { - tuning_fork_state->current_tuning_index = 0; - } else { - tuning_fork_state->current_tuning_index += 1; - } - updateTuning(tuning_fork_state); -} - -static void prev_tuning(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->current_tuning_index - 1 < 0) { - tuning_fork_state->current_tuning_index = TUNINGS_COUNT - 1; - } else { - tuning_fork_state->current_tuning_index -= 1; - } - updateTuning(tuning_fork_state); -} - -static void next_note(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->current_tuning_note_index == - current_tuning(tuning_fork_state).notes_length - 1) { - tuning_fork_state->current_tuning_note_index = 0; - } else { - tuning_fork_state->current_tuning_note_index += 1; - } -} - -static void prev_note(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->current_tuning_note_index == 0) { - tuning_fork_state->current_tuning_note_index = - current_tuning(tuning_fork_state).notes_length - 1; - } else { - tuning_fork_state->current_tuning_note_index -= 1; - } -} - -static void increase_volume(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->volume < 1.0f) { - tuning_fork_state->volume += 0.1f; - } -} - -static void decrease_volume(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->volume > 0.0f) { - tuning_fork_state->volume -= 0.1f; - } -} - -static void play(TuningForkState* tuning_fork_state) { - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start( - current_tuning_note_freq(tuning_fork_state), tuning_fork_state->volume); - } -} - -static void stop() { - if(furi_hal_speaker_is_mine()) { - furi_hal_speaker_stop(); - furi_hal_speaker_release(); - } -} - -static void replay(TuningForkState* tuning_fork_state) { - stop(); - play(tuning_fork_state); -} - -static void render_callback(Canvas* const canvas, void* ctx) { - TuningForkState* tuning_fork_state = acquire_mutex((ValueMutex*)ctx, 25); - if(tuning_fork_state == NULL) { - return; - } - - string_t tempStr; - string_init(tempStr); - - canvas_draw_frame(canvas, 0, 0, 128, 64); - - canvas_set_font(canvas, FontPrimary); - - if(tuning_fork_state->page == Tunings) { - char tuningLabel[20]; - current_tuning_label(tuning_fork_state, tuningLabel); - string_printf(tempStr, "< %s >", tuningLabel); - canvas_draw_str_aligned( - canvas, 64, 28, AlignCenter, AlignCenter, string_get_cstr(tempStr)); - string_reset(tempStr); - } else { - char tuningLabel[20]; - current_tuning_label(tuning_fork_state, tuningLabel); - string_printf(tempStr, "%s", tuningLabel); - canvas_draw_str_aligned(canvas, 64, 8, AlignCenter, AlignCenter, string_get_cstr(tempStr)); - string_reset(tempStr); - - char tuningNoteLabel[20]; - current_tuning_note_label(tuning_fork_state, tuningNoteLabel); - string_printf(tempStr, "< %s >", tuningNoteLabel); - canvas_draw_str_aligned( - canvas, 64, 24, AlignCenter, AlignCenter, string_get_cstr(tempStr)); - string_reset(tempStr); - } - - canvas_set_font(canvas, FontSecondary); - elements_button_left(canvas, "Prev"); - elements_button_right(canvas, "Next"); - - if(tuning_fork_state->page == Notes) { - if(tuning_fork_state->playing) { - elements_button_center(canvas, "Stop "); - } else { - elements_button_center(canvas, "Play"); - } - } else { - elements_button_center(canvas, "Select"); - } - if(tuning_fork_state->page == Notes) { - elements_progress_bar(canvas, 8, 36, 112, tuning_fork_state->volume); - } - - string_clear(tempStr); - release_mutex((ValueMutex*)ctx, tuning_fork_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void tuning_fork_state_init(TuningForkState* const tuning_fork_state) { - tuning_fork_state->playing = false; - tuning_fork_state->page = Tunings; - tuning_fork_state->volume = 1.0f; - tuning_fork_state->tuning = GuitarStandard6; - tuning_fork_state->current_tuning_index = 2; - tuning_fork_state->current_tuning_note_index = 0; -} - -int32_t tuning_fork_app() { - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - TuningForkState* tuning_fork_state = malloc(sizeof(TuningForkState)); - tuning_fork_state_init(tuning_fork_state); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, tuning_fork_state, sizeof(TuningForkState))) { - FURI_LOG_E("TuningFork", "cannot create mutex\r\n"); - free(tuning_fork_state); - return 255; - } - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - - TuningForkState* tuning_fork_state = (TuningForkState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - if(event.type == EventTypeKey) { - if(event.input.type == InputTypeShort) { - // push events - switch(event.input.key) { - case InputKeyUp: - if(tuning_fork_state->page == Notes) { - increase_volume(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - break; - case InputKeyDown: - if(tuning_fork_state->page == Notes) { - decrease_volume(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - break; - case InputKeyRight: - if(tuning_fork_state->page == Tunings) { - next_tuning(tuning_fork_state); - } else { - next_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - break; - case InputKeyLeft: - if(tuning_fork_state->page == Tunings) { - prev_tuning(tuning_fork_state); - } else { - prev_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - break; - case InputKeyOk: - if(tuning_fork_state->page == Tunings) { - tuning_fork_state->page = Notes; - } else { - tuning_fork_state->playing = !tuning_fork_state->playing; - if(tuning_fork_state->playing) { - play(tuning_fork_state); - } else { - stop(); - } - } - break; - case InputKeyBack: - if(tuning_fork_state->page == Tunings) { - processing = false; - } else { - tuning_fork_state->playing = false; - tuning_fork_state->current_tuning_note_index = 0; - stop(); - tuning_fork_state->page = Tunings; - } - break; - default: - break; - } - } else if(event.input.type == InputTypeLong) { - // hold events - switch(event.input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyRight: - if(tuning_fork_state->page == Tunings) { - next_tuning(tuning_fork_state); - } else { - next_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - - break; - case InputKeyLeft: - if(tuning_fork_state->page == Tunings) { - prev_tuning(tuning_fork_state); - } else { - prev_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - - break; - case InputKeyOk: - break; - case InputKeyBack: - if(tuning_fork_state->page == Tunings) { - processing = false; - } else { - tuning_fork_state->playing = false; - stop(); - tuning_fork_state->page = Tunings; - tuning_fork_state->current_tuning_note_index = 0; - } - break; - default: - break; - } - } else if(event.input.type == InputTypeRepeat) { - // repeat events - switch(event.input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyRight: - if(tuning_fork_state->page == Tunings) { - next_tuning(tuning_fork_state); - } else { - next_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - - break; - case InputKeyLeft: - if(tuning_fork_state->page == Tunings) { - prev_tuning(tuning_fork_state); - } else { - prev_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - - break; - case InputKeyOk: - break; - case InputKeyBack: - if(tuning_fork_state->page == Tunings) { - processing = false; - } else { - tuning_fork_state->playing = false; - stop(); - tuning_fork_state->page = Tunings; - tuning_fork_state->current_tuning_note_index = 0; - } - break; - default: - break; - } - } - } - } else { - FURI_LOG_D("TuningFork", "FuriMessageQueue: event timeout"); - } - - view_port_update(view_port); - release_mutex(&state_mutex, tuning_fork_state); - } - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close("gui"); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - furi_record_close(RECORD_NOTIFICATION); - free(tuning_fork_state); - - return 0; -} diff --git a/applications/plugins/tuning_fork/tuning_fork_icon.png b/applications/plugins/tuning_fork/tuning_fork_icon.png deleted file mode 100644 index 074d9d590..000000000 Binary files a/applications/plugins/tuning_fork/tuning_fork_icon.png and /dev/null differ diff --git a/applications/plugins/tuning_fork/tunings.h b/applications/plugins/tuning_fork/tunings.h deleted file mode 100644 index 14bf469fe..000000000 --- a/applications/plugins/tuning_fork/tunings.h +++ /dev/null @@ -1,151 +0,0 @@ -#include "notes.h" - -#ifndef TUNINGS -#define TUNINGS - -typedef struct { - char label[20]; - float frequency; -} NOTE; - -typedef struct { - char label[20]; - int notes_length; - NOTE notes[20]; -} TUNING; - -const TUNING TuningForks = { - "Tuning forks", - 6, - { - {"Common A4 (440)", 440.00f}, - {"Sarti's A4 (436)", 436.00f}, - {"1858 A4 (435)", 435.00f}, - {"Verdi's A4 (432)", 432.00f}, - {"1750-1820 A4 (423.5)", 423.50f}, - {"Verdi's C4 (256.00)", 256.00f}, - }}; - -const TUNING ScientificPitch = { - "Scientific pitch", - 12, - {{"C0 (16Hz)", 16.0f}, - {"C1 (32Hz)", 32.0f}, - {"C2 (64Hz)", 64.0f}, - {"C3 (128Hz)", 128.0f}, - {"C4 (256Hz)", 256.0f}, - {"C5 (512Hz)", 512.0f}, - {"C6 (1024Hz)", 1024.0f}, - {"C7 (2048Hz)", 2048.0f}, - {"C8 (4096Hz)", 4096.0f}, - {"C9 (8192Hz)", 8192.0f}, - {"C10 (16384Hz)", 16384.0f}, - {"C11 (32768Hz)", 32768.0f}}}; - -const TUNING GuitarStandard6 = { - "Guitar Standard 6", - 6, - {{"String 1", E4}, - {"String 2", B3}, - {"String 3", G3}, - {"String 4", D3}, - {"String 5", A2}, - {"String 6", E2}}}; - -const TUNING GuitarDropD6 = { - "Guitar Drop D 6", - 6, - {{"String 1", E4}, - {"String 2", B3}, - {"String 3", G3}, - {"String 4", D3}, - {"String 5", A2}, - {"String 6", D2}}}; - -const TUNING GuitarD6 = { - "Guitar D 6", - 6, - {{"String 1", D4}, - {"String 2", A3}, - {"String 3", F3}, - {"String 4", C3}, - {"String 5", G2}, - {"String 6", D2}}}; - -const TUNING GuitarDropC6 = { - "Guitar Drop C 6", - 6, - {{"String 1", D4}, - {"String 2", A3}, - {"String 3", F3}, - {"String 4", C3}, - {"String 5", G2}, - {"String 6", C2}}}; - -const TUNING GuitarStandard7 = { - "Guitar Standard 7", - 7, - {{"String 1", E4}, - {"String 2", B3}, - {"String 3", G3}, - {"String 4", D3}, - {"String 5", A2}, - {"String 6", E2}, - {"String 7", B1}}}; - -const TUNING BassStandard4 = { - "Bass Standard 4", - 4, - {{"String 1", G2}, {"String 2", D2}, {"String 3", A1}, {"String 4", E1}}}; - -const TUNING BassStandardTenor4 = { - "Bass Stand Tenor 4", - 4, - {{"String 1", C3}, {"String 2", G2}, {"String 3", D2}, {"String 4", A1}}}; - -const TUNING BassStandard5 = { - "Bass Standard 5", - 5, - {{"String 1", G2}, {"String 2", D2}, {"String 3", A1}, {"String 4", E1}, {"String 5", B0}}}; - -const TUNING BassStandardTenor5 = { - "Bass Stand Tenor 5", - 5, - {{"String 1", C3}, {"String 2", G2}, {"String 3", D2}, {"String 4", A1}, {"String 5", E1}}}; - -const TUNING BassDropD4 = { - "Bass Drop D 4", - 4, - {{"String 1", G2}, {"String 2", D2}, {"String 3", A1}, {"String 4", D1}}}; - -const TUNING BassD4 = { - "Bass D 4", - 4, - {{"String 1", F2}, {"String 2", C2}, {"String 3", G1}, {"String 4", D1}}}; - -const TUNING BassDropA5 = { - "Bass Drop A 5", - 5, - {{"String 1", G2}, {"String 2", D2}, {"String 3", A1}, {"String 4", E1}, {"String 5", A0}}}; - -#define TUNINGS_COUNT 14 - -TUNING TuningList[TUNINGS_COUNT] = { - ScientificPitch, - TuningForks, - - GuitarStandard6, - GuitarDropD6, - GuitarD6, - GuitarDropC6, - GuitarStandard7, - - BassStandard4, - BassStandardTenor4, - BassStandard5, - BassStandardTenor5, - BassDropD4, - BassD4, - BassDropA5}; - -#endif //TUNINGS diff --git a/applications/plugins/usb_midi/usb_midi.c b/applications/plugins/usb_midi/usb_midi.c deleted file mode 100644 index d82fb74d7..000000000 --- a/applications/plugins/usb_midi/usb_midi.c +++ /dev/null @@ -1,84 +0,0 @@ -#include -#include -#include "usb/usb_midi_driver.h" -#include "midi/parser.h" -#include "midi/usb_message.h" -#include - -float note_to_frequency(int note) { - float a = 440; - return (a / 32) * powf(2, ((note - 9) / 12.0)); -} - -typedef enum { - MidiThreadEventStop = (1 << 0), - MidiThreadEventRx = (1 << 1), - MidiThreadEventAll = MidiThreadEventStop | MidiThreadEventRx, -} MidiThreadEvent; - -static void midi_rx_callback(void* context) { - furi_assert(context); - FuriThreadId thread_id = (FuriThreadId)context; - furi_thread_flags_set(thread_id, MidiThreadEventRx); -} - -int32_t usb_midi_app(void* p) { - UNUSED(p); - - FuriHalUsbInterface* usb_config_prev; - usb_config_prev = furi_hal_usb_get_config(); - midi_usb_set_context(furi_thread_get_id(furi_thread_get_current())); - midi_usb_set_rx_callback(midi_rx_callback); - furi_hal_usb_set_config(&midi_usb_interface, NULL); - - MidiParser* parser = midi_parser_alloc(); - uint32_t events; - uint8_t current_note = 255; - - while(1) { - events = furi_thread_flags_wait(MidiThreadEventAll, FuriFlagWaitAny, FuriWaitForever); - - if(!(events & FuriFlagError)) { - if(events & MidiThreadEventRx) { - uint8_t buffer[64]; - size_t size = midi_usb_rx(buffer, sizeof(buffer)); - // loopback - // midi_usb_tx(buffer, size); - size_t start = 0; - while(start < size) { - CodeIndex code_index = code_index_from_data(buffer[start]); - uint8_t data_size = usb_message_data_size(code_index); - if(data_size == 0) break; - - start += 1; - for(size_t j = 0; j < data_size; j++) { - if(midi_parser_parse(parser, buffer[start + j])) { - MidiEvent* event = midi_parser_get_message(parser); - if(event->type == NoteOn) { - NoteOnEvent note_on = AsNoteOn(event); - current_note = note_on.note; - if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { - furi_hal_speaker_start( - note_to_frequency(note_on.note), - note_on.velocity / 127.0f); - } - } else if(event->type == NoteOff) { - NoteOffEvent note_off = AsNoteOff(event); - if(note_off.note == current_note && furi_hal_speaker_is_mine()) { - furi_hal_speaker_stop(); - furi_hal_speaker_release(); - } - } - } - } - start += data_size; - } - } - } - } - - midi_parser_free(parser); - furi_hal_usb_set_config(usb_config_prev, NULL); - - return 0; -} \ No newline at end of file