12
This commit is contained in:
@@ -58,8 +58,16 @@ void OnDetectionResult(uint32_t frameNumber, uint8_t resultStatus)
|
||||
(void)frameNumber;
|
||||
/* resultStatus: 0 = NG, 1 = OK */
|
||||
if (resultStatus == 0) {
|
||||
ConfigCommon_t tmp_common;
|
||||
Config2D_t tmp_cfg2d;
|
||||
Config1D_t tmp_cfg1d;
|
||||
uint32_t pulse_ms = NG_PULSE_MS; /* fallback default */
|
||||
if (TcpLogic_GetLatestConfig(&tmp_common, &tmp_cfg2d, &tmp_cfg1d) == 0
|
||||
&& tmp_cfg2d.NGioDelay > 0) {
|
||||
pulse_ms = tmp_cfg2d.NGioDelay;
|
||||
}
|
||||
GPIO_SetBits(NG_GPIO_PORT, NG_GPIO_PIN);
|
||||
g_ng_off_time = sys_tick_ms + NG_PULSE_MS;
|
||||
g_ng_off_time = sys_tick_ms + pulse_ms;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +207,9 @@ static void task_heartbeat_entry(void *pvParameters)
|
||||
uint32_t cnt = 0;
|
||||
while (1)
|
||||
{
|
||||
printf("[HB] %lu tick=%lu\r\n", cnt++, xTaskGetTickCount());
|
||||
printf("[HB] %d tick=%d dvp_frm=%d row_irq=%d\r\n",
|
||||
(int)cnt++, (int)xTaskGetTickCount(),
|
||||
(int)dvp_frame_count, (int)dvp_row_irq_cnt);
|
||||
vTaskDelay(pdMS_TO_TICKS(2000));
|
||||
}
|
||||
}
|
||||
@@ -222,6 +232,13 @@ static void task_wchnet_entry(void *pvParameters)
|
||||
/* ============================================================
|
||||
* RTOS Task: Business logic (DVP + preprocess + send)
|
||||
* ============================================================ */
|
||||
/* ============================================================
|
||||
* Burst capture state machine
|
||||
* ============================================================ */
|
||||
static uint8_t burst_active = 0; /* 1 = currently in burst */
|
||||
static uint8_t burst_remaining = 0; /* frames left to capture */
|
||||
static uint32_t burst_next_time_ms = 0; /* next burst frame time */
|
||||
|
||||
static void task_business_entry(void *pvParameters)
|
||||
{
|
||||
(void)pvParameters;
|
||||
@@ -247,15 +264,62 @@ static void task_business_entry(void *pvParameters)
|
||||
raw_img.Height = SENSOR_HEIGHT;
|
||||
raw_img.FrameNumber = Ready_Frame_Count;
|
||||
|
||||
if (Preprocess_CheckInternalTrigger2D(&raw_img) == 1)
|
||||
if (burst_active)
|
||||
{
|
||||
/* Burst mode: wait for interval, then capture & send */
|
||||
if (sys_tick_ms >= burst_next_time_ms)
|
||||
{
|
||||
PreprocessResult_t meta;
|
||||
TcpTxBuffer_t *tx_buf = use_buffer_A ? &g_TxNetBuffer_A : &g_TxNetBuffer_B;
|
||||
use_buffer_A = !use_buffer_A;
|
||||
tx_buf->ValidPayloadLen = 0;
|
||||
|
||||
if (Preprocess_Execute(&raw_img, tx_buf, &meta) == 0)
|
||||
{
|
||||
TcpLogic_BuildAndSendTemperatureFrame(tx_buf, &meta, 0x01, 1);
|
||||
}
|
||||
burst_remaining--;
|
||||
if (burst_remaining == 0) {
|
||||
burst_active = 0;
|
||||
DBG_APP("Burst complete\r\n");
|
||||
} else {
|
||||
/* Read interval from config */
|
||||
ConfigCommon_t tc; Config2D_t t2; Config1D_t t1;
|
||||
uint16_t interval_ms = 0;
|
||||
if (TcpLogic_GetLatestConfig(&tc, &t2, &t1) == 0)
|
||||
interval_ms = t2.TriggerInternalIntervalMs;
|
||||
burst_next_time_ms = sys_tick_ms + interval_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Preprocess_CheckInternalTrigger2D(&raw_img) == 1)
|
||||
{
|
||||
/* Trigger hit! Start burst: this frame is frame #0 */
|
||||
PreprocessResult_t meta;
|
||||
TcpTxBuffer_t *tx_buf = use_buffer_A ? &g_TxNetBuffer_A : &g_TxNetBuffer_B;
|
||||
use_buffer_A = !use_buffer_A;
|
||||
tx_buf->ValidPayloadLen = 0;
|
||||
|
||||
if (Preprocess_Execute(&raw_img, tx_buf, &meta) == 0)
|
||||
{
|
||||
TcpLogic_BuildAndSendTemperatureFrame(tx_buf, &meta, 1, 1);
|
||||
TcpLogic_BuildAndSendTemperatureFrame(tx_buf, &meta, 0x01, 1);
|
||||
}
|
||||
|
||||
/* Determine burst count from config */
|
||||
ConfigCommon_t tc; Config2D_t t2; Config1D_t t1;
|
||||
uint8_t total_burst = 1;
|
||||
uint16_t interval_ms = 0;
|
||||
if (TcpLogic_GetLatestConfig(&tc, &t2, &t1) == 0) {
|
||||
if (t2.TriggerBurstCount > 1)
|
||||
total_burst = t2.TriggerBurstCount;
|
||||
interval_ms = t2.TriggerInternalIntervalMs;
|
||||
}
|
||||
if (total_burst > 1) {
|
||||
burst_active = 1;
|
||||
burst_remaining = total_burst - 1; /* frame #0 already sent */
|
||||
burst_next_time_ms = sys_tick_ms + interval_ms;
|
||||
DBG_APP("Burst start: %d frames, interval=%d ms\r\n",
|
||||
(int)total_burst, (int)interval_ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user