File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ struct Delay(cortex_m::delay::Delay);
5757impl DelayNs for Delay {
5858 fn delay_ns ( & mut self , ns : u32 ) {
5959 // Round up to microseconds
60- self . 0 . delay_us ( ( ns + 999 ) / 1000 ) ;
60+ self . 0 . delay_us ( ns . div_ceil ( 1000 ) ) ;
6161 }
6262
6363 fn delay_us ( & mut self , us : u32 ) {
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ impl Iterator for GameOfLifeIterator {
119119 if self . frames_remaining > 0 {
120120 self . frames_remaining -= 1 ;
121121 // Only update every 8th frame, otherwise the animation is too fast
122- if self . frames_remaining % 8 == 0 {
122+ if self . frames_remaining . is_multiple_of ( 8 ) {
123123 self . state . tick ( ) ;
124124 }
125125 Some ( self . state . draw_matrix ( ) )
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ impl GameOfLifeState {
8484 for row in 0 ..HEIGHT {
8585 for col in 0 ..WIDTH {
8686 let i = col * HEIGHT + row;
87- if i % 2 == 0 || i % 7 == 0 {
87+ if i. is_multiple_of ( 2 ) || i. is_multiple_of ( 7 ) {
8888 cells[ row] [ col] = Cell :: Alive ;
8989 }
9090 }
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ impl Iterator for SnakeIterator {
3232 }
3333
3434 // Slow down animation by a factor of 4
35- if self . current_tick % 4 == 0 {
35+ if self . current_tick . is_multiple_of ( 4 ) {
3636 let ( maybe_cmd, random) = self . commands [ self . current_tick / 4 ] ;
3737 if let Some ( command) = maybe_cmd {
3838 self . state . handle_control ( & command) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ const FLASH_OFFSET: usize = 0x10000000;
33const LAST_4K_BLOCK : usize = 0xff000 ;
44const SERIALNUM_LEN : usize = 18 ;
55
6- #[ repr( packed) ]
6+ #[ repr( C , packed) ]
77pub struct SerialnumStructRaw {
88 sn_rev : u8 ,
99 serialnum : [ u8 ; SERIALNUM_LEN ] ,
Original file line number Diff line number Diff line change @@ -627,7 +627,7 @@ fn handle_sleep(
627627 let mut brightness = state. brightness ;
628628 loop {
629629 delay. delay_ms ( 100 ) ;
630- brightness = if brightness <= 5 { 0 } else { brightness - 5 } ;
630+ brightness = brightness. saturating_sub ( 5 ) ;
631631 set_brightness ( state, brightness, matrix) ;
632632 if brightness == 0 {
633633 break ;
You can’t perform that action at this time.
0 commit comments