Code formatted

This commit is contained in:
Kai Lauterbach 2024-02-05 19:46:13 +01:00
parent 37bb02e065
commit 5ec94fa665

View file

@ -175,75 +175,90 @@ void core0_task( void * pvParameters ) {
} }
void core1_task( void * pvParameters ) { void core1_task(void *pvParameters)
{
(void) pvParameters; (void)pvParameters;
for (;;) { for (;;)
if (!single_trigger) { {
while (updating_screen) { if (!single_trigger)
{
while (updating_screen)
{
vTaskDelay(pdMS_TO_TICKS(1)); vTaskDelay(pdMS_TO_TICKS(1));
} }
if (!stop) { if (!stop)
if (stop_change) { {
if (stop_change)
{
i2s_adc_enable(I2S_NUM_0); i2s_adc_enable(I2S_NUM_0);
stop_change = false; stop_change = false;
} }
ADC_Sampling(i2s_buff); ADC_Sampling(i2s_buff);
new_data = true; new_data = true;
} }
else { else
if (!stop_change) { {
if (!stop_change)
{
i2s_adc_disable(I2S_NUM_0); i2s_adc_disable(I2S_NUM_0);
i2s_zero_dma_buffer(I2S_NUM_0); i2s_zero_dma_buffer(I2S_NUM_0);
stop_change = true; stop_change = true;
} }
} }
//Serial.println("CORE1"); // Serial.println("CORE1");
vTaskDelay(pdMS_TO_TICKS(300)); vTaskDelay(pdMS_TO_TICKS(300));
} }
else { else
{
float old_mean = 0; float old_mean = 0;
while (single_trigger) { while (single_trigger)
{
stop = true; stop = true;
ADC_Sampling(i2s_buff); ADC_Sampling(i2s_buff);
float mean = 0; float mean = 0;
float max_v, min_v; float max_v, min_v;
peak_mean(i2s_buff, BUFF_SIZE, &max_v, &min_v, &mean); peak_mean(i2s_buff, BUFF_SIZE, &max_v, &min_v, &mean);
//signal captured (pp > 0.4V || changing mean > 0.2V) -> DATA ANALYSIS // signal captured (pp > 0.4V || changing mean > 0.2V) -> DATA ANALYSIS
if ((old_mean != 0 && fabs(mean - old_mean) > 0.2) || to_voltage(max_v) - to_voltage(min_v) > 0.05) { if ((old_mean != 0 && fabs(mean - old_mean) > 0.2) || to_voltage(max_v) - to_voltage(min_v) > 0.05)
{
float freq = 0; float freq = 0;
float period = 0; float period = 0;
uint32_t trigger0 = 0; uint32_t trigger0 = 0;
uint32_t trigger1 = 0; uint32_t trigger1 = 0;
//if analog mode OR auto mode and wave recognized as analog // if analog mode OR auto mode and wave recognized as analog
bool digital_data = !false; bool digital_data = !false;
if (digital_wave_option == 1) { if (digital_wave_option == 1)
{
trigger_freq_analog(i2s_buff, RATE, mean, max_v, min_v, &freq, &period, &trigger0, &trigger1); trigger_freq_analog(i2s_buff, RATE, mean, max_v, min_v, &freq, &period, &trigger0, &trigger1);
} }
else if (digital_wave_option == 0) { else if (digital_wave_option == 0)
{
digital_data = digital_analog(i2s_buff, max_v, min_v); digital_data = digital_analog(i2s_buff, max_v, min_v);
if (!digital_data) { if (!digital_data)
{
trigger_freq_analog(i2s_buff, RATE, mean, max_v, min_v, &freq, &period, &trigger0, &trigger1); trigger_freq_analog(i2s_buff, RATE, mean, max_v, min_v, &freq, &period, &trigger0, &trigger1);
} }
else { else
{
trigger_freq_digital(i2s_buff, RATE, mean, max_v, min_v, &freq, &period, &trigger0); trigger_freq_digital(i2s_buff, RATE, mean, max_v, min_v, &freq, &period, &trigger0);
} }
} }
else { else
{
trigger_freq_digital(i2s_buff, RATE, mean, max_v, min_v, &freq, &period, &trigger0); trigger_freq_digital(i2s_buff, RATE, mean, max_v, min_v, &freq, &period, &trigger0);
} }
single_trigger = false; single_trigger = false;
new_data = true; new_data = true;
Serial.println("Single GOT"); Serial.println("Single GOT");
//return to normal execution in stop mode // return to normal execution in stop mode
} }
vTaskDelay(pdMS_TO_TICKS(1)); //time for the other task to start (low priorit) vTaskDelay(pdMS_TO_TICKS(1)); // time for the other task to start (low priorit)
} }
vTaskDelay(pdMS_TO_TICKS(300)); vTaskDelay(pdMS_TO_TICKS(300));
} }