Skip to content

Commit 3a13a51

Browse files
committed
Quick messy emulation edits/fixes
1 parent 8449706 commit 3a13a51

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

scenes/mag_scene_emulate_test.c

+15-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#define PIN_A 0
44
#define PIN_B 1 // currently unused
55
#define CLOCK_US 250 // typically set between 200-500us
6+
#define TEST_STR "%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?;1234567812?"
67

78
uint8_t magspoof_bit_dir = 0;
9+
const char* test_str = TEST_STR;
810

911
void mag_scene_emulate_test_dialog_callback(DialogExResult result, void* context) {
1012
Mag* mag = context;
@@ -66,6 +68,8 @@ static void mag_spoof(FuriString* track_str, uint8_t track) {
6668
furi_hal_ibutton_start_drive();
6769
furi_hal_ibutton_pin_low();
6870

71+
// Initializing at GpioSpeedLow seems sufficient for our needs; no improvements seen by increasing speed setting
72+
6973
// this doesn't seem to make a difference, leaving it in
7074
furi_hal_gpio_init(&gpio_rfid_data_in, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
7175
furi_hal_gpio_write(&gpio_rfid_data_in, false);
@@ -81,8 +85,11 @@ static void mag_spoof(FuriString* track_str, uint8_t track) {
8185
// A7 GPIO pin for debugging purposes
8286
//furi_hal_gpio_init(&gpio_ext_pa7, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
8387

88+
// TODO: initialize pins on scene enter, perhaps, so as to avoid this delay each time the button is pressed?
89+
// Also, why is such a long delay needed?
8490
furi_delay_ms(300);
8591

92+
// prevents interrupts &c. from impacting critical timings
8693
FURI_CRITICAL_ENTER();
8794

8895
const uint8_t bitlen[] = {7, 5, 5};
@@ -126,6 +133,7 @@ static void mag_spoof(FuriString* track_str, uint8_t track) {
126133
gpio_item_set_rfid_pin(PIN_A, 0);
127134
gpio_item_set_rfid_pin(PIN_B, 0);
128135

136+
// end critical timing section
129137
FURI_CRITICAL_EXIT();
130138

131139
furi_hal_rfid_pins_reset();
@@ -140,11 +148,11 @@ void mag_scene_emulate_test_on_enter(void* context) {
140148
tmp_string = furi_string_alloc();
141149

142150
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", mag_widget_callback, mag);
143-
widget_add_button_element(widget, GuiButtonTypeCenter, "Emulate", mag_widget_callback, mag);
151+
widget_add_button_element(widget, GuiButtonTypeRight, "Emulate", mag_widget_callback, mag);
144152

145-
furi_string_printf(tmp_string, "Emulate?");
153+
furi_string_printf(tmp_string, test_str);
146154
widget_add_string_element(
147-
widget, 64, 0, AlignCenter, AlignTop, FontPrimary, furi_string_get_cstr(tmp_string));
155+
widget, 64, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_string));
148156
furi_string_reset(tmp_string);
149157

150158
view_dispatcher_switch_to_view(mag->view_dispatcher, MagViewWidget);
@@ -157,15 +165,15 @@ bool mag_scene_emulate_test_on_event(void* context, SceneManagerEvent event) {
157165
bool consumed = false;
158166

159167
if(event.type == SceneManagerEventTypeCustom) {
160-
if(event.event == DialogExResultCenter) {
168+
if(event.event == GuiButtonTypeRight) {
161169
consumed = true;
162170

163171
// Hardcoding a test string for the time being, while we debug/improve LF RFID TX
164172
FuriString* v = furi_string_alloc();
165-
furi_string_set_str(
166-
v,
167-
"%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?;1234567812?");
173+
furi_string_set_str(v, test_str);
174+
notification_message(mag->notifications, &sequence_blink_start_magenta);
168175
mag_spoof(v, 0);
176+
notification_message(mag->notifications, &sequence_blink_stop);
169177
furi_string_free(v);
170178
} else if(event.event == GuiButtonTypeLeft) {
171179
consumed = true;

0 commit comments

Comments
 (0)