# mako777/renaultaffa2 architecture

> Architecture diagram of the GitHub repository mako777/renaultaffa2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mako777/renaultaffa2
- Repository: https://github.com/mako777/renaultaffa2

## Overview

RenaultAffa2 is Arduino firmware for operating a Renault AFFA2++ display: it communicates over I2C with MIRQ control, displays text, and responds to steering-wheel remote buttons; the README also documents a resistor-ladder output and supply-voltage display. The graph separates application behavior, display transport, and AVR support libraries. The main source is listed as read in the index, but its contents were not excerpted here, so application-level links rely on README descriptions; standalone timer and USART support are shown without assumed connections.

Main entry points: [`src/main.cpp`](https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp) (Firmware), [`lib/sagem_affa2/sagem_affa2.c`](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/sagem_affa2/sagem_affa2.c) (AFFA2 protocol), [`lib/I2CBase/I2CBase.c`](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/I2CBase/I2CBase.c) (I2C driver), [`lib/AVRTools/Analog2Digital.cpp`](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/AVRTools/Analog2Digital.cpp) (Analog conversion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application behavior"]
  node_firmware["Firmware<br/>[main.cpp]"]
  node_remote["Remote buttons<br/>[main.cpp]"]
  node_radio_dac["Radio DAC<br/>[main.cpp]"]
  node_supply_voltage["Supply voltage<br/>[main.cpp]"]
end

subgraph group_display["Display communication"]
  node_display_protocol["AFFA2 protocol<br/>[sagem_affa2.c]"]
  node_i2c["I2C driver<br/>[I2CBase.c]"]
end

subgraph group_hardware["AVR support"]
  node_adc["Analog conversion<br/>[Analog2Digital.cpp]"]
  node_gpio["GPIO macros<br/>[GpioPinMacros.h]"]
  node_timer["Timer queue<br/>[timer.c]"]
  node_usart["USART library<br/>[usart.c]"]
end

node_car_radio(("Car radio"))
node_display_device["AFFA2 display"]

node_firmware -.->|"uses display"| node_display_protocol
node_display_protocol -->|"calls I2C"| node_i2c
node_i2c -.->|"transfers data"| node_display_device
node_firmware -.->|"handles presses"| node_remote
node_remote -.->|"triggers buttons"| node_car_radio
node_firmware -.->|"drives outputs"| node_radio_dac
node_radio_dac -.->|"signals buttons"| node_car_radio
node_firmware -.->|"measures voltage"| node_supply_voltage
node_supply_voltage -.->|"samples analog"| node_adc
node_adc -->|"uses pin macros"| node_gpio

click node_firmware "https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp"
click node_remote "https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp"
click node_radio_dac "https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp"
click node_supply_voltage "https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp"
click node_display_protocol "https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/sagem_affa2/sagem_affa2.c"
click node_i2c "https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/I2CBase/I2CBase.c"
click node_adc "https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/AVRTools/Analog2Digital.cpp"
click node_gpio "https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/AVRTools/GpioPinMacros.h"
click node_timer "https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/timer/timer.c"
click node_usart "https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/usart/usart.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_firmware,node_remote,node_radio_dac,node_supply_voltage toneBlue
class node_display_protocol,node_i2c toneAmber
class node_adc,node_gpio,node_timer,node_usart toneMint
class node_car_radio,node_display_device toneIndigo
```

## Components

### Application behavior

- [Firmware](https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp): `src/main.cpp`
- [Remote buttons](https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp): `src/main.cpp`
- [Radio DAC](https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp): `src/main.cpp`
- [Supply voltage](https://github.com/mako777/renaultaffa2/blob/PlatformIO/src/main.cpp): `src/main.cpp`

### Display communication

- [AFFA2 protocol](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/sagem_affa2/sagem_affa2.c): `lib/sagem_affa2/sagem_affa2.c`
- [I2C driver](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/I2CBase/I2CBase.c): `lib/I2CBase/I2CBase.c`

### AVR support

- [Analog conversion](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/AVRTools/Analog2Digital.cpp): `lib/AVRTools/Analog2Digital.cpp`
- [GPIO macros](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/AVRTools/GpioPinMacros.h): `lib/AVRTools/GpioPinMacros.h`
- [Timer queue](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/timer/timer.c): `lib/timer/timer.c`
- [USART library](https://github.com/mako777/renaultaffa2/blob/PlatformIO/lib/usart/usart.c): `lib/usart/usart.c`

### Other components

- **Car radio**
- **AFFA2 display**

## Connections

- Firmware → AFFA2 protocol: uses display (evidence: `README.md`)
- AFFA2 protocol → I2C driver: calls I2C (evidence: `lib/sagem_affa2/sagem_affa2.c`)
- I2C driver → AFFA2 display: transfers data (evidence: `README.md`)
- Firmware → Remote buttons: handles presses (evidence: `README.md`)
- Remote buttons → Car radio: triggers buttons (evidence: `README.md`)
- Firmware → Radio DAC: drives outputs (evidence: `README.md`)
- Radio DAC → Car radio: signals buttons (evidence: `README.md`)
- Firmware → Supply voltage: measures voltage (evidence: `README.md`)
- Supply voltage → Analog conversion: samples analog (evidence: `README.md`)
- Analog conversion → GPIO macros: uses pin macros
