Skip to content

Commit

Permalink
Removed logging calls
Browse files Browse the repository at this point in the history
  • Loading branch information
squee72564 committed Jan 7, 2024
1 parent cf60398 commit fd93f13
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 37 deletions.
5 changes: 2 additions & 3 deletions helpers/mine_sweeper_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ static void mine_sweeper_close_config_file(FlipperFormat* file) {
void mine_sweeper_save_settings(void* context) {
MineSweeperApp* app = context;

FURI_LOG_D(TAG, "Saving Settings");
Storage* storage = mine_sweeper_open_storage();
FlipperFormat* fff_file = flipper_format_file_alloc(storage);

Expand All @@ -29,9 +28,9 @@ void mine_sweeper_save_settings(void* context) {

// Open File, create if not exists
if(!storage_common_stat(storage, MINESWEEPER_SETTINGS_SAVE_PATH, NULL) == FSE_OK) {
FURI_LOG_D(TAG, "Config file %s is not found. Will create new.", MINESWEEPER_SETTINGS_SAVE_PATH);
FURI_LOG_I(TAG, "Config file %s is not found. Will create new.", MINESWEEPER_SETTINGS_SAVE_PATH);
if(storage_common_stat(storage, CONFIG_FILE_DIRECTORY_PATH, NULL) == FSE_NOT_EXIST) {
FURI_LOG_D(
FURI_LOG_I(
TAG,
"Directory %s doesn't exist. Will create new.",
CONFIG_FILE_DIRECTORY_PATH);
Expand Down
11 changes: 4 additions & 7 deletions minesweeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static MineSweeperApp* app_alloc() {

// If we cannot read the save file set to default values
if (!(mine_sweeper_read_settings(app))) {
FURI_LOG_D(TAG, "Cannot read save file, loading defaults");
FURI_LOG_I(TAG, "Cannot read save file, loading defaults");
app->settings_info.board_width = 16;
app->settings_info.board_height = 7;
app->settings_info.difficulty = 0;
Expand All @@ -60,7 +60,7 @@ static MineSweeperApp* app_alloc() {

mine_sweeper_save_settings(app);
} else {
FURI_LOG_D(TAG, "Save file loaded sucessfully");
FURI_LOG_I(TAG, "Save file loaded sucessfully");
}

// Alloc views and add to view dispatcher
Expand Down Expand Up @@ -107,7 +107,6 @@ static void app_free(MineSweeperApp* app) {
// Remove each view from View Dispatcher
for (MineSweeperView minesweeper_view = (MineSweeperView)0; minesweeper_view < MineSweeperViewCount; minesweeper_view++) {

FURI_LOG_D(TAG, "Removing view from View Dispatcher : %d", minesweeper_view);
view_dispatcher_remove_view(app->view_dispatcher, minesweeper_view);
}

Expand Down Expand Up @@ -136,17 +135,15 @@ int32_t minesweeper_app(void* p) {
UNUSED(p);

MineSweeperApp* app = app_alloc();
FURI_LOG_D(TAG, "Mine Sweeper app allocated with size : %d", sizeof(*app));
FURI_LOG_I(TAG, "Mine Sweeper app allocated with size : %d", sizeof(*app));

// This will be the initial scene on app startup
scene_manager_next_scene(app->scene_manager, MineSweeperSceneStartScreen);
FURI_LOG_D(TAG, "Scene Manager initial scene set : %d", MineSweeperSceneStartScreen);

FURI_LOG_D(TAG, "Starting View Dispatcher");
view_dispatcher_run(app->view_dispatcher);

app_free(app);
FURI_LOG_D(TAG, "Mine Sweeper app freed");
FURI_LOG_I(TAG, "Mine Sweeper app freed");

return 0;
}
27 changes: 0 additions & 27 deletions views/minesweeper_game_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ static void setup_board(MineSweeperGameScreen* instance) {
);

uint16_t num_mines = board_tile_count * difficulty_multiplier[ board_difficulty ];
FURI_LOG_D(MS_DEBUG_TAG, "Placing %hd mines", num_mines);

/** We can use a temporary buffer to set the tile types initially
* and manipulate then save to actual model
Expand Down Expand Up @@ -322,7 +321,6 @@ static inline Point bfs_to_closest_tile(MineSweeperGameScreenModel* model) {
uint32_t ticks_elapsed = furi_get_tick() - start_tick;
double sec = (double)ticks_elapsed / (double)furi_kernel_get_tick_frequency();
double milliseconds = 1000.0L * sec;

Check failure on line 323 in views/minesweeper_game_screen.c

View workflow job for this annotation

GitHub Actions / Build Minesweeper for dev channel

unused variable 'milliseconds' [-Werror=unused-variable]

Check failure on line 323 in views/minesweeper_game_screen.c

View workflow job for this annotation

GitHub Actions / Build Minesweeper for release channel

unused variable 'milliseconds' [-Werror=unused-variable]
FURI_LOG_D(MS_DEBUG_TAG, "BFS: %.2f MS in %d iterations.", milliseconds, i);

point_set_clear(set);
point_deq_clear(deq);
Expand Down Expand Up @@ -403,7 +401,6 @@ static inline void bfs_tile_clear(MineSweeperGameScreenModel* model) {
uint32_t ticks_elapsed = furi_get_tick() - start_tick;
double sec = (double)ticks_elapsed / (double)furi_kernel_get_tick_frequency();
double milliseconds = 1000.0L * sec;

Check failure on line 403 in views/minesweeper_game_screen.c

View workflow job for this annotation

GitHub Actions / Build Minesweeper for dev channel

unused variable 'milliseconds' [-Werror=unused-variable]

Check failure on line 403 in views/minesweeper_game_screen.c

View workflow job for this annotation

GitHub Actions / Build Minesweeper for release channel

unused variable 'milliseconds' [-Werror=unused-variable]
FURI_LOG_D(MS_DEBUG_TAG, "FLOOD FILL TOOK: %.2f MS", milliseconds);

point_set_clear(set);
point_deq_clear(deq);
Expand Down Expand Up @@ -789,7 +786,6 @@ static bool mine_sweeper_game_screen_view_end_input_callback(InputEvent* event,
switch (event->key) {

case InputKeyUp :
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && InputKeyUp");
model->curr_pos.x_abs = (model->curr_pos.x_abs-1 < 0) ? 0 : model->curr_pos.x_abs-1;

is_outside_boundary = model->curr_pos.x_abs <
Expand All @@ -803,7 +799,6 @@ static bool mine_sweeper_game_screen_view_end_input_callback(InputEvent* event,
break;

case InputKeyDown :
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && Inputdown");
model->curr_pos.x_abs = (model->curr_pos.x_abs+1 >= model->board_height) ?
model->board_height-1 : model->curr_pos.x_abs+1;

Expand All @@ -817,7 +812,6 @@ static bool mine_sweeper_game_screen_view_end_input_callback(InputEvent* event,
break;

case InputKeyLeft :
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && InputKeyLeft");
model->curr_pos.y_abs = (model->curr_pos.y_abs-1 < 0) ? 0 : model->curr_pos.y_abs-1;

is_outside_boundary = model->curr_pos.y_abs <
Expand All @@ -831,7 +825,6 @@ static bool mine_sweeper_game_screen_view_end_input_callback(InputEvent* event,
break;

case InputKeyRight :
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && InputKeyRight");
model->curr_pos.y_abs = (model->curr_pos.y_abs+1 >= model->board_width) ?
model->board_width-1 : model->curr_pos.y_abs+1;

Expand Down Expand Up @@ -882,8 +875,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,

if (event->type == InputTypePress) {

FURI_LOG_D(MS_DEBUG_TAG, "Event Type: InputTypePress && InputKeyOk");

with_view_model(
instance->view,
MineSweeperGameScreenModel * model,
Expand Down Expand Up @@ -944,9 +935,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,

if (state == MineSweeperGameScreenTileStateCleared) {

FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypeLong || InputTypeRepeat) && InputKeyBack");


// BFS to closest uncovered position
Point res = bfs_to_closest_tile(model);

Expand All @@ -957,8 +945,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,
model->curr_pos.x_abs = res.x;
model->curr_pos.y_abs = res.y;

FURI_LOG_D(MS_DEBUG_TAG, "After DFS pos: (%hd,%hd)", res.x, res.y);

bool is_outside_top_boundary = model->curr_pos.x_abs <
(model->bottom_boundary - MINESWEEPER_SCREEN_TILE_HEIGHT);

Expand Down Expand Up @@ -987,7 +973,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,

// Flag or Unflag tile and check win condition
} else if (!model->is_holding_down_button && (state == MineSweeperGameScreenTileStateUncleared || state == MineSweeperGameScreenTileStateFlagged)) {
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: InputTypeLong && InputKeyOk");

if (state == MineSweeperGameScreenTileStateFlagged) {
if (model->board[curr_pos_1d].tile_type == MineSweeperGameScreenTileMine) model->mines_left++;
Expand Down Expand Up @@ -1028,7 +1013,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,
switch (event->key) {

case InputKeyUp :
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && InputKeyUp");
model->curr_pos.x_abs = (model->curr_pos.x_abs-1 < 0) ? 0 : model->curr_pos.x_abs-1;

is_outside_boundary = model->curr_pos.x_abs <
Expand All @@ -1042,7 +1026,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,
break;

case InputKeyDown :
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && Inputdown");
model->curr_pos.x_abs = (model->curr_pos.x_abs+1 >= model->board_height) ?
model->board_height-1 : model->curr_pos.x_abs+1;

Expand All @@ -1056,7 +1039,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,
break;

case InputKeyLeft :
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && InputKeyLeft");
model->curr_pos.y_abs = (model->curr_pos.y_abs-1 < 0) ? 0 : model->curr_pos.y_abs-1;

is_outside_boundary = model->curr_pos.y_abs <
Expand All @@ -1070,7 +1052,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,
break;

case InputKeyRight :
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && InputKeyRight");
model->curr_pos.y_abs = (model->curr_pos.y_abs+1 >= model->board_width) ?
model->board_width-1 : model->curr_pos.y_abs+1;

Expand All @@ -1084,7 +1065,6 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,
break;

default:
FURI_LOG_D(MS_DEBUG_TAG, "Event Type: (InputTypePress || InputTypeRepeat) && DEFAULT CASE");
break;
}
},
Expand All @@ -1094,12 +1074,7 @@ static bool mine_sweeper_game_screen_view_play_input_callback(InputEvent* event,


if (!consumed && instance->input_callback != NULL) {
FURI_LOG_D(MS_DEBUG_TAG, "Event type: %d, Key: %d, not consumed, sending to custom callback.", event->type, event->key);
consumed = instance->input_callback(event, instance->context);
} else if (!consumed) {
FURI_LOG_D(MS_DEBUG_TAG, "Event type: %d, Key: %d, not consumed and custom callback NULL.", event->type, event->key);
} else {
FURI_LOG_D(MS_DEBUG_TAG, "Event type: %d, Key: %d, consumed.", event->type, event->key);
}

return consumed;
Expand Down Expand Up @@ -1142,7 +1117,6 @@ MineSweeperGameScreen* mine_sweeper_game_screen_alloc(uint8_t width, uint8_t hei
// We need to initize board width and height before setup
mine_sweeper_game_screen_set_board_information(mine_sweeper_game_screen, width, height, difficulty);

FURI_LOG_D(MS_DEBUG_TAG, "Setting up board with w:%03hhd h:%03hhd d:%02hhd", width, height, difficulty);
setup_board(mine_sweeper_game_screen);

return mine_sweeper_game_screen;
Expand Down Expand Up @@ -1178,7 +1152,6 @@ void mine_sweeper_game_screen_reset(MineSweeperGameScreen* instance, uint8_t wid

mine_sweeper_game_screen_reset_clock(instance);

FURI_LOG_D(MS_DEBUG_TAG, "Setting up board with w:%03hhd h:%03hhd d:%02hhd", width, height, difficulty);
setup_board(instance);

}
Expand Down

0 comments on commit fd93f13

Please sign in to comment.