Skip to content

Commit 5ab3699

Browse files
committed
Merge branch 'async-orient'
2 parents 2765f56 + f4c53b4 commit 5ab3699

File tree

14 files changed

+40
-288
lines changed

14 files changed

+40
-288
lines changed

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ set(DBB-FIRMWARE-SOURCES
3535
${CMAKE_SOURCE_DIR}/src/touch/gestures.c
3636
${CMAKE_SOURCE_DIR}/src/reset.c
3737
${CMAKE_SOURCE_DIR}/src/cipher/cipher.c
38-
${CMAKE_SOURCE_DIR}/src/workflow/blocking.c
39-
${CMAKE_SOURCE_DIR}/src/workflow/idle_workflow.c
4038
${CMAKE_SOURCE_DIR}/src/workflow/orientation_screen.c
4139
${CMAKE_SOURCE_DIR}/src/queue.c
4240
${CMAKE_SOURCE_DIR}/src/usb/usb_processing.c

src/firmware.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "qtouch.h"
2323
#include "screen.h"
2424
#include "ui/screen_stack.h"
25-
#include "workflow/idle_workflow.h"
26-
#include "workflow/orientation_screen.h"
2725

2826
uint32_t __stack_chk_guard = 0;
2927

@@ -38,8 +36,6 @@ int main(void)
3836
qtouch_init();
3937
common_main();
4038
bitbox02_smarteeprom_init();
41-
orientation_screen_blocking();
42-
idle_workflow_blocking();
4339
firmware_main_loop();
4440
return 0;
4541
}

src/firmware_main_loop.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@
2222
#include "ui/screen_stack.h"
2323
#include "usb/usb.h"
2424
#include "usb/usb_processing.h"
25+
#include "workflow/orientation_screen.h"
2526
#include <rust/rust.h>
2627

2728
void firmware_main_loop(void)
2829
{
30+
// This starts the async orientation screen workflow, which is processed by the loop below.
31+
orientation_screen();
32+
2933
while (1) {
3034
screen_process();
3135
/* And finally, run the high-level event processing. */

src/workflow/blocking.c

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/workflow/blocking.h

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/workflow/idle_workflow.c

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/workflow/idle_workflow.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/workflow/orientation_screen.c

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2019 Shift Cryptosecurity AG
2+
// Copyright 2025 Shift Crypto AG
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -14,25 +15,49 @@
1415

1516
#include "orientation_screen.h"
1617

17-
#include "blocking.h"
18-
18+
#ifndef TESTING
19+
#include <hal_timer.h>
20+
#include <platform/driver_init.h>
21+
#endif
22+
#include <hww.h>
1923
#include <screen.h>
24+
#include <ui/components/lockscreen.h>
2025
#include <ui/components/orientation_arrows.h>
2126
#include <ui/screen_stack.h>
27+
#include <usb/usb.h>
2228

23-
static void _select_orientation_done(bool upside_down, void* cb_param)
29+
#ifndef TESTING
30+
#define IDLE_PERIOD_MS 1300
31+
32+
static struct timer_task _idle_timer_task = {0};
33+
34+
static void _idle_timer_cb(const struct timer_task* const timer_task)
2435
{
25-
*(bool*)cb_param = upside_down;
26-
workflow_blocking_unblock();
36+
(void)timer_task;
37+
usb_start(hww_setup);
38+
ui_screen_stack_push(lockscreen_create());
2739
}
40+
#endif
2841

29-
void orientation_screen_blocking(void)
42+
static void _select_orientation_done(bool upside_down, void* cb_param)
3043
{
31-
bool upside_down;
32-
ui_screen_stack_push(orientation_arrows_create(_select_orientation_done, &upside_down));
33-
workflow_blocking_block();
34-
ui_screen_stack_pop_and_clean();
44+
(void)cb_param;
3545
if (upside_down) {
3646
screen_rotate();
3747
}
48+
ui_screen_stack_pop();
49+
50+
#ifndef TESTING
51+
// Added deliberately as a UX/visual improvement, to show the BB02 logo first before moving onto
52+
// the lock screen and unlocking USB.
53+
_idle_timer_task.interval = IDLE_PERIOD_MS;
54+
_idle_timer_task.cb = _idle_timer_cb;
55+
_idle_timer_task.mode = TIMER_TASK_ONE_SHOT;
56+
timer_add_task(&TIMER_0, &_idle_timer_task);
57+
#endif
58+
}
59+
60+
void orientation_screen(void)
61+
{
62+
ui_screen_stack_push(orientation_arrows_create(_select_orientation_done, NULL));
3863
}

src/workflow/orientation_screen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
#ifndef __ORIENTATION_SCREEN_H
1616
#define __ORIENTATION_SCREEN_H
1717

18-
void orientation_screen_blocking(void);
18+
void orientation_screen(void);
1919

2020
#endif // __ORIENTATION_SCREEN_H

test/simulator/simulator.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "usb/usb_packet.c"
1818
#include "usb/usb_processing.c"
1919
#include "usb/usb_processing.h"
20-
#include "workflow/idle_workflow.h"
2120
#include <fcntl.h>
2221
#include <memory/memory.h>
2322
#include <mock_memory.h>
@@ -133,7 +132,6 @@ int main(int argc, char* argv[])
133132

134133
smarteeprom_bb02_config();
135134
bitbox02_smarteeprom_init();
136-
idle_workflow_blocking();
137135

138136
// Establish socket connection with client
139137
sockfd = socket(AF_INET, SOCK_STREAM, 0);

0 commit comments

Comments
 (0)