33
44use panic_halt as _;
55
6- use embedded_graphics:: fonts:: { Font6x8 , Text } ;
6+ use embedded_graphics:: mono_font:: {
7+ ascii:: FONT_5X8 ,
8+ MonoTextStyleBuilder ,
9+ } ;
710use embedded_graphics:: pixelcolor:: Rgb565 ;
811use embedded_graphics:: prelude:: * ;
9- use embedded_graphics:: primitives:: Rectangle ;
10- use embedded_graphics:: { primitive_style , text_style } ;
12+ use embedded_graphics:: primitives:: { Rectangle , PrimitiveStyle } ;
13+ use embedded_graphics:: text :: Text ;
1114use longan_nano:: hal:: { pac, prelude:: * } ;
1215use longan_nano:: { lcd, lcd_pins} ;
1316use riscv_rt:: entry;
@@ -33,20 +36,19 @@ fn main() -> ! {
3336 let ( width, height) = ( lcd. size ( ) . width as i32 , lcd. size ( ) . height as i32 ) ;
3437
3538 // Clear screen
36- Rectangle :: new ( Point :: new ( 0 , 0 ) , Point :: new ( width - 1 , height - 1 ) )
37- . into_styled ( primitive_style ! ( fill_color = Rgb565 :: BLACK ) )
39+ Rectangle :: new ( Point :: new ( 0 , 0 ) , Size :: new ( width as u32 - 1 , height as u32 - 1 ) )
40+ . into_styled ( PrimitiveStyle :: with_fill ( Rgb565 :: BLACK ) )
3841 . draw ( & mut lcd)
3942 . unwrap ( ) ;
4043
41- let style = text_style ! (
42- font = Font6x8 ,
43- text_color = Rgb565 :: BLACK ,
44- background_color = Rgb565 :: GREEN
45- ) ;
44+ let style = MonoTextStyleBuilder :: new ( )
45+ . font ( & FONT_5X8 )
46+ . text_color ( Rgb565 :: BLACK )
47+ . background_color ( Rgb565 :: GREEN )
48+ . build ( ) ;
4649
4750 // Create a text at position (20, 30) and draw it using style defined above
48- Text :: new ( " Hello Rust! " , Point :: new ( 40 , 35 ) )
49- . into_styled ( style)
51+ Text :: new ( " Hello Rust! " , Point :: new ( 40 , 35 ) , style)
5052 . draw ( & mut lcd)
5153 . unwrap ( ) ;
5254
0 commit comments