General code and comment cleanup

This commit is contained in:
2025-09-04 16:59:00 +03:00
parent 7244b57061
commit bf5e3a4426
25 changed files with 213 additions and 218 deletions

View File

@@ -30,7 +30,7 @@ void prepare_channels_for_tilt_with_mixed_runs() {
// Ensure the channel reset tilt control
relay_chn_tilt_stop_all();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
// Ensure the channel has had a 'last_run_cmd'
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
if (i % 2 == 0) {
@@ -39,7 +39,7 @@ void prepare_channels_for_tilt_with_mixed_runs() {
relay_chn_run_reverse(i);
}
}
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); // Allow command to process
relay_chn_stop_all(); // Stop it to set last_run_cmd but return to FREE for next test
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
@@ -60,11 +60,11 @@ void prepare_all_channels_for_tilt(int initial_cmd) {
break;
}
}
if (not_idle) {
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS));
}
// Ensure the channel has had a 'last_run_cmd'
if (initial_cmd == RELAY_CHN_CMD_FORWARD) {
relay_chn_run_forward_all();
@@ -74,7 +74,7 @@ void prepare_all_channels_for_tilt(int initial_cmd) {
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); // Allow command to process
relay_chn_stop_all(); // Stop all to set last_run_cmd but return to FREE for next test
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_IDLE);
}
@@ -86,15 +86,15 @@ TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][ti
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
// 1. Start in forward direction
relay_chn_run_forward_all();
relay_chn_run_forward_all();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_FORWARD);
// 2. Issue tilt forward command
relay_chn_tilt_forward_all();
relay_chn_tilt_forward_all();
// After tilt command, it should immediately stop and then trigger inertia.
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_STOPPED);
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_STOPPED);
// Wait for the inertia period (after which the tilt command will be dispatched)
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS));
@@ -109,12 +109,12 @@ TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][ti
prepare_all_channels_for_tilt(RELAY_CHN_CMD_REVERSE);
// 1. Start in reverse direction
relay_chn_run_reverse_all();
relay_chn_run_reverse_all();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE);
// 2. Issue tilt reverse command
relay_chn_tilt_reverse_all();
relay_chn_tilt_reverse_all();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_STOPPED);
@@ -130,9 +130,9 @@ TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
// Issue tilt forward command
relay_chn_tilt_forward_all();
relay_chn_tilt_forward_all();
// From FREE state, tilt command should still incur the inertia due to the internal timer logic
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_TILT_FORWARD);
}
@@ -144,7 +144,7 @@ TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn
prepare_all_channels_for_tilt(RELAY_CHN_CMD_REVERSE);
// Issue tilt reverse command
relay_chn_tilt_reverse_all();
relay_chn_tilt_reverse_all();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_TILT_REVERSE);
}
@@ -160,7 +160,7 @@ TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][ti
check_all_channels_for_state(RELAY_CHN_STATE_TILT_FORWARD);
// 2. Issue run forward command
relay_chn_run_forward_all();
relay_chn_run_forward_all();
// From Tilt to Run in the same logical name but in the opposite direction, inertia is expected.
check_all_channels_for_state(RELAY_CHN_STATE_FORWARD_PENDING);
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
@@ -178,7 +178,7 @@ TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][ti
check_all_channels_for_state(RELAY_CHN_STATE_TILT_REVERSE);
// 2. Issue run reverse command
relay_chn_run_reverse_all();
relay_chn_run_reverse_all();
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE_PENDING);
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE);
@@ -195,7 +195,7 @@ TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn]
check_all_channels_for_state(RELAY_CHN_STATE_TILT_FORWARD);
// 2. Issue run reverse command (opposite direction)
relay_chn_run_reverse_all();
relay_chn_run_reverse_all();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE);
}
@@ -251,7 +251,7 @@ TEST_CASE("tilt_stop_all stops all tilting channels", "[relay_chn][tilt][batch]"
{
// 1. Prepare and start all channels tilting forward
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward_all();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
@@ -279,7 +279,7 @@ TEST_CASE("tilt_auto_all tilts channels based on last run direction", "[relay_ch
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
relay_chn_state_t state = i % 2 == 0 ?
RELAY_CHN_STATE_TILT_FORWARD : RELAY_CHN_STATE_TILT_REVERSE;
TEST_ASSERT_EQUAL(state, relay_chn_get_state(i));
}
}
@@ -319,11 +319,11 @@ TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivi
TEST_ASSERT_EQUAL_UINT8(100, relay_chn_tilt_get_sensitivity(ch));
// Set all channels
relay_chn_tilt_set_sensitivity_all_with(42);
uint8_t vals[CONFIG_RELAY_CHN_COUNT] = {0};
uint8_t expect[CONFIG_RELAY_CHN_COUNT];
memset(expect, 42, CONFIG_RELAY_CHN_COUNT);
TEST_ESP_OK(relay_chn_tilt_get_sensitivity_all(vals));
TEST_ASSERT_EQUAL_UINT8_ARRAY(expect, vals, CONFIG_RELAY_CHN_COUNT);
}
@@ -371,7 +371,6 @@ TEST_CASE("relay_chn_tilt_set_sensitivity functions handle upper boundary", "[re
// Test tilt counter logic: forward x3, reverse x3, extra reverse fails
TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][tilt][counter]")
{
// Tilt execution time at 100% sensitivity in milliseconds (10 + 90)
#define TEST_TILT_EXECUTION_TIME_MS 100