Skip to content

Commit 31d1466

Browse files
committed
Fix clippy warnings
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 2a62fa5 commit 31d1466

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

b1display/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct Delay(cortex_m::delay::Delay);
5757
impl 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) {

fl16-inputmodules/src/animations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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())

fl16-inputmodules/src/games/game_of_life.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

fl16-inputmodules/src/games/snake_animation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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);

fl16-inputmodules/src/serialnum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const FLASH_OFFSET: usize = 0x10000000;
33
const LAST_4K_BLOCK: usize = 0xff000;
44
const SERIALNUM_LEN: usize = 18;
55

6-
#[repr(packed)]
6+
#[repr(C, packed)]
77
pub struct SerialnumStructRaw {
88
sn_rev: u8,
99
serialnum: [u8; SERIALNUM_LEN],

ledmatrix/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)