Skip to content

Commit 8c2d1fb

Browse files
committed
Use BAGL glyphs from C SDK (may slighlty impact UI for Nano S+/X)
1 parent 1c5ce34 commit 8c2d1fb

File tree

4 files changed

+192
-39
lines changed

4 files changed

+192
-39
lines changed

ledger_device_sdk/src/ui/bagls.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const fn middle_y(glyph: &Glyph) -> i16 {
3535
((crate::ui::SCREEN_HEIGHT as u32 - glyph.height) / 2) as i16
3636
}
3737

38+
#[derive(Clone, Copy)]
3839
pub struct Icon<'a> {
3940
pub icon: &'a Glyph<'a>,
4041
pub pos: (i16, i16),
@@ -95,25 +96,27 @@ use crate::ui::bitmaps;
9596
pub const OUTER_PADDING: usize = 2;
9697
pub const SCREENW: i16 = (crate::ui::SCREEN_WIDTH - OUTER_PADDING) as i16;
9798

98-
pub const DOWN_ARROW: Icon =
99+
pub static DOWN_ARROW: Icon =
99100
Icon::from(&bitmaps::DOWN_ARROW).set_x(SCREENW - bitmaps::DOWN_ARROW.width as i16);
100-
pub const LEFT_ARROW: Icon = Icon::from(&bitmaps::LEFT_ARROW).set_x(OUTER_PADDING as i16);
101-
pub const RIGHT_ARROW: Icon =
101+
pub static LEFT_ARROW: Icon = Icon::from(&bitmaps::LEFT_ARROW).set_x(OUTER_PADDING as i16);
102+
pub static RIGHT_ARROW: Icon =
102103
Icon::from(&bitmaps::RIGHT_ARROW).set_x(SCREENW - bitmaps::RIGHT_ARROW.width as i16);
103-
pub const UP_ARROW: Icon = Icon::from(&bitmaps::UP_ARROW).set_x(OUTER_PADDING as i16);
104-
pub const DOWN_S_ARROW: Icon = DOWN_ARROW.shift_v(4);
105-
pub const LEFT_S_ARROW: Icon = LEFT_ARROW.shift_h(4);
106-
pub const RIGHT_S_ARROW: Icon = RIGHT_ARROW.shift_h(-4);
107-
pub const UP_S_ARROW: Icon = UP_ARROW.shift_v(-4);
104+
pub static UP_ARROW: Icon = Icon::from(&bitmaps::UP_ARROW).set_x(OUTER_PADDING as i16);
105+
pub static DOWN_S_ARROW: Icon = DOWN_ARROW.shift_v(4);
106+
pub static LEFT_S_ARROW: Icon = LEFT_ARROW.shift_h(4);
107+
pub static RIGHT_S_ARROW: Icon = RIGHT_ARROW.shift_h(-4);
108+
pub static UP_S_ARROW: Icon = UP_ARROW.shift_v(-4);
108109

109-
pub const CHECKMARK_ICON: Icon = Icon::from(&bitmaps::CHECKMARK);
110-
pub const CROSS_ICON: Icon = Icon::from(&bitmaps::CROSS);
111-
pub const COGGLE_ICON: Icon = Icon::from(&bitmaps::COGGLE);
112-
pub const CERTIFICATE_ICON: Icon = Icon::from(&bitmaps::CERTIFICATE);
113-
pub const CROSSMARK_ICON: Icon = Icon::from(&bitmaps::CROSSMARK);
114-
pub const DASHBOARD_ICON: Icon = Icon::from(&bitmaps::DASHBOARD);
115-
pub const DASHBOARD_X_ICON: Icon = Icon::from(&bitmaps::DASHBOARD_X);
116-
pub const EYE_ICON: Icon = Icon::from(&bitmaps::EYE);
117-
pub const PROCESSING_ICON: Icon = Icon::from(&bitmaps::PROCESSING);
118-
pub const VALIDATE_14_ICON: Icon = Icon::from(&bitmaps::VALIDATE_14);
119-
pub const WARNING_ICON: Icon = Icon::from(&bitmaps::WARNING);
110+
//pub static BACK_ICON: Icon = Icon::from(&bitmaps::BACK);
111+
pub static BACK_X_ICON: Icon = Icon::from(&bitmaps::BACK_X);
112+
pub static COGGLE_ICON: Icon = Icon::from(&bitmaps::COGGLE);
113+
pub static PROCESSING_ICON: Icon = Icon::from(&bitmaps::PROCESSING);
114+
pub static CERTIFICATE_ICON: Icon = Icon::from(&bitmaps::CERTIFICATE);
115+
pub static CROSSMARK_ICON: Icon = Icon::from(&bitmaps::CROSSMARK);
116+
pub static DASHBOARD_ICON: Icon = Icon::from(&bitmaps::DASHBOARD);
117+
pub static DASHBOARD_X_ICON: Icon = Icon::from(&bitmaps::DASHBOARD_X);
118+
pub static EYE_ICON: Icon = Icon::from(&bitmaps::EYE);
119+
pub static VALIDATE_14_ICON: Icon = Icon::from(&bitmaps::VALIDATE_14);
120+
pub static WARNING_ICON: Icon = Icon::from(&bitmaps::WARNING);
121+
pub static CHECKMARK_ICON: Icon = Icon::from(&bitmaps::CHECKMARK);
122+
pub static CROSS_ICON: Icon = Icon::from(&bitmaps::CROSS);

ledger_device_sdk/src/ui/bitmaps.rs

Lines changed: 162 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,167 @@ pub fn manual_screen_clear() {
5353
}
5454
}
5555

56-
use include_gif::include_gif;
57-
5856
pub const BLANK: [u8; 1024] = [0u8; 1024];
5957

60-
pub const BACK: Glyph = Glyph::from_include(include_gif!("icons/badge_back.gif"));
61-
pub const CHECKMARK: Glyph = Glyph::from_include(include_gif!("icons/badge_check.gif"));
62-
pub const COGGLE: Glyph = Glyph::from_include(include_gif!("icons/icon_coggle.gif"));
63-
pub const CROSS: Glyph = Glyph::from_include(include_gif!("icons/icon_cross_badge.gif"));
64-
pub const DOWN_ARROW: Glyph = Glyph::from_include(include_gif!("icons/icon_down.gif"));
65-
pub const LEFT_ARROW: Glyph = Glyph::from_include(include_gif!("icons/icon_left.gif"));
66-
pub const RIGHT_ARROW: Glyph = Glyph::from_include(include_gif!("icons/icon_right.gif"));
67-
pub const UP_ARROW: Glyph = Glyph::from_include(include_gif!("icons/icon_up.gif"));
68-
pub const CERTIFICATE: Glyph = Glyph::from_include(include_gif!("icons/icon_certificate.gif"));
69-
pub const CROSSMARK: Glyph = Glyph::from_include(include_gif!("icons/icon_crossmark.gif"));
70-
pub const DASHBOARD: Glyph = Glyph::from_include(include_gif!("icons/icon_dashboard.gif"));
71-
pub const DASHBOARD_X: Glyph = Glyph::from_include(include_gif!("icons/icon_dashboard_x.gif"));
72-
pub const EYE: Glyph = Glyph::from_include(include_gif!("icons/icon_eye.gif"));
73-
pub const PROCESSING: Glyph = Glyph::from_include(include_gif!("icons/icon_processing.gif"));
74-
pub const VALIDATE_14: Glyph = Glyph::from_include(include_gif!("icons/icon_validate_14.gif"));
75-
pub const WARNING: Glyph = Glyph::from_include(include_gif!("icons/icon_warning.gif"));
58+
extern "C" {
59+
/// The bitmap for the back icon.
60+
pub static C_icon_back_bitmap: [u8; 25];
61+
}
62+
pub static BACK: Glyph = Glyph {
63+
bitmap: unsafe { &C_icon_back_bitmap },
64+
width: ledger_secure_sdk_sys::GLYPH_icon_back_WIDTH,
65+
height: ledger_secure_sdk_sys::GLYPH_icon_back_HEIGHT,
66+
inverted: false,
67+
};
68+
extern "C" {
69+
/// The bitmap for the back_x icon.
70+
pub static C_icon_back_x_bitmap: [u8; 25];
71+
}
72+
pub static BACK_X: Glyph = Glyph {
73+
bitmap: unsafe { &C_icon_back_x_bitmap },
74+
width: ledger_secure_sdk_sys::GLYPH_icon_back_x_WIDTH,
75+
height: ledger_secure_sdk_sys::GLYPH_icon_back_x_HEIGHT,
76+
inverted: false,
77+
};
78+
extern "C" {
79+
/// The bitmap for the coggle icon.
80+
pub static C_icon_coggle_bitmap: [u8; 25];
81+
}
82+
pub static COGGLE: Glyph = Glyph {
83+
bitmap: unsafe { &C_icon_coggle_bitmap },
84+
width: ledger_secure_sdk_sys::GLYPH_icon_coggle_WIDTH,
85+
height: ledger_secure_sdk_sys::GLYPH_icon_coggle_HEIGHT,
86+
inverted: false,
87+
};
88+
extern "C" {
89+
/// The bitmap for the processing icon.
90+
pub static C_icon_down_bitmap: [u8; 25];
91+
}
92+
pub static DOWN_ARROW: Glyph = Glyph {
93+
bitmap: unsafe { &C_icon_down_bitmap },
94+
width: ledger_secure_sdk_sys::GLYPH_icon_down_WIDTH,
95+
height: ledger_secure_sdk_sys::GLYPH_icon_down_HEIGHT,
96+
inverted: false,
97+
};
98+
extern "C" {
99+
/// The bitmap for the left arrow icon.
100+
pub static C_icon_left_bitmap: [u8; 25];
101+
}
102+
pub static LEFT_ARROW: Glyph = Glyph {
103+
bitmap: unsafe { &C_icon_left_bitmap },
104+
width: ledger_secure_sdk_sys::GLYPH_icon_left_WIDTH,
105+
height: ledger_secure_sdk_sys::GLYPH_icon_left_HEIGHT,
106+
inverted: false,
107+
};
108+
extern "C" {
109+
/// The bitmap for the right arrow icon.
110+
pub static C_icon_right_bitmap: [u8; 25];
111+
}
112+
pub static RIGHT_ARROW: Glyph = Glyph {
113+
bitmap: unsafe { &C_icon_right_bitmap },
114+
width: ledger_secure_sdk_sys::GLYPH_icon_right_WIDTH,
115+
height: ledger_secure_sdk_sys::GLYPH_icon_right_HEIGHT,
116+
inverted: false,
117+
};
118+
extern "C" {
119+
/// The bitmap for the up arrow icon.
120+
pub static C_icon_up_bitmap: [u8; 25];
121+
}
122+
pub static UP_ARROW: Glyph = Glyph {
123+
bitmap: unsafe { &C_icon_up_bitmap },
124+
width: ledger_secure_sdk_sys::GLYPH_icon_up_WIDTH,
125+
height: ledger_secure_sdk_sys::GLYPH_icon_up_HEIGHT,
126+
inverted: false,
127+
};
128+
extern "C" {
129+
/// The bitmap for the certificate icon.
130+
pub static C_icon_certificate_bitmap: [u8; 25];
131+
}
132+
pub static CERTIFICATE: Glyph = Glyph {
133+
bitmap: unsafe { &C_icon_certificate_bitmap },
134+
width: ledger_secure_sdk_sys::GLYPH_icon_certificate_WIDTH,
135+
height: ledger_secure_sdk_sys::GLYPH_icon_certificate_HEIGHT,
136+
inverted: false,
137+
};
138+
extern "C" {
139+
/// The bitmap for the crossmark icon.
140+
pub static C_icon_crossmark_bitmap: [u8; 25];
141+
}
142+
pub static CROSSMARK: Glyph = Glyph {
143+
bitmap: unsafe { &C_icon_crossmark_bitmap },
144+
width: ledger_secure_sdk_sys::GLYPH_icon_crossmark_WIDTH,
145+
height: ledger_secure_sdk_sys::GLYPH_icon_crossmark_HEIGHT,
146+
inverted: false,
147+
};
148+
pub static CROSS: Glyph = Glyph {
149+
bitmap: unsafe { &C_icon_crossmark_bitmap },
150+
width: ledger_secure_sdk_sys::GLYPH_icon_crossmark_WIDTH,
151+
height: ledger_secure_sdk_sys::GLYPH_icon_crossmark_HEIGHT,
152+
inverted: false,
153+
};
154+
extern "C" {
155+
/// The bitmap for the dashboard icon.
156+
pub static C_icon_dashboard_bitmap: [u8; 25];
157+
}
158+
pub static DASHBOARD: Glyph = Glyph {
159+
bitmap: unsafe { &C_icon_dashboard_bitmap },
160+
width: ledger_secure_sdk_sys::GLYPH_icon_dashboard_WIDTH,
161+
height: ledger_secure_sdk_sys::GLYPH_icon_dashboard_HEIGHT,
162+
inverted: false,
163+
};
164+
extern "C" {
165+
/// The bitmap for the dashboard x icon.
166+
pub static C_icon_dashboard_x_bitmap: [u8; 25];
167+
}
168+
pub static DASHBOARD_X: Glyph = Glyph {
169+
bitmap: unsafe { &C_icon_dashboard_x_bitmap },
170+
width: ledger_secure_sdk_sys::GLYPH_icon_dashboard_x_WIDTH,
171+
height: ledger_secure_sdk_sys::GLYPH_icon_dashboard_x_HEIGHT,
172+
inverted: false,
173+
};
174+
extern "C" {
175+
/// The bitmap for the eye icon.
176+
pub static C_icon_eye_bitmap: [u8; 25];
177+
}
178+
pub static EYE: Glyph = Glyph {
179+
bitmap: unsafe { &C_icon_eye_bitmap },
180+
width: ledger_secure_sdk_sys::GLYPH_icon_eye_WIDTH,
181+
height: ledger_secure_sdk_sys::GLYPH_icon_eye_HEIGHT,
182+
inverted: false,
183+
};
184+
extern "C" {
185+
/// The bitmap for the processing icon.
186+
pub static C_icon_processing_bitmap: [u8; 25];
187+
}
188+
pub static PROCESSING: Glyph = Glyph {
189+
bitmap: unsafe { &C_icon_processing_bitmap },
190+
width: ledger_secure_sdk_sys::GLYPH_icon_processing_WIDTH,
191+
height: ledger_secure_sdk_sys::GLYPH_icon_processing_HEIGHT,
192+
inverted: false,
193+
};
194+
extern "C" {
195+
/// The bitmap for the validate icon.
196+
pub static C_icon_validate_14_bitmap: [u8; 25];
197+
}
198+
pub static VALIDATE_14: Glyph = Glyph {
199+
bitmap: unsafe { &C_icon_validate_14_bitmap },
200+
width: ledger_secure_sdk_sys::GLYPH_icon_validate_14_WIDTH,
201+
height: ledger_secure_sdk_sys::GLYPH_icon_validate_14_HEIGHT,
202+
inverted: false,
203+
};
204+
pub static CHECKMARK: Glyph = Glyph {
205+
bitmap: unsafe { &C_icon_validate_14_bitmap },
206+
width: ledger_secure_sdk_sys::GLYPH_icon_validate_14_WIDTH,
207+
height: ledger_secure_sdk_sys::GLYPH_icon_validate_14_HEIGHT,
208+
inverted: false,
209+
};
210+
extern "C" {
211+
/// The bitmap for the warning icon.
212+
pub static C_icon_warning_bitmap: [u8; 25];
213+
}
214+
pub static WARNING: Glyph = Glyph {
215+
bitmap: unsafe { &C_icon_warning_bitmap },
216+
width: ledger_secure_sdk_sys::GLYPH_icon_warning_WIDTH,
217+
height: ledger_secure_sdk_sys::GLYPH_icon_warning_HEIGHT,
218+
inverted: false,
219+
};

ledger_device_sdk/src/ui/gadgets.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ impl<'a> MessageValidator<'a> {
228228
let draw = |page: usize| {
229229
clear_screen();
230230
if page == page_count - 2 {
231-
draw_icon_and_text(CHECKMARK_ICON, self.confirm);
231+
draw_icon_and_text(VALIDATE_14_ICON, self.confirm);
232232
RIGHT_ARROW.display();
233233
} else if page == page_count - 1 {
234-
draw_icon_and_text(CROSS_ICON, self.cancel);
234+
draw_icon_and_text(CROSSMARK_ICON, self.cancel);
235235
} else {
236236
self.message[page].place(Location::Middle, Layout::Centered, false);
237237
RIGHT_ARROW.display();

ledger_secure_sdk_sys/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,12 @@ impl SDKBuilder<'_> {
460460
if s.0 == "HAVE_NBGL" {
461461
configure_lib_nbgl(&mut command, &self.device.c_sdk);
462462
}
463+
if s.0 == "HAVE_BAGL" {
464+
let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs");
465+
command
466+
.include(&glyphs_path)
467+
.file(glyphs_path.join("glyphs.c"));
468+
}
463469
}
464470

465471
// Add the defines found in the Makefile.conf.cx to our build command.

0 commit comments

Comments
 (0)