static msg_t seThread(void *arg) { (void)arg; chRegSetThreadName("servo"); while (true) { OutputPin *pin = &pins[0]; pin->setValue(1); percent_t position = (currentTimeMillis() / 5) % 200; if (position > 100) position = 200 - position; float durationMs = 0 + position * 0.02f; scheduleForLater(&servoTurnSignalOff, (int)MS2US(durationMs), (schfunc_t) &servoTachPinLow, pin); chThdSleepMilliseconds(19); } return 0; }
void SleepExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) { scheduleForLater(scheduling, timeUs - getTimeNowUs(), callback, param); }