mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
删除RTC,改用TIM进行非中断定时时间戳
This commit is contained in:
@@ -56,6 +56,7 @@ static void main_timer_cb(lv_timer_t * timer)
|
||||
{
|
||||
// 1s 刷新一次全屏,防止有时候不知什么原因的LCD刷新错误(需要后续找到问题从根本解决)
|
||||
ui_full_screen_refresh(lv_screen_active());
|
||||
ui_GetElapsedTime_HMS(NULL, NULL, NULL); // 更新经过时间计数器
|
||||
}
|
||||
|
||||
////////////////////////// Animation //////////////////////
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Project name: PowerPico
|
||||
|
||||
#include "BL24C02.h" // system settings
|
||||
#include "rtc.h" // elapsed time
|
||||
#include "tim.h" // elapsed time
|
||||
#include "data_queue.h" // bsp/data_queue.h for voltage/current queues
|
||||
#include "user_PDUFPTask.h" // comunicate with PD UFP Task
|
||||
|
||||
@@ -19,10 +19,30 @@ void ui_full_screen_refresh(lv_obj_t * screen) {
|
||||
|
||||
//////////// interface for system hw settings ///////////
|
||||
|
||||
// get functions
|
||||
//////////////// get functions ///////////////
|
||||
|
||||
uint64_t ui_GetElaspseMicroseconds(void) {
|
||||
return GetMicrosecondCounter();
|
||||
}
|
||||
|
||||
// 获取经过的时间, 单位为时分秒, 必须定时运行以更新32位计数器溢出
|
||||
void ui_GetElapsedTime_HMS(uint8_t *hours, uint8_t *minutes, uint8_t *seconds) {
|
||||
GetElapsedTime_HMS(hours, minutes, seconds);
|
||||
// 1. 更新64位计数器
|
||||
UpdateMicrosecondCounter();
|
||||
|
||||
// 2. 基于更新后的64位计数值进行计算
|
||||
uint64_t total_us = GetMicrosecondCounter();
|
||||
uint32_t total_seconds = total_us / 1000000;
|
||||
|
||||
if (hours) {
|
||||
*hours = (total_seconds / 3600); // 这里不取模,可以显示超过24小时
|
||||
}
|
||||
if (minutes) {
|
||||
*minutes = (total_seconds % 3600) / 60;
|
||||
}
|
||||
if (seconds) {
|
||||
*seconds = total_seconds % 60;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ui_get_back_light_level(void) {
|
||||
@@ -49,7 +69,11 @@ float ui_get_current(void) {
|
||||
return queue_average(global_current_queue);
|
||||
}
|
||||
|
||||
// set functions
|
||||
//////////////// set functions ///////////////
|
||||
|
||||
void ui_clear_microsecond_counter(void) {
|
||||
ClearMicrosecondCounter();
|
||||
}
|
||||
|
||||
void ui_set_back_light_level(uint8_t level) {
|
||||
Sys_Set_BacklightLevel(level);
|
||||
@@ -67,7 +91,7 @@ void ui_set_display_rotation(uint16_t rotation) {
|
||||
Sys_Set_Rotation(rotation);
|
||||
}
|
||||
|
||||
// sys save function
|
||||
//////////////// sys save functions ///////////////
|
||||
void ui_system_settings_save(void) {
|
||||
EEPROM_SysSetting_Save();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ void ui_full_screen_refresh(lv_obj_t * screen);
|
||||
|
||||
// get functions
|
||||
|
||||
uint64_t ui_GetElapsedMicroseconds(void);
|
||||
void ui_GetElapsedTime_HMS(uint8_t *hours, uint8_t *minutes, uint8_t *seconds);
|
||||
uint8_t ui_get_back_light_level(void);
|
||||
bool ui_get_key_sound_enable(void);
|
||||
@@ -29,6 +30,7 @@ float ui_get_current(void);
|
||||
|
||||
// set functions
|
||||
|
||||
void ui_clear_microsecond_counter(void);
|
||||
void ui_set_back_light_level(uint8_t level);
|
||||
void ui_set_key_sound_enable(bool enable);
|
||||
void ui_set_language_select(uint8_t lang);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "tim.h"
|
||||
#include "stm32f4xx_it.h"
|
||||
#include "adc.h"
|
||||
#include "rtc.h"
|
||||
#include "i2c.h"
|
||||
|
||||
// user
|
||||
#include "user_TasksInit.h"
|
||||
|
||||
@@ -96,8 +96,8 @@ void HardwareInitTask(void *argument)
|
||||
// lcd
|
||||
// done in lvgl disp init
|
||||
|
||||
// rtc
|
||||
SetReferenceTime();
|
||||
// tim5 for elapsed time (us)
|
||||
HAL_TIM_Base_Start(&htim5);
|
||||
|
||||
// ui
|
||||
// LVGL and disp init
|
||||
|
||||
Reference in New Issue
Block a user