From d517a825c688a35bb0d4441726fc42a2cef118ae Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Thu, 09 Oct 2025 00:25:54 +0800 Subject: [PATCH] OLED显示屏示例程序 --- Core/Src/main.c | 35 ++++++++++++++++++++++------------- 1 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index b804c64..5f8f55a 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -19,6 +19,7 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "adc.h" +#include "spi.h" #include "tim.h" #include "usart.h" #include "gpio.h" @@ -26,7 +27,9 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "miscdev.h" -#include "ds18b20.h" +#include "sht20.h" +#include "w25q.h" +#include "hal_oled.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -69,8 +72,8 @@ { /* USER CODE BEGIN 1 */ - int rv; - float temperature; + int pos_x = 25; + int pos_y = 1; /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ @@ -95,24 +98,30 @@ MX_ADC1_Init(); MX_TIM6_Init(); MX_TIM1_Init(); + MX_SPI1_Init(); /* USER CODE BEGIN 2 */ + beep_start(2, 300); + OLED_Init(); + /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { - rv = ds18b20_sample( &temperature); - if( rv < 0 ) - { - printf("ERROR: DS18B20 sample data failure, rv=%d\r\n", rv); - } - else - { - printf("DS18B20 sample temperature: %.3f\r\n", temperature); - } - HAL_Delay(1000); + OLED_Clear(); + OLED_ShowString(pos_x, pos_y, "ISKBoard", OLED_FONT16); + HAL_Delay(1000); + + OLED_Clear(); + for(int i=0; i<HZK_LEN_LINGYUN; i++) + OLED_ShowChinese(Hzk_LingYun, pos_x+i*16, pos_y, i); + HAL_Delay(1000); + + OLED_Clear(); + OLED_DrawBMP(0,0, X_WIDTH,Y_WIDTH/2, bmp_logo); + HAL_Delay(1000); /* USER CODE END WHILE */ -- Gitblit v1.9.1