第1章 概述
1.1 项目背景
在当前科技飞速发展的背景下,嵌入式系统的广泛应用成为推动各行业创新的主要驱动力。我们秉持着培养学生实际操作能力的宗旨,特别设计了这个生产实习项目。通过嵌入式系统开发任务,我们旨在全面锻炼学生的工程实践技能,尤其是在STM32单片机编程领域的深度培养。
嵌入式系统不仅在消费电子、医疗设备、工业自动化等多个领域广泛渗透,而且为解决实际问题提供了创新的解决方案。通过积极参与这个项目,学生将深入了解嵌入式系统的核心概念,拓展在不同领域中的应用场景,为未来职业发展打下坚实而全面的基础。
起源与初衷
这嵌入式系统开发项目源于对现有技术局限性的认识和对未来需求的洞察。我们发现某些领域缺乏满足特定需求的嵌入式系统,因此决定启动这个项目,以填补这一技术空白。
关键问题
项目启动的关键问题涉及到提高系统性能、数据采集精度和更多传感器接入。解决这些问题是为了满足日益复杂和多样化的应用场景对嵌入式系统的要求。
市场背景
考虑到市场上对嵌入式系统的不断增长的需求,我们致力于提供更灵活、高效、全面的解决方案。市场对于具备多功能、高性能的嵌入式系统的需求是驱动我们前行的动力。
技术背景
项目的实施离不开先进的技术支持,我们采用了STM32单片机编程,并充分利用了SPI通信、LED控制、OLED显示和温湿度传感器数据采集等技术。这些技术为项目提供了坚实的技术基础。
通过深入了解项目背景,我们能更好地理解项目的价值和意义,为未来的工作奠定了坚实的基础。
1.2 应用概况
项目主要专注于嵌入式系统开发,重点涉及STM32单片机编程。具体工作范围包括SPI通信、串口通信、LED控制、OLED显示,以及温湿度传感器的数据采集与显示。通过这些具体任务,学生将有机会深入实践并掌握嵌入式系统开发中的关键技能,为日后应用于各种领域的项目做好准备。
目标应用领域
该嵌入式系统的目标应用领域涵盖了广泛的领域,包括但不限于智能家居、工业自动化、环境监测等。我们的系统旨在为这些领域提供高效、可靠的解决方案,满足不同场景下的需求。
潜在用户群体
潜在用户群体主要包括工程师、研究人员以及对嵌入式系统开发感兴趣的个人和团队。我们希望通过提供全面而灵活的系统,满足用户在各种项目中的需求,推动嵌入式技术的广泛应用。
应用场景
项目的应用场景丰富多样,包括智能家居中的智能控制、工业自动化中的数据采集与控制、环境监测中的数据记录等。这些场景展示了系统在实际应用中的多功能性和适应性。
技术特点
系统的技术特点主要体现在其高度可定制性、稳定性和低功耗上。通过充分利用STM32单片机编程、SPI通信等先进技术,我们致力于提供一个适用于不同领域的全面解决方案。
通过深入了解应用概况,我们能更好地把握项目的定位和应用范围,确保系统能够满足多样化的用户需求。
1.3 项目目标
通过本项目,学生将掌握以下技能:
- STM32单片机编程及外设配置。
- SPI通信协议的实现与配置。
- 串口通信的设置与使用。
- LED控制与状态指示的设计。
- OLED显示屏的初始化与图形显示。
- 温湿度传感器数据采集与实时显示。
主要目标
项目的主要目标是设计和实现一款功能强大、灵活可定制的嵌入式系统,以满足智能家居、工业自动化和环境监测等多领域的需求。重点在于提供高性能的数据采集、实时控制以及良好的扩展性,使其能够适应不同场景下的复杂应用。
具体任务
- 完善SPI通信模块,优化通信效率和稳定性。
- 进一步提升LED控制和OLED显示的功能,增加更多交互性和实用性。
- 优化温湿度传感器数据采集算法,提高数据准确性和稳定性。
- 引入RTOS实现多任务处理,提高系统并发性能。
1.4 学习收获
学生在完成该项目后,将具备:
- 独立进行嵌入式系统开发的能力。
- 对STM32单片机及其外设的深入理解。
- 良好的团队协作与沟通能力。
- 项目实施中解决问题的经验。
技术提升
通过项目,我在STM32单片机编程、SPI通信、LED控制、OLED显示、温湿度传感器数据采集等方面取得了显著的技术提升。深入学习和实践这些关键技能,为我未来在嵌入式系统领域的发展奠定了坚实基础。
解决问题能力
在实习过程中,面对SPI通信参数调优和温湿度传感器数据精度处理等挑战,我通过不断学习和实践,成功解决了这些问题。这锻炼了我解决实际问题的能力,提高了应变能力。
1.5 开发环境
项目采用Keil MDK-ARM作为开发环境,涉及的编程语言为嵌入式C。版本控制使用Git进行团队协作。
硬件环境
- STM32单片机
- LED、OLED显示屏
- 温湿度传感器
- XCOM串口通信模块
软件环境
- Keil开发环境
- STM32CubeMX
- 嵌入式C语言
- RTOS(计划引入)
1.6 项目组织结构
项目组织结构分为硬件组、软件组和测试组。硬件组负责硬件设计与搭建,软件组负责嵌入式系统的开发,测试组进行系统测试与验证。
团队成员
项目团队由工程师和开发人员组成,涵盖硬件、软件和嵌入式系统开发方面的专业人才。
分工合作
团队成员分工合作,共同负责系统的不同模块开发和优化。定期的团队协调会议确保项目按计划推进。
1.7 项目周期
项目计划周期为8周,包括需求分析、系统设计、开发、测试、优化与文档编写。
阶段性规划
项目周期划分为不同的阶段,包括硬件搭建、软件开发、功能优化和测试等多个阶段。每个阶段都有明确的目标和计划,以确保项目的顺利进行。
时间安排
项目周期为2周,每个阶段都有相应的时间安排,以确保在规定时间内完成各项任务。
1.8 风险与挑战
在项目中可能面临的风险与挑战包括硬件兼容性、通信协议稳定性、代码优化难题等。团队将采取迭代开发和风险管理策略以应对这些挑战。
风险分析
项目可能面临硬件兼容性、通信稳定性和数据准确性等风险。团队将采取有效措施,及时应对和解决可能出现的问题。
挑战应对
项目挑战主要在于系统的高性能要求和多样化的应用场景。团队将以挑战为动力,不断优化和提升系统的性能,以适应未来嵌入式系统开发的复杂需求。
第2章 生产实习过程
2.1 实习过程
生产实习分为不同阶段,从任务安排到编程实践,经历了一系列独立完成任务的过程。在这个过程中,我逐步掌握了STM32单片机的编程技巧,解决了一些挑战性问题。
全面学习
在生产实习过程中,我全面学习了STM32单片机编程,涵盖了硬件配置、嵌入式C语言编程以及外设驱动等多个方面。
多阶段任务
实习任务划分为多个阶段,每个阶段都有具体目标,从基础的STM32单片机学习到系统功能的逐步完善。
2.2 阶段成果
在实习的不同阶段,取得了以下成果:
2.2.1 阶段一:STM32单片机基础
首先,通过学习STM32单片机的基础知识,包括寄存器配置、时钟设置等,成功完成了单片机的初始化。
2.2.2 阶段二:SPI通信与LED控制
在第二阶段,学习了SPI通信协议的实现与配置,成功搭建了与传感器的SPI通信。同时,实现了LED的控制功能,通过SPI与LED模块的配合,实现了灯光效果的设计。
#include "stm32f10x.h"
#include "key.h"
#include "led.h"
int main(void) {
// 初始化按键和LED
key_init();
LED_init();
while (1) {
// 扫描按键
u8 keyVal = key_scan(0);
// 根据按键值控制LED
switch (keyVal) {
case KEY_1:
LED1_FZ;
break;
case KEY_2:
LED2_FZ;
break;
case KEY_3:
LED3_FZ;
break;
default:
break;
}
}
}
2.2.3 阶段三:OLED显示屏初始化与图形显示
第三阶段主要涉及OLED显示屏的初始化与图形显示。成功配置了SPI通信,并通过OLED库实现了图形的显示。这一阶段的成果为后续温湿度数据的实时展示奠定了基础。
#include "stm32f10x.h"
#include "led.h"
#include "oled.h"
#include "stdio.h"
#include <stdlib.h>
extern const u8 gb2312_ziku[];
extern const u8 asc_ziku[];
extern const u8 gb2312_model[];
extern const u8 asc_model[];
extern const u8 an_ziku[];
extern const u8 an_model[];
// 定义结构体,用于配置SPI参数
typedef struct {
uint16_t BaudRatePrescaler; // 波特率分频
uint16_t CPHA; // 时钟相位
uint16_t CPOL; // 时钟极性
uint16_t CRCPolynomial; // CRC校验
uint16_t DataSize; // 字长
uint16_t Direction; // 传输模式
uint16_t FirstBit; // 高/低位在前
uint16_t Mode; // SPI主/从模式
uint16_t Nss; // NSs
} SPI_Config;
// 函数原型
void SPI_Configuration(SPI_TypeDef* SPIx, SPI_Config* spiConfig);
// 模拟从传感器读取数据的函数
uint16_t ReadSensorData(void) {
return (uint16_t)rand();
}
// 初始化串口1
void SPI1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
SPI_InitTypeDef SPI_InitStruct;
//部分1: 管脚复用
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_2MHz;
GPIO_Init(GPIOB, &GPIO_InitStruct);
//部分2: SPI功能配置
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
SPI_InitStruct.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_16;
SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStruct.SPI_CRCPolynomial= 0x7;
SPI_InitStruct.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStruct.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
SPI_InitStruct.SPI_NSS = SPI_NSS_Soft;
SPI_Init(SPI1,&SPI_InitStruct);
SPI_Cmd(SPI1,ENABLE);
}
int main(void) {
// 初始化SPI
SPI1_Init();
// 初始化LED
LED_init();
// 初始化OLED
OLED_Init();
OLED_drawPic(0, 0, 64, 64, an_model);
}
const u8 an_model[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x70,0x0E,0x01,0x00,0x00,0x0F,0x70,0x40,0x20,0x20,0x20,0x20,
0x20,0x20,0x60,0x40,0x38,0x07,0x00,0x00,0x01,0x1E,0xE0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x60,0x10,0x08,
0x04,0x02,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0xE0,0xC0,0x00,0x00,0x00,0x80,0x80,
0x80,0x00,0x00,0x00,0xE0,0xC0,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x04,0x0C,0x18,
0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0xE3,0x00,0x00,0x00,
0x00,0x08,0x0A,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x08,0x0C,0x07,
0x08,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x08,0x0A,0x12,0x12,0x12,0x00,0x00,0x00,
0x00,0xC0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x06,0x08,
0x10,0x30,0x20,0x40,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x40,0x20,0x20,0x10,0x08,0x04,
0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"C:\Users\HP\Pictures\Camera Roll\m.bmp",0*/
};
2.2.4 阶段四:串口通信与XCOM控制
在第四阶段,学习了串口通信的设置与使用。通过USART配置,实现了与外部设备XCOM的串口通信。成功设计了XCOM控制模式,可以通过串口指令控制LED灯的状态。
#include "stm32f10x.h"
#include "key.h"
#include "led.h"
void delay_ms(u16 nms) {
u32 temp;
SysTick->LOAD = 9000 * nms;
SysTick->VAL = 0x00;
SysTick->CTRL = 0x01;
do {
temp = SysTick->CTRL;
} while ((temp & 0x01) && (!(temp & (1 << 16))));
SysTick->CTRL = 0x00;
SysTick->VAL = 0x00;
}
void USART1_Configuration(void) {
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE);
}
void USART1_SendChar(char ch) {
USART_SendData(USART1, (uint8_t)ch);
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)
;
}
void circularFlowLight() {
static int currentLED = 0;
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
switch (currentLED) {
case 0:
GPIO_SetBits(GPIOB, GPIO_Pin_11);
break;
case 1:
GPIO_SetBits(GPIOB, GPIO_Pin_14);
break;
case 2:
GPIO_SetBits(GPIOA, GPIO_Pin_11);
break;
default:
break;
}
delay_ms(500);
currentLED = (currentLED + 1) % 3;
}
void xcomControlLED(char command) {
static int mode = 0;
if (strncmp(command, "LED1_ON", 7) == 0) {
// 打开 LED1
command=1;
}
else if (strncmp(command, "LED2_ON", 7) == 0) {
// 打开 LED2
command=2;
}
else if (strncmp(command, "LED3_ON", 7) == 0) {
// 打开 LED3
command=3;
}
if (strncmp(command, "LED1_OFF", 7) == 0) {
command=4;
}
else if (strncmp(command, "LED2_OFF", 7) == 0) {
command=5;
}
else if (strncmp(command, "LED3_OFF", 7) == 0) {
command=6;
}
switch (command) {
case '1':
GPIO_SetBits(GPIOB, GPIO_Pin_11);
delay_ms(500);
break;
case '2':
GPIO_SetBits(GPIOB, GPIO_Pin_14);
delay_ms(500);
break;
case '3':
GPIO_SetBits(GPIOA, GPIO_Pin_11);
delay_ms(500);
break;
case '4':
GPIO_ResetBits(GPIOB, GPIO_Pin_11);
delay_ms(500);
break;
case '5':
GPIO_ResetBits(GPIOB, GPIO_Pin_14);
delay_ms(500);
break;
case '6':
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
delay_ms(500);
break;
default:
// ???????
mode = 0;
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
break;
}
}
int main(void) {
SystemInit();
SysTick_Config(SystemCoreClock / 1000);
key_init();
LED_init();
USART1_Configuration();
int flowLightEnabled = 0;
int xcomControlEnabled = 0;
while (1) {
if (flowLightEnabled) {
circularFlowLight();
}
if (xcomControlEnabled && USART_GetFlagStatus(USART1, USART_FLAG_RXNE) != RESET) {
char command = USART_ReceiveData(USART1);
xcomControlLED(command);
}
if (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) != RESET) {
char command = USART_ReceiveData(USART1);
switch (command) {
case 's':
flowLightEnabled = 1;
xcomControlEnabled = 0; // ??XCOM??
break;
case 'p':
flowLightEnabled = 0;
break;
case 'c':
xcomControlEnabled = 1;
flowLightEnabled = 0; // ???????
break;
case 'x':
xcomControlEnabled = 0;
break;
case '1':
// ?? '1' ??
xcomControlLED('1');
break;
case '2':
// ?? '2' ??
xcomControlLED('2');
break;
case '3':
// ?? '3' ??
xcomControlLED('3');
break;
case '4':
// ?? '1' ??
xcomControlLED('4');
break;
case '5':
// ?? '2' ??
xcomControlLED('5');
break;
case '6':
// ?? '3' ??
xcomControlLED('6');
break;
default:
break;
}
}
}
}
2.2.5 阶段五:温湿度传感器数据采集与显示
最后,通过集成温湿度传感器,成功实现了数据采集与实时显示。利用OLED显示屏清晰展示温湿度信息,为整个项目的顺利完成提供了重要支持。
#include "stm32f10x.h"
#include "timer.h"
#include "dht.h"
#include "oled.h"
#include <stdio.h>
#include <string.h>
// 引入其他已存在的 OLED 函数
extern const u8 asc_ziku[];
extern const u8 asc_model[];
// 初始化 XCOM 串口
void XCOM_Init(void) {
// TODO: 根据具体的串口配置进行初始化
// 使用 USART2 作为例子
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
// 配置 USART1 的 TX 引脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 配置 USART1 的 RX 引脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 配置 USART1
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
// 使能 USART1
USART_Cmd(USART1, ENABLE);
}
// 发送字符串到 XCOM 串口
void XCOM_SendString(const char* str) {
while (*str) {
// 等待发送缓冲区为空
while (!(USART1->SR & USART_FLAG_TXE))
;
USART_SendData(USART1, *str++);
}
}
void displayTemperature(double temperature,double humidity);
int main(void) {
// 初始化
SystemInit();
dht_init();
OLED_Init();
XCOM_Init();
double temperature = 0.0, humidity = 0.0;
int measureEnabled = 1;
while (1) {
if (measureEnabled) {
DHT_ERROR dhtResult = dht_measure(&temperature, &humidity);
if (dhtResult == ERR_NONE) {
char xcomString[50];
snprintf(xcomString, sizeof(xcomString), "Temperature: %.2fC, Humidity: %.2f%%\r\n", temperature, humidity);
XCOM_SendString(xcomString);
displayTemperature(temperature, humidity);
measureEnabled = 0;
} else {
// 处理错误
measureEnabled = 0;
}
}
TIM2_delayms(2000);
measureEnabled = 1;
}
}
void displayTemperature(double temperature, double humidity) {
char tempString[10];
char humString[10];
// Format temperature string
snprintf(tempString, sizeof(tempString), "T=%.2fDC", temperature);
// Format humidity string
snprintf(humString, sizeof(humString), "H=%.2f%%", humidity);
u8 lenTemp = strlen(tempString);
u8 lenHum = strlen(humString);
// Display temperature
for (u8 i = 0; i < lenTemp; i++) {
u8 index = 0;
if (tempString[i] == 'T') {
index = 11;
} else if (tempString[i] == '=') {
index = 12;
} else if (tempString[i] == '.') {
index = 13;
} else if (tempString[i] == 'D') {
index = 16;
} else if (tempString[i] == 'C') {
index = 10;
} else if (tempString[i] >= '0' && tempString[i] <= '9') {
index = tempString[i] - '0';
}
OLED_drawPic(i * 8, 0, 8, 16, (u8*)&asc_model[index * 16]);
}
// Display humidity on the next line
for (u8 i = 0; i < lenHum; i++) {
u8 index = 0;
if (humString[i] == 'H') {
index = 14;
} else if (humString[i] == '=') {
index = 12;
} else if (humString[i] == '.') {
index = 13;
} else if (humString[i] == '%') {
index = 15;
} else if (humString[i] >= '0' && humString[i] <= '9') {
index = humString[i] - '0';
}
OLED_drawPic(i * 8, 2, 8, 16, (u8*)&asc_model[index * 16]);
}
}
#include "stm32f10x.h"
const u8 gb2312_ziku[]= "云家居温湿度窗帘彩灯风扇";
//此数组需要和数组gb2312_model内容保持对应关系
//(文字顺序和字模出现顺序一致)
const u8 asc_ziku[]= "0123456789T=.°C";
//此数组需要和数组asc_model内容保持对应关系
//(文字顺序和字模出现顺序一致)
const u8 gb2312_model[]={
0x40,0x40,0x42,0x42,0x42,0x42,0xC2,0x42,0x42,0x42,0x42,0x42,0x42,0x40,0x40,0x00,
0x00,0x20,0x70,0x28,0x24,0x23,0x20,0x20,0x20,0x24,0x28,0x30,0xE0,0x00,0x00,0x00,/*"云",0*/
0x10,0x2C,0x24,0x24,0xA4,0xA4,0x65,0xA6,0x24,0x24,0x24,0x24,0xA4,0x34,0x0C,0x00,
0x40,0x49,0x49,0x29,0x24,0x14,0x52,0x89,0x7F,0x04,0x0A,0x11,0x10,0x20,0x20,0x00,/*"家",1*/
0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xF2,0x92,0x92,0x92,0x9E,0x80,0x80,0x00,
0x40,0x30,0x0F,0x00,0xFC,0x44,0x44,0x44,0x47,0x44,0x44,0x44,0xFC,0x00,0x00,0x00,/*"居",2*/
0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00,/*"温",3*/
0x10,0x60,0x02,0x8C,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x04,0x04,0x7E,0x01,0x44,0x48,0x50,0x7F,0x40,0x40,0x7F,0x50,0x48,0x44,0x40,0x00,/*"湿",4*/
0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,
0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00,/*"度",5*/
0x10,0x0C,0xC4,0x54,0x4C,0x64,0xD5,0x46,0x44,0x44,0x4C,0x54,0xC4,0x14,0x0C,0x00,
0x00,0x00,0xFF,0x40,0x44,0x62,0x55,0x49,0x55,0x43,0x40,0x40,0xFF,0x00,0x00,0x00,/*"窗",6*/
0x10,0x0C,0x44,0x24,0x14,0x04,0x05,0xC6,0x04,0x04,0x14,0x24,0x44,0x14,0x0C,0x00,
0x00,0x00,0x3F,0x01,0x01,0x01,0x01,0xFF,0x01,0x01,0x11,0x21,0x1F,0x00,0x00,0x00,/*"帘",7*/
0x00,0x14,0x64,0x04,0x0C,0xB2,0x02,0x23,0x1A,0x00,0x20,0x10,0x08,0x86,0x60,0x00,
0x40,0x21,0x11,0x0D,0x03,0xFF,0x05,0x09,0x11,0x80,0x84,0x42,0x21,0x10,0x0C,0x00,/*"彩",8*/
0x80,0x70,0x00,0xFF,0x20,0x10,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,
0x80,0x60,0x18,0x07,0x08,0x30,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,/*"灯",9*/
0x00,0x00,0xFE,0x02,0x12,0x22,0xC2,0x02,0xC2,0x32,0x02,0xFE,0x00,0x00,0x00,0x00,
0x80,0x60,0x1F,0x00,0x20,0x10,0x0C,0x03,0x0C,0x30,0x00,0x0F,0x30,0x40,0xF8,0x00,/*"风",10*/
0x00,0x00,0xFC,0x24,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x24,0x24,0x3C,0x00,0x00,
0x40,0x30,0x0F,0x21,0x15,0x49,0x81,0x7F,0x00,0x21,0x15,0x49,0x81,0x7F,0x00,0x00,/*"扇",11*/
};
const u8 asc_model[]={
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*"0",0*/
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,/*"1",1*/
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*"2",2*/
0x00,0x30,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00,/*"3",3*/
0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00,0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24,/*"4",4*/
0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x20,0x20,0x20,0x11,0x0E,0x00,/*"5",5*/
0x00,0xE0,0x10,0x88,0x88,0x90,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x20,0x1F,0x00,/*"6",6*/
0x00,0x18,0x08,0x08,0x88,0x68,0x18,0x00,0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00,/*"7",7*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,/*"8",8*/
0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00,0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00,/*"9",9*/
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,/*"C",0*/
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,/*"T",10*/
0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x00,/*"=",11*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,/*".",12*/
0x00,0x00,0x30,0x48,0x48,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"°",13*/
};
const u8 cat_model[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x70,0x0E,0x01,0x00,0x00,0x0F,0x70,0x40,0x20,0x20,0x20,0x20,
0x20,0x20,0x60,0x40,0x38,0x07,0x00,0x00,0x01,0x1E,0xE0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x60,0x10,0x08,
0x04,0x02,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0xE0,0xC0,0x00,0x00,0x00,0x80,0x80,
0x80,0x00,0x00,0x00,0xE0,0xC0,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x04,0x0C,0x18,
0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0xE3,0x00,0x00,0x00,
0x00,0x08,0x0A,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x08,0x0C,0x07,
0x08,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x08,0x0A,0x12,0x12,0x12,0x00,0x00,0x00,
0x00,0xC0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x06,0x08,
0x10,0x30,0x20,0x40,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x40,0x20,0x20,0x10,0x08,0x04,
0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"C:\Users\HP\Pictures\Camera Roll\m.bmp",0*/
};
const u8 deng0_model[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x60,0x10,0x08,0x04,0x02,0x02,0x01,0x01,0x00,0x00,0x00,0x00,
0x02,0x05,0x06,0x19,0xC1,0x08,0x32,0x0C,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0x60,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80,
0x00,0x00,0x00,0x00,0x3F,0x20,0x18,0xC0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x60,0x80,0x07,0x82,0xF7,0x85,0x84,0xE7,
0x8C,0x01,0x01,0x40,0x90,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x26,0xDC,0x50,0x50,0x00,0x00,0x00,0x40,
0x44,0x04,0xA0,0xE4,0x1B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x0E,0x0A,0x02,0x08,
0x05,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"E:\2?á?\png\2.bmp",0*/
};
const u8 deng1_model[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x50,0x00,0x00,
0x00,0x00,0x00,0x80,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x84,0x40,0x20,0x20,0x00,0x10,0x01,0x00,0x00,0x00,
0x50,0x40,0x90,0x10,0x80,0x00,0x80,0x00,0x00,0x08,0x02,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x01,
0x01,0x01,0x01,0x00,0x8C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFC,0x00,0xC3,0x00,0xFE,0x00,0x00,0x00,0x40,0x20,0x20,0x20,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x20,0x20,0x00,
0x10,0x08,0x08,0x00,0x01,0x04,0x08,0x30,0x80,0x00,0x38,0x30,0x3C,0x20,0x1C,0xE0,
0x18,0x1C,0x00,0xC1,0x11,0x08,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x95,0x72,0x40,0x00,0x00,0x20,0x02,0x12,
0x12,0x92,0x93,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x05,0x0C,0x10,0x22,0x25,0x14,
0x08,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"E:\2?á?\png\3.bmp",0*/
};
2.3 经验与教训
在实习过程中,积累了丰富的经验,同时也遇到了一些教训:
- 经验一:团队协作关键性:团队的协作对于项目的成功至关重要。通过有效的沟通与合作,解决了一些在个人难以应对的问题。
- 经验二:阶段性总结与反馈:定期进行阶段性总结与反馈,有助于及时调整项目进度,确保项目按计划推进。
- 教训一:风险预判与应对:在项目初期,未充分预判到一些潜在风险,导致后期工作的不同程度受到影响。教训是在项目启动时更加细致地进行风险分析。
成功经验
• 划分任务为多个阶段,有助于集中精力解决每个阶段的具体问题。
• 团队协作,及时沟通和合作,保证项目按计划推进。
教训与改进
• 部分任务中对硬件连接的理解不够深入,导致调试过程中出现一些问题,以后需要更加仔细学习硬件相关知识。
• 需要更具备独立解决问题的能力,对遇到的问题要深入分析,不仅仅停留在解决表面问题。
成功经验
- 划分任务为多个阶段,有助于集中精力解决每个阶段的具体问题。
- 团队协作,及时沟通和合作,保证项目按计划推进。
教训与改进
- 部分任务中对硬件连接的理解不够深入,导致调试过程中出现一些问题,以后需要更加仔细学习硬件相关知识。
- 需要更具备独立解决问题的能力,对遇到的问题要深入分析,不仅仅停留在解决表面问题。
第3章 STM32单片机编程
3.1 系统需求
项目旨在构建嵌入式系统,实现LED控制、OLED显示和温湿度传感器数据采集的功能。系统需求明确,使用NABC模型进行需求分析。
在满足功能需求的基础上,系统对性能有着明确的要求。稳定性是系统的基石,尤其是对于温湿度传感器数据采集,系统需要保证高精度和快速响应。
3.1.1 功能需求
系统旨在实现多个关键功能,其中包括SPI通信、LED控制、OLED屏幕显示和温湿度传感器数据采集。这些功能的协同作用使得整个项目更具实用性。
3.1.2 性能需求
// 在满足功能需求的基础上,系统对性能有着明确的要求。稳定性是系统的基石,尤其是对于温湿度传感器数据采集,系统需要保证高精度和快速响应。
3.2 工具选择
在实习中,我选择了STM32单片机作为目标平台,使用C语言进行编程。开发集成环境选择CubeMX和Keil,这些工具在嵌入式系统开发中得到广泛应用,提高了开发效率。
3.2.1 STM32CubeMX
STM32CubeMX被选用用于自动生成初始化代码。这不仅简化了配置过程,还提高了整体开发效率。
3.2.2 Keil uVision
Keil uVision是主要的集成开发环境。在这里,我们进行代码的编写、编译和调试,确保项目的正常运行。
3.3 系统设计
系统划分为SPI通信模块、串口通信模块、LED控制模块、OLED显示模块和温湿度传感器模块。主要工作流程包括数据通信、显示控制和传感器数据采集。这些模块之间协同工作,构成了完整的嵌入式系统。
3.3.1 模块划分
将系统划分为SPI通信模块、LED控制模块、OLED显示模块和温湿度传感器数据采集模块,以便更好地管理各个功能的实现。
3.3.2 数据流设计
通过设计合理的数据流,确保各个模块之间能够高效地传递信息。这有助于提高整个系统的协同效果。
3.4 关键模块实现
详细实现了SPI通信初始化、XCOM串口初始化、LED控制、OLED屏幕显示和温湿度传感器数据采集等功能。以下是每个关键模块的伪代码和技术分析:
3.4.1 SPI通信初始化
// 定义结构体,用于配置SPI参数
typedef struct {
uint16_t BaudRatePrescaler; // 波特率分频
uint16_t CPHA; // 时钟相位
uint16_t CPOL; // 时钟极性
uint16_t CRCPolynomial; // CRC校验
uint16_t DataSize; // 字长
uint16_t Direction; // 传输模式
uint16_t FirstBit; // 高/低位在前
uint16_t Mode; // SPI主/从模式
uint16_t Nss; // NSs
} SPI_Config;
void SPI_Configuration(SPI_TypeDef* SPIx, SPI_Config* spiConfig) {
// 实现SPI参数配置,包括波特率分频、时钟相位、时钟极性等
SPI_InitTypeDef SPI_InitStruct;
SPI_InitStruct.SPI_BaudRatePrescaler = spiConfig->BaudRatePrescaler;
SPI_InitStruct.SPI_CPHA = spiConfig->CPHA;
SPI_InitStruct.SPI_CPOL = spiConfig->CPOL;
SPI_InitStruct.SPI_CRCPolynomial = spiConfig->CRCPolynomial;
SPI_InitStruct.SPI_DataSize = spiConfig->DataSize;
SPI_InitStruct.SPI_Direction = spiConfig->Direction;
SPI_InitStruct.SPI_FirstBit = spiConfig->FirstBit;
SPI_InitStruct.SPI_Mode = spiConfig->Mode;
SPI_InitStruct.SPI_NSS = spiConfig->Nss;
SPI_Init(SPIx, &SPI_InitStruct);
SPI_Cmd(SPIx, ENABLE);
}
技术分析: 此函数用于配置SPI参数,确保SPI通信正常工作。
3.4.2 XCOM串口初始化
void XCOM_Init(void) {
// 使用 USART2 作为例子
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
// 配置 USART1 的 TX 引脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 配置 USART1 的 RX 引脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 配置 USART1
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
// 使能 USART1
USART_Cmd(USART1, ENABLE);
}
技术分析: 通过该函数,成功配置了USART2作为XCOM串口,包括引脚配置和波特率设置。
3.4.3 LED控制
void xcomControlLED(char command) {
// 根据接收到的指令控制LED灯的状态
static int mode = 0;
switch (command) {
case '1':
// 控制LED灯的状态,模拟流水灯效果
// ...
break;
case '2':
// 控制LED灯的状态,根据具体需求添加逻辑
// ...
break;
case '3':
// 控制LED灯的状态,根据具体需求添加逻辑
// ...
break;
default:
// 默认情况下关闭LED灯
mode = 0;
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
break;
}
}
技术分析: 通过串口接收指令,实现对LED灯状态的控制,提高了系统的可操作性。
3.4.4 OLED屏幕显示
void displayTemperature(double temperature, double humidity) {
char tempString[10];
char humString[10];
// Format temperature string
snprintf(tempString, sizeof(tempString), "T=%.2fDC", temperature);
// Format humidity string
snprintf(humString, sizeof(humString), "H=%.2f%%", humidity);
u8 lenTemp = strlen(tempString);
u8 lenHum = strlen(humString);
// Display temperature
for (u8 i = 0; i < lenTemp; i++) {
u8 index = 0;
if (tempString[i] == 'T') {
index = 11;
} else if (tempString[i] == '=') {
index = 12;
} else if (tempString[i] == '.') {
index = 13;
} else if (tempString[i] == 'D') {
index = 16;
} else if (tempString[i] == 'C') {
index = 10;
} else if (tempString[i] >= '0' && tempString[i] <= '9') {
index = tempString[i] - '0';
}
OLED_drawPic(i * 8, 0, 8, 16, (u8*)&asc_model[index * 16]);
}
// Display humidity on the next line
for (u8 i = 0; i < lenHum; i++) {
u8 index = 0;
if (humString[i] == 'H') {
index = 14;
} else if (humString[i] == '=') {
index = 12;
} else if (humString[i] == '.') {
index = 13;
} else if (humString[i] == '%') {
index = 15;
} else if (humString[i] >= '0' && humString[i] <= '9') {
index = humString[i] - '0';
}
OLED_drawPic(i * 8, 2, 8, 16, (u8*)&asc_model[index * 16]);
}
}
技术分析: 该函数用于将温湿度数据格式化为字符串,并在OLED上进行显示,提供了直观的温湿度信息展示。
3.4.5 温湿度传感器数据采集
DHT_ERROR dht_measure(double* temperature, double* humidity) {
// 通过DHT传感器采集温湿度数据
// ...
}
技术分析: 利用DHT传感器进行数据采集,成功获取温湿度信息,为实时显示提供数据支持。
3.4.6 阶段成果总结
在关键模块实现的基础上,项目已经取得了阶段性的成果。SPI通信、串口通信、LED控制、OLED显示和温湿度传感器数据采集等功能的实现为整个系统的顺利运行打下了坚实基础。
第4章 相关问题讨论
4.1 计算机与环境和可持续发展
4.1.1 能耗与效率
在计算机系统的复杂工程实践中,对能耗的关注不仅仅是技术问题,更是环境和可持续发展的责任。通过采用先进的优化算法,精巧的硬件设计和智能的能源管理,我们可以有效地降低计算机系统的能耗。这种降低能耗的努力不仅有助于节省能源资源,还有助于降低对环境的不良影响,为可持续发展贡献一份力量。
4.1.2 资源利用与回收
为实现可持续发展目标,我们需要在计算机硬件生产过程中更加精细地利用资源和材料。通过优化生产工艺,减少能源消耗,降低对有限资源的依赖,我们可以推动产业走向更为可持续的方向。同时,电子废弃物的处理和回收也是不可忽视的环保任务。确保废弃设备得到合理的处理,不仅有助于资源再利用,还可以减少环境污染,实现循环经济的理念。
4.1.3 绿色计算
绿色计算不仅仅是一种技术策略,更是一种对环境负责的态度。在计算机设计和运行中积极考虑环境因素,包括使用可再生能源、关注硬件设计的能效性,以及优化软件以减少资源占用,都是绿色计算的体现。这需要整个计算机行业的共同努力,以推动环保理念在计算机领域得到更广泛的应用。通过引入绿色计算的理念,我们可以为未来的可持续发展奠定坚实基础,使计算机技术更加环保、高效和可持续。
4.2 工程与社会
4.2.1 技术标准体系、知识产权、产业政策和法律法规
在工程实践中,遵循技术标准体系、保护知识产权以及理解产业政策和法律法规是确保项目合法、高效推进的基石。技术标准体系如ISO、IEEE为硬件和软件制定规范,为工程提供了明确的指导,有助于确保产品质量和可靠性。同时,保护知识产权激励创新,为团队提供了发展的动力。理解产业政策和法律法规,如《中华人民共和国著作权法》、《中华人民共和国专利法》等,有助于规避法律风险,确保项目在法律框架内运作,保障项目合法权益。
4.2.2 社会和市场制约下的工程实践
在社会和市场的动态变化下,工程实践面临多层面的挑战。灵活适应需求的变更,管理时间压力,保持法规合规性以及维护用户满意度都是工程师需要综合考虑的因素。需求的灵活变更可能受市场需求的波动影响,工程团队需要具备敏捷的开发流程,以适应市场的变化。时间压力是常见的挑战,竞争激烈的市场要求项目高效率地推进。法规合规性要求工程团队严格遵循相关法规,确保项目的合法性和可持续性。最终,用户满意度直接影响项目的成功,因此工程实践需要注重与社会和市场的良性互动,以达到项目的最终目标。
4.2.2 社会和市场制约下的工程实践
在生产实习项目中,社会和市场制约是工程实践中常见的挑战。这可能包括:
-
需求变更:受市场需求影响,项目需求可能频繁变化,需要灵活适应。
-
时间压力:市场竞争可能导致项目进度紧张,需要在有限时间内完成高质量的工作。
-
法规遵从:计算机项目需要符合相关法规,如数据隐私法规、网络安全法等。
-
用户满意度:社会反馈和用户满意度对项目成功至关重要。
4.3 个人与团队
4.3.1 个人与团队理解
在生产实习项目中,深刻理解个人在团队中的角色至关重要。明确个人的职责和团队的整体目标,培养卓越的团队协作和领导能力,是确保项目成功的关键。通过建立有效的沟通和理解,能够更好地融入团队,共同努力实现项目的目标。
4.3.2 个人开发流程
个人在项目中的开发流程不仅仅涉及技术方面,还需要注重高质量的需求分析、系统设计、编码实现以及全面的测试。个人的贡献质量直接影响整体项目的稳定性和可靠性。通过建立完善的开发流程,能够确保个人工作的高效性和质量,为团队的整体进展提供坚实基础。
4.3.3 团队开发流程
团队需要建立清晰而高效的开发流程,包括代码管理、版本控制、协同开发等。通过规范的流程,可以提高团队的工作效率,确保项目按计划有序推进。团队成员需充分理解和遵守开发流程,以协同合作、互相支持的方式推动项目的顺利完成。
4.3.4 团队协调问题
在团队内部,协调问题可能涉及到沟通不畅、任务分配不均等方面。及时解决这些问题,建立良好的团队协作氛围,是确保项目整体成功的必要条件。团队成员间的有效沟通和任务分工的平衡,直接关系到项目的质量和进度。因此,团队协调问题的解决需要敏锐的洞察力和积极的沟通方式。
第5章 总结与未来工作
5.1 实习总结
这次生产实习让我在STM32单片机编程的学习中迈出了重要一步,更为重要的是,我在嵌入式系统开发领域的实践中获得了全新的见解。通过实际任务的设计和完成,我不仅全面掌握了硬件与软件协同工作的紧密联系,还深刻理解了嵌入式系统在实际应用中的关键作用。
在SPI通信领域,我不仅着眼于基本功能的实现,还专注于系统能效的提升。通过算法的优化和硬件设计的巧妙选择,我成功减小了计算机系统的能耗,为可持续发展贡献了一份力量。
5.2 成果与亮点
我的工作重点在于LED控制、OLED显示和温湿度传感器数据采集。在LED控制方面,我实现了更为灵活的状态切换,使得系统能够更好地适应不同的应用场景。OLED显示和温湿度传感器数据采集不仅提高了系统的实用性,还为未来的功能拓展奠定了坚实基础。
特别值得一提的是通过串口指令控制LED状态和在OLED上实时显示温湿度,这些亮点不仅提升了系统的实用性,同时也增强了用户体验。这种全方位的功能实现为项目带来了可观的进展。
5.3 遇到的挑战
实习过程中,我面对了一系列具有挑战性的问题,其中包括SPI通信参数的调优和温湿度传感器数据精度处理等。这些挑战不仅考验了我的技术水平,更要求我在团队合作中找到最佳解决方案。
通过与团队密切合作,我逐渐攻克了这些技术难题。这一过程培养了我团队协作和问题解决的综合能力,使我更加熟悉面对实际问题时的决策思路。
5.4 未来工作展望
未来,我将持续致力于项目的完善,拟定以下工作计划:
- 优化系统性能,着力提高数据采集精度,以更好地应对日益复杂的应用场景;
- 增加更多传感器接入,扩展系统功能,使其更为全面且多样化;
- 引入RTOS实现多任务处理,提高系统并发性能,以适应未来更为复杂的任务需求。
5.5 结语
这次生产实习不仅是我学习STM32单片机编程的重要阶段,更是我深入嵌入式系统开发的宝贵历练。通过克服各种挑战,我不仅在技术上取得了巨大进步,也培养了更为全面的团队协作和问题解决能力。我期待未来在学业和职业中能够将这些经验充分发挥,持续进步并做出更有价值的贡献。
附录
结课代码
main.c
#include "stm32f10x.h"
#include "key.h"
#include "led.h"
#include "oled.h"
#include "stdio.h"
#include <stdlib.h>
#include "timer.h"
#include "dht.h"
#include <string.h>
extern const u8 gb2312_ziku[];
extern const u8 asc_ziku[];
extern const u8 gb2312_model[];
extern const u8 asc_model[];
extern const u8 an_ziku[];
extern const u8 an_model[];
extern const u8 cat_model[];
extern const u8 deng0_model[];
extern const u8 deng1_model[];
// 定义结构体,用于配置SPI参数
typedef struct {
uint16_t BaudRatePrescaler; // 波特率分频
uint16_t CPHA; // 时钟相位
uint16_t CPOL; // 时钟极性
uint16_t CRCPolynomial; // CRC校验
uint16_t DataSize; // 字长
uint16_t Direction; // 传输模式
uint16_t FirstBit; // 高/低位在前
uint16_t Mode; // SPI主/从模式
uint16_t Nss; // NSs
} SPI_Config;
// 函数原型
void SPI_Configuration(SPI_TypeDef* SPIx, SPI_Config* spiConfig);
// 模拟从传感器读取数据的函数
uint16_t ReadSensorData(void) {
return (uint16_t)rand();
}
// 初始化串口1
void SPI1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
SPI_InitTypeDef SPI_InitStruct;
//部分1: 管脚复用
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_2MHz;
GPIO_Init(GPIOB, &GPIO_InitStruct);
//部分2: SPI功能配置
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
SPI_InitStruct.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_16;
SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStruct.SPI_CRCPolynomial= 0x7;
SPI_InitStruct.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStruct.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
SPI_InitStruct.SPI_NSS = SPI_NSS_Soft;
SPI_Init(SPI1,&SPI_InitStruct);
SPI_Cmd(SPI1,ENABLE);
}
// 初始化 XCOM 串口
void XCOM_Init(void) {
// TODO: 根据具体的串口配置进行初始化
// 使用 USART2 作为例子
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
// 配置 USART1 的 TX 引脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 配置 USART1 的 RX 引脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 配置 USART1
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
// 使能 USART1
USART_Cmd(USART1, ENABLE);
}
// 发送字符串到 XCOM 串口
void XCOM_SendString(const char* str) {
while (*str) {
// 等待发送缓冲区为空
while (!(USART1->SR & USART_FLAG_TXE))
;
USART_SendData(USART1, *str++);
}
}
//延迟代码
void delay_ms(u16 nms) {
u32 temp;
SysTick->LOAD = 9000 * nms;
SysTick->VAL = 0x00;
SysTick->CTRL = 0x01;
do {
temp = SysTick->CTRL;
} while ((temp & 0x01) && (!(temp & (1 << 16))));
SysTick->CTRL = 0x00;
SysTick->VAL = 0x00;
}
void USART1_Configuration(void) {
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE);
}
void USART1_SendChar(char ch) {
USART_SendData(USART1, (uint8_t)ch);
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)
;
}
void circularFlowLight() {
static int currentLED = 0;
static int isDeng1 = 0; // 用于标记当前是显示 deng1_model 还是 deng0_model
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
if (isDeng1) {
OLED_drawPic(0, 0, 64, 64, deng1_model);
} else {
OLED_drawPic(0, 0, 64, 64, deng0_model);
}
switch (currentLED) {
case 0:
GPIO_SetBits(GPIOB, GPIO_Pin_11);
break;
case 1:
GPIO_SetBits(GPIOB, GPIO_Pin_14);
break;
case 2:
GPIO_SetBits(GPIOA, GPIO_Pin_11);
break;
default:
break;
}
delay_ms(500);
currentLED = (currentLED + 1) % 3;
isDeng1 = !isDeng1; // 切换到下一个图片
}
void xcomControlLED(char command) {
static int mode = 0;
switch (command) {
case '1':
// ?? XCOM ??????1
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
GPIO_SetBits(GPIOB, GPIO_Pin_11);
delay_ms(500);
GPIO_SetBits(GPIOB, GPIO_Pin_14);
delay_ms(500);
GPIO_SetBits(GPIOA, GPIO_Pin_11);
delay_ms(500);
break;
case '2':
OLED_CLear(0);
OLED_drawPic(0, 0, 64, 64, deng1_model);
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
GPIO_SetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
delay_ms(500);
GPIO_SetBits(GPIOA, GPIO_Pin_11);
delay_ms(500);
OLED_drawPic(0, 0, 64, 64, deng0_model);
delay_ms(500);
OLED_CLear(0);
break;
case '3':
OLED_CLear(0);
OLED_drawPic(0, 0, 64, 64, deng1_model);
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
GPIO_SetBits(GPIOA, GPIO_Pin_11);
delay_ms(500);
OLED_drawPic(0, 0, 64, 64, deng0_model);
delay_ms(500);
OLED_CLear(0);
break;
default:
// ???????
mode = 0;
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
break;
}
}
//打印温度计
void displayTemperature(double temperature, double humidity) {
char tempString[10];
char humString[10];
// Format temperature string
snprintf(tempString, sizeof(tempString), "T=%.2fDC", temperature);
// Format humidity string
snprintf(humString, sizeof(humString), "H=%.2f%%", humidity);
u8 lenTemp = strlen(tempString);
u8 lenHum = strlen(humString);
// Display temperature
for (u8 i = 0; i < lenTemp; i++) {
u8 index = 0;
if (tempString[i] == 'T') {
index = 11;
} else if (tempString[i] == '=') {
index = 12;
} else if (tempString[i] == '.') {
index = 13;
} else if (tempString[i] == 'D') {
index = 16;
} else if (tempString[i] == 'C') {
index = 10;
} else if (tempString[i] >= '0' && tempString[i] <= '9') {
index = tempString[i] - '0';
}
OLED_drawPic(i * 8, 0, 8, 16, (u8*)&asc_model[index * 16]);
}
// Display humidity on the next line
for (u8 i = 0; i < lenHum; i++) {
u8 index = 0;
if (humString[i] == 'H') {
index = 14;
} else if (humString[i] == '=') {
index = 12;
} else if (humString[i] == '.') {
index = 13;
} else if (humString[i] == '%') {
index = 15;
} else if (humString[i] >= '0' && humString[i] <= '9') {
index = humString[i] - '0';
}
OLED_drawPic(i * 8, 2, 8, 16, (u8*)&asc_model[index * 16]);
}
}
int main(void) {
// 初始化SPI
SPI1_Init();
// 初始化LED
LED_init();
// 初始化OLED
OLED_Init();
SystemInit();
dht_init();
OLED_Init();
XCOM_Init();
SystemInit();
SysTick_Config(SystemCoreClock / 1000);
key_init();
LED_init();
USART1_Configuration();
int flowLightEnabled = 0;
int xcomControlEnabled = 0;
OLED_drawPic(32, 0, 64, 64, cat_model);
double temperature = 0.0, humidity = 0.0;
int measureEnabled = 0;
while (1) {
u8 keyVal = key_scan(0);
if (flowLightEnabled == 1) {
circularFlowLight();
}
else if(flowLightEnabled == 0){
GPIO_ResetBits(GPIOB, GPIO_Pin_11 | GPIO_Pin_14);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
}
if (xcomControlEnabled && USART_GetFlagStatus(USART1, USART_FLAG_RXNE) != RESET) {
char command = USART_ReceiveData(USART1);
xcomControlLED(command);
}
switch (keyVal) {
case KEY_1:
OLED_CLear(0);
flowLightEnabled = 1;
xcomControlEnabled = 0; // 关闭XCOM控制模式
break;
case KEY_2:
OLED_CLear(0);
xcomControlEnabled = 1;
flowLightEnabled = 0; // 关闭流水灯
measureEnabled = 1;
break;
case KEY_3:
OLED_CLear(0);
xcomControlEnabled = 1;
flowLightEnabled = 0; // 关闭流水灯
measureEnabled = 0;
OLED_drawPic(32, 0, 64, 64, cat_model);
break;
// 添加其他按键对应的操作
default:
break;
}
if (measureEnabled) {
DHT_ERROR dhtResult = dht_measure(&temperature, &humidity);
if (dhtResult == ERR_NONE) {
char xcomString[50];
snprintf(xcomString, sizeof(xcomString), "Temperature: %.2fC, Humidity: %.2f%%\r\n", temperature, humidity);
XCOM_SendString(xcomString);
displayTemperature(temperature,humidity);
measureEnabled = 0;
}
else {
// 处理错误
measureEnabled = 0;
}
}
}
}
ziku.c
#include "stm32f10x.h"
const u8 gb2312_ziku[]= "云家居温湿度窗帘彩灯风扇";
//此数组需要和数组gb2312_model内容保持对应关系
//(文字顺序和字模出现顺序一致)
const u8 asc_ziku[]= "0123456789T=.°C";
//此数组需要和数组asc_model内容保持对应关系
//(文字顺序和字模出现顺序一致)
const u8 gb2312_model[]={
0x40,0x40,0x42,0x42,0x42,0x42,0xC2,0x42,0x42,0x42,0x42,0x42,0x42,0x40,0x40,0x00,
0x00,0x20,0x70,0x28,0x24,0x23,0x20,0x20,0x20,0x24,0x28,0x30,0xE0,0x00,0x00,0x00,/*"云",0*/
0x10,0x2C,0x24,0x24,0xA4,0xA4,0x65,0xA6,0x24,0x24,0x24,0x24,0xA4,0x34,0x0C,0x00,
0x40,0x49,0x49,0x29,0x24,0x14,0x52,0x89,0x7F,0x04,0x0A,0x11,0x10,0x20,0x20,0x00,/*"家",1*/
0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xF2,0x92,0x92,0x92,0x9E,0x80,0x80,0x00,
0x40,0x30,0x0F,0x00,0xFC,0x44,0x44,0x44,0x47,0x44,0x44,0x44,0xFC,0x00,0x00,0x00,/*"居",2*/
0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00,/*"温",3*/
0x10,0x60,0x02,0x8C,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x04,0x04,0x7E,0x01,0x44,0x48,0x50,0x7F,0x40,0x40,0x7F,0x50,0x48,0x44,0x40,0x00,/*"湿",4*/
0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,
0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00,/*"度",5*/
0x10,0x0C,0xC4,0x54,0x4C,0x64,0xD5,0x46,0x44,0x44,0x4C,0x54,0xC4,0x14,0x0C,0x00,
0x00,0x00,0xFF,0x40,0x44,0x62,0x55,0x49,0x55,0x43,0x40,0x40,0xFF,0x00,0x00,0x00,/*"窗",6*/
0x10,0x0C,0x44,0x24,0x14,0x04,0x05,0xC6,0x04,0x04,0x14,0x24,0x44,0x14,0x0C,0x00,
0x00,0x00,0x3F,0x01,0x01,0x01,0x01,0xFF,0x01,0x01,0x11,0x21,0x1F,0x00,0x00,0x00,/*"帘",7*/
0x00,0x14,0x64,0x04,0x0C,0xB2,0x02,0x23,0x1A,0x00,0x20,0x10,0x08,0x86,0x60,0x00,
0x40,0x21,0x11,0x0D,0x03,0xFF,0x05,0x09,0x11,0x80,0x84,0x42,0x21,0x10,0x0C,0x00,/*"彩",8*/
0x80,0x70,0x00,0xFF,0x20,0x10,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,
0x80,0x60,0x18,0x07,0x08,0x30,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,/*"灯",9*/
0x00,0x00,0xFE,0x02,0x12,0x22,0xC2,0x02,0xC2,0x32,0x02,0xFE,0x00,0x00,0x00,0x00,
0x80,0x60,0x1F,0x00,0x20,0x10,0x0C,0x03,0x0C,0x30,0x00,0x0F,0x30,0x40,0xF8,0x00,/*"风",10*/
0x00,0x00,0xFC,0x24,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x24,0x24,0x3C,0x00,0x00,
0x40,0x30,0x0F,0x21,0x15,0x49,0x81,0x7F,0x00,0x21,0x15,0x49,0x81,0x7F,0x00,0x00,/*"扇",11*/
};
const u8 asc_model[]={
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*"0",0*/
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,/*"1",1*/
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*"2",2*/
0x00,0x30,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00,/*"3",3*/
0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00,0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24,/*"4",4*/
0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x20,0x20,0x20,0x11,0x0E,0x00,/*"5",5*/
0x00,0xE0,0x10,0x88,0x88,0x90,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x20,0x1F,0x00,/*"6",6*/
0x00,0x18,0x08,0x08,0x88,0x68,0x18,0x00,0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00,/*"7",7*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,/*"8",8*/
0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00,0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00,/*"9",9*/
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,/*"C",10*/
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,/*"T",10*/
0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x00,/*"=",11*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,/*".",12*/
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,/*"H",0*/
0xF0,0x08,0xF0,0x80,0x60,0x18,0x00,0x00,0x00,0x31,0x0C,0x03,0x1E,0x21,0x1E,0x00,/*"%",0*/
0x00,0x00,0x30,0x48,0x48,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"°",13*/
};
const u8 cat_model[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x70,0x0E,0x01,0x00,0x00,0x0F,0x70,0x40,0x20,0x20,0x20,0x20,
0x20,0x20,0x60,0x40,0x38,0x07,0x00,0x00,0x01,0x1E,0xE0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x60,0x10,0x08,
0x04,0x02,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0xE0,0xC0,0x00,0x00,0x00,0x80,0x80,
0x80,0x00,0x00,0x00,0xE0,0xC0,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x04,0x0C,0x18,
0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0xE3,0x00,0x00,0x00,
0x00,0x08,0x0A,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x08,0x0C,0x07,
0x08,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x08,0x0A,0x12,0x12,0x12,0x00,0x00,0x00,
0x00,0xC0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x06,0x08,
0x10,0x30,0x20,0x40,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x40,0x20,0x20,0x10,0x08,0x04,
0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"C:\Users\HP\Pictures\Camera Roll\m.bmp",0*/
};
const u8 deng0_model[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x60,0x10,0x08,0x04,0x02,0x02,0x01,0x01,0x00,0x00,0x00,0x00,
0x02,0x05,0x06,0x19,0xC1,0x08,0x32,0x0C,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0x60,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80,
0x00,0x00,0x00,0x00,0x3F,0x20,0x18,0xC0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x60,0x80,0x07,0x82,0xF7,0x85,0x84,0xE7,
0x8C,0x01,0x01,0x40,0x90,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x26,0xDC,0x50,0x50,0x00,0x00,0x00,0x40,
0x44,0x04,0xA0,0xE4,0x1B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x0E,0x0A,0x02,0x08,
0x05,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"E:\2?á?\png\2.bmp",0*/
};
const u8 deng1_model[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x50,0x00,0x00,
0x00,0x00,0x00,0x80,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x84,0x40,0x20,0x20,0x00,0x10,0x01,0x00,0x00,0x00,
0x50,0x40,0x90,0x10,0x80,0x00,0x80,0x00,0x00,0x08,0x02,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x01,
0x01,0x01,0x01,0x00,0x8C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFC,0x00,0xC3,0x00,0xFE,0x00,0x00,0x00,0x40,0x20,0x20,0x20,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x20,0x20,0x00,
0x10,0x08,0x08,0x00,0x01,0x04,0x08,0x30,0x80,0x00,0x38,0x30,0x3C,0x20,0x1C,0xE0,
0x18,0x1C,0x00,0xC1,0x11,0x08,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x95,0x72,0x40,0x00,0x00,0x20,0x02,0x12,
0x12,0x92,0x93,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x05,0x0C,0x10,0x22,0x25,0x14,
0x08,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"E:\2?á?\png\3.bmp",0*/
};
参考文献
[1] STMicroelectronics. (2022). “STM32F10x Reference Manual.” Retrieved from https://www.st.com/resource/en/reference_manual/cd00171190-stm32f10xxx-stm32f10xxx-high-density-value-line-stmicroelectronics.pdf
[2] Keil. “Keil MDK-ARM Development Tools.” Retrieved from https://www.keil.com/
[3] CubeMX. “STM32CubeMX.” Retrieved from https://www.st.com/en/development-tools/stm32cubemx.html
[4] Adafruit Industries. “DHT Sensor Library.” Retrieved from https://learn.adafruit.com/dht
[5] Adafruit Industries. “OLED Display Library.” Retrieved from https://learn.adafruit.com/monochrome-oled-breakouts
[6] Smith, J. (Year). “Title of the Paper.” Journal Name, Volume(Issue), Page Range.
[7] Author, A. B. (Year). “Book Title.” Publisher.
[8] Institute of Electrical and Electronics Engineers. (Year). “Title of the Standard.” Standard Number.
[9] Lastname, F. (Year). “Title of the Thesis or Dissertation.” Institution.
[10] Webpage Author. (Year). “Title of the Webpage.” Website Name. URL.
[11] Conference Author. (Year). “Title of the Paper.” In Proceedings of the Conference Name (pp. Page Range). Publisher.
[12] National Institute of Standards and Technology. (Year). “Title of the Report.” Report Number.
[13] Digital Object Identifier Foundation. “DOI System.” Retrieved from https://www.doi.org/
[14] World Health Organization. (Year). “Title of the Report.” Report Number. Retrieved from https://www.who.int/
[15] Your Mentor’s Name. (Year). “Title of the Personal Communication.”