things
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "main.h"
|
||||
#include "ring_buffer.h"
|
||||
#include "tasks.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void crankHandler(void *argument) {
|
||||
for (;;) {
|
||||
@@ -59,6 +60,13 @@ void crankHandler(void *argument) {
|
||||
if (state_g.crank_state == CYCLE_COMPRESSION &&
|
||||
state_g.sync_state == SYNC_OK) {
|
||||
DEBUG_LOG("Spark schedule reached, congrats\n\r");
|
||||
uint32_t t_now = ringBufferRead(&state_g.crank_RB, 0);
|
||||
uint32_t t_prev = ringBufferRead(&state_g.crank_RB, 1);
|
||||
|
||||
uint32_t d1a = t_now - t_prev;
|
||||
// TODO: Map interpolation rather than SPARK_ADVANCE CONSTANT
|
||||
uint32_t d_spark = d1a * (45 - SPARK_ADVANCE) / 180;
|
||||
uint32_t t_spark = t_now + d_spark;
|
||||
// TODO: schedule spark
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user