diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..e3155317d3d92dd1a1e66af569cfe58d231ed9d5 --- /dev/null +++ b/README.en.md @@ -0,0 +1,106 @@ +# AC Remote Control + +An infrared remote signal decoding and control project based on the STM32L031xx. + +## Project Overview + +This project implements an air conditioner infrared remote signal decoding and brand identification system running on an STM32L0xx microcontroller. The system decodes infrared signals emitted by air conditioner remote controls, identifies the air conditioner brand, and supports pairing and control via serial port. + +## Hardware Configuration + +- **Main Controller**: STM32L031xx (Cortex-M0+) +- **Infrared Reception**: Infrared receiver connected to ADC or GPIO +- **Display**: OLED display (128x64, I2C interface) +- **Communication**: UART2 for serial communication and debugging +- **Battery Monitoring**: ADC for battery voltage sampling + +## Features + +- Infrared signal decoding and analysis +- Multi-brand air conditioner code recognition (Gree, Haier, Midea, etc.) +- Serial port pairing command support +- OLED display output (Chinese and English) +- Battery level monitoring and display + +## System Architecture + +### Core Modules + +| Module | File | Description | +|--------|------|-------------| +| Infrared Decoding | `codelib.c` | Infrared signal reception, verification, and pairing command handling | +| Brand Codes | `air_brands.c` | Air conditioner brand code database and lookup | +| Display Driver | `oled.c` | OLED display driver and graphics rendering | +| Font Library | `font.c` | Chinese and English dot-matrix font library | +| ADC | `adc.c` | Battery voltage sampling | +| GPIO | `gpio.c` | GPIO configuration | +| I2C | `i2c.c` | I2C bus configuration | +| UART | `usart.c` | Serial communication | +| Timer | `tim.c` | Timer configuration | + +### API Interfaces + +```c +// Infrared-related +void Ircode_Init(void); // Initialize infrared receiver +void Ircode_PairCmdSend(void); // Send pairing command +void PairCode2Str(char *str); // Convert pairing code to string +void Ircode_process(void); // Process infrared signal + +// Brand lookup +void find_brands_by_code(uint16_t target, uint8_t* results, uint8_t* count); + +// OLED Display +void OLED_Init(void); // Initialize OLED +void OLED_ClearScreen(void); // Clear screen +void OLED_WriteText(...); // Write text +void OLED_DrawRect(...); // Draw rectangle + +// Battery +float Get_Battery_Voltage(void); // Get battery voltage +uint8_t Get_Battery_Percent(void); // Get battery percentage +``` + +## Usage Instructions + +### Hardware Connections + +``` +STM32L031xx +├── PA0 (ADC_IN0): Battery voltage detection +├── PA1 (UART2_TX): Serial transmit +├── PA2 (UART2_RX): Serial receive +├── PB6 (I2C1_SCL): OLED SCL +├── PB7 (I2C1_SDA): OLED SDA +└── Infrared Receiver: Connect to appropriate pin +``` + +### Serial Command Format + +Send pairing commands via UART to pair and control the air conditioner: + +``` +Send Format: [Header (2B)] + [Length (1B)] + [Data] + [Checksum (1B)] +Response Format: Same as above +``` + +Header: `0x55 0xAA` + +### Compilation and Flashing + +1. Generate the project using CMake or STM32CubeMX +2. Compile: `cmake -B build && cmake --build build` +3. Flash to target board using ST-Link or J-Link + +## Dependencies + +- STM32 HAL Driver +- CMSIS Device Header + +## License + +MIT License + +## Supported Brands + +(See the brand code database in `air_brands.c` for details) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..320c50cc97c6308001caee0893fd6132a1abe9cd --- /dev/null +++ b/README.md @@ -0,0 +1,108 @@ + + +# AC Remote Control + +基于 STM32L031xx 的空调红外遥控信号解码与控制项目。 + +## 项目简介 + +本项目实现了一个空调红外遥控信号解码与品牌识别系统,运行于 STM32L0xx 微控制器上。系统通过红外接收头解码空调遥控器发出的红外信号,识别空调品牌,并可通过串口进行配对和控制。 + +## 硬件配置 + +- **主控芯片**: STM32L031xx (Cortex-M0+) +- **红外接收**: 红外接收头连接到 ADC 或 GPIO +- **显示**: OLED 显示屏 (128x64, I2C 接口) +- **通信**: UART2 用于串口通信和调试 +- **电池监测**: ADC 监测电池电压 + +## 功能特性 + +- 红外信号解码与分析 +- 多品牌空调代码识别 (格力、海尔、美的等) +- 串口配对命令支持 +- OLED 显示屏输出 (中文和英文) +- 电池电量监测与显示 + +## 系统架构 + +### 核心模块 + +| 模块 | 文件 | 功能描述 | +|------|------|----------| +| 红外解码 | `codelib.c` | 红外信号接收、校验、配对命令处理 | +| 品牌代码 | `air_brands.c` | 空调品牌代码数据库与查询 | +| 显示驱动 | `oled.c` | OLED 显示屏驱动与图形绘制 | +| 字体 | `font.c` | 中英文点阵字库 | +| ADC | `adc.c` | 电池电压采样 | +| GPIO | `gpio.c` | GPIO 配置 | +| I2C | `i2c.c` | I2C 总线配置 | +| UART | `usart.c` | 串口通信 | +| 定时器 | `tim.c` | 定时器配置 | + +### API 接口 + +```c +// 红外相关 +void Ircode_Init(void); // 初始化红外接收 +void Ircode_PairCmdSend(void); // 发送配对命令 +void PairCode2Str(char *str); // 配对码转字符串 +void Ircode_process(void); // 红外信号处理 + +// 品牌查询 +void find_brands_by_code(uint16_t target, uint8_t* results, uint8_t* count); + +// OLED 显示 +void OLED_Init(void); // 初始化 OLED +void OLED_ClearScreen(void); // 清屏 +void OLED_WriteText(...); // 写文本 +void OLED_DrawRect(...); // 绘制矩形 + +// 电池 +float Get_Battery_Voltage(void); // 获取电池电压 +uint8_t Get_Battery_Percent(void); // 获取电池百分比 +``` + +## 使用说明 + +### 硬件连接 + +``` +STM32L031xx +├── PA0 (ADC_IN0): 电池电压检测 +├── PA1 (UART2_TX): 串口发送 +├── PA2 (UART2_RX): 串口接收 +├── PB6 (I2C1_SCL): OLED SCL +├── PB7 (I2C1_SDA): OLED SDA +└── 红外接收头: 连接到相应引脚 +``` + +### 串口命令格式 + +通过 UART 发送配对命令进行空调配对和控制: + +``` +发送格式: [帧头(2B)] + [长度(1B)] + [数据] + [校验和(1B)] +响应格式: 同上 +``` + +帧头: `0x55 0xAA` + +### 编译与烧录 + +1. 使用 CMake 或 STM32CubeMX 生成工程 +2. 编译: `cmake -B build && cmake --build build` +3. 使用 ST-Link 或 J-Link 烧录到目标板 + +## 依赖 + +- STM32 HAL Driver +- CMSIS Device Header + +## 许可证 + +MIT License + +## 支持的品牌 + +(详见 `air_brands.c` 中的品牌代码数据库) \ No newline at end of file