-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
380 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
App( | ||
appid="flipper_random", | ||
name="Random", | ||
apptype=FlipperAppType.EXTERNAL, | ||
entry_point="flipper_random_app", | ||
cdefines=["APP_FLIPPER_RANDOM"], | ||
requires=[ | ||
"gui", | ||
], | ||
stack_size=1 * 1024, | ||
fap_icon="random.png", | ||
fap_category="Tools", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// CC0 1.0 Universal (CC0 1.0) | ||
// Public Domain Dedication | ||
// https://github.com/nmrr | ||
|
||
#include <stdio.h> | ||
#include <furi.h> | ||
#include <gui/gui.h> | ||
#include <input/input.h> | ||
#include <notification/notification_messages.h> | ||
#include <furi_hal_random.h> | ||
|
||
#include <storage/storage.h> | ||
#include <stream/buffered_file_stream.h> | ||
|
||
typedef enum { | ||
EventTypeInput, | ||
} EventType; | ||
|
||
typedef struct { | ||
EventType type; | ||
InputEvent input; | ||
} EventApp; | ||
|
||
static void draw_callback(Canvas* canvas, void* ctx) | ||
{ | ||
UNUSED(ctx); | ||
canvas_set_font(canvas, FontPrimary); | ||
canvas_draw_str_aligned(canvas, 64, 22, AlignCenter, AlignBottom, "Copy 256MB of random"); | ||
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignBottom, "data on /random.dat"); | ||
|
||
canvas_draw_str_aligned(canvas, 64, 52, AlignCenter, AlignBottom, "Please wait..."); | ||
} | ||
|
||
int32_t flipper_random_app() | ||
{ | ||
ViewPort* view_port = view_port_alloc(); | ||
view_port_draw_callback_set(view_port, draw_callback, NULL); | ||
|
||
Gui* gui = furi_record_open(RECORD_GUI); | ||
gui_add_view_port(gui, view_port, GuiLayerFullscreen); | ||
|
||
////////////////// | ||
|
||
Storage* storage = furi_record_open(RECORD_STORAGE); | ||
|
||
furi_record_close(RECORD_STORAGE); | ||
Stream* file_stream = buffered_file_stream_alloc(storage); | ||
buffered_file_stream_open(file_stream, EXT_PATH("/random.dat"), FSAM_WRITE, FSOM_CREATE_ALWAYS); | ||
|
||
uint8_t randomuint8[8]; | ||
FuriString* data_str = furi_string_alloc(); | ||
|
||
for (unsigned int i=0;i<1024*1024*32;i++) | ||
{ | ||
furi_hal_random_fill_buf(randomuint8,8); | ||
furi_string_printf(data_str, "%c%c%c%c%c%c%c%c", randomuint8[0], randomuint8[1], randomuint8[2], randomuint8[3], randomuint8[4], randomuint8[5], randomuint8[6], randomuint8[7]); | ||
stream_write_string(file_stream, data_str); | ||
} | ||
|
||
buffered_file_stream_close(file_stream); | ||
stream_free(file_stream); | ||
furi_string_free(data_str); | ||
|
||
////////////////// | ||
|
||
gui_remove_view_port(gui, view_port); | ||
view_port_free(view_port); | ||
furi_record_close(RECORD_GUI); | ||
|
||
furi_record_close(RECORD_NOTIFICATION); | ||
|
||
return 0; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.