Skip to main content

Crate automation_hat

Crate automation_hat 

Source
Expand description

§Automation HAT Rust Library

A Rust library for controlling the Pimoroni Automation HAT, Automation pHAT, and Automation HAT Mini.

This library provides a convenient interface to control all features of the Automation HAT devices, including relays, digital outputs, digital inputs, analog inputs, and LEDs. The library also supports the display on the Automation HAT Mini.

§Features

  • Control relays, digital outputs, and read digital/analog inputs
  • Full LED control with automatic status indication
  • Support for all Automation HAT variants (HAT, pHAT, Mini)
  • Display support for Automation HAT Mini

§Example

use automation_hat::{AutomationHAT, HatType};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a new AutomationHAT instance
    let mut hat = AutomationHAT::new(HatType::AutomationHAT);

    // Toggle relay 3
    hat.relays.three.write(true)?;

    // Read digital input 1
    let input_value = hat.inputs.one.read()?;
    println!("Input 1: {}", input_value);

    // Set digital output 2
    hat.outputs.two.write(true)?;

    // Read analog input 3
    let analog_value = hat.analog_inputs.three.read()?;
    println!("Analog 3: {}", analog_value);

    Ok(())
}

Structs§

AnalogInput
Controls an analog input on the Automation HAT.
AnalogInputs
Container for analog input controls on the Automation HAT.
AutomationHAT
Main interface for the Automation HAT family of boards.
DigitalInput
Controls a digital input on the Automation HAT.
DigitalOutput
Controls a digital output on the Automation HAT.
Inputs
Container for digital input controls on the Automation HAT.
LED
Represents a single LED on the Automation HAT.
Outputs
Container for digital output controls on the Automation HAT.
Relay
Controls a relay output on the Automation HAT.
Relays
Container for relay controls on the Automation HAT.

Enums§

HatType
Represents the type of Automation HAT hardware being used.