Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Update apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed May 29, 2023
1 parent 75b939a commit 4e38f7f
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 49 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 8 additions & 13 deletions applications/external/ifttt/ifttt_virtual_button.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "ifttt_virtual_button.h"

#define IFTTT_FOLDER "/ext/ifttt"
#define IFTTT_CONFIG_FOLDER "/ext/ifttt/config"
const char* CONFIG_FILE_PATH = "/ext/ifttt/config/config.settings";
#define IFTTT_FOLDER "/ext/apps_data/ifttt"
#define IFTTT_CONFIG_FOLDER "/ext/apps_data/ifttt/config"
const char* CONFIG_FILE_PATH = "/ext/apps_data/ifttt/config/config.settings";

#define FLIPPERZERO_SERIAL_BAUD 115200
typedef enum ESerialCommand { ESerialCommand_Config } ESerialCommand;
Expand Down Expand Up @@ -46,16 +46,11 @@ Settings* load_settings() {
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* file = flipper_format_file_alloc(storage);

FuriString* string_value;
string_value = furi_string_alloc();
FuriString* text_ssid_value;
text_ssid_value = furi_string_alloc();
FuriString* text_password_value;
text_password_value = furi_string_alloc();
FuriString* text_key_value;
text_key_value = furi_string_alloc();
FuriString* text_event_value;
text_event_value = furi_string_alloc();
FuriString* string_value = furi_string_alloc();
FuriString* text_ssid_value = furi_string_alloc();
FuriString* text_password_value = furi_string_alloc();
FuriString* text_key_value = furi_string_alloc();
FuriString* text_event_value = furi_string_alloc();

if(storage_common_stat(storage, CONFIG_FILE_PATH, NULL) != FSE_OK) {
if(flipper_format_file_open_new(file, CONFIG_FILE_PATH)) {
Expand Down
22 changes: 9 additions & 13 deletions applications/external/rc2014_coleco/coleco.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ typedef struct {
} PluginEvent;

typedef struct {
FuriMutex* mutex;
bool dpad;
int row;
int column;
FuriMutex* mutex;
} Coleco;

static void render_callback(Canvas* const canvas, void* context) {
Coleco* coleco = (Coleco*)context;
furi_assert(context);
Coleco* coleco = context;
furi_mutex_acquire(coleco->mutex, FuriWaitForever);

if(coleco->dpad) {
Expand Down Expand Up @@ -174,20 +175,12 @@ static Coleco* coleco_alloc() {
coleco->row = 0;
coleco->column = 1;

coleco->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
if(!coleco->mutex) {
FURI_LOG_E("Coleco", "cannot create mutex\r\n");
free(coleco);
return NULL;
}

return coleco;
}

static void coleco_free(Coleco* coleco) {
furi_assert(coleco);

furi_mutex_free(coleco->mutex);
free(coleco);
}

Expand All @@ -197,7 +190,11 @@ int32_t coleco_app(void* p) {
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));

Coleco* coleco = coleco_alloc();
if(coleco == NULL) {

coleco->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
if(!coleco->mutex) {
FURI_LOG_E("Coleco", "cannot create mutex\r\n");
coleco_free(coleco);
return 255;
}

Expand Down Expand Up @@ -349,8 +346,6 @@ int32_t coleco_app(void* p) {

view_port_update(view_port);
}
} else {
FURI_LOG_D("Coleco", "FuriMessageQueue: event timeout");
}

furi_mutex_release(coleco->mutex);
Expand All @@ -363,6 +358,7 @@ int32_t coleco_app(void* p) {
furi_record_close("gui");
view_port_free(view_port);
furi_message_queue_free(event_queue);
furi_mutex_free(coleco->mutex);
coleco_free(coleco);
return 0;
}

This file was deleted.

20 changes: 12 additions & 8 deletions applications/external/tanksgame/tanks_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ int32_t tanks_game_app(void* p) {
tanks_state->menu_state = MenuStateCooperativeServerMode;
}
} else if(tanks_state->state == GameStateCooperativeClient) {
FuriString* goesUp = NULL;
FuriString* goesUp = furi_string_alloc();
char arr[2];
arr[0] = GoesUp;
arr[1] = 0;
Expand All @@ -1246,7 +1246,7 @@ int32_t tanks_game_app(void* p) {
subghz_txrx,
(uint8_t*)furi_string_get_cstr(goesUp),
strlen(furi_string_get_cstr(goesUp)));

furi_string_free(goesUp);
} else {
tanks_state->p1->moving = true;
tanks_state->p1->direction = DirectionUp;
Expand All @@ -1260,7 +1260,7 @@ int32_t tanks_game_app(void* p) {
tanks_state->menu_state = MenuStateCooperativeClientMode;
}
} else if(tanks_state->state == GameStateCooperativeClient) {
FuriString* goesDown = NULL;
FuriString* goesDown = furi_string_alloc();
char arr[2];
arr[0] = GoesDown;
arr[1] = 0;
Expand All @@ -1270,14 +1270,15 @@ int32_t tanks_game_app(void* p) {
subghz_txrx,
(uint8_t*)furi_string_get_cstr(goesDown),
strlen(furi_string_get_cstr(goesDown)));
furi_string_free(goesDown);
} else {
tanks_state->p1->moving = true;
tanks_state->p1->direction = DirectionDown;
}
break;
case InputKeyRight:
if(tanks_state->state == GameStateCooperativeClient) {
FuriString* goesRight = NULL;
FuriString* goesRight = furi_string_alloc();
char arr[2];
arr[0] = GoesRight;
arr[1] = 0;
Expand All @@ -1287,14 +1288,15 @@ int32_t tanks_game_app(void* p) {
subghz_txrx,
(uint8_t*)furi_string_get_cstr(goesRight),
strlen(furi_string_get_cstr(goesRight)));
furi_string_free(goesRight);
} else {
tanks_state->p1->moving = true;
tanks_state->p1->direction = DirectionRight;
}
break;
case InputKeyLeft:
if(tanks_state->state == GameStateCooperativeClient) {
FuriString* goesLeft = NULL;
FuriString* goesLeft = furi_string_alloc();
char arr[2];
arr[0] = GoesLeft;
arr[1] = 0;
Expand All @@ -1304,6 +1306,7 @@ int32_t tanks_game_app(void* p) {
subghz_txrx,
(uint8_t*)furi_string_get_cstr(goesLeft),
strlen(furi_string_get_cstr(goesLeft)));
furi_string_free(goesLeft);
} else {
tanks_state->p1->moving = true;
tanks_state->p1->direction = DirectionLeft;
Expand All @@ -1327,7 +1330,7 @@ int32_t tanks_game_app(void* p) {
} else if(tanks_state->state == GameStateGameOver) {
tanks_game_init_game(tanks_state, tanks_state->state);
} else if(tanks_state->state == GameStateCooperativeClient) {
FuriString* shoots = NULL;
FuriString* shoots = furi_string_alloc();
char arr[2];
arr[0] = Shoots;
arr[1] = 0;
Expand All @@ -1337,6 +1340,7 @@ int32_t tanks_game_app(void* p) {
subghz_txrx,
(uint8_t*)furi_string_get_cstr(shoots),
strlen(furi_string_get_cstr(shoots)));
furi_string_free(shoots);
} else {
tanks_state->p1->shooting = true;
}
Expand Down Expand Up @@ -1385,7 +1389,7 @@ int32_t tanks_game_app(void* p) {

tanks_game_process_game_step(tanks_state);

FuriString* serializedData = NULL;
FuriString* serializedData = furi_string_alloc();
unsigned char* data = tanks_game_serialize(tanks_state);
char arr[11 * 16 + 1];

Expand All @@ -1401,7 +1405,7 @@ int32_t tanks_game_app(void* p) {
subghz_txrx,
(uint8_t*)furi_string_get_cstr(serializedData),
strlen(furi_string_get_cstr(serializedData)));

furi_string_free(serializedData);
tanks_state->sent++;
} else if(tanks_state->state == GameStateSingle) {
tanks_game_process_game_step(tanks_state);
Expand Down
2 changes: 1 addition & 1 deletion applications/external/timelapse/zeitraffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ int32_t zeitraffer_app(void* p) {
}
if(!flipper_format_write_comment_cstr(
save,
"Zeitraffer app settings: of frames, interval time, backlight type, Delay")) {
"Zeitraffer app settings: n of frames, interval time, backlight type, Delay")) {
notification_message(notifications, &sequence_error);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void wifi_deauther_scene_console_output_on_enter(void* context) {
furi_string_reset(app->text_box_store);
app->text_box_store_strlen = 0;
if(0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
const char* help_msg = "For app support/feedback,\nreach out to\n";
const char* help_msg = "No help here\nonly pain\n";
furi_string_cat_str(app->text_box_store, help_msg);
app->text_box_store_strlen += strlen(help_msg);
}
Expand All @@ -43,9 +43,9 @@ void wifi_deauther_scene_console_output_on_enter(void* context) {
furi_string_cat_str(app->text_box_store, help_msg);
app->text_box_store_strlen += strlen(help_msg);
}
} else { // "View Log" menu action
text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store));
}
// "View Log" menu action
text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store));

scene_manager_set_scene_state(app->scene_manager, WifideautherSceneConsoleOutput, 0);
view_dispatcher_switch_to_view(app->view_dispatcher, WifideautherAppViewConsoleOutput);
Expand Down
13 changes: 6 additions & 7 deletions applications/external/wifi_deauther/wifi_deauther_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

struct WifideautherUart {
WifideautherApp* app;
FuriHalUartId channel;
FuriThread* rx_thread;
StreamBufferHandle_t rx_stream;
FuriStreamBuffer* rx_stream;
uint8_t rx_buf[RX_BUF_SIZE + 1];
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context);
};
Expand All @@ -30,12 +31,10 @@ void wifi_deauther_uart_set_handle_rx_data_cb(

void wifi_deauther_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
WifideautherUart* uart = (WifideautherUart*)context;
BaseType_t xHigherPriorityTaskWoken = pdFALSE;

if(ev == UartIrqEventRXNE) {
xStreamBufferSendFromISR(uart->rx_stream, &data, 1, &xHigherPriorityTaskWoken);
furi_stream_buffer_send(uart->rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}

Expand All @@ -48,14 +47,14 @@ static int32_t uart_worker(void* context) {
furi_check((events & FuriFlagError) == 0);
if(events & WorkerEvtStop) break;
if(events & WorkerEvtRxDone) {
size_t len = xStreamBufferReceive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
size_t len = furi_stream_buffer_receive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
if(len > 0) {
if(uart->handle_rx_data_cb) uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);
}
}
}

vStreamBufferDelete(uart->rx_stream);
furi_stream_buffer_free(uart->rx_stream);

return 0;
}
Expand All @@ -68,7 +67,7 @@ WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app) {
WifideautherUart* uart = malloc(sizeof(WifideautherUart));

uart->app = app;
uart->rx_stream = xStreamBufferCreate(RX_BUF_SIZE, 1);
uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
uart->rx_thread = furi_thread_alloc();
furi_thread_set_name(uart->rx_thread, "WifideautherUartRxThread");
furi_thread_set_stack_size(uart->rx_thread, 1024);
Expand Down

0 comments on commit 4e38f7f

Please sign in to comment.