@@ -49,7 +49,7 @@ use esp_hal::system::{CpuControl, Stack};
4949
5050#[ panic_handler]
5151fn panic ( _info : & core:: panic:: PanicInfo ) -> ! {
52- error ! ( "Panic: {}" , _info ) ;
52+ error ! ( "Panic: {_info}" ) ;
5353 loop { }
5454}
5555
@@ -71,13 +71,13 @@ impl<C: PixelColor, const N: usize> HeapBuffer<C, N> {
7171impl < C : PixelColor , const N : usize > core:: ops:: Deref for HeapBuffer < C , N > {
7272 type Target = [ C ; N ] ;
7373 fn deref ( & self ) -> & Self :: Target {
74- & * self . 0
74+ & self . 0
7575 }
7676}
7777
7878impl < C : PixelColor , const N : usize > core:: ops:: DerefMut for HeapBuffer < C , N > {
7979 fn deref_mut ( & mut self ) -> & mut Self :: Target {
80- & mut * self . 0
80+ & mut self . 0
8181 }
8282}
8383
@@ -135,10 +135,13 @@ fn update_game_of_life(
135135 }
136136 let nx = x as i32 + dx;
137137 let ny = y as i32 + dy;
138- if nx >= 0 && nx < GRID_WIDTH as i32 && ny >= 0 && ny < GRID_HEIGHT as i32 {
139- if current[ ny as usize ] [ nx as usize ] > 0 {
140- neighbors += 1 ;
141- }
138+ if nx >= 0
139+ && nx < GRID_WIDTH as i32
140+ && ny >= 0
141+ && ny < GRID_HEIGHT as i32
142+ && current[ ny as usize ] [ nx as usize ] > 0
143+ {
144+ neighbors += 1 ;
142145 }
143146 }
144147 }
@@ -208,7 +211,7 @@ fn write_generation<D: DrawTarget<Color = Rgb565>>(
208211 generation : usize ,
209212) -> Result < ( ) , D :: Error > {
210213 let mut num_str = String :: < 20 > :: new ( ) ;
211- write ! ( num_str, "{}" , generation ) . unwrap ( ) ;
214+ write ! ( num_str, "{generation}" ) . unwrap ( ) ;
212215 Text :: new (
213216 num_str. as_str ( ) ,
214217 Point :: new ( 8 , 13 ) ,
@@ -252,14 +255,11 @@ async fn main(_spawner: Spawner) -> ! {
252255 eeprom. read_data ( 0x00 , & mut eeid) . unwrap ( ) ;
253256 let display_width = u16:: from_be_bytes ( [ eeid[ 8 ] , eeid[ 9 ] ] ) as usize ;
254257 let display_height = u16:: from_be_bytes ( [ eeid[ 10 ] , eeid[ 11 ] ] ) as usize ;
255- info ! (
256- "Display size from EEPROM: {}x{}" ,
257- display_width, display_height
258- ) ;
258+ info ! ( "Display size from EEPROM: {display_width}x{display_height}" ) ;
259259
260260 // Full-screen DMA constants
261261 const MAX_FRAME_BYTES : usize = 320 * 240 * 2 ;
262- const MAX_NUM_DMA_DESC : usize = ( MAX_FRAME_BYTES + CHUNK_SIZE - 1 ) / CHUNK_SIZE ;
262+ const MAX_NUM_DMA_DESC : usize = MAX_FRAME_BYTES . div_ceil ( CHUNK_SIZE ) ;
263263
264264 #[ unsafe( link_section = ".dma" ) ]
265265 static mut TX_DESCRIPTORS : [ DmaDescriptor ; MAX_NUM_DMA_DESC ] =
@@ -273,7 +273,7 @@ async fn main(_spawner: Spawner) -> ! {
273273 unsafe { core:: slice:: from_raw_parts_mut ( fb_ptr as * mut u8 , FRAME_BYTES ) } ;
274274 // Verify PSRAM buffer allocation and alignment
275275 let buf_ptr = psram_buf. as_ptr ( ) as usize ;
276- info ! ( "PSRAM buffer allocated at address: 0x{:08X}" , buf_ptr ) ;
276+ info ! ( "PSRAM buffer allocated at address: 0x{buf_ptr :08X}" ) ;
277277 info ! ( "PSRAM buffer length: {}" , psram_buf. len( ) ) ;
278278 info ! ( "PSRAM buffer alignment modulo 32: {}" , buf_ptr % 32 ) ;
279279 assert ! (
@@ -322,14 +322,14 @@ async fn main(_spawner: Spawner) -> ! {
322322
323323 // Log all infomration about display configuration
324324 info ! ( "Display configuration:" ) ;
325- info ! ( " Resolution: {}x{}" , h_res , v_res ) ;
326- info ! ( " PCLK: {} Hz" , pclk_hz ) ;
327- info ! ( " HSYNC pulse: {} pixels" , hsync_pulse ) ;
328- info ! ( " HSYNC back porch: {} pixels" , hsync_back ) ;
329- info ! ( " HSYNC front porch: {} pixels" , hsync_front ) ;
330- info ! ( " VSYNC pulse: {} lines" , vsync_pulse ) ;
331- info ! ( " VSYNC back porch: {} lines" , vsync_back ) ;
332- info ! ( " VSYNC front porch: {} lines" , vsync_front ) ;
325+ info ! ( " Resolution: {h_res }x{v_res}" ) ;
326+ info ! ( " PCLK: {pclk_hz } Hz" ) ;
327+ info ! ( " HSYNC pulse: {hsync_pulse } pixels" ) ;
328+ info ! ( " HSYNC back porch: {hsync_back } pixels" ) ;
329+ info ! ( " HSYNC front porch: {hsync_front } pixels" ) ;
330+ info ! ( " VSYNC pulse: {vsync_pulse } lines" ) ;
331+ info ! ( " VSYNC back porch: {vsync_back } lines" ) ;
332+ info ! ( " VSYNC front porch: {vsync_front } lines" ) ;
333333
334334 let dpi_config = DpiConfig :: default ( )
335335 . with_clock_mode ( ClockMode {
@@ -482,11 +482,11 @@ async fn dma_display_task(mut dpi: Dpi<'static, esp_hal::Blocking>, mut dma_tx:
482482 dpi = new_dpi;
483483 dma_tx = new_dma_tx;
484484 if let Err ( e) = res {
485- error ! ( "[CORE 1] DMA transfer error: {:?}" , e ) ;
485+ error ! ( "[CORE 1] DMA transfer error: {e :?}" ) ;
486486 }
487487 }
488488 Err ( ( e, new_dpi, new_dma_tx) ) => {
489- error ! ( "[CORE 1] DMA send error: {:?}" , e ) ;
489+ error ! ( "[CORE 1] DMA send error: {e :?}" ) ;
490490 dpi = new_dpi;
491491 dma_tx = new_dma_tx;
492492 }
@@ -501,14 +501,10 @@ async fn conway_task(psram_ptr: *mut u8, _psram_len: usize, mut rng: Rng) {
501501 let fb: & mut [ Rgb565 ; LCD_BUFFER_SIZE ] =
502502 unsafe { & mut * ( psram_ptr as * mut [ Rgb565 ; LCD_BUFFER_SIZE ] ) } ;
503503 let mut game_grid = Box :: new ( [ [ 0u8 ; GRID_WIDTH ] ; GRID_HEIGHT ] ) ;
504- randomize_grid ( & mut rng, & mut * game_grid) ;
504+ randomize_grid ( & mut rng, & mut game_grid) ;
505505 let mut next_grid = Box :: new ( [ [ 0u8 ; GRID_WIDTH ] ; GRID_HEIGHT ] ) ;
506506
507- let mut frame_buf = FrameBuf :: new (
508- PSRAMFrameBuffer :: new ( fb) ,
509- LCD_H_RES_USIZE . into ( ) ,
510- LCD_V_RES_USIZE . into ( ) ,
511- ) ;
507+ let mut frame_buf = FrameBuf :: new ( PSRAMFrameBuffer :: new ( fb) , LCD_H_RES_USIZE , LCD_V_RES_USIZE ) ;
512508 let mut ticker = Ticker :: every ( embassy_time:: Duration :: from_millis ( 100 ) ) ;
513509 let mut generation_count: usize = 0 ;
514510 const RESET_AFTER_GENERATIONS : usize = 500 ;
@@ -519,13 +515,13 @@ async fn conway_task(psram_ptr: *mut u8, _psram_len: usize, mut rng: Rng) {
519515 // Cpu::current() as usize
520516 // );
521517
522- update_game_of_life ( & * game_grid, & mut * next_grid) ;
518+ update_game_of_life ( & game_grid, & mut next_grid) ;
523519 core:: mem:: swap ( & mut game_grid, & mut next_grid) ;
524- draw_grid ( & mut frame_buf, & * game_grid) . ok ( ) ;
520+ draw_grid ( & mut frame_buf, & game_grid) . ok ( ) ;
525521 generation_count += 1 ;
526522 write_generation ( & mut frame_buf, generation_count) . ok ( ) ;
527523 if generation_count >= RESET_AFTER_GENERATIONS {
528- randomize_grid ( & mut rng, & mut * game_grid) ;
524+ randomize_grid ( & mut rng, & mut game_grid) ;
529525 generation_count = 0 ;
530526 }
531527 ticker. next ( ) . await ;
0 commit comments