adding pins and task class

This commit is contained in:
2026-04-11 12:27:19 +02:00
parent 37fa6a686f
commit 684c34e209
6 changed files with 118 additions and 25 deletions

View File

@@ -47,7 +47,7 @@ public:
};
public:
RGBled(const uint8_t pin = 48);
RGBled(const uint8_t pin = LED);
~RGBled();
void setStatus(const LedStatus s);

View File

@@ -18,7 +18,7 @@
// Defines to enable channel B
#define CH_B_ENABLE
#define TEST
//#define TEST
// Debug Defines
#define WIFI_SSID "AstroRotaxMonitor"
@@ -52,6 +52,7 @@ void setup()
IPAddress gateway(10, 11, 12, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.softAPConfig(local_IP, gateway, subnet);
WiFi.setTxPower(WIFI_POWER_5dBm); // reduce wifi power
if (WiFi.softAP(WIFI_SSID, WIFI_PASSWORD))
{
LOG_INFO("WiFi AP Mode Started");
@@ -116,7 +117,7 @@ void loop()
.trig_pin_34n = TRIG_PIN_A34N,
.spark_pin_12 = SPARK_PIN_A12,
.spark_pin_34 = SPARK_PIN_A34},
.rt_resets = rtTaskResets{.rst_io_peak = RST_EXT_PEAK_DETECT_A, .rst_io_sh = RST_EXT_SAMPLE_HOLD_A}};
.rt_resets = rtTaskResets{.rst_io_peak = POT_CS_12A, .rst_io_sh = POT_CS_34A}};
#ifdef CH_B_ENABLE
rtTaskParams taskB_params{
@@ -131,7 +132,7 @@ void loop()
.trig_pin_34n = TRIG_PIN_B34N,
.spark_pin_12 = SPARK_PIN_B12,
.spark_pin_34 = SPARK_PIN_B34},
.rt_resets = rtTaskResets{.rst_io_peak = RST_EXT_PEAK_DETECT_B, .rst_io_sh = RST_EXT_SAMPLE_HOLD_B}};
.rt_resets = rtTaskResets{.rst_io_peak = SS_FORCE_A, .rst_io_sh = SS_INIBHIT_A12}};
#endif
if (!rt_taskA_queue || !rt_taskB_queue)
@@ -189,7 +190,7 @@ void loop()
// Ignition A on Core 0
auto ignA_task_success = pdPASS;
ignA_task_success = xTaskCreatePinnedToCore(
rtIgnitionTask,
rtIgnitionTask_run,
"rtTask_A",
RT_TASK_STACK,
(void *)&taskA_params,
@@ -203,7 +204,7 @@ void loop()
#ifdef CH_B_ENABLE
ignB_task_success = xTaskCreatePinnedToCore(
rtIgnitionTask,
rtIgnitionTask_run,
"rtTask_B",
RT_TASK_STACK,
(void *)&taskB_params,

View File

@@ -80,31 +80,86 @@
#define SPARK_PIN_B34 2
// =====================
// PCA9555 (I2C EXPANDER)
// PCA9555 I/O EXPANDER BOX_A
// =====================
// --- RESET LINES ---
#define RST_EXT_PEAK_DETECT_A 0
#define RST_EXT_SAMPLE_HOLD_A 1
#define RST_EXT_PEAK_DETECT_B 2
#define RST_EXT_SAMPLE_HOLD_B 3
#define BTN_3 4
#define BTN_4 5
#define BTN_5 6
#define BTN_6 7
#define EXPANDER_A_ADDR 0x010101
// --- DIGITAL POT CHIP SELECT LINES ---
#define POT_CS_A12 0
#define POT_CS_A34 1
// --- SOFT START FORCE LINES ---
#define SS_FORCE_A 2
#define SS_INIBHIT_A12 3
#define SS_INHIBIT_A34 4
// --- SAMPLE AND HOLD ARM AND DISCHARGE ---
#define SH_DISCH_A12 5
#define SH_DISCH_A34 6
#define SH_ARM_A12 7
#define SH_ARM_A34 8
// --- RELAY ---
#define EXT_RELAY_A 8
#define EXT_RELAY_B 9
#define RELAY_IN_A12 9
#define RELAY_OUT_A12 10
#define RELAY_IN_A34 11
#define RELAY_OUT_A34 12
// --- STATUS / BUTTON ---
#define BTN_7 10
#define BTN_8 11
#define STA_1 12
#define STA_2 13
#define STA_3 14
#define STA_4 15
// =====================
// PCA9555 I/O EXPANDER BOX_B
// =====================
#define EXPANDER_B_ADDR 0x101010
// --- DIGITAL POT CHIP SELECT LINES ---
#define POT_CS_B12 0
#define POT_CS_B34 1
// --- SOFT START FORCE LINES ---
#define SS_FORCE_A 2
#define SS_INIBHIT_B12 3
#define SS_INHIBIT_B34 4
// --- SAMPLE AND HOLD ARM AND DISCHARGE ---
#define SH_DISCH_B12 5
#define SH_DISCH_B34 6
#define SH_ARM_B12 7
#define SH_ARM_B34 8
// --- RELAY ---
#define RELAY_IN_B12 9
#define RELAY_OUT_B12 10
#define RELAY_IN_B34 11
#define RELAY_OUT_B34 12
// --- STATUS / BUTTON ---
#define STA_2 13
#define STA_3 14
#define STA_4 15
// =====================
// PCA9555 I/O EXPANDER INPUTS A+B
// =====================
#define EXPANDER_IN_ADDR 0x0a0a0a
#define SS_A12_ON
#define SS_A12_OFF
#define SS_A34_ON
#define SS_A34_OFF
#define SS_B12_ON
#define SS_B12_OFF
#define SS_B34_ON
#define SS_B34_OFF
// Init Pin Functions
inline void initTriggerPinsInputs()
{

View File

@@ -65,7 +65,7 @@
#define RST_EXT_A34N 3
// --- RELAY ---
#define EXT_RELAY_A 8
#define SH_ARM_A34 8
// Init Pin Functions

View File

@@ -8,7 +8,7 @@ void spark_timeout_callback(void *arg)
xTaskNotify(handle, SPARK_FLAG_TIMEOUT, eSetValueWithOverwrite);
}
void rtIgnitionTask(void *pvParameters)
void rtIgnitionTask::rtIgnitionTask_run(void *pvParameters)
{
// Invalid real time rt_task_ptr parameters, exit immediate

View File

@@ -2,12 +2,14 @@
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
// Serial debug flag
//#define DEBUG
// #define DEBUG
// Arduino Libraries
#include <Arduino.h>
#include <DebugLog.h>
#include "utils.h"
#include <memory>
#include <mutex>
// ISR
#include "isr.h"
@@ -60,4 +62,39 @@ struct rtTaskParams
const rtTaskResets rt_resets; // reset ping for peak detectors
};
void rtIgnitionTask(void *pvParameters);
class rtIgnitionTask
{
using PShistory = PSRAMVector<ignitionBoxStatus>;
public:
rtIgnitionTask();
~rtIgnitionTask();
static void rtIgnitionTask_run(void *pvParameters);
void run();
void start();
void stop();
private:
bool m_running = true;
std::shared_ptr<Devices> m_devices;
std::string m_name;
TaskHandle_t m_handle;
QueueHandle_t m_queue;
rtTaskParams m_params;
PShistory m_history_0;
PShistory m_history_1;
std::unique_ptr<PShistory> m_active_history;
std::unique_ptr<PShistory> m_save_history;
fs::FS m_filesystem;
};