-
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.
Add streaming review support in NBGL module
- Loading branch information
1 parent
3c22c1c
commit c656e6d
Showing
3 changed files
with
220 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#![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, NbglStreamingReview, TransactionType}; | ||
use ledger_secure_sdk_sys::*; | ||
|
||
#[panic_handler] | ||
fn panic(_: &core::panic::PanicInfo) -> ! { | ||
exit_app(1); | ||
} | ||
|
||
#[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); | ||
|
||
// 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)); | ||
|
||
let mut review: NbglStreamingReview = | ||
NbglStreamingReview::new(TransactionType::Message).glyph(&FERRIS); | ||
|
||
review.start("Example Title", "Example Subtitle"); | ||
|
||
let fields = [ | ||
Field { | ||
name: "Name1", | ||
value: "Value1", | ||
}, | ||
Field { | ||
name: "Name2", | ||
value: "Value2", | ||
}, | ||
Field { | ||
name: "Name3", | ||
value: "Value3", | ||
}, | ||
Field { | ||
name: "Name4", | ||
value: "Value4", | ||
}, | ||
Field { | ||
name: "Name5", | ||
value: "Value5", | ||
}, | ||
]; | ||
|
||
for i in 0..fields.len() { | ||
review.continue_review(&fields[i..i + 1]); | ||
} | ||
|
||
review.finish("Sign to send token\n"); | ||
} |
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