Skip to content

Commit ca5877d

Browse files
committed
Merge branch 'fix-waiting'
2 parents 54ebf26 + 3d5ed1f commit ca5877d

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

src/ui/components/waiting.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ component_t* waiting_create(void)
5252
Abort("Error: malloc waiting data");
5353
}
5454
memset(data, 0, sizeof(data_t));
55+
data->show_logo = true;
5556

5657
component_t* waiting = malloc(sizeof(component_t));
5758
if (!waiting) {
@@ -65,7 +66,16 @@ component_t* waiting_create(void)
6566
waiting->position.left = 0;
6667
waiting->data = data;
6768

68-
ui_util_add_sub_component(waiting, lockscreen_create());
69+
image_logo_data_t logo = image_logo_data();
70+
component_t* bb2_logo = image_create(
71+
logo.buffer.data,
72+
logo.buffer.len,
73+
logo.dimensions.width,
74+
logo.dimensions.height,
75+
CENTER,
76+
waiting);
77+
78+
ui_util_add_sub_component(waiting, bb2_logo);
6979

7080
return waiting;
7181
}
@@ -97,3 +107,22 @@ void waiting_switch_to_logo(component_t* component)
97107

98108
component->sub_components.sub_components[0] = bb2_logo;
99109
}
110+
111+
void waiting_switch_to_lockscreen(component_t* component)
112+
{
113+
data_t* data = (data_t*)component->data;
114+
if (!data->show_logo) {
115+
return;
116+
}
117+
data->show_logo = false;
118+
119+
if (component->sub_components.amount != 1) {
120+
// Sanity check to avoid memory bugs, should never happen.
121+
Abort("waiting_switch_to_lockscreen");
122+
return;
123+
}
124+
125+
ui_util_component_cleanup(component->sub_components.sub_components[0]);
126+
127+
component->sub_components.sub_components[0] = lockscreen_create();
128+
}

src/ui/components/waiting.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include <ui/component.h>
1919

2020
/**
21-
* Creates a waiting screen. It starts out with a lockscreen (see lockscreen.c). Once
22-
* `waiting_switch_to_logo()` is called, the waiting screen will switch to showing the logo image.
21+
* Creates a waiting screen. It starts out with the logo. Use `waiting_switch_to_lockscreen()` and
22+
* `waiting_switch_to_logo()` to change the display between logo and lockscreen.
2323
*/
2424
component_t* waiting_create(void);
2525

@@ -28,4 +28,9 @@ component_t* waiting_create(void);
2828
*/
2929
void waiting_switch_to_logo(component_t* component);
3030

31+
/**
32+
* Switch the waiting screen to show the lockscreen instead (see lockscreen.c).
33+
*/
34+
void waiting_switch_to_lockscreen(component_t* component);
35+
3136
#endif

src/ui/screen_process.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ void screen_process_waiting_switch_to_logo(void)
4949
waiting_switch_to_logo(_get_waiting_screen());
5050
}
5151

52+
void screen_process_waiting_switch_to_lockscreen(void)
53+
{
54+
waiting_switch_to_lockscreen(_get_waiting_screen());
55+
}
56+
5257
component_t* screen_process_get_top_component(void)
5358
{
5459
component_t* saver = screen_saver_get();

src/ui/screen_process.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ component_t* screen_process_get_top_component(void);
3232
*/
3333
void screen_process_waiting_switch_to_logo(void);
3434

35+
/**
36+
* Wraps `waiting_switch_to_lockscreen()` for the waiting screen.
37+
*/
38+
void screen_process_waiting_switch_to_lockscreen(void);
39+
3540
/**
3641
* Runs the UI once.
3742
*

src/workflow/orientation_screen.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <screen.h>
2626
#include <ui/components/lockscreen.h>
2727
#include <ui/components/orientation_arrows.h>
28+
#include <ui/screen_process.h>
2829
#include <ui/screen_stack.h>
2930
#include <usb/usb.h>
3031
#include <utils_ringbuffer.h>
@@ -73,6 +74,7 @@ static void _idle_timer_cb(const struct timer_task* const timer_task)
7374
}
7475

7576
usb_start();
77+
screen_process_waiting_switch_to_lockscreen();
7678
}
7779
#endif
7880

0 commit comments

Comments
 (0)