Skip to main content

Module srm

Module srm 

Source
Expand description

§Scaling, Rotation, and Mirroring (SRM)

§Overview

The SRM engine scales, rotates, mirrors, and converts images using the pixel processing accelerator (PPA) and 2D-DMA.

§Configuration

Config selects the transformation. Input and Output describe the images.

Image buffers must meet the following requirements:

  • Each buffer must contain at least width * height * format.bytes_per_pixel() bytes for its image size.
  • Buffers must be entirely within internal RAM or initialized PSRAM.
  • PSRAM destination addresses and buffer lengths must be multiples of 64 bytes.

PSRAM encryption and ECC configurations requiring strictly aligned memory transactions are not supported.

§Examples

§Rotating an RGB565 image

use esp_hal::ppa::srm::{Config, Input, Offset, Output, PixelFormat, Rotation, Size, Srm};

let source = [0; 17 * 4 * 2];
let mut destination = [0; 17 * 4 * 2];
let size = Size {
    width: 17,
    height: 4,
};
let config = Config::default().with_rotation(Rotation::Degrees90);
let mut srm = Srm::new(peripherals.PPA, peripherals.DMA2D);
srm.run(
    Input {
        data: &source,
        size,
        format: PixelFormat::Rgb565,
    },
    Output {
        data: &mut destination,
        size: config.output_size(size)?,
        format: PixelFormat::Rgb565,
        offset: Offset::default(),
    },
    config,
)?;

Structs§

Configunstable
Configuration for a PPA SRM operation.
Inputunstable
Source image for an SRM operation.
Offsetunstable
Position within a destination image, in pixels.
Outputunstable
Destination image for an SRM operation.
Sizeunstable
Image dimensions in pixels.
Srmunstable
PPA SRM driver.

Enums§

Errorunstable
Errors returned by the PPA SRM operation.
PixelFormatunstable
Pixel formats supported by the PPA SRM operation.
Rotationunstable
Counterclockwise image rotation.