@@ -24,7 +24,7 @@ extern crate alloc;
2424
2525use alloc:: boxed:: Box ;
2626use alloc:: string:: String ;
27- use bitbox02_rust:: workflow:: confirm;
27+ use bitbox02_rust:: workflow:: { confirm, orientation_screen } ;
2828use core:: task:: Poll ;
2929use util:: bb02_async:: { Task , spin} ;
3030
@@ -42,6 +42,8 @@ static mut CONFIRM_PARAMS: Option<confirm::Params> = None;
4242static mut CONFIRM_STATE : TaskState < ' static , Result < ( ) , confirm:: UserAbort > > = TaskState :: Nothing ;
4343static mut BITBOX02_HAL : bitbox02_rust:: hal:: BitBox02Hal = bitbox02_rust:: hal:: BitBox02Hal :: new ( ) ;
4444
45+ static mut ORIENTATION_SCREEN_STATE : TaskState < ' static , ( ) > = TaskState :: Nothing ;
46+
4547#[ unsafe( no_mangle) ]
4648pub unsafe extern "C" fn rust_workflow_spawn_unlock ( ) {
4749 unsafe {
@@ -71,6 +73,22 @@ pub unsafe extern "C" fn rust_workflow_spawn_confirm(
7173 }
7274}
7375
76+ #[ unsafe( no_mangle) ]
77+ pub unsafe extern "C" fn rust_workflow_spawn_orientation_screen (
78+ orientation_selected_cb : Option < extern "C" fn ( * mut core:: ffi:: c_void ) > ,
79+ user_data : * mut core:: ffi:: c_void ,
80+ ) {
81+ let callback = move || {
82+ if let Some ( cb) = orientation_selected_cb {
83+ cb ( user_data)
84+ }
85+ } ;
86+ unsafe {
87+ ORIENTATION_SCREEN_STATE =
88+ TaskState :: Running ( Box :: pin ( orientation_screen:: create ( callback) ) ) ;
89+ }
90+ }
91+
7492#[ unsafe( no_mangle) ]
7593pub unsafe extern "C" fn rust_workflow_spin ( ) {
7694 unsafe {
@@ -92,6 +110,15 @@ pub unsafe extern "C" fn rust_workflow_spin() {
92110 }
93111 _ => ( ) ,
94112 }
113+ match ORIENTATION_SCREEN_STATE {
114+ TaskState :: Running ( ref mut task) => {
115+ let result = spin ( task) ;
116+ if let Poll :: Ready ( result) = result {
117+ ORIENTATION_SCREEN_STATE = TaskState :: ResultAvailable ( result) ;
118+ }
119+ }
120+ _ => ( ) ,
121+ }
95122 }
96123}
97124
@@ -131,6 +158,20 @@ pub unsafe extern "C" fn rust_workflow_confirm_poll(result_out: &mut bool) -> bo
131158 }
132159}
133160
161+ /// Returns true if there was a result.
162+ #[ unsafe( no_mangle) ]
163+ pub unsafe extern "C" fn rust_workflow_orientation_screen_poll ( ) -> bool {
164+ unsafe {
165+ match ORIENTATION_SCREEN_STATE {
166+ TaskState :: ResultAvailable ( _) => {
167+ ORIENTATION_SCREEN_STATE = TaskState :: Nothing ;
168+ true
169+ }
170+ _ => false ,
171+ }
172+ }
173+ }
174+
134175#[ unsafe( no_mangle) ]
135176pub unsafe extern "C" fn rust_workflow_abort_current ( ) {
136177 unsafe {
@@ -140,5 +181,7 @@ pub unsafe extern "C" fn rust_workflow_abort_current() {
140181 CONFIRM_BODY = None ;
141182 CONFIRM_PARAMS = None ;
142183 CONFIRM_STATE = TaskState :: Nothing ;
184+
185+ ORIENTATION_SCREEN_STATE = TaskState :: Nothing ;
143186 }
144187}
0 commit comments