Skip to content

Commit

Permalink
add files
Browse files Browse the repository at this point in the history
  • Loading branch information
nmrr committed Dec 22, 2022
1 parent 6d6466b commit 4c0d21f
Show file tree
Hide file tree
Showing 7 changed files with 380 additions and 1 deletion.
295 changes: 294 additions & 1 deletion README.md

Large diffs are not rendered by default.

Binary file added flipper_random.fap
Binary file not shown.
13 changes: 13 additions & 0 deletions flipper_random/application.fam
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",
)
73 changes: 73 additions & 0 deletions flipper_random/flipper_random.c
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;
}
Binary file added flipper_random/random.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Flipper_Zero.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/flipper1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4c0d21f

Please sign in to comment.