Skip to content

Commit

Permalink
removed files
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrodude6119 committed Jun 30, 2023
1 parent 457fbb7 commit feccb92
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
13 changes: 6 additions & 7 deletions evil_portal_app.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "evil_portal_app_i.h"
#include "helpers/evil_portal_speaker.h"
#include "helpers/evil_portal_storage.h"

#include <furi.h>
Expand Down Expand Up @@ -69,7 +70,8 @@ Evil_PortalApp *evil_portal_app_alloc() {
return app;
}

void evil_portal_app_free(Evil_PortalApp *app) {
void evil_portal_app_free(Evil_PortalApp *app) {

// save latest logs
if (strlen(app->portal_logs) > 0) {
write_logs(app->portal_logs);
Expand All @@ -86,10 +88,6 @@ void evil_portal_app_free(Evil_PortalApp *app) {
Evil_PortalAppViewVarItemList);
view_dispatcher_remove_view(app->view_dispatcher,
Evil_PortalAppViewConsoleOutput);
view_dispatcher_remove_view(app->view_dispatcher,
Evil_PortalAppViewTextInput);
view_dispatcher_remove_view(app->view_dispatcher,
Evil_PortalAppViewStartPortal);

text_box_free(app->text_box);
furi_string_free(app->text_box_store);
Expand All @@ -106,14 +104,15 @@ void evil_portal_app_free(Evil_PortalApp *app) {
free(app);
}

int32_t evil_portal_app(void *p) {
int32_t evil_portal_app(void *p) {
UNUSED(p);
Evil_PortalApp *evil_portal_app = evil_portal_app_alloc();

evil_portal_app->uart = evil_portal_uart_init(evil_portal_app);

view_dispatcher_run(evil_portal_app->view_dispatcher);
view_dispatcher_run(evil_portal_app->view_dispatcher);

// crashing here
evil_portal_app_free(evil_portal_app);

return 0;
Expand Down
4 changes: 0 additions & 4 deletions evil_portal_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "evil_portal_custom_event.h"
#include "evil_portal_uart.h"
#include "scenes/evil_portal_scene.h"
// #include "uart_text_input.h"

#include <gui/gui.h>
#include <gui/modules/text_box.h>
Expand All @@ -15,7 +14,6 @@
#define NUM_MENU_ITEMS (4)

#define EVIL_PORTAL_TEXT_BOX_STORE_SIZE (4096)
#define EVIL_PORTAL_TEXT_INPUT_STORE_SIZE (512)
#define UART_CH (FuriHalUartIdUSART1)

struct Evil_PortalApp {
Expand All @@ -25,7 +23,6 @@ struct Evil_PortalApp {

char* portal_logs;

char text_input_store[EVIL_PORTAL_TEXT_INPUT_STORE_SIZE + 1];
FuriString *text_box_store;
size_t text_box_store_strlen;
TextBox *text_box;
Expand Down Expand Up @@ -55,6 +52,5 @@ struct Evil_PortalApp {
typedef enum {
Evil_PortalAppViewVarItemList,
Evil_PortalAppViewConsoleOutput,
Evil_PortalAppViewTextInput,
Evil_PortalAppViewStartPortal,
} Evil_PortalAppView;
10 changes: 1 addition & 9 deletions evil_portal_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,22 @@ void evil_portal_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void *context) {
static int32_t uart_worker(void *context) {
Evil_PortalUart *uart = (void *)context;


// FURI_LOG_I("EP", "in worker");
while (1) {

uint32_t events = furi_thread_flags_wait(WORKER_ALL_RX_EVENTS,
FuriFlagWaitAny, FuriWaitForever);
furi_check((events & FuriFlagError) == 0);
if (events & WorkerEvtStop)
// FURI_LOG_I("EP", "event 1");
break;
if (events & WorkerEvtRxDone) {
// FURI_LOG_I("EP", "event 2");
size_t len = furi_stream_buffer_receive(uart->rx_stream, uart->rx_buf,
RX_BUF_SIZE, 0);

// FURI_LOG_I("EP", "comp len");
if (len > 0) {
// FURI_LOG_I("EP", "check cb");
if (uart->handle_rx_data_cb) {
uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);

if (uart->app->has_command_queue) {
// FURI_LOG_I("EP", "Has command queue");
// FURI_LOG_I("EP", (char *)uart->rx_buf);
if (uart->app->has_command_queue) {
if (uart->app->command_index < 1) {

// check the current command
Expand Down
19 changes: 19 additions & 0 deletions helpers/evil_portal_speaker.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "evil_portal_speaker.h"
#include "../evil_portal_app_i.h"

#define NOTE_INPUT 587.33f

void evil_portal_play_input_sound() {
float volume = 1.0f;
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
furi_hal_speaker_start(NOTE_INPUT, volume);
}

}

void evil_portal_stop_all_sound() {
if(furi_hal_speaker_is_mine()) {
furi_hal_speaker_stop();
furi_hal_speaker_release();
}
}
4 changes: 4 additions & 0 deletions helpers/evil_portal_speaker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define NOTE_INPUT 587.33f

void evil_portal_play_input_sound();
void evil_portal_stop_all_sound();
18 changes: 9 additions & 9 deletions scenes/evil_portal_scene_start.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../evil_portal_app_i.h"
#include "../helpers/evil_portal_speaker.h"

// For each command, define whether additional arguments are needed
// (enabling text input to fill them out), and whether the console
Expand Down Expand Up @@ -72,17 +73,17 @@ static void evil_portal_scene_start_var_list_enter_callback(void *context,
: item->focus_console;
app->show_stopscan_tip = item->show_stopscan_tip;

bool needs_keyboard = (item->needs_keyboard == TOGGLE_ARGS)
? (selected_option_index != 0)
: item->needs_keyboard;
// bool needs_keyboard = (item->needs_keyboard == TOGGLE_ARGS)
// ? (selected_option_index != 0)
// : item->needs_keyboard;

if (needs_keyboard) {
view_dispatcher_send_custom_event(app->view_dispatcher,
Evil_PortalEventStartKeyboard);
} else {
// if (needs_keyboard) {
// view_dispatcher_send_custom_event(app->view_dispatcher,
// Evil_PortalEventStartKeyboard);
// } else {
view_dispatcher_send_custom_event(app->view_dispatcher,
Evil_PortalEventStartConsole);
}
// }
}

static void
Expand Down Expand Up @@ -138,7 +139,6 @@ bool evil_portal_scene_start_on_event(void *context, SceneManagerEvent event) {
} else if (event.event == Evil_PortalEventStartKeyboard) {
scene_manager_set_scene_state(app->scene_manager, Evil_PortalSceneStart,
app->selected_menu_index);
scene_manager_next_scene(app->scene_manager, Evil_PortalAppViewTextInput);
} else if (event.event == Evil_PortalEventStartConsole) {
scene_manager_set_scene_state(app->scene_manager, Evil_PortalSceneStart,
app->selected_menu_index);
Expand Down

0 comments on commit feccb92

Please sign in to comment.