-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove status screens at the end of reviews, add new structures
so that developers may add such screens themselves in the apps.
- Loading branch information
1 parent
bd050f4
commit e9eb6d2
Showing
8 changed files
with
252 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
// Force boot section to be embedded in | ||
use ledger_device_sdk as _; | ||
|
||
use include_gif::include_gif; | ||
use ledger_device_sdk::io::*; | ||
use ledger_device_sdk::nbgl::{ | ||
init_comm, Field, NbglGlyph, NbglReview, NbglReviewStatus, NbglSpinner, StatusType, | ||
}; | ||
use ledger_device_sdk::testing::debug_print; | ||
use ledger_secure_sdk_sys::*; | ||
|
||
#[panic_handler] | ||
fn panic(_: &core::panic::PanicInfo) -> ! { | ||
exit_app(1); | ||
} | ||
|
||
// static spin_end: bool = false; | ||
|
||
#[no_mangle] | ||
extern "C" fn sample_main() { | ||
unsafe { | ||
nbgl_refreshReset(); | ||
} | ||
|
||
let mut comm = Comm::new(); | ||
// Initialize reference to Comm instance for NBGL | ||
// API calls. | ||
init_comm(&mut comm); | ||
|
||
let my_field = [Field { | ||
name: "Amount", | ||
value: "111 CRAB", | ||
}]; | ||
|
||
// Load glyph from 64x64 4bpp gif file with include_gif macro. Creates an NBGL compatible glyph. | ||
const FERRIS: NbglGlyph = | ||
NbglGlyph::from_include(include_gif!("examples/crab_64x64.gif", NBGL)); | ||
// Create NBGL review. Maximum number of fields and string buffer length can be customised | ||
// with constant generic parameters of NbglReview. Default values are 32 and 1024 respectively. | ||
let success = NbglReview::new() | ||
.titles( | ||
"Please review transaction", | ||
"To send CRAB", | ||
"Sign transaction\nto send CRAB", | ||
) | ||
.glyph(&FERRIS) | ||
.show(&my_field); | ||
|
||
NbglSpinner::new().text("Please wait...").show(); | ||
|
||
// Simulate an idle state of the app where it just | ||
// waits for some event to happen (such as APDU reception), going through | ||
// the event loop to process TickerEvents so that the spinner can be animated | ||
// every 800ms. | ||
let mut loop_count = 50; | ||
while loop_count > 0 { | ||
comm.next_event::<ApduHeader>(); | ||
loop_count -= 1; | ||
} | ||
NbglReviewStatus::new().show(success); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.