From 4638f385c8b66e798ae6fb02d376dc66abc51e14 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sat, 12 Apr 2025 22:01:18 +0800 Subject: [PATCH] update --- Project.uvoptx | 103 +++++++++++++++++++++++++++++++----------------- Project.uvprojx | 30 +++++++++++--- Src/main.cpp | 2 +- Src/ztOLED.hpp | 29 +++++++++----- 4 files changed, 112 insertions(+), 52 deletions(-) diff --git a/Project.uvoptx b/Project.uvoptx index 16ee25b..95e1ee0 100644 --- a/Project.uvoptx +++ b/Project.uvoptx @@ -146,24 +146,7 @@ UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) - - - 0 - 0 - 21 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\Src\main.cpp - - -
-
+ 0 @@ -217,7 +200,7 @@ Start - 0 + 1 0 0 0 @@ -248,18 +231,6 @@ 1 3 - 2 - 0 - 0 - 0 - .\Start\startup_stm32f10x_md.s - startup_stm32f10x_md.s - 0 - 0 - - - 1 - 4 5 0 0 @@ -271,7 +242,7 @@ 1 - 5 + 4 5 0 0 @@ -281,6 +252,18 @@ 0 0 + + 1 + 5 + 2 + 0 + 0 + 0 + .\Start\startup_stm32f10x_md.s + startup_stm32f10x_md.s + 0 + 0 + @@ -609,6 +592,54 @@ 0 0 + + 3 + 32 + 5 + 0 + 0 + 0 + .\Src\OLED.h + OLED.h + 0 + 0 + + + 3 + 33 + 5 + 0 + 0 + 0 + .\Src\OLED_Font.h + OLED_Font.h + 0 + 0 + + + 3 + 34 + 5 + 0 + 0 + 0 + .\Src\ztLed.hpp + ztLed.hpp + 0 + 0 + + + 3 + 35 + 5 + 0 + 0 + 0 + .\Src\ztOLED.hpp + ztOLED.hpp + 0 + 0 + @@ -619,7 +650,7 @@ 0 4 - 32 + 36 5 0 0 @@ -631,7 +662,7 @@ 4 - 33 + 37 1 0 0 @@ -643,7 +674,7 @@ 4 - 34 + 38 5 0 0 @@ -655,7 +686,7 @@ 4 - 35 + 39 1 0 0 diff --git a/Project.uvprojx b/Project.uvprojx index 346bad5..a0231ca 100644 --- a/Project.uvprojx +++ b/Project.uvprojx @@ -390,11 +390,6 @@ 5 .\Start\core_cm3.h - - startup_stm32f10x_md.s - 2 - .\Start\startup_stm32f10x_md.s - stm32f10x.h 5 @@ -405,6 +400,11 @@ 5 .\Start\system_stm32f10x.h + + startup_stm32f10x_md.s + 2 + .\Start\startup_stm32f10x_md.s + @@ -545,6 +545,26 @@ 5 .\Src\Delay.hpp + + OLED.h + 5 + .\Src\OLED.h + + + OLED_Font.h + 5 + .\Src\OLED_Font.h + + + ztLed.hpp + 5 + .\Src\ztLed.hpp + + + ztOLED.hpp + 5 + .\Src\ztOLED.hpp + diff --git a/Src/main.cpp b/Src/main.cpp index fcd5428..ee404d8 100644 --- a/Src/main.cpp +++ b/Src/main.cpp @@ -23,6 +23,6 @@ int main(){ leda0.setOff(); ledc13.setOn(); delay_ms(delayTime); - oled.ShowUNum(4, 6, time,10); + oled.ShowUNum(4, 6, time); } } \ No newline at end of file diff --git a/Src/ztOLED.hpp b/Src/ztOLED.hpp index 2422eef..573ab5d 100644 --- a/Src/ztOLED.hpp +++ b/Src/ztOLED.hpp @@ -5,8 +5,6 @@ #include "stm32f10x_rcc.h" #include "OLED_Font.h" #include -#include -#include namespace zt{ class Oled{ @@ -254,16 +252,27 @@ namespace zt{ } return *this; } - Oled&ShowUNum(const uint8_t line, const uint8_t column, uint8_t number){ - std::list chars; - while(number>0){ - chars.push_front(number%10); - number/=10; + Oled& ShowUNum(uint8_t Line, uint8_t Column, uint32_t Number) { + // 特殊情况处理:如果数字为0 + if (Number == 0) { + ShowChar(Line, Column, '0'); + return *this; } - std::list::iterator it = chars.begin(); - for(uint8_t i=0;i 0) { + temp /= 10; + Length++; } + + // 显示每一位数字 + for (uint8_t i = 0; i < Length; i++) { + char digit = (Number / Pow(10, Length - i - 1)) % 10 + '0'; // 将数字转换为字符 + ShowChar(Line, Column + i, digit); // 在指定位置显示字符 + } + return *this; }