Add default tilt sensitivity get function

Added `relay_chn_tilt_get_default_sensitivity` function and test cases.

Refs #1085 and fixes #1101
This commit is contained in:
2025-09-04 16:16:10 +03:00
parent ad377ebfc8
commit 7bafc4845f
4 changed files with 39 additions and 0 deletions

View File

@@ -322,6 +322,17 @@ TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivi
TEST_ASSERT_EQUAL_UINT8_ARRAY(expect, vals, CONFIG_RELAY_CHN_COUNT);
}
TEST_CASE("relay_chn_tilt_get_default_sensitivity returns correct value", "[relay_chn][tilt][sensitivity]")
{
// The default sensitivity is calculated from default timing values.
// Default run time: 15ms, Min run time: 50ms, Max run time: 10ms.
// Formula: ( (DEFAULT_RUN - MIN_RUN) * 100 ) / (MAX_RUN - MIN_RUN)
// ( (15 - 50) * 100 ) / (10 - 50) = (-35 * 100) / -40 = -3500 / -40 = 87.5
// As integer arithmetic, this is 87.
uint8_t expected_sensitivity = 87;
TEST_ASSERT_EQUAL_UINT8(expected_sensitivity, relay_chn_tilt_get_default_sensitivity());
}
// Test sensitivity upper boundary for all set functions
TEST_CASE("relay_chn_tilt_set_sensitivity functions handle upper boundary", "[relay_chn][tilt][sensitivity]")
{

View File

@@ -205,6 +205,17 @@ TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivi
TEST_ASSERT_EQUAL_UINT8(42, relay_chn_tilt_get_sensitivity());
}
TEST_CASE("relay_chn_tilt_get_default_sensitivity returns correct value", "[relay_chn][tilt][sensitivity]")
{
// The default sensitivity is calculated from default timing values.
// Default run time: 15ms, Min run time: 50ms, Max run time: 10ms.
// Formula: ( (DEFAULT_RUN - MIN_RUN) * 100 ) / (MAX_RUN - MIN_RUN)
// ( (15 - 50) * 100 ) / (10 - 50) = (-35 * 100) / -40 = -3500 / -40 = 87.5
// As integer arithmetic, this is 87.
uint8_t expected_sensitivity = 87;
TEST_ASSERT_EQUAL_UINT8(expected_sensitivity, relay_chn_tilt_get_default_sensitivity());
}
// Test sensitivity upper boundary
TEST_CASE("relay_chn_tilt_set_sensitivity handles upper boundary", "[relay_chn][tilt][sensitivity]")
{