Skip to content

Commit

Permalink
FW-specific macros, debug-locked items, reorder config
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyweiss committed Apr 26, 2024
1 parent 1ef6e01 commit 12808bd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
1 change: 1 addition & 0 deletions mag.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static MagSetting* mag_setting_alloc() {
setting->tx = SETTING_DEFAULT_TX_RFID;
setting->us_clock = SETTING_DEFAULT_US_CLOCK;
setting->us_interpacket = SETTING_DEFAULT_US_INTERPACKET;
setting->is_debug = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);

return setting;
}
Expand Down
11 changes: 11 additions & 0 deletions mag_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@

#define MAG_TEXT_STORE_SIZE 150

// CFWs have `submenue_add_lockable_item`; OFW doesn't,
// replace with conditional submenu item
#ifdef FW_ORIGIN_Official
#define submenu_add_lockable_item( \
submenu, label, index, callback, callback_context, locked, locked_message) \
if(!locked) { \
submenu_add_item(submenu, label, index, callback, callback_context) \
}
#endif

enum MagCustomEvent {
MagEventNext = 100,
MagEventExit,
Expand All @@ -48,6 +58,7 @@ typedef struct {
MagReverseState reverse;
uint32_t us_clock;
uint32_t us_interpacket;
bool is_debug;
} MagSetting;

typedef struct {
Expand Down
31 changes: 19 additions & 12 deletions scenes/mag_scene_emulate_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ void mag_scene_emulate_config_on_enter(void* context) {
VariableItem* item;
uint8_t value_index;

// TX
// Clock
item = variable_item_list_add(
mag->variable_item_list, "TX via:", TX_COUNT, mag_scene_emulate_config_set_tx, mag);
value_index = value_index_uint32(mag->setting->tx, tx_value, TX_COUNT);
mag->variable_item_list, "Clock:", CLOCK_COUNT, mag_scene_emulate_config_set_clock, mag);
value_index = value_index_uint32(mag->setting->us_clock, clock_value, CLOCK_COUNT);
scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, tx_text[value_index]);
variable_item_set_current_value_text(item, clock_text[value_index]);

// Track
item = variable_item_list_add(
Expand All @@ -217,14 +217,21 @@ void mag_scene_emulate_config_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, reverse_text[value_index]);

// Clock
item = variable_item_list_add(
mag->variable_item_list, "Clock:", CLOCK_COUNT, mag_scene_emulate_config_set_clock, mag);
value_index = value_index_uint32(mag->setting->us_clock, clock_value, CLOCK_COUNT);
scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, clock_text[value_index]);

// TX
#ifdef FW_ORIGIN_Official
if(mag->setting->is_debug) {
#endif
item = variable_item_list_add(
mag->variable_item_list, "TX via:", TX_COUNT, mag_scene_emulate_config_set_tx, mag);
value_index = value_index_uint32(mag->setting->tx, tx_value, TX_COUNT);
scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, tx_text[value_index]);
#ifdef FW_ORIGIN_Official
}
#else
variable_item_set_locked(item, !mag->setting->is_debug, "Enable Debug!");
#endif
// Interpacket
/*
item = variable_item_list_add(
Expand Down
9 changes: 8 additions & 1 deletion scenes/mag_scene_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ void mag_scene_start_on_enter(void* context) {
Submenu* submenu = mag->submenu;

submenu_add_item(submenu, "Saved", SubmenuIndexSaved, mag_scene_start_submenu_callback, mag);
submenu_add_item(submenu, "Read", SubmenuIndexRead, mag_scene_start_submenu_callback, mag);
submenu_add_lockable_item(
submenu,
"Read",
SubmenuIndexRead,
mag_scene_start_submenu_callback,
mag,
!mag->setting->is_debug,
"Enable Debug!");
//submenu_add_item(
// submenu, "Add Manually", SubmenuIndexAddManually, mag_scene_start_submenu_callback, mag);
submenu_add_item(submenu, "About", SubmenuIndexAbout, mag_scene_start_submenu_callback, mag);
Expand Down

0 comments on commit 12808bd

Please sign in to comment.