From 662f02f28a7c1f34ba597e461d95f054e451fb2a Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 19 Jan 2015 14:05:26 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/algo/signal_executor.cpp | 6 ++++-- firmware/controllers/system/SingleTimerExecutor.cpp | 8 ++++---- firmware/controllers/system/SingleTimerExecutor.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/algo/signal_executor.cpp b/firmware/controllers/algo/signal_executor.cpp index 5599c146ad..392c9f0be7 100644 --- a/firmware/controllers/algo/signal_executor.cpp +++ b/firmware/controllers/algo/signal_executor.cpp @@ -134,7 +134,9 @@ void scheduleOutput(OutputSignal *signal, float delayMs, float durationMs) { scheduling_s * sUp = &signal->signalTimerUp[index]; scheduling_s * sDown = &signal->signalTimerDown[index]; - scheduleTask("out up", sUp, (int) MS2US(delayMs), (schfunc_t) &turnPinHigh, signal->output); - scheduleTask("out down", sDown, (int) MS2US(delayMs) + MS2US(durationMs), (schfunc_t) &turnPinLow, signal->output); + efitimeus_t nowUs = getTimeNowUs(); + + scheduleByTime("out up", sUp, nowUs + (int) MS2US(delayMs), (schfunc_t) &turnPinHigh, signal->output); + scheduleByTime("out down", sDown, nowUs + (int) MS2US(delayMs + durationMs), (schfunc_t) &turnPinLow, signal->output); #endif } diff --git a/firmware/controllers/system/SingleTimerExecutor.cpp b/firmware/controllers/system/SingleTimerExecutor.cpp index dd155f37d5..c14b975ce2 100644 --- a/firmware/controllers/system/SingleTimerExecutor.cpp +++ b/firmware/controllers/system/SingleTimerExecutor.cpp @@ -55,7 +55,7 @@ Executor::Executor() { #define lock() lockAnyContext() #define unlock() unlockAnyContext() -void Executor::schedule2(scheduling_s *scheduling, uint64_t timeUs, schfunc_t callback, +void Executor::scheduleByTime(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) { // if (delayUs < 0) { // firmwareError("Negative delayUs %s: %d", prefix, delayUs); @@ -78,7 +78,7 @@ void Executor::schedule2(scheduling_s *scheduling, uint64_t timeUs, schfunc_t ca void Executor::schedule(scheduling_s *scheduling, uint64_t nowUs, int delayUs, schfunc_t callback, void *param) { - schedule2(scheduling, nowUs + delayUs, callback, param); + scheduleByTime(scheduling, nowUs + delayUs, callback, param); } void Executor::onTimerCallback() { @@ -141,12 +141,12 @@ void Executor::doExecute() { */ void scheduleTask(const char *prefix, scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) { scheduling->name = prefix; - instance.schedule(scheduling, getTimeNowUs(), delayUs, callback, param); + instance.scheduleByTime(scheduling, getTimeNowUs() + delayUs, callback, param); } void scheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) { scheduling->name = prefix; - instance.schedule2(scheduling, time, callback, param); + instance.scheduleByTime(scheduling, time, callback, param); } void initSignalExecutorImpl(void) { diff --git a/firmware/controllers/system/SingleTimerExecutor.h b/firmware/controllers/system/SingleTimerExecutor.h index 06cfd4e312..2b586c862b 100644 --- a/firmware/controllers/system/SingleTimerExecutor.h +++ b/firmware/controllers/system/SingleTimerExecutor.h @@ -15,7 +15,7 @@ class Executor { public: Executor(); void schedule(scheduling_s *scheduling, uint64_t nowUs, int delayUs, schfunc_t callback, void *param); - void schedule2(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param); + void scheduleByTime(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param); void onTimerCallback(); private: EventQueue queue;