225 lines
8.0 KiB
C
225 lines
8.0 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file fm33lg0xx_fl_common.c
|
|
* @author Motor Control SDK Team, Yuwell Software XiangenWang
|
|
* @brief Voice Recognition Module Initialization Section,
|
|
including peripheral initialization and message node insertion, etc.
|
|
* @version 1.0
|
|
* @changelog version 1.0 初始版本 2025.11.13
|
|
- 新增:新建第一个版本的软件,待完善解析命令后的程序执行部分
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* <h2><center>© Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China.
|
|
* All rights reserved.</center></h2>
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted, provided that the following conditions are met:
|
|
*
|
|
* 1. Redistribution of source code must retain the above copyright notice,
|
|
* this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
* and/or other materials provided with the distribution.
|
|
* 3. Neither the name of Yuwell Software nor the names of other
|
|
* contributors to this software may be used to endorse or promote products
|
|
* derived from this software without specific written permission.
|
|
* 4. This software, including modifications and/or derivative works of this
|
|
* software, must execute solely and exclusively on microcontroller or
|
|
* microprocessor devices manufactured by or for Yuwell Software.
|
|
* 5. Redistribution and use of this software other than as permitted under
|
|
* this license is void and will automatically terminate your rights under
|
|
* this license.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY Yuwell Software AND CONTRIBUTORS "AS IS"
|
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
|
* SHALL Yuwell Software OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
#include "fm33lg0xx_fl_common.h"
|
|
|
|
|
|
|
|
void total_time_record_task(void)
|
|
{
|
|
static uint16_t ms_count = 0;
|
|
|
|
// 记录本次开机累计运行的时间
|
|
static uint32_t current_seconds = 0;
|
|
static uint32_t current_minutes = 0;
|
|
static uint32_t current_hours = 0;
|
|
|
|
MsgQueueItem queue_item_time_send;
|
|
MsgQueueItem qitem_current_time_modify;
|
|
MsgQueueItem filter_item;
|
|
|
|
if(ms_count < 10) // 在后台悄摸刷新累时 1秒钟刷新一次全局变量
|
|
{
|
|
ms_count++;
|
|
}else{
|
|
|
|
ms_count = 0;
|
|
if(ui.disp_info.work_seconds < 59)
|
|
{
|
|
ui.disp_info.work_seconds++;
|
|
}else{
|
|
ui.disp_info.work_seconds = 0;
|
|
|
|
if(ui.disp_info.work_minutes < 59)
|
|
{
|
|
|
|
ui.disp_info.work_minutes++;
|
|
queue_item_time_send.type = MSG_TYPE_MINUTE_SAVE;
|
|
queue_item_time_send.data.hour_meter.minute = ui.disp_info.work_minutes;
|
|
insert_queue_node_in_head(&global_queue, queue_item_time_send); // 向队列中插入一个分钟数存储消息
|
|
|
|
}else{
|
|
|
|
ui.disp_info.work_minutes = 1;
|
|
queue_item_time_send.type = MSG_TYPE_MINUTE_SAVE;
|
|
queue_item_time_send.data.hour_meter.minute = ui.disp_info.work_minutes;
|
|
insert_queue_node_in_head(&global_queue, queue_item_time_send); // 向队列中插入一个分钟数存储消息
|
|
|
|
ui.disp_info.work_hours++;
|
|
queue_item_time_send.type = MSG_TYPE_HOUR_SAVE;
|
|
queue_item_time_send.data.hour_meter.hour = ui.disp_info.work_hours;
|
|
insert_queue_node_in_head(&global_queue, queue_item_time_send); // 向队列中插入一个小时数存储消息
|
|
|
|
|
|
peek_queue_node_by_type(&global_queue, MSG_TYPE_FILTER_SERVER, &filter_item);
|
|
|
|
// 1800小时换一次滤盒、100小时清洁一次滤清器 出现标志后重新开机可取消显示等待下个周期重新显示
|
|
if(ui.disp_info.work_hours%100 == 0) // 到达第100小时
|
|
{
|
|
|
|
if(ui.disp_info.work_hours%1800 == 0)
|
|
{
|
|
|
|
if((ui.disp_info.work_hours > filter_item.data.filter_server.last_replace_filter_hours)&&
|
|
!xOxygenEventGroupCheckBit(&global_event, EVENT_REPLACE_FILTER_NOTIFY))
|
|
{
|
|
|
|
vOxygenEventGroupSetBits(&global_event, EVENT_CLEAN_FILTER_NOTIFY);
|
|
vOxygenEventGroupSetBits(&global_event, EVENT_REPLACE_FILTER_NOTIFY);
|
|
|
|
// 向EEPROM中写入当前清理滤清器的时间
|
|
filter_item.data.filter_server.last_clean_filter_hours = ui.disp_info.work_hours;
|
|
filter_item.data.filter_server.last_replace_filter_hours = ui.disp_info.work_hours;
|
|
filter_item.data.filter_server.clean_filter_time_need_stored = true;
|
|
filter_item.data.filter_server.replace_filter_time_need_stored = true;
|
|
|
|
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_FILTER_TIME_SAVE, filter_item);
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
if((ui.disp_info.work_hours > filter_item.data.filter_server.last_clean_filter_hours)&&
|
|
!xOxygenEventGroupCheckBit(&global_event, EVENT_CLEAN_FILTER_NOTIFY))
|
|
{
|
|
|
|
vOxygenEventGroupSetBits(&global_event, EVENT_CLEAN_FILTER_NOTIFY);
|
|
|
|
// 向EEPROM中写入当前清理滤清器的时间
|
|
filter_item.data.filter_server.last_clean_filter_hours = ui.disp_info.work_hours;
|
|
filter_item.data.filter_server.clean_filter_time_need_stored = true;
|
|
filter_item.data.filter_server.replace_filter_time_need_stored = false;
|
|
|
|
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_FILTER_TIME_SAVE, filter_item);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// 本次开机时间累加
|
|
if(current_seconds < 60)
|
|
{
|
|
current_seconds++; // 累加一秒钟
|
|
qitem_current_time_modify.type = MSG_TYPE_CURRENT_TIME;
|
|
|
|
qitem_current_time_modify.data.hour_meter.second = current_seconds;
|
|
qitem_current_time_modify.data.hour_meter.minute = current_minutes;
|
|
qitem_current_time_modify.data.hour_meter.hour = current_hours;
|
|
|
|
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_CURRENT_TIME, qitem_current_time_modify);
|
|
|
|
}else{
|
|
|
|
current_seconds = 0; // 满一分钟 清零
|
|
|
|
if(current_minutes < 60)
|
|
{
|
|
current_minutes++;
|
|
}else{
|
|
|
|
current_minutes = 1;
|
|
|
|
if(current_hours < 4000000000) // 单次运行最大记录四十亿小时
|
|
{
|
|
current_hours++;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void led_blink_task(void)
|
|
{
|
|
|
|
static uint16_t state_led_blink_count = 0;
|
|
|
|
const uint16_t BLINK_FREQ_HZ = 2; // 定义闪烁频率为1s一次 可选频率为1Hz 2Hz 5Hz 10Hz
|
|
|
|
MsgQueueItem stm_item;
|
|
|
|
peek_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, &stm_item); // 取出当前节点关于系统状态的记录
|
|
|
|
if(stm_item.data.state_machine.oxg_stm == STM_INIT) // 根据状态机确定LED显示状态
|
|
{
|
|
STATE_LED_ON;
|
|
return;
|
|
}
|
|
|
|
if(state_led_blink_count == 10/BLINK_FREQ_HZ)
|
|
{
|
|
STATE_LED_TOGGLE;
|
|
|
|
|
|
state_led_blink_count = 1;
|
|
}else{
|
|
|
|
state_led_blink_count++;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************ (C) COPYRIGHT FMSH *****END OF FILE****/
|
|
|