# wagiminator/ch32v003-ir-remote architecture

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

- Interactive diagram: https://gitdiagram.com/wagiminator/ch32v003-ir-remote
- Repository: https://github.com/wagiminator/ch32v003-ir-remote

## Overview

TinyRemote is a five-button, battery-powered CH32V003 infrared remote. A button press selects its configured command; firmware encodes that command using NEC, Samsung, RC-5, or Sony SIRC timings and drives an IR LED, then can return the MCU to standby. Hardware documentation and enclosure files support the physical device. The protocol implementations and button dispatch live in main.c; the excerpts show protocol encoders and key setup, but omit the dispatch and sleep loop, so those links are documented rather than source-verified.

Main entry points: [`software/ir_remote/src/main.c`](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c) (Remote firmware), [`hardware/IR_Remote_schematic.pdf`](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/hardware/IR_Remote_schematic.pdf) (IR LED output), [`software/ir_remote/src/system.h`](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/system.h) (System functions), [`software/ir_remote/src/gpio.h`](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/gpio.h) (GPIO helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Buttons and configuration"]
  node_key_config["Key mappings<br/>[config.h]"]
end

subgraph group_firmware["Firmware and protocols"]
  node_firmware_main["Remote firmware<br/>[main.c]"]
  node_nec["NEC encoder<br/>[main.c]"]
  node_samsung["Samsung encoder<br/>[main.c]"]
  node_rc5["RC-5 encoder<br/>[main.c]"]
  node_sirc["Sony SIRC encoder<br/>[main.c]"]
end

subgraph group_device["Remote hardware"]
  node_buttons["Five buttons"]
  node_ir_led["IR LED output"]
  node_power["Coin-cell supply"]
  node_enclosure["Remote enclosure<br/>[IR_Remote_case.stl]"]
end

subgraph group_runtime["MCU support"]
  node_gpio["GPIO helpers<br/>[gpio.h]"]
  node_system["System startup<br/>[system.c]"]
  node_system_api["System functions<br/>[system.h]"]
  node_mcu_defs["CH32V003 definitions<br/>[ch32v003.h]"]
end

node_user(("User"))
node_target(("IR-controlled device"))

node_user -->|"presses"| node_buttons
node_buttons -.->|"trigger"| node_firmware_main
node_key_config -->|"configures"| node_firmware_main
node_firmware_main -.->|"dispatches"| node_nec
node_firmware_main -.->|"dispatches"| node_samsung
node_firmware_main -.->|"dispatches"| node_rc5
node_firmware_main -.->|"dispatches"| node_sirc
node_firmware_main -->|"sets pins"| node_gpio
node_firmware_main -->|"modulates"| node_ir_led
node_nec -->|"emits pulses"| node_ir_led
node_samsung -->|"emits pulses"| node_ir_led
node_rc5 -->|"emits pulses"| node_ir_led
node_sirc -->|"emits pulses"| node_ir_led
node_ir_led -->|"sends IR"| node_target
node_firmware_main -.->|"uses standby"| node_system
node_system -->|"implements"| node_system_api
node_system_api -->|"uses registers"| node_mcu_defs
node_gpio -->|"uses system definitions"| node_system_api
node_power -->|"powers"| node_firmware_main

click node_buttons "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/hardware/IR_Remote_schematic.pdf"
click node_key_config "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/config.h"
click node_firmware_main "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c"
click node_nec "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c"
click node_samsung "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c"
click node_rc5 "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c"
click node_sirc "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c"
click node_gpio "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/gpio.h"
click node_system "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/system.c"
click node_system_api "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/system.h"
click node_mcu_defs "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/ch32v003.h"
click node_ir_led "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/hardware/IR_Remote_schematic.pdf"
click node_power "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/hardware/IR_Remote_schematic.pdf"
click node_enclosure "https://github.com/wagiminator/ch32v003-ir-remote/blob/main/3dprint/IR_Remote_case.stl"

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_key_config,node_user toneBlue
class node_firmware_main,node_nec,node_samsung,node_rc5,node_sirc toneAmber
class node_buttons,node_ir_led,node_power,node_enclosure toneMint
class node_gpio,node_system,node_system_api,node_mcu_defs toneRose
class node_target toneIndigo
```

## Components

### Buttons and configuration

- [Key mappings](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/config.h): `software/ir_remote/config.h`

### Firmware and protocols

- [Remote firmware](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c): `software/ir_remote/src/main.c`
- [NEC encoder](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c): `software/ir_remote/src/main.c`
- [Samsung encoder](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c): `software/ir_remote/src/main.c`
- [RC-5 encoder](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c): `software/ir_remote/src/main.c`
- [Sony SIRC encoder](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/main.c): `software/ir_remote/src/main.c`

### Remote hardware

- [Five buttons](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/hardware/IR_Remote_schematic.pdf): `hardware/IR_Remote_schematic.pdf`
- [IR LED output](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/hardware/IR_Remote_schematic.pdf): `hardware/IR_Remote_schematic.pdf`
- [Coin-cell supply](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/hardware/IR_Remote_schematic.pdf): `hardware/IR_Remote_schematic.pdf`
- [Remote enclosure](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/3dprint/IR_Remote_case.stl): `3dprint/IR_Remote_case.stl`

### MCU support

- [GPIO helpers](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/gpio.h): `software/ir_remote/src/gpio.h`
- [System startup](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/system.c): `software/ir_remote/src/system.c`
- [System functions](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/system.h): `software/ir_remote/src/system.h`
- [CH32V003 definitions](https://github.com/wagiminator/ch32v003-ir-remote/blob/main/software/ir_remote/src/ch32v003.h): `software/ir_remote/src/ch32v003.h`

### Other components

- **User**
- **IR-controlled device**

## Connections

- User → Five buttons: presses (evidence: `README.md`)
- Five buttons → Remote firmware: trigger
- Key mappings → Remote firmware: configures (evidence: `README.md`)
- Remote firmware → NEC encoder: dispatches (evidence: `software/ir_remote/src/main.c`)
- Remote firmware → Samsung encoder: dispatches (evidence: `software/ir_remote/src/main.c`)
- Remote firmware → RC-5 encoder: dispatches (evidence: `software/ir_remote/src/main.c`)
- Remote firmware → Sony SIRC encoder: dispatches (evidence: `software/ir_remote/src/main.c`)
- Remote firmware → GPIO helpers: sets pins (evidence: `software/ir_remote/src/main.c`)
- Remote firmware → IR LED output: modulates (evidence: `software/ir_remote/src/main.c`)
- NEC encoder → IR LED output: emits pulses (evidence: `README.md`)
- Samsung encoder → IR LED output: emits pulses (evidence: `README.md`)
- RC-5 encoder → IR LED output: emits pulses (evidence: `README.md`)
- Sony SIRC encoder → IR LED output: emits pulses (evidence: `README.md`)
- IR LED output → IR-controlled device: sends IR (evidence: `README.md`)
- Remote firmware → System startup: uses standby
- System startup → System functions: implements (evidence: `software/ir_remote/src/system.c`)
- System functions → CH32V003 definitions: uses registers (evidence: `software/ir_remote/src/system.h`)
- GPIO helpers → System functions: uses system definitions (evidence: `software/ir_remote/src/gpio.h`)
- Coin-cell supply → Remote firmware: powers (evidence: `README.md`)
