Skip to content

Commit d6f32ef

Browse files
authored
picopass: apply card to back view (#118)
1 parent 9a26cf8 commit d6f32ef

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

scenes/picopass_scene_elite_dict_attack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ static bool picopass_elite_dict_attack_change_dict(Picopass* picopass) {
4040
PICOPASS_KEY_LEN);
4141
scene_state = PicopassSceneEliteDictAttackDictElite;
4242
}
43-
picopass->dict_attack_ctx.card_detected = true;
4443
picopass->dict_attack_ctx.total_keys = keys_dict_get_total_keys(picopass->dict);
4544
picopass->dict_attack_ctx.current_key = 0;
4645
picopass->dict_attack_ctx.name = picopass_dict_name[scene_state];
@@ -153,7 +152,8 @@ void picopass_scene_elite_dict_attack_on_enter(void* context) {
153152
PICOPASS_KEY_LEN);
154153
state = PicopassSceneEliteDictAttackDictStandard;
155154
}
156-
picopass->dict_attack_ctx.card_detected = true;
155+
dict_attack_reset(picopass->dict_attack);
156+
picopass->dict_attack_ctx.card_detected = false;
157157
picopass->dict_attack_ctx.total_keys = keys_dict_get_total_keys(picopass->dict);
158158
picopass->dict_attack_ctx.current_key = 0;
159159
picopass->dict_attack_ctx.name = picopass_dict_name[state];

views/dict_attack.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <gui/elements.h>
44

55
typedef enum {
6+
DictAttackStateStart,
67
DictAttackStateRead,
78
DictAttackStateCardRemoved,
89
} DictAttackState;
@@ -29,7 +30,12 @@ typedef struct {
2930

3031
static void dict_attack_draw_callback(Canvas* canvas, void* model) {
3132
DictAttackViewModel* m = model;
32-
if(m->state == DictAttackStateCardRemoved) {
33+
if(m->state == DictAttackStateStart) {
34+
canvas_draw_icon(canvas, 0, 8, &I_RFIDDolphinReceive_97x61);
35+
canvas_set_font(canvas, FontPrimary);
36+
elements_multiline_text_aligned(
37+
canvas, 128, 40, AlignRight, AlignCenter, "Apply card to\nthe back");
38+
} else if(m->state == DictAttackStateCardRemoved) {
3339
canvas_set_font(canvas, FontPrimary);
3440
canvas_draw_str_aligned(canvas, 64, 4, AlignCenter, AlignTop, "Lost the tag!");
3541
canvas_set_font(canvas, FontSecondary);
@@ -78,8 +84,8 @@ static void dict_attack_draw_callback(Canvas* canvas, void* model) {
7884
m->sectors_read,
7985
m->sectors_total);
8086
canvas_draw_str_aligned(canvas, 0, 43, AlignLeft, AlignTop, draw_str);
87+
elements_button_center(canvas, "Skip");
8188
}
82-
elements_button_center(canvas, "Skip");
8389
}
8490

8591
static bool dict_attack_input_callback(InputEvent* event, void* context) {
@@ -126,7 +132,7 @@ void dict_attack_reset(DictAttack* dict_attack) {
126132
dict_attack->view,
127133
DictAttackViewModel * model,
128134
{
129-
model->state = DictAttackStateRead;
135+
model->state = DictAttackStateStart;
130136
model->sectors_total = 1;
131137
model->sectors_read = 0;
132138
model->sector_current = 0;
@@ -181,7 +187,12 @@ void dict_attack_set_card_removed(DictAttack* dict_attack) {
181187
with_view_model(
182188
dict_attack->view,
183189
DictAttackViewModel * model,
184-
{ model->state = DictAttackStateCardRemoved; },
190+
{
191+
// Only mark card as removed it if had been Read
192+
if(model->state == DictAttackStateRead) {
193+
model->state = DictAttackStateCardRemoved;
194+
}
195+
},
185196
true);
186197
}
187198

views/dict_attack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <stdint.h>
33
#include <gui/view.h>
44
#include <gui/modules/widget.h>
5+
#include <picopass_icons.h>
56

67
typedef struct DictAttack DictAttack;
78

0 commit comments

Comments
 (0)