# e-ink-me

A personal e-ink display app for the M5Stack Paper S3. Displays your avatar, name, and a QR code linking to your website or personal contact info. A digital, electronic, e-ink event/conference badge! Or anything you wanted it to be.

![Hardware](https://img.shields.io/static/v1?label=Hardware&message=M5PaperS3&color=red)
![ESP32-S3](https://img.shields.io/badge/ESP32-S3-blue)
![Platform](https://img.shields.io/badge/Platform-PlatformIO-orange)
![License](https://img.shields.io/badge/License-MIT-green)

<img src="docs/images/me.JPEG" alt="My Avatar" />

## Features

- High-quality 8-bit grayscale avatar rendering
- Unicode text support (accented characters like é, è, ê)
- Auto-sizing text to fit display width
- QR code generation for easy URL sharing
- Fast image loading via LittleFS + PSRAM

## Hardware

- **Device**: [M5Stack Paper S3](https://shop.m5stack.com/products/m5papers3-esp32s3-development-kit)
- **Display**: 540x960 pixel e-ink (grayscale)
- **Processor**: ESP32-S3 with PSRAM

## Project Structure

```
e-ink-me/
├── src/
│   ├── main.cpp      # Application code
│   └── config.h      # User configuration
├── data/
│   └── avatar.bin    # Avatar image (uploaded to flash)
├── tools/
│   ├── avatar.png    # Source avatar image
│   └── convert_to_bin.py  # Image converter script
└── platformio.ini    # Build configuration
```

## Quick Start

### 1. Configure Your Display

Edit `src/config.h`:

```c
#define MY_NAME       u8"Your Name"
#define QR_URL        "https://yourwebsite.com"
```

### 2. Add Your Avatar

***Recommend your first convert your image to black and white!***

"The included sample avatar image is from [Avatar PNGs by Vecteezy -> QasimVisuals .](https://www.vecteezy.com/free-png/avatar)"

Place your image as `tools/avatar.png`, then convert it:

```bash
cd tools
pip install -r requirements.txt  # First time only
python3 convert_to_bin.py avatar.png ../data/avatar.bin 375
```

The third argument (375) is the width in pixels. Height is calculated automatically.

### 3. Build & Upload

```bash
# Build firmware
pio run

# Upload firmware
pio run -t upload

# Upload avatar to flash filesystem
pio run -t uploadfs
```

## Configuration Reference

All settings are in `src/config.h`:

| Setting | Description | Default |
|---------|-------------|---------|
| `MY_NAME` | Display name (supports Unicode) | `u8"John Doe"` |
| `QR_URL` | URL encoded in QR code | `"https://github.com/sfrechette"` |
| `AVATAR_FILE` | Path to avatar on flash | `"/avatar.bin"` |
| `ELEMENT_SPACING` | Vertical gap between elements | `50` |
| `NAME_OFFSET` | Gap between avatar and name | `40` |
| `TEXT_MARGIN` | Horizontal text margin | `30` |
| `TEXT_SIZE_START` | Initial text scale | `2.5` |
| `QR_VERSION` | QR complexity (1-40) | `3` |
| `QR_PIXEL_SIZE` | QR module size in pixels | `6` |
| `QR_PADDING` | White border around QR | `10` |

### Debug Mode

Uncomment in `config.h` to enable serial logging:

```c
#define DEBUG_SERIAL
```

## Image Requirements

- **Format**: PNG (any size, will be resized)
- **Recommended width**: 350-400 pixels
- **Transparency**: Converted to white background
- **Output**: 8-bit grayscale binary

## Dependencies

Managed automatically by PlatformIO:

- [M5Unified](https://github.com/m5stack/M5Unified) - Hardware abstraction
- [epdiy](https://github.com/vroland/epdiy) - E-paper driver
- [QRCode](https://github.com/ricmoo/qrcode) - QR code generation
- LittleFS - Flash filesystem

## Troubleshooting

### Display is upside down

The code sets `setRotation(2)`. Change to `0`, `1`, or `3` if needed.

### Avatar looks bad

Ensure you're using the `convert_to_bin.py` script. Raw PNG files won't work.

### Accents not showing

Make sure your name uses the `u8"..."` prefix for UTF-8 encoding.

### Build errors after changes

```bash
pio run -t clean
pio run
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

- **Issues**: [GitHub Issues](https://github.com/sfrechette/e-ink-me/issues)
