F1CTL/Core/Src/bubble.c

75 lines
2.2 KiB
C
Raw Normal View History

2024-12-17 07:57:50 +00:00
// 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;
}
}