zwo_mount_control 0.2.1

Rust library for controlling ZWO AM5/AM3 telescope mounts with satellite tracking support
Documentation
# ZWO Mount Control

A Rust library for controlling ZWO AM5/AM3 telescope mounts via serial communication, with built-in support for satellite tracking using the `space-dust` crate for TLE/SGP4 propagation.

## Features

- **GoTo/Slewing**: Command the mount to slew to any celestial coordinates
- **Manual Motion**: Control axis motion at various speeds (guide to max slew)
- **Tracking**: Enable/disable tracking with sidereal, lunar, solar, or custom rates
- **Alt-Az & Equatorial Modes**: Switch between altitude-azimuth and equatorial tracking
- **Autoguiding**: Send guide pulses for autoguiding applications
- **Satellite Tracking**: Track satellites using TLE data and SGP4 propagation
- **Mock Mount**: Test your application without physical hardware

## Installation

Add to your `Cargo.toml`:

```toml
[dependencies]
zwo_mount_control = { git = "https://github.com/jmcguigs/zwo_mount_control" }
```

## Quick Start

### Connect to a Real Mount

```rust
use zwo_mount_control::{SerialMount, Mount, EquatorialPosition};

// Connect via serial port (typical on Linux/Mac)
let mut mount = SerialMount::new("/dev/ttyUSB0");
mount.connect()?;

// Get current position
let pos = mount.get_position()?;
println!("RA: {}h, Dec: {}°", pos.ra, pos.dec);

// Slew to Vega
let vega = EquatorialPosition::from_hms_dms(18, 36, 56.0, 38, 47, 1.0);
mount.goto_equatorial(vega)?;
```

### Use the Mock for Testing

```rust
use zwo_mount_control::{MockMount, Mount, HorizontalPosition};

let mut mount = MockMount::new();
mount.connect()?;
mount.unpark()?;

// Set Alt-Az mode and slew to horizontal coordinates
mount.set_altaz_mode()?;
let target = HorizontalPosition::new(180.0, 45.0);
mount.goto_altaz(target)?;
```

### Satellite Tracking

```rust
use zwo_mount_control::{SatelliteTracker, MockMount, Mount};

// ISS TLE data
let line1 = "1 25544U 98067A   24001.50000000  .00016717  00000-0  10270-3 0  9025";
let line2 = "2 25544  51.6400 208.9163 0006703  35.6028  75.3281 15.49560066429339";

let mut tracker = SatelliteTracker::from_tle(line1, line2)?;

// Set observer location (Los Angeles)
tracker.set_observer_location(34.0522, -118.2437, 71.0);

// Find next pass
let pass = tracker.find_next_pass(chrono::Utc::now(), 24.0)?;
if let Some(p) = pass {
    println!("Next pass: {}", p);
}
```

## Examples

### Basic Control (Alt-Az Slewing)

```bash
cargo run --example basic_control
```

This example demonstrates:
- Connecting to a mock mount
- Setting Alt-Az mode
- Going to home position
- Slewing to Az/Alt coordinates

### Satellite Tracking

```bash
cargo run --example satellite_tracking -- 25544  # ISS
cargo run --example satellite_tracking -- 20580  # Hubble Space Telescope
```

The example fetches TLE data from Celestrak and demonstrates satellite position calculations and pass predictions.

## Module Overview

| Module | Description |
|--------|-------------|
| `mount` | Core `Mount` trait and mount status types |
| `serial_mount` | Serial port mount implementation for real hardware |
| `mock_mount` | Simulated mount for testing |
| `protocol` | Serial command definitions (LX200-compatible with ZWO extensions) |
| `coordinates` | Coordinate conversion utilities (RA/Dec, Az/Alt, HMS/DMS) |
| `satellite_tracker` | Satellite tracking with TLE propagation |
| `error` | Error types |

## Coordinate Systems

### Equatorial Coordinates (RA/Dec)

Used when mount is in equatorial mode (on wedge, polar aligned):
- **Right Ascension (RA)**: Decimal hours (0-24)
- **Declination (Dec)**: Decimal degrees (-90 to +90)

### Horizontal Coordinates (Az/Alt)

Used when mount is in Alt-Az mode (on tripod, no wedge):
- **Azimuth (Az)**: Degrees from North (0-360°, clockwise)
- **Altitude (Alt)**: Degrees above horizon (0-90°)

## Hardware Requirements

- ZWO AM5 or AM3 mount (or compatible)
- USB-serial connection to the mount
- Serial port permissions (on Linux, add user to `dialout` group)

```bash
# Linux: Add user to dialout group for serial access
sudo usermod -a -G dialout $USER
# Log out and back in for changes to take effect
```

## Dependencies

- `space-dust` - Satellite propagation (SGP4/TLE)
- `serialport` - Serial communication
- `chrono` - Date/time handling
- `thiserror` - Error types

## License

MIT

## Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.