F1CTL/Core/Src/bubble.c
2024-12-17 15:57:50 +08:00

75 lines
2.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Interface Mode 6 / 7
// The output is configured as PWM output, the input is configured as test input.
/*
+----------------------------+----------+--------------------------------------------+
| mode | Priority | ABD-OUT |
+----------------------------+----------+--------------------------------------------+
| Liquid/small-bubbles | Low | PWM-signal:20-<80%,represents-bubble-size |
+----------------------------+----------+--------------------------------------------+
| Air/Bubble | Medium | 80% |
+----------------------------+----------+--------------------------------------------+
| Internal-error(self-test) | High | 90% |
+----------------------------+----------+--------------------------------------------+
| Serious-fault(watchdog) | Highest | Static-H |
+----------------------------+----------+--------------------------------------------+
| Start-Mode | -- | H |
+----------------------------+----------+--------------------------------------------+
| Boot-mode | -- | UART-Tx |
+----------------------------+----------+--------------------------------------------+
*/
#include "bubble.h"
#define DELTA 1
/**
* 初始化
*
* @return 0:成功 其他:失败
*/
uint8_t bubble_init(void)
{
return 0;
}
/**
* 设置模式
*
* @param mode 模式
* @return 0:成功 其他:失败
*/
uint8_t bubble_set_mode(uint8_t mode)
{
return 0;
}
/**
* 获取气泡大小
*
* @return 气泡大小,20-80%/小气泡80-90%/大气泡90%以上/故障
*/
uint8_t bubbleGetSize(void)
{
return getPWMDutyCycle();
}
/**
* 获取气泡状态
*
* @return 气泡状态,0:无气泡,1:有气泡,2:故障
*/
uint8_t bubbleGetStatus(void)
{
uint8_t size = bubbleGetSize();
if (size < (80 - DELTA))
{
return 0;
}
else if (size >= (80 - DELTA) && size < (90 + DELTA))
{
return 1;
}
else if (size <= (90 + DELTA) && size >= (90 - DELTA))
{
return 2;
}
}