mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 19:20:30 +08:00
tarot: avoid mandatory function call on every tick (#185)
This commit is contained in:
parent
8d20b46fec
commit
3cd8e5c47e
|
@ -179,30 +179,28 @@ static void pick_cards(tarot_state_t *state) {
|
|||
}
|
||||
|
||||
static void display_animation(tarot_state_t *state) {
|
||||
if (state->is_picking) {
|
||||
if (state->animation_frame == 0) {
|
||||
watch_display_string(" ", 7);
|
||||
watch_set_pixel(1, 4);
|
||||
watch_set_pixel(1, 6);
|
||||
state->animation_frame = 1;
|
||||
} else if (state->animation_frame == 1) {
|
||||
watch_clear_pixel(1, 4);
|
||||
watch_clear_pixel(1, 6);
|
||||
watch_set_pixel(2, 4);
|
||||
watch_set_pixel(0, 6);
|
||||
state->animation_frame = 2;
|
||||
} else if (state->animation_frame == 2) {
|
||||
watch_clear_pixel(2, 4);
|
||||
watch_clear_pixel(0, 6);
|
||||
watch_set_pixel(2, 5);
|
||||
watch_set_pixel(0, 5);
|
||||
state->animation_frame = 3;
|
||||
} else if (state->animation_frame == 3) {
|
||||
state->animation_frame = 0;
|
||||
state->is_picking = false;
|
||||
movement_request_tick_frequency(1);
|
||||
tarot_display(state);
|
||||
}
|
||||
if (state->animation_frame == 0) {
|
||||
watch_display_string(" ", 7);
|
||||
watch_set_pixel(1, 4);
|
||||
watch_set_pixel(1, 6);
|
||||
state->animation_frame = 1;
|
||||
} else if (state->animation_frame == 1) {
|
||||
watch_clear_pixel(1, 4);
|
||||
watch_clear_pixel(1, 6);
|
||||
watch_set_pixel(2, 4);
|
||||
watch_set_pixel(0, 6);
|
||||
state->animation_frame = 2;
|
||||
} else if (state->animation_frame == 2) {
|
||||
watch_clear_pixel(2, 4);
|
||||
watch_clear_pixel(0, 6);
|
||||
watch_set_pixel(2, 5);
|
||||
watch_set_pixel(0, 5);
|
||||
state->animation_frame = 3;
|
||||
} else if (state->animation_frame == 3) {
|
||||
state->animation_frame = 0;
|
||||
state->is_picking = false;
|
||||
movement_request_tick_frequency(1);
|
||||
tarot_display(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +244,9 @@ bool tarot_face_loop(movement_event_t event, movement_settings_t *settings, void
|
|||
tarot_display(state);
|
||||
break;
|
||||
case EVENT_TICK:
|
||||
display_animation(state);
|
||||
if (state->is_picking) {
|
||||
display_animation(state);
|
||||
}
|
||||
break;
|
||||
case EVENT_MODE_BUTTON_UP:
|
||||
movement_move_to_next_face();
|
||||
|
|
Loading…
Reference in a new issue