fix false fps reading

This commit is contained in:
2025-11-08 22:04:01 -07:00
parent 60758f3cb5
commit d9af87eb92
2 changed files with 9 additions and 7 deletions

View File

@@ -93,11 +93,6 @@ pub async fn display_handler(mut display: DISPLAY) {
}; };
} }
#[cfg(feature = "fps")]
if unsafe { FPS_COUNTER.should_draw() } {
fps::draw_fps(&mut display).await;
}
// small yield to allow other tasks to run // small yield to allow other tasks to run
Timer::after_millis(10).await; Timer::after_millis(10).await;
} }

View File

@@ -175,6 +175,9 @@ impl<'a> AtomicFrameBuffer<'a> {
return self.draw(display).await; return self.draw(display).await;
} }
#[cfg(feature = "fps")]
let mut any_drawn = false;
for tile_row in 0..NUM_TILE_ROWS { for tile_row in 0..NUM_TILE_ROWS {
let row_start_idx = tile_row * NUM_TILE_COLS; let row_start_idx = tile_row * NUM_TILE_COLS;
let mut col = 0; let mut col = 0;
@@ -215,6 +218,10 @@ impl<'a> AtomicFrameBuffer<'a> {
&self.batch_tile_buf[..run_len * TILE_SIZE * TILE_SIZE], &self.batch_tile_buf[..run_len * TILE_SIZE * TILE_SIZE],
) )
.await?; .await?;
if cfg!(feature = "fps") {
any_drawn = true;
}
} }
col += 1; col += 1;
@@ -222,8 +229,8 @@ impl<'a> AtomicFrameBuffer<'a> {
} }
#[cfg(feature = "fps")] #[cfg(feature = "fps")]
unsafe { if any_drawn {
crate::display::FPS_COUNTER.measure() unsafe { crate::display::FPS_COUNTER.measure() }
} }
Ok(()) Ok(())