Skip to content

Commit

Permalink
Use new include_gif macro to generate NBGL glyphs.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrojean-ledger committed Mar 29, 2024
1 parent e1a97f2 commit 8119259
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 44 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ numtoa = "0.2.4"
[patch.crates-io]
ledger_device_sdk = { path = 'ledger-device-rust-sdk/ledger_device_sdk' }
ledger_secure_sdk_sys = { path = 'ledger-device-rust-sdk/ledger_secure_sdk_sys' }
include_gif = { path = 'ledger-device-rust-sdk/include_gif' }

[profile.release]
opt-level = 'z'
Expand Down
Binary file added crab_64x64.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 3 additions & 42 deletions src/app_ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ledger_device_sdk::ui::bitmaps::{Glyph, BACK, CERTIFICATE, DASHBOARD_X};
use ledger_device_sdk::ui::gadgets::{EventOrPageIndex, MultiPageMenu, Page};

#[cfg(target_os = "stax")]
use ledger_device_sdk::nbgl::NbglHome;
use ledger_device_sdk::nbgl::{NbglHome, NbglGlyph};


use crate::Instruction;
Expand Down Expand Up @@ -68,49 +68,10 @@ pub fn ui_menu_main(comm: &mut Comm) -> Event<Instruction> {

#[cfg(target_os = "stax")]
pub fn ui_menu_main(comm: &mut Comm) -> Event<Instruction> {
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif",NBGL));
NbglHome::new(comm)
.app_name("Boilerplate\0")
.info_contents(env!("CARGO_PKG_VERSION"), env!("CARGO_PKG_AUTHORS"))
.icon(&BTC_BMP)
.glyph(&FERRIS)
.show()
}

#[cfg(target_os = "stax")]
const BTC_BMP: [u8; 573] = [
0x40, 0x00, 0x40, 0x00, 0x21, 0x35, 0x02, 0x00, 0x33, 0x02, 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, 0xe7, 0x7f, 0x81, 0xae, 0x00, 0x08, 0x00, 0x00,
];
20 changes: 18 additions & 2 deletions src/app_ui/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ use crate::handlers::sign_tx::Tx;
use crate::utils::concatenate;
use crate::AppSW;

use ledger_secure_sdk_sys::*;

#[cfg(not(target_os = "stax"))]
use ledger_device_sdk::ui::bitmaps::{CROSSMARK, EYE, VALIDATE_14};
#[cfg(not(target_os = "stax"))]
use ledger_device_sdk::ui::gadgets::{Field, MultiFieldReview};

#[cfg(target_os = "stax")]
use ledger_device_sdk::nbgl::{Field, NbglReview};
use ledger_device_sdk::nbgl::{Field, NbglReview, NbglGlyph};
#[cfg(target_os = "stax")]
use include_gif::include_gif;

use numtoa::NumToA;

Expand Down Expand Up @@ -88,7 +92,19 @@ pub fn ui_display_tx(tx: &Tx) -> Result<bool, AppSW> {

#[cfg(target_os = "stax")]
{
Ok(NbglReview.review_transaction(&my_fields))
// This will copy the fields into the nbgl format, not ideal
// memory-wise...
let nbgl_fields: [nbgl_layoutTagValue_t; 3] = [
my_fields[0].into(),
my_fields[1].into(),
my_fields[2].into(),
];

const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif",NBGL));
Ok(NbglReview::new()
.status_strings("TRANSACTION\nSIGNED\0", "Transaction\nRejected\0")
.glyph(&FERRIS)
.show(&nbgl_fields))
}

}

0 comments on commit 8119259

Please sign in to comment.