Skip to content

Commit c6bb80d

Browse files
committed
Fixed load control?
1 parent dd68699 commit c6bb80d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,15 +417,15 @@ vTaskAdjustLoad([[maybe_unused]] void *pvParameters) { // NOSONAR
417417
// ESP_LOGI(TAG, "Pitch PID Output: %f",
418418
// pitchPIDController.compute(
419419
// i)); // todo - just a quick performances test
420-
i += 20;
421-
static int_fast32_t lastPower = 0;
420+
// i += 20;
421+
static int_fast32_t lastPower = INT_FAST32_MIN;
422422
static int_fast8_t powerIndex = 46;
423423
if (INA260::current_mA > 0) {
424424
// Don't run at startup
425425
delay(RUN::TASK_INTERVALS::TI_ADJUST_LOAD_mS);
426426
} else if (abs(INA260::dPower_mWPS) > (abs(INA260::power_mW) * 0.05)) {
427427
// Wait for power to stabilize
428-
} else if ((lastPower == 0) && (powerIndex > 0)) {
428+
} else if ((lastPower == INT_FAST32_MIN) && (powerIndex > 0)) {
429429
powerIndex--;
430430
load.setLoadGPIO(LOAD::RES_INDEX_TABLE[powerIndex]);
431431
ESP_LOGI(TAG, "Initial load adjustment, setpoint: %d",
@@ -443,6 +443,7 @@ vTaskAdjustLoad([[maybe_unused]] void *pvParameters) { // NOSONAR
443443
delay(20 *
444444
1000); // todo RUN::TASK_INTERVALS::TI_ADJUST_LOAD_mS * 100
445445
} // todo: change trigger to when rpm changes or when power changes
446+
lastPower = INA260::power_mW;
446447

447448
delay(RUN::TASK_INTERVALS::TI_ADJUST_LOAD_mS);
448449
}

0 commit comments

Comments
 (0)