refactoring: wider usage of new periodic task

This commit is contained in:
rusefi 2019-07-09 16:08:49 -04:00
parent 7288f8aab9
commit 4ef2a72930
5 changed files with 24 additions and 30 deletions

View File

@ -15,7 +15,7 @@
#include "voltage.h" #include "voltage.h"
#include "pid.h" #include "pid.h"
#include "local_version_holder.h" #include "local_version_holder.h"
#include "periodic_thread_controller.h" #include "periodic_task.h"
#include "pwm_generator.h" #include "pwm_generator.h"
#include "pin_repository.h" #include "pin_repository.h"
@ -47,14 +47,12 @@ static void pidReset(void) {
altPid.reset(); altPid.reset();
} }
class AlternatorController : public PeriodicController<UTILITY_THREAD_STACK_SIZE> { class AlternatorController : public PeriodicTimerController {
public: int getPeriodMs() override {
AlternatorController() : PeriodicController("AlternatorController") { } return GET_PERIOD_LIMITED(&engineConfiguration->alternatorControl);
private: }
void PeriodicTask(efitime_t nowNt) override {
UNUSED(nowNt);
setPeriod(GET_PERIOD_LIMITED(&engineConfiguration->alternatorControl));
void PeriodicTask() override {
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
if (shouldResetPid) { if (shouldResetPid) {
pidReset(); pidReset();

View File

@ -77,7 +77,7 @@
#include "pwm_generator_logic.h" #include "pwm_generator_logic.h"
#include "pid.h" #include "pid.h"
#include "engine_controller.h" #include "engine_controller.h"
#include "periodic_thread_controller.h" #include "periodic_task.h"
#include "pin_repository.h" #include "pin_repository.h"
#include "pwm_generator.h" #include "pwm_generator.h"
#include "dc_motor.h" #include "dc_motor.h"
@ -169,17 +169,15 @@ static percent_t currentEtbDuty;
#define ETB_DUTY_LIMIT 0.9 #define ETB_DUTY_LIMIT 0.9
#define PERCENT_TO_DUTY(X) (maxF(minF((X / 100.0), ETB_DUTY_LIMIT - 0.01), 0.01 - ETB_DUTY_LIMIT)) #define PERCENT_TO_DUTY(X) (maxF(minF((X / 100.0), ETB_DUTY_LIMIT - 0.01), 0.01 - ETB_DUTY_LIMIT))
class EtbController : public PeriodicController<UTILITY_THREAD_STACK_SIZE> { class EtbController : public PeriodicTimerController {
public:
EtbController() : PeriodicController("ETB") { }
private:
float feedForward = 0; float feedForward = 0;
void PeriodicTask(efitime_t nowNt) override { int getPeriodMs() override {
UNUSED(nowNt); return GET_PERIOD_LIMITED(&engineConfiguration->etb);
setPeriod(GET_PERIOD_LIMITED(&engineConfiguration->etb)); }
void PeriodicTask() override {
// set debug_mode 17 // set debug_mode 17
if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) { if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) {
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO

View File

@ -33,7 +33,7 @@
#include "idle_thread.h" #include "idle_thread.h"
#include "pin_repository.h" #include "pin_repository.h"
#include "engine.h" #include "engine.h"
#include "periodic_thread_controller.h" #include "periodic_task.h"
#include "stepper.h" #include "stepper.h"
#include "allsensors.h" #include "allsensors.h"
@ -249,14 +249,12 @@ static percent_t automaticIdleController() {
return newValue; return newValue;
} }
class IdleController : public PeriodicController<UTILITY_THREAD_STACK_SIZE> { class IdleController : public PeriodicTimerController {
public: int getPeriodMs() override {
IdleController() : PeriodicController("IdleValve") { } return GET_PERIOD_LIMITED(&engineConfiguration->idleRpmPid);
private: }
void PeriodicTask(efitime_t nowNt) override {
UNUSED(nowNt);
setPeriod(GET_PERIOD_LIMITED(&engineConfiguration->idleRpmPid));
void PeriodicTask() override {
/* /*
* Here we have idle logic thread - actual stepper movement is implemented in a separate * Here we have idle logic thread - actual stepper movement is implemented in a separate
* working thread, * working thread,

View File

@ -337,8 +337,8 @@ static void doPeriodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
} }
void initPeriodicEvents(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void initPeriodicEvents(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
slowController.start(); slowController.Start();
fastController.start(); fastController.Start();
} }
char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer) { char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer) {
@ -793,7 +793,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
// help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail // help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail
// linking process which is the way to raise the alarm // linking process which is the way to raise the alarm
#ifndef RAM_UNUSED_SIZE #ifndef RAM_UNUSED_SIZE
#define RAM_UNUSED_SIZE 7400 #define RAM_UNUSED_SIZE 11000
#endif #endif
#ifndef CCM_UNUSED_SIZE #ifndef CCM_UNUSED_SIZE
#define CCM_UNUSED_SIZE 4600 #define CCM_UNUSED_SIZE 4600
@ -814,6 +814,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0) if (initBootloader() != 0)
return 123; return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */ #endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20190706; return 20190709;
} }
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */

View File

@ -28,7 +28,7 @@ public:
virtual void PeriodicTask() = 0; virtual void PeriodicTask() = 0;
void start() { void Start() {
runAndScheduleNext(this); runAndScheduleNext(this);
} }
}; };