mirror of
https://github.com/D4C1-Labs/Flipper-ARF.git
synced 2026-03-29 09:19:56 +00:00
Added Term of Services & Easter egg
All checks were successful
Build Dev Firmware / build (push) Successful in 6m17s
All checks were successful
Build Dev Firmware / build (push) Successful in 6m17s
This commit is contained in:
@@ -282,6 +282,7 @@ static Desktop* desktop_alloc(void) {
|
||||
desktop->pin_input_view = desktop_view_pin_input_alloc();
|
||||
desktop->pin_timeout_view = desktop_view_pin_timeout_alloc();
|
||||
desktop->slideshow_view = desktop_view_slideshow_alloc();
|
||||
desktop->tos_view = desktop_view_tos_alloc();
|
||||
|
||||
desktop->main_view_stack = view_stack_alloc();
|
||||
desktop->main_view = desktop_main_alloc();
|
||||
@@ -326,6 +327,10 @@ static Desktop* desktop_alloc(void) {
|
||||
desktop->view_dispatcher,
|
||||
DesktopViewIdSlideshow,
|
||||
desktop_view_slideshow_get_view(desktop->slideshow_view));
|
||||
view_dispatcher_add_view(
|
||||
desktop->view_dispatcher,
|
||||
DesktopViewIdTos,
|
||||
desktop_view_tos_get_view(desktop->tos_view));
|
||||
|
||||
// Lock icon
|
||||
desktop->lock_icon_viewport = view_port_alloc();
|
||||
@@ -513,6 +518,8 @@ int32_t desktop_srv(void* p) {
|
||||
scene_manager_next_scene(desktop->scene_manager, DesktopSceneSlideshow);
|
||||
}
|
||||
|
||||
scene_manager_next_scene(desktop->scene_manager, DesktopSceneTos);
|
||||
|
||||
if(!furi_hal_version_do_i_belong_here()) {
|
||||
scene_manager_next_scene(desktop->scene_manager, DesktopSceneHwMismatch);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "views/desktop_view_lock_menu.h"
|
||||
#include "views/desktop_view_debug.h"
|
||||
#include "views/desktop_view_slideshow.h"
|
||||
#include "views/desktop_view_tos.h"
|
||||
#include "helpers/arf_boot_jingle.h"
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_stack.h>
|
||||
@@ -32,6 +34,7 @@ typedef enum {
|
||||
DesktopViewIdPinInput,
|
||||
DesktopViewIdPinTimeout,
|
||||
DesktopViewIdSlideshow,
|
||||
DesktopViewIdTos,
|
||||
DesktopViewIdTotal,
|
||||
} DesktopViewId;
|
||||
|
||||
@@ -55,6 +58,7 @@ struct Desktop {
|
||||
DesktopMainView* main_view;
|
||||
DesktopViewPinTimeout* pin_timeout_view;
|
||||
DesktopSlideshowView* slideshow_view;
|
||||
DesktopViewTos* tos_view;
|
||||
DesktopViewPinInput* pin_input_view;
|
||||
|
||||
ViewStack* main_view_stack;
|
||||
|
||||
98
applications/services/desktop/helpers/arf_boot_jingle.c
Normal file
98
applications/services/desktop/helpers/arf_boot_jingle.c
Normal file
@@ -0,0 +1,98 @@
|
||||
#include "arf_boot_jingle.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal_speaker.h>
|
||||
|
||||
typedef struct {
|
||||
float frequency;
|
||||
uint32_t duration_ms;
|
||||
} ArfBootNote;
|
||||
|
||||
static const ArfBootNote arf_boot_jingle[] = {
|
||||
{1046.50f, 50},
|
||||
{1046.50f, 200},
|
||||
{0.0f, 100},
|
||||
{783.99f, 300},
|
||||
{0.0f, 50},
|
||||
{659.26f, 300},
|
||||
{0.0f, 50},
|
||||
{783.99f, 250},
|
||||
{880.00f, 100},
|
||||
{880.00f, 100},
|
||||
{783.99f, 300},
|
||||
{1046.50f, 150},
|
||||
{1318.51f, 150},
|
||||
{1760.00f, 250},
|
||||
{1396.91f, 150},
|
||||
{1567.98f, 100},
|
||||
{1318.51f, 250},
|
||||
{1174.66f, 150},
|
||||
{1396.91f, 150},
|
||||
{1318.51f, 400},
|
||||
{392.00f, 100},
|
||||
{523.25f, 300},
|
||||
{0.0f, 50},
|
||||
{1567.98f, 150},
|
||||
{1479.98f, 150},
|
||||
{1396.91f, 150},
|
||||
{1174.66f, 250},
|
||||
{1318.51f, 300},
|
||||
{783.99f, 150},
|
||||
{1046.50f, 100},
|
||||
{1318.51f, 100},
|
||||
{783.99f, 100},
|
||||
{1046.50f, 100},
|
||||
{1318.51f, 150},
|
||||
{0.0f, 50},
|
||||
{1567.98f, 150},
|
||||
{1479.98f, 100},
|
||||
{1396.91f, 150},
|
||||
{1174.66f, 250},
|
||||
{1318.51f, 300},
|
||||
{0.0f, 50},
|
||||
{2093.00f, 700},
|
||||
};
|
||||
|
||||
static const uint32_t arf_boot_jingle_len =
|
||||
sizeof(arf_boot_jingle) / sizeof(arf_boot_jingle[0]);
|
||||
|
||||
static FuriThread* jingle_thread = NULL;
|
||||
|
||||
static int32_t arf_jingle_thread_cb(void* context) {
|
||||
UNUSED(context);
|
||||
|
||||
if(!furi_hal_speaker_acquire(1000)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < arf_boot_jingle_len; i++) {
|
||||
const ArfBootNote* note = &arf_boot_jingle[i];
|
||||
if(note->frequency == 0.0f) {
|
||||
furi_hal_speaker_stop();
|
||||
} else {
|
||||
furi_hal_speaker_start(note->frequency, 0.8f);
|
||||
}
|
||||
furi_delay_ms(note->duration_ms);
|
||||
}
|
||||
|
||||
furi_hal_speaker_stop();
|
||||
furi_hal_speaker_release();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void arf_boot_jingle_play(void) {
|
||||
if(jingle_thread != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
jingle_thread = furi_thread_alloc_ex("ArfJingle", 512, arf_jingle_thread_cb, NULL);
|
||||
furi_thread_start(jingle_thread);
|
||||
}
|
||||
|
||||
void arf_boot_jingle_stop(void) {
|
||||
if(jingle_thread != NULL) {
|
||||
furi_thread_join(jingle_thread);
|
||||
furi_thread_free(jingle_thread);
|
||||
jingle_thread = NULL;
|
||||
}
|
||||
}
|
||||
4
applications/services/desktop/helpers/arf_boot_jingle.h
Normal file
4
applications/services/desktop/helpers/arf_boot_jingle.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
void arf_boot_jingle_play(void);
|
||||
void arf_boot_jingle_stop(void);
|
||||
@@ -8,3 +8,4 @@ ADD_SCENE(desktop, pin_input, PinInput)
|
||||
ADD_SCENE(desktop, pin_timeout, PinTimeout)
|
||||
ADD_SCENE(desktop, slideshow, Slideshow)
|
||||
ADD_SCENE(desktop, secure_enclave, SecureEnclave)
|
||||
ADD_SCENE(desktop, tos, Tos)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../desktop_i.h"
|
||||
#include "../views/desktop_view_slideshow.h"
|
||||
#include "../views/desktop_events.h"
|
||||
#include "desktop_scene.h"
|
||||
#include <power/power_service/power.h>
|
||||
|
||||
void desktop_scene_slideshow_callback(DesktopEvent event, void* context) {
|
||||
|
||||
52
applications/services/desktop/scenes/desktop_scene_tos.c
Normal file
52
applications/services/desktop/scenes/desktop_scene_tos.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <power/power_service/power.h>
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
#include "desktop_scene.h"
|
||||
#include "../desktop_i.h"
|
||||
#include "../views/desktop_events.h"
|
||||
#include "../views/desktop_view_tos.h"
|
||||
|
||||
static void desktop_scene_tos_callback(DesktopEvent event, void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void desktop_scene_tos_on_enter(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
|
||||
arf_boot_jingle_play();
|
||||
|
||||
gui_set_hide_status_bar(desktop->gui, true);
|
||||
desktop_view_tos_set_callback(desktop->tos_view, desktop_scene_tos_callback, desktop);
|
||||
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdTos);
|
||||
}
|
||||
|
||||
bool desktop_scene_tos_on_event(void* context, SceneManagerEvent event) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case DesktopTosAccepted:
|
||||
scene_manager_previous_scene(desktop->scene_manager);
|
||||
consumed = true;
|
||||
break;
|
||||
case DesktopTosDeclined: {
|
||||
Power* power = furi_record_open(RECORD_POWER);
|
||||
power_off(power);
|
||||
furi_record_close(RECORD_POWER);
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void desktop_scene_tos_on_exit(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
arf_boot_jingle_stop();
|
||||
gui_set_hide_status_bar(desktop->gui, false);
|
||||
}
|
||||
@@ -39,6 +39,8 @@ typedef enum {
|
||||
|
||||
DesktopSlideshowCompleted,
|
||||
DesktopSlideshowPoweroff,
|
||||
DesktopTosAccepted,
|
||||
DesktopTosDeclined,
|
||||
|
||||
DesktopHwMismatchExit,
|
||||
|
||||
|
||||
79
applications/services/desktop/views/desktop_view_tos.c
Normal file
79
applications/services/desktop/views/desktop_view_tos.c
Normal file
@@ -0,0 +1,79 @@
|
||||
#include <furi.h>
|
||||
#include "desktop_view_tos.h"
|
||||
|
||||
struct DesktopViewTos {
|
||||
View* view;
|
||||
DesktopViewTosCallback callback;
|
||||
void* context;
|
||||
};
|
||||
|
||||
static void desktop_view_tos_draw(Canvas* canvas, void* model) {
|
||||
UNUSED(model);
|
||||
canvas_clear(canvas);
|
||||
|
||||
static const uint8_t mario_bits[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x00,0x00,0x82,0x01,0x00,
|
||||
0xc1,0x00,0x00,0xe1,0x07,0x80,0x09,0x08,0x40,0x46,0x07,0x40,0x42,0x03,0x40,0x08,
|
||||
0x04,0x80,0x30,0x04,0x00,0xf1,0x04,0x80,0x82,0x07,0x20,0xfc,0x00,0x30,0x7e,0x00,
|
||||
0x10,0x91,0x00,0x10,0xa0,0x02,0xe0,0x20,0x05,0x60,0x31,0x07,0xf0,0xfb,0x03,0xf0,
|
||||
0xe3,0x00,0xe8,0xe9,0x00,0x08,0xfe,0x00,0x1c,0x7c,0x01,0xf4,0x1f,0x06,0xe4,0x13,
|
||||
0x0e,0x84,0x90,0x09,0x84,0x40,0x08,0x88,0x20,0x06,0x70,0xe0,0x03,0x00,0x00,0x00};
|
||||
|
||||
canvas_draw_xbm(canvas, 105, 0, 22, 32, mario_bits);
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 2, 11, "Term of use:");
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 3, 22, "Authorize RF research");
|
||||
canvas_draw_str(canvas, 3, 30, "use ONLY. Unauthorized");
|
||||
canvas_draw_str(canvas, 3, 39, "use is prohibited.");
|
||||
canvas_draw_str(canvas, 2, 61, "Back=Shutdown");
|
||||
canvas_draw_str(canvas, 80, 62, "Ok=Accept");
|
||||
}
|
||||
|
||||
static bool desktop_view_tos_input(InputEvent* event, void* context) {
|
||||
furi_assert(event);
|
||||
DesktopViewTos* instance = context;
|
||||
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyOk) {
|
||||
instance->callback(DesktopTosAccepted, instance->context);
|
||||
return true;
|
||||
} else if(event->key == InputKeyBack) {
|
||||
instance->callback(DesktopTosDeclined, instance->context);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DesktopViewTos* desktop_view_tos_alloc(void) {
|
||||
DesktopViewTos* instance = malloc(sizeof(DesktopViewTos));
|
||||
instance->view = view_alloc();
|
||||
view_set_context(instance->view, instance);
|
||||
view_set_draw_callback(instance->view, desktop_view_tos_draw);
|
||||
view_set_input_callback(instance->view, desktop_view_tos_input);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void desktop_view_tos_free(DesktopViewTos* instance) {
|
||||
furi_assert(instance);
|
||||
view_free(instance->view);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
View* desktop_view_tos_get_view(DesktopViewTos* instance) {
|
||||
furi_assert(instance);
|
||||
return instance->view;
|
||||
}
|
||||
|
||||
void desktop_view_tos_set_callback(
|
||||
DesktopViewTos* instance,
|
||||
DesktopViewTosCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
instance->callback = callback;
|
||||
instance->context = context;
|
||||
}
|
||||
14
applications/services/desktop/views/desktop_view_tos.h
Normal file
14
applications/services/desktop/views/desktop_view_tos.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <gui/view.h>
|
||||
#include "desktop_events.h"
|
||||
|
||||
typedef struct DesktopViewTos DesktopViewTos;
|
||||
typedef void (*DesktopViewTosCallback)(DesktopEvent event, void* context);
|
||||
|
||||
DesktopViewTos* desktop_view_tos_alloc(void);
|
||||
void desktop_view_tos_free(DesktopViewTos* instance);
|
||||
View* desktop_view_tos_get_view(DesktopViewTos* instance);
|
||||
void desktop_view_tos_set_callback(
|
||||
DesktopViewTos* instance,
|
||||
DesktopViewTosCallback callback,
|
||||
void* context);
|
||||
Reference in New Issue
Block a user