-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from acegoal07/Settings
Settings
- Loading branch information
Showing
8 changed files
with
171 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#pragma once | ||
|
||
#include "scences/main_menu.h" | ||
#include "scences/settings.h" | ||
#include "scences/emulation.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#include "nfc_playlist.h" | ||
#include "scences/settings.h" | ||
|
||
typedef enum { | ||
NfcPlaylistSettings_Timeout, | ||
NfcPlaylistSettings_Delay, | ||
NfcPlaylistSettings_LedIndicator, | ||
NfcPlaylistSettings_Reset | ||
} NfcPlaylistMenuSelection; | ||
|
||
static void nfc_playlist_menu_callback(void* context, uint32_t index) { | ||
NfcPlaylist* nfc_playlist = context; | ||
switch(index) { | ||
case NfcPlaylistSettings_Reset: | ||
nfc_playlist->emulate_timeout = default_emulate_timeout; | ||
VariableItem* emulation_timeout_settings = variable_item_list_get(nfc_playlist->variable_item_list, NfcPlaylistSettings_Timeout); | ||
variable_item_set_current_value_index(emulation_timeout_settings, nfc_playlist->emulate_timeout); | ||
char emulation_timeout_settings_text[3]; | ||
snprintf(emulation_timeout_settings_text, 3, "%ds", options_emulate_timeout[nfc_playlist->emulate_timeout]); | ||
variable_item_set_current_value_text(emulation_timeout_settings, (char*)emulation_timeout_settings_text); | ||
|
||
nfc_playlist->emulate_delay = default_emulate_delay; | ||
VariableItem* emulation_delay_settings = variable_item_list_get(nfc_playlist->variable_item_list, NfcPlaylistSettings_Delay); | ||
variable_item_set_current_value_index(emulation_delay_settings, nfc_playlist->emulate_delay); | ||
char emulation_delay_settings_text[3]; | ||
snprintf(emulation_delay_settings_text, 3, "%ds", options_emulate_delay[nfc_playlist->emulate_delay]); | ||
variable_item_set_current_value_text(emulation_delay_settings, (char*)emulation_delay_settings_text); | ||
|
||
nfc_playlist->emulate_led_indicator = default_emulate_led_indicator; | ||
VariableItem* emulation_led_indicator_settings = variable_item_list_get(nfc_playlist->variable_item_list, NfcPlaylistSettings_LedIndicator); | ||
variable_item_set_current_value_index(emulation_led_indicator_settings, nfc_playlist->emulate_led_indicator); | ||
variable_item_set_current_value_text(emulation_led_indicator_settings, nfc_playlist->emulate_led_indicator ? "ON" : "OFF"); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
static void nfc_playlist_settings_options_change_callback(VariableItem* item) { | ||
NfcPlaylist* nfc_playlist = variable_item_get_context(item); | ||
|
||
uint8_t current_option = variable_item_list_get_selected_item_index(nfc_playlist->variable_item_list); | ||
uint8_t option_value_index = variable_item_get_current_value_index(item); | ||
|
||
switch(current_option) { | ||
case NfcPlaylistSettings_Timeout: { | ||
nfc_playlist->emulate_timeout = option_value_index; | ||
char emulate_timeout_text[3]; | ||
snprintf(emulate_timeout_text, 3, "%ds", options_emulate_timeout[option_value_index]); | ||
variable_item_set_current_value_text(item, (char*)emulate_timeout_text); | ||
break; | ||
} | ||
case NfcPlaylistSettings_Delay: { | ||
nfc_playlist->emulate_delay = option_value_index; | ||
char emulate_delay_text[3]; | ||
snprintf(emulate_delay_text, 3, "%ds", options_emulate_delay[option_value_index]); | ||
variable_item_set_current_value_text(item, (char*)emulate_delay_text); | ||
break; | ||
} | ||
case NfcPlaylistSettings_LedIndicator: | ||
nfc_playlist->emulate_led_indicator = option_value_index; | ||
variable_item_set_current_value_text(item, nfc_playlist->emulate_led_indicator ? "ON" : "OFF"); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void nfc_playlist_settings_scene_on_enter(void* context) { | ||
NfcPlaylist* nfc_playlist = context; | ||
variable_item_list_set_header(nfc_playlist->variable_item_list, "Settings"); | ||
|
||
VariableItem* emulation_timeout_settings = variable_item_list_add( | ||
nfc_playlist->variable_item_list, | ||
"Emulate time", | ||
(sizeof(options_emulate_timeout)/sizeof(options_emulate_timeout[0])), | ||
nfc_playlist_settings_options_change_callback, | ||
nfc_playlist); | ||
variable_item_set_current_value_index(emulation_timeout_settings, nfc_playlist->emulate_timeout); | ||
char emulation_timeout_settings_text[3]; | ||
snprintf(emulation_timeout_settings_text, 3, "%ds", options_emulate_timeout[nfc_playlist->emulate_timeout]); | ||
variable_item_set_current_value_text(emulation_timeout_settings, (char*)emulation_timeout_settings_text); | ||
|
||
VariableItem* emulation_delay_settings = variable_item_list_add( | ||
nfc_playlist->variable_item_list, | ||
"Delay time", | ||
(sizeof(options_emulate_delay)/sizeof(options_emulate_delay[0])), | ||
nfc_playlist_settings_options_change_callback, | ||
nfc_playlist); | ||
variable_item_set_current_value_index(emulation_delay_settings, nfc_playlist->emulate_delay); | ||
char emulation_delay_settings_text[3]; | ||
snprintf(emulation_delay_settings_text, 3, "%ds", options_emulate_delay[nfc_playlist->emulate_delay]); | ||
variable_item_set_current_value_text(emulation_delay_settings, (char*)emulation_delay_settings_text); | ||
|
||
VariableItem* emulation_led_indicator_settings = variable_item_list_add( | ||
nfc_playlist->variable_item_list, | ||
"LED Indicator", | ||
2, | ||
nfc_playlist_settings_options_change_callback, | ||
nfc_playlist); | ||
variable_item_set_current_value_index(emulation_led_indicator_settings, nfc_playlist->emulate_led_indicator); | ||
variable_item_set_current_value_text(emulation_led_indicator_settings, nfc_playlist->emulate_led_indicator ? "ON" : "OFF"); | ||
|
||
variable_item_list_add(nfc_playlist->variable_item_list, "Reset settings", 0, NULL, NULL); | ||
|
||
variable_item_list_set_enter_callback(nfc_playlist->variable_item_list, nfc_playlist_menu_callback, nfc_playlist); | ||
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_Settings); | ||
} | ||
|
||
bool nfc_playlist_settings_scene_on_event(void* context, SceneManagerEvent event) { | ||
UNUSED(context); | ||
UNUSED(event); | ||
return false; | ||
} | ||
|
||
void nfc_playlist_settings_scene_on_exit(void* context) { | ||
NfcPlaylist* nfc_playlist = context; | ||
variable_item_list_reset(nfc_playlist->variable_item_list); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
#include <furi.h> | ||
#include <gui/gui.h> | ||
#include <gui/view_dispatcher.h> | ||
#include <gui/scene_manager.h> | ||
#include <gui/modules/variable_item_list.h> | ||
|
||
void nfc_playlist_settings_scene_on_enter(void* context); | ||
bool nfc_playlist_settings_scene_on_event(void* context, SceneManagerEvent event); | ||
void nfc_playlist_settings_scene_on_exit(void* context); |