2020
2121use cortex_m_rt:: { entry, exception, ExceptionFrame } ;
2222use embedded_graphics:: {
23- fonts :: { Font6x8 , Text } ,
23+ mono_font :: { ascii :: FONT_6X10 , MonoTextStyleBuilder } ,
2424 pixelcolor:: BinaryColor ,
2525 prelude:: * ,
26- style :: TextStyle ,
26+ text :: { Baseline , Text } ,
2727} ;
2828use panic_semihosting as _;
2929use sh1106:: { prelude:: * , Builder } ;
@@ -54,7 +54,7 @@ fn main() -> ! {
5454 ( scl, sda) ,
5555 & mut afio. mapr ,
5656 Mode :: Fast {
57- frequency : 400_000 ,
57+ frequency : 100_000 ,
5858 duty_cycle : DutyCycle :: Ratio2to1 ,
5959 } ,
6060 clocks,
@@ -70,13 +70,16 @@ fn main() -> ! {
7070 display. init ( ) . unwrap ( ) ;
7171 display. flush ( ) . unwrap ( ) ;
7272
73- Text :: new ( "Hello world!" , Point :: zero ( ) )
74- . into_styled ( TextStyle :: new ( Font6x8 , BinaryColor :: On ) )
73+ let text_style = MonoTextStyleBuilder :: new ( )
74+ . font ( & FONT_6X10 )
75+ . text_color ( BinaryColor :: On )
76+ . build ( ) ;
77+
78+ Text :: with_baseline ( "Hello world!" , Point :: zero ( ) , text_style, Baseline :: Top )
7579 . draw ( & mut display)
7680 . unwrap ( ) ;
7781
78- Text :: new ( "Hello Rust!" , Point :: new ( 0 , 16 ) )
79- . into_styled ( TextStyle :: new ( Font6x8 , BinaryColor :: On ) )
82+ Text :: with_baseline ( "Hello Rust!" , Point :: new ( 0 , 16 ) , text_style, Baseline :: Top )
8083 . draw ( & mut display)
8184 . unwrap ( ) ;
8285
0 commit comments