# Pendule Project IHM

**Pendule IHM** allows you to **simulate** and **plot CSV data** simultaneously, making it easy to compare datasets from different sources.

---

## Environment Setup

The project uses a **Bash script** (`runPyScript.sh`) to manage the Python virtual environment and dependencies. While you can manually install all requirements, using the script is **recommended**.

### First Steps

1. **Make the script executable:**
   ```bash
   chmod +x runPyScript.sh
   ```

2. **Available Commands:**

   | Command                          | Description |
   |----------------------------------|-------------|
   | `./runPyScript.sh main.py`       | Run the main HMI with virtual environment |
   | `./runPyScript.sh record2csv.py` | Record data from pendulum sensors (via STM32 serial communication) and save as CSV |

---

## HMI Overview

The **HMI interface** is designed to **compare two pendulums side by side**.

### Features
- **Data Source Selection:** For each pendulum, choose between:
  - **CSV Data** (generated using `record2csv.py`)
  - **Simulation**
- **Parameters testing:** Changes simulation parameters to find which ones fit
- **Visualisation:** See two pendulum at the same time
- **Plot:** Plot all data from both pendulum
- **Compare:** Compare data from pendulum1 and pendulum1 and see data1 - data2

---

## Usage Examples

### 1. Record Sensor Data to CSV
```bash
./runPyScript.sh record2csv.py
```
> This will read data from the STM32 via serial and save it as a CSV file.

### 2. Launch the HMI
```bash
./runPyScript.sh main.py
```
> This will start the main interface, allowing you to compare simulations and CSV data.

---
**Note:** If you prefer to manage dependencies manually, you can install the required packages using `pip install -r requirements.txt`

