Skip to content

Commit

Permalink
Merge pull request #10 from H4ckd4ddy/rogue-version
Browse files Browse the repository at this point in the history
Merge roguemaster version
  • Loading branch information
H4ckd4ddy authored Jun 3, 2023
2 parents 626457e + 0c912f5 commit 708e275
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 2 additions & 3 deletions application.fam
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
App(
appid="Sentry_Safe",
name="Sentry Safe",
appid="GPIO_Sentry_Safe",
name="[GPIO] Sentry Safe",
apptype=FlipperAppType.EXTERNAL,
entry_point="sentry_safe_app",
cdefines=["APP_SENTRY_SAFE"],
requires=["gui"],
stack_size=1 * 1024,
order=40,
Expand Down
16 changes: 9 additions & 7 deletions sentry_safe.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <gui/gui.h>
#include <input/input.h>
#include <stdlib.h>
#include <dolphin/dolphin.h>

#include <furi_hal.h>

Expand All @@ -23,10 +24,9 @@ typedef struct {
const char* status_texts[3] = {"[Press OK to open safe]", "Sending...", "Done !"};

static void sentry_safe_render_callback(Canvas* const canvas, void* ctx) {
SentryState* state = ctx;
if (furi_mutex_acquire(state->mutex, 25) != FuriStatusOk){
return;
}
furi_assert(ctx);
const SentryState* sentry_state = ctx;
furi_mutex_acquire(sentry_state->mutex, FuriWaitForever);

// Before the function is called, the state is set with the canvas_reset(canvas)

Expand All @@ -40,9 +40,9 @@ static void sentry_safe_render_callback(Canvas* const canvas, void* ctx) {
canvas_draw_str_aligned(canvas, 64, 15, AlignCenter, AlignBottom, "BLACK <-> GND");
canvas_draw_str_aligned(canvas, 64, 25, AlignCenter, AlignBottom, "GREEN <-> C1 ");
canvas_draw_str_aligned(
canvas, 64, 50, AlignCenter, AlignBottom, status_texts[state->status]);
canvas, 64, 50, AlignCenter, AlignBottom, status_texts[sentry_state->status]);

furi_mutex_release(state->mutex);
furi_mutex_release(sentry_state->mutex);
}

static void sentry_safe_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
Expand Down Expand Up @@ -85,10 +85,12 @@ int32_t sentry_safe_app(void* p) {
UNUSED(p);

FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(Event));
DOLPHIN_DEED(DolphinDeedPluginStart);

SentryState* sentry_state = malloc(sizeof(SentryState));

sentry_state->status = 0;

sentry_state->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
if(!sentry_state->mutex) {
FURI_LOG_E("SentrySafe", "cannot create mutex\r\n");
Expand Down Expand Up @@ -166,4 +168,4 @@ int32_t sentry_safe_app(void* p) {
free(sentry_state);

return 0;
}
}

0 comments on commit 708e275

Please sign in to comment.