First Attempt to print data async, fields not working
This commit is contained in:
@@ -11,9 +11,11 @@ void trig_isr(void *arg)
|
|||||||
// exit if invalid args
|
// exit if invalid args
|
||||||
if (!arg)
|
if (!arg)
|
||||||
return;
|
return;
|
||||||
|
// FOR TESTING ONLY
|
||||||
|
digitalWrite(POT_A_CS, HIGH);
|
||||||
|
|
||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
isrParams *params = (isrParams*)arg;
|
isrParams *params = (isrParams *)arg;
|
||||||
ignitionBoxStatus *box = params->ign_stat;
|
ignitionBoxStatus *box = params->ign_stat;
|
||||||
TaskHandle_t task_handle = *params->rt_handle_ptr;
|
TaskHandle_t task_handle = *params->rt_handle_ptr;
|
||||||
|
|
||||||
@@ -28,10 +30,12 @@ void trig_isr(void *arg)
|
|||||||
switch (params->flag)
|
switch (params->flag)
|
||||||
{
|
{
|
||||||
case TRIG_FLAG_12P:
|
case TRIG_FLAG_12P:
|
||||||
|
case TRIG_FLAG_12N:
|
||||||
box->coils12.trig_time = time_us;
|
box->coils12.trig_time = time_us;
|
||||||
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||||
break;
|
break;
|
||||||
case TRIG_FLAG_34P:
|
case TRIG_FLAG_34P:
|
||||||
|
case TRIG_FLAG_34N:
|
||||||
box->coils34.trig_time = time_us;
|
box->coils34.trig_time = time_us;
|
||||||
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||||
break;
|
break;
|
||||||
@@ -48,6 +52,8 @@ void trig_isr(void *arg)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// FOR TESTING ONLY
|
||||||
|
digitalWrite(POT_A_CS, LOW);
|
||||||
|
|
||||||
if (xHigherPriorityTaskWoken)
|
if (xHigherPriorityTaskWoken)
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ enum sparkStatus
|
|||||||
|
|
||||||
enum softStartStatus
|
enum softStartStatus
|
||||||
{
|
{
|
||||||
SOFT_START,
|
NORMAL,
|
||||||
NORMAL
|
SOFT_START
|
||||||
};
|
};
|
||||||
|
|
||||||
struct coilsStatus
|
struct coilsStatus
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <tasks.h>
|
#include <tasks.h>
|
||||||
#include <channels.h>
|
#include <channels.h>
|
||||||
#include <devices.h>
|
#include <devices.h>
|
||||||
|
#include <ui.h>
|
||||||
|
|
||||||
void printTaskList()
|
void printTaskList()
|
||||||
{
|
{
|
||||||
@@ -58,7 +59,7 @@ void loop()
|
|||||||
|
|
||||||
QueueHandle_t rt_taskA_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
QueueHandle_t rt_taskA_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
||||||
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
||||||
rtTaskParams taskA_params {
|
rtTaskParams taskA_params{
|
||||||
.rt_running = true,
|
.rt_running = true,
|
||||||
.dev = &dev,
|
.dev = &dev,
|
||||||
.rt_handle_ptr = &trigA_TaskHandle,
|
.rt_handle_ptr = &trigA_TaskHandle,
|
||||||
@@ -71,17 +72,12 @@ void loop()
|
|||||||
.trig_pin_34n = TRIG_PIN_A34N,
|
.trig_pin_34n = TRIG_PIN_A34N,
|
||||||
.spark_pin_12 = SPARK_PIN_A12,
|
.spark_pin_12 = SPARK_PIN_A12,
|
||||||
.spark_pin_34 = SPARK_PIN_A34},
|
.spark_pin_34 = SPARK_PIN_A34},
|
||||||
.rt_resets = rtTaskResets{
|
.rt_resets = rtTaskResets{.rst_io_12p = RST_EXT_A12P, .rst_io_12n = RST_EXT_A12N, .rst_io_34p = RST_EXT_A34P, .rst_io_34n = RST_EXT_A34N}};
|
||||||
.rst_io_12p = RST_EXT_A12P,
|
|
||||||
.rst_io_12n = RST_EXT_A12N,
|
|
||||||
.rst_io_34p = RST_EXT_A34P,
|
|
||||||
.rst_io_34n = RST_EXT_A34N}
|
|
||||||
};
|
|
||||||
|
|
||||||
LOG_INFO("Task Variables OK");
|
LOG_INFO("Task Variables OK");
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
||||||
rtTaskParams taskB_params {
|
rtTaskParams taskB_params{
|
||||||
.rt_running = true,
|
.rt_running = true,
|
||||||
.dev = &dev,
|
.dev = &dev,
|
||||||
.rt_queue = rt_taskB_queue,
|
.rt_queue = rt_taskB_queue,
|
||||||
@@ -94,12 +90,7 @@ void loop()
|
|||||||
.trig_pin_34n = TRIG_PIN_B34N,
|
.trig_pin_34n = TRIG_PIN_B34N,
|
||||||
.spark_pin_12 = SPARK_PIN_B12,
|
.spark_pin_12 = SPARK_PIN_B12,
|
||||||
.spark_pin_34 = SPARK_PIN_B34},
|
.spark_pin_34 = SPARK_PIN_B34},
|
||||||
.rt_resets = rtTaskResets{
|
.rt_resets = rtTaskResets{.rst_io_12p = RST_EXT_B12P, .rst_io_12n = RST_EXT_B12N, .rst_io_34p = RST_EXT_B34P, .rst_io_34n = RST_EXT_B34N}};
|
||||||
.rst_io_12p = RST_EXT_B12P,
|
|
||||||
.rst_io_12n = RST_EXT_B12N,
|
|
||||||
.rst_io_34p = RST_EXT_B34P,
|
|
||||||
.rst_io_34n = RST_EXT_B34N}
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool spiA_ok = true;
|
bool spiA_ok = true;
|
||||||
@@ -120,7 +111,7 @@ void loop()
|
|||||||
}
|
}
|
||||||
LOG_INFO("Init SPI OK");
|
LOG_INFO("Init SPI OK");
|
||||||
|
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
// Init ADC_A
|
// Init ADC_A
|
||||||
dev.adc_a = new ADS1256(ADC_A_DRDY, ADC_A_RST, ADC_A_SYNC, ADC_A_CS, 2.5, &SPI_A);
|
dev.adc_a = new ADS1256(ADC_A_DRDY, ADC_A_RST, ADC_A_SYNC, ADC_A_CS, 2.5, &SPI_A);
|
||||||
dev.adc_a->InitializeADC();
|
dev.adc_a->InitializeADC();
|
||||||
@@ -132,7 +123,7 @@ void loop()
|
|||||||
dev.adc_a->InitializeADC();
|
dev.adc_a->InitializeADC();
|
||||||
dev.adc_a->setPGA(PGA_1);
|
dev.adc_a->setPGA(PGA_1);
|
||||||
dev.adc_a->setDRATE(DRATE_1000SPS);
|
dev.adc_a->setDRATE(DRATE_1000SPS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOG_INFO("Init ADC OK");
|
LOG_INFO("Init ADC OK");
|
||||||
|
|
||||||
@@ -172,16 +163,49 @@ void loop()
|
|||||||
|
|
||||||
////////////////////// MAIN LOOP //////////////////////
|
////////////////////// MAIN LOOP //////////////////////
|
||||||
uint32_t count(0);
|
uint32_t count(0);
|
||||||
|
clearScreen();
|
||||||
|
setCursor(0, 0);
|
||||||
|
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
delay(10);
|
|
||||||
ignitionBoxStatus ignA;
|
ignitionBoxStatus ignA;
|
||||||
if (xQueueReceive(rt_taskA_queue, &ignA, 0) == pdTRUE){
|
if (xQueueReceive(rt_taskA_queue, &ignA, pdMS_TO_TICKS(100)) == pdTRUE)
|
||||||
|
{
|
||||||
|
printField("++ Timestamp", (uint32_t)ignA.timestamp, 0, 0);
|
||||||
|
if (firstRun)
|
||||||
|
Serial.println("========== Coils 12 =============");
|
||||||
|
printField("Pickup Tim", (uint32_t)ignA.coils12.trig_time, 0, 1);
|
||||||
|
printField("Spark Tim", (uint32_t)ignA.coils12.spark_time, 0, 2);
|
||||||
|
printField("Spark Dly", (uint32_t)ignA.coils12.spark_delay, 0, 3);
|
||||||
|
printField("Spark Sts", (uint32_t)ignA.coils12.spark_status, 0, 4);
|
||||||
|
printField("Peak P_IN", ignA.coils12.peak_p_in, 0, 5);
|
||||||
|
printField("Peak P_OUT", ignA.coils12.peak_p_out, 0, 6);
|
||||||
|
printField("Peak N_IN", ignA.coils12.peak_n_in, 0, 7);
|
||||||
|
printField("Peak N_OUT", ignA.coils12.peak_n_out, 0, 8);
|
||||||
|
printField("SoftStart ", (uint32_t)ignA.coils12.sstart_status, 0, 9);
|
||||||
|
if (firstRun)
|
||||||
|
Serial.println("========== Coils 34 =============");
|
||||||
|
printField("Pickup Tim", (uint32_t)ignA.coils34.trig_time, 0, 11);
|
||||||
|
printField("Spark Tim", (uint32_t)ignA.coils34.spark_time, 0, 12);
|
||||||
|
printField("Spark Dly", (uint32_t)ignA.coils34.spark_delay, 0, 13);
|
||||||
|
printField("Spark Sts", (uint32_t)ignA.coils34.spark_delay, 0, 14);
|
||||||
|
printField("Peak P_IN", ignA.coils34.peak_p_in, 0, 15);
|
||||||
|
printField("Peak P_OUT", ignA.coils34.peak_p_out, 0, 16);
|
||||||
|
printField("Peak N_IN", ignA.coils34.peak_n_in, 0, 17);
|
||||||
|
printField("Peak N_OUT", ignA.coils34.peak_n_out, 0, 18);
|
||||||
|
printField("SoftStart ", (uint32_t)ignA.coils34.sstart_status, 0, 19);
|
||||||
|
if (firstRun)
|
||||||
|
Serial.println("========== END =============");
|
||||||
|
if (count++ % 10 == 0)
|
||||||
|
{
|
||||||
|
firstRun = true;
|
||||||
|
clearScreen();
|
||||||
|
setCursor(0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
|
||||||
|
firstRun = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(count++ % 100))
|
|
||||||
printTaskList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trigA_TaskHandle)
|
if (trigA_TaskHandle)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
const rtTaskInterrupts rt_int = params->rt_int; // copy to avoid external override
|
const rtTaskInterrupts rt_int = params->rt_int; // copy to avoid external override
|
||||||
const rtTaskResets rt_rst = params->rt_resets; // copy to avoid external override
|
const rtTaskResets rt_rst = params->rt_resets; // copy to avoid external override
|
||||||
QueueHandle_t rt_queue = params->rt_queue;
|
QueueHandle_t rt_queue = params->rt_queue;
|
||||||
TaskHandle_t* rt_handle_ptr = params->rt_handle_ptr;
|
TaskHandle_t *rt_handle_ptr = params->rt_handle_ptr;
|
||||||
Devices *dev = params->dev;
|
Devices *dev = params->dev;
|
||||||
ADS1256 *adc = dev->adc_a;
|
ADS1256 *adc = dev->adc_a;
|
||||||
PCA9555 *io = dev->io;
|
PCA9555 *io = dev->io;
|
||||||
@@ -50,13 +50,15 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
|
|
||||||
LOG_INFO("rtTask ISR Params OK");
|
LOG_INFO("rtTask ISR Params OK");
|
||||||
|
|
||||||
|
pinMode(POT_A_CS, OUTPUT);
|
||||||
|
|
||||||
// Attach Pin Interrupts
|
// Attach Pin Interrupts
|
||||||
attachInterruptArg(rt_int.trig_pin_12p, rt_int.isr_ptr, (void *)&isr_params_t12p, RISING);
|
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_12p), rt_int.isr_ptr, (void *)&isr_params_t12p, RISING);
|
||||||
attachInterruptArg(rt_int.trig_pin_12n, rt_int.isr_ptr, (void *)&isr_params_t12n, RISING);
|
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_12n), rt_int.isr_ptr, (void *)&isr_params_t12n, RISING);
|
||||||
attachInterruptArg(rt_int.trig_pin_34p, rt_int.isr_ptr, (void *)&isr_params_t34p, RISING);
|
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_34p), rt_int.isr_ptr, (void *)&isr_params_t34p, RISING);
|
||||||
attachInterruptArg(rt_int.trig_pin_34n, rt_int.isr_ptr, (void *)&isr_params_t34n, RISING);
|
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_34n), rt_int.isr_ptr, (void *)&isr_params_t34n, RISING);
|
||||||
attachInterruptArg(rt_int.spark_pin_12, rt_int.isr_ptr, (void *)&isr_params_sp12, RISING);
|
attachInterruptArg(digitalPinToInterrupt(rt_int.spark_pin_12), rt_int.isr_ptr, (void *)&isr_params_sp12, RISING);
|
||||||
attachInterruptArg(rt_int.spark_pin_34, rt_int.isr_ptr, (void *)&isr_params_sp34, RISING);
|
attachInterruptArg(digitalPinToInterrupt(rt_int.spark_pin_34), rt_int.isr_ptr, (void *)&isr_params_sp34, RISING);
|
||||||
|
|
||||||
LOG_INFO("rtTask ISR Attach OK");
|
LOG_INFO("rtTask ISR Attach OK");
|
||||||
|
|
||||||
@@ -66,29 +68,27 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
(1 << rt_rst.rst_io_34p) |
|
(1 << rt_rst.rst_io_34p) |
|
||||||
(1 << rt_rst.rst_io_34n);
|
(1 << rt_rst.rst_io_34n);
|
||||||
|
|
||||||
LOG_WARN("rt Task Init Correct");
|
LOG_WARN("rtTask Init Correct");
|
||||||
|
// Global rt_task_ptr variables
|
||||||
uint32_t it = 0;
|
uint32_t it = 0;
|
||||||
uint32_t q_fail_count = 0;
|
uint32_t q_fail_count = 0;
|
||||||
|
|
||||||
while (params->rt_running)
|
while (params->rt_running)
|
||||||
{
|
{
|
||||||
// Global rt_task_ptr variables
|
|
||||||
uint32_t pickup_flag = 0;
|
uint32_t pickup_flag = 0;
|
||||||
uint32_t spark_flag = 0;
|
uint32_t spark_flag = 0;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
Serial.print("\033[2J"); // clear screen
|
|
||||||
Serial.print("\033[H"); // cursor home
|
|
||||||
LOG_INFO("Iteration [", it++, "]");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// WAIT FOR PICKUP SIGNAL
|
// WAIT FOR PICKUP SIGNAL
|
||||||
xTaskNotifyWait(
|
xTaskNotifyWait(
|
||||||
0x00, // non pulire all'ingresso
|
ULONG_MAX, // non pulire all'ingresso
|
||||||
ULONG_MAX, // pulisci i primi 8 bit
|
ULONG_MAX, // pulisci i primi 8 bit
|
||||||
&pickup_flag, // valore ricevuto
|
&pickup_flag, // valore ricevuto
|
||||||
portMAX_DELAY);
|
portMAX_DELAY);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
LOG_INFO("Iteration [", it++, "]");
|
||||||
|
Serial.print("\033[2J"); // clear screen
|
||||||
|
Serial.print("\033[H"); // cursor home
|
||||||
LOG_INFO("Pickup Flags: ", printBits(pickup_flag).c_str());
|
LOG_INFO("Pickup Flags: ", printBits(pickup_flag).c_str());
|
||||||
if (!names.contains(pickup_flag))
|
if (!names.contains(pickup_flag))
|
||||||
{
|
{
|
||||||
@@ -105,9 +105,12 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
auto spark_timeout = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(spark_timeout_max));
|
auto spark_timeout = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(spark_timeout_max));
|
||||||
if (ign_box_sts.coils12.spark_ok || ign_box_sts.coils34.spark_ok) // otherwise timeout if none is set in the ISR
|
if (ign_box_sts.coils12.spark_ok || ign_box_sts.coils34.spark_ok) // otherwise timeout if none is set in the ISR
|
||||||
spark_flag = ign_box_sts.coils12.spark_ok ? SPARK_FLAG_12 : SPARK_FLAG_34;
|
spark_flag = ign_box_sts.coils12.spark_ok ? SPARK_FLAG_12 : SPARK_FLAG_34;
|
||||||
|
else
|
||||||
|
spark_flag == SPARK_FLAG_NIL;
|
||||||
|
|
||||||
xTaskNotifyStateClear(NULL);
|
xTaskNotifyStateClear(NULL);
|
||||||
ulTaskNotifyValueClear(NULL, 0xFFFFFFFF);
|
ulTaskNotifyValueClear(NULL, 0xFFFFFFFF);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LOG_INFO("Spark Flags: ", printBits(spark_flag).c_str());
|
LOG_INFO("Spark Flags: ", printBits(spark_flag).c_str());
|
||||||
if (!names.contains(spark_flag))
|
if (!names.contains(spark_flag))
|
||||||
@@ -141,12 +144,11 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
bool new_data = false;
|
bool new_data = false;
|
||||||
switch (pickup_flag)
|
switch (pickup_flag)
|
||||||
{
|
{
|
||||||
// CASES for NEGATIVE cycle triggering of pickup and sparks 12 & 34
|
|
||||||
case TRIG_FLAG_12P:
|
case TRIG_FLAG_12P:
|
||||||
case TRIG_FLAG_34P:
|
case TRIG_FLAG_34P:
|
||||||
{
|
{
|
||||||
// Timeout not occourred, expected POSITIVE edge spark OCCOURRED
|
// Timeout not occourred, expected POSITIVE edge spark OCCOURRED
|
||||||
if (spark_timeout == pdPASS)
|
if (spark_flag != SPARK_FLAG_NIL)
|
||||||
{
|
{
|
||||||
coils->spark_delay = coils->spark_time - coils->trig_time;
|
coils->spark_delay = coils->spark_time - coils->trig_time;
|
||||||
coils->sstart_status = softStartStatus::NORMAL; // because spark on positive edge
|
coils->sstart_status = softStartStatus::NORMAL; // because spark on positive edge
|
||||||
@@ -157,12 +159,12 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
||||||
else if (spark_timeout == pdFAIL)
|
else if (spark_flag == SPARK_FLAG_NIL)
|
||||||
{
|
{
|
||||||
coils->spark_status = sparkStatus::SPARK_NEG_WAIT;
|
coils->spark_status = sparkStatus::SPARK_NEG_WAIT;
|
||||||
coils->sstart_status = softStartStatus::NORMAL;
|
coils->sstart_status = softStartStatus::NORMAL;
|
||||||
}
|
}
|
||||||
new_data = false;
|
new_data = true;
|
||||||
break; // Do nothing more on positive pulse
|
break; // Do nothing more on positive pulse
|
||||||
}
|
}
|
||||||
// CASES for NEGATIVE cycle triggering of pickup and sparks 12 & 34
|
// CASES for NEGATIVE cycle triggering of pickup and sparks 12 & 34
|
||||||
@@ -171,7 +173,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
{
|
{
|
||||||
const bool expected_negative12 = coils->spark_status == sparkStatus::SPARK_NEG_WAIT;
|
const bool expected_negative12 = coils->spark_status == sparkStatus::SPARK_NEG_WAIT;
|
||||||
// Timeout not occourred, expected NEGATIVE edge spark OCCOURRED
|
// Timeout not occourred, expected NEGATIVE edge spark OCCOURRED
|
||||||
if (spark_timeout == pdPASS && expected_negative12)
|
if (spark_flag != SPARK_FLAG_NIL && expected_negative12)
|
||||||
{
|
{
|
||||||
coils->spark_delay = coils->spark_time - coils->trig_time;
|
coils->spark_delay = coils->spark_time - coils->trig_time;
|
||||||
coils->sstart_status = softStartStatus::SOFT_START;
|
coils->sstart_status = softStartStatus::SOFT_START;
|
||||||
@@ -182,13 +184,13 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
||||||
else if (spark_timeout == pdFAIL && expected_negative12)
|
else if (spark_flag == SPARK_FLAG_NIL && expected_negative12)
|
||||||
{
|
{
|
||||||
coils->sstart_status = softStartStatus::NORMAL;
|
coils->sstart_status = softStartStatus::NORMAL;
|
||||||
coils->spark_status = sparkStatus::SPARK_NEG_FAIL;
|
coils->spark_status = sparkStatus::SPARK_NEG_FAIL;
|
||||||
}
|
}
|
||||||
// Timeout not occouured, unexpected negative edge spark
|
// Timeout not occouured, unexpected negative edge spark
|
||||||
else if (spark_timeout == pdPASS && !expected_negative12)
|
else if (spark_flag != SPARK_FLAG_NIL && !expected_negative12)
|
||||||
{
|
{
|
||||||
coils->sstart_status = softStartStatus::SOFT_START;
|
coils->sstart_status = softStartStatus::SOFT_START;
|
||||||
coils->spark_status = sparkStatus::SPARK_NEG_UNEXPECTED;
|
coils->spark_status = sparkStatus::SPARK_NEG_UNEXPECTED;
|
||||||
@@ -198,7 +200,11 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
#ifdef DEUG
|
||||||
LOG_ERROR("Invalid Interrupt");
|
LOG_ERROR("Invalid Interrupt");
|
||||||
|
LOG_ERROR("Pickup Flags: ", printBits(pickup_flag).c_str());
|
||||||
|
LOG_ERROR("Spark Flags: ", printBits(spark_flag).c_str());
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,12 @@
|
|||||||
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
|
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
|
||||||
|
|
||||||
// Serial debug flag
|
// Serial debug flag
|
||||||
//#define DEBUG
|
// #define DEBUG
|
||||||
|
|
||||||
// Arduino Libraries
|
// Arduino Libraries
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <DebugLog.h>
|
#include <DebugLog.h>
|
||||||
#ifdef DEBUG
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
// ISR
|
// ISR
|
||||||
#include "isr.h"
|
#include "isr.h"
|
||||||
|
|||||||
48
RotaxMonitor/src/ui.h
Normal file
48
RotaxMonitor/src/ui.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
static bool firstRun = true;
|
||||||
|
|
||||||
|
void clearScreen(){
|
||||||
|
Serial.print("\033[2J"); // clear screen
|
||||||
|
Serial.print("\033[H"); // cursor home
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCursor(const uint8_t x, const uint8_t y) {
|
||||||
|
Serial.printf("\033[%d;%d", y, x+1);
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void printField(const char name[], const uint32_t val, const uint8_t x, const uint8_t y) {
|
||||||
|
if (firstRun) {
|
||||||
|
setCursor(x,y);
|
||||||
|
Serial.printf("%15s: %06d\n", name, val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setCursor(x+16, y);
|
||||||
|
Serial.print(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void printField(const char name[], const int64_t val, const uint8_t x, const uint8_t y) {
|
||||||
|
if (firstRun) {
|
||||||
|
setCursor(x,y);
|
||||||
|
Serial.printf("%15s: %06u\n", name, (uint64_t)val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setCursor(x+16, y);
|
||||||
|
Serial.print((uint64_t)val);
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void printField(const char name[], const float val, const uint8_t x, const uint8_t y) {
|
||||||
|
if (firstRun) {
|
||||||
|
setCursor(x,y);
|
||||||
|
Serial.printf("%15s: %4.2f\n", name, val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setCursor(x+16, y);
|
||||||
|
Serial.print(val);
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user