From 68b0b367e5130ee93736f34a3cc3dac47ec8e3d4 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sun, 4 Feb 2024 12:42:23 +0100 Subject: [PATCH] Applied website user comment bugfixes. --- ESP32_Oscilloscope/i2s.ino | 8 ++++++++ ESP32_Oscilloscope/screen.ino | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ESP32_Oscilloscope/i2s.ino b/ESP32_Oscilloscope/i2s.ino index 3abf955..a4c319a 100644 --- a/ESP32_Oscilloscope/i2s.ino +++ b/ESP32_Oscilloscope/i2s.ino @@ -23,12 +23,20 @@ void configure_i2s(int rate) { i2s_adc_enable(I2S_NUM_0); } +/* void ADC_Sampling(uint16_t *i2s_buff){ for (int i = 0; i < B_MULT; i++) { //TODO i2s_read_bytes is deprecated, replace with new function i2s_read_bytes(I2S_NUM_0, (char*)&i2s_buff[i * NUM_SAMPLES], NUM_SAMPLES * sizeof(uint16_t), portMAX_DELAY); } } +*/ +void ADC_Sampling(uint16_t *i2s_buff){ + size_t bytes_read; for (int i = 0; i < B_MULT; i++) { + i2s_read(I2S_NUM_0, (void*)&i2s_buff[i * NUM_SAMPLES], NUM_SAMPLES * sizeof(uint16_t), &bytes_read, portMAX_DELAY); + for(size_t ix = 0; ix < bytes_read/2; ix++) i2s_buff[(i * NUM_SAMPLES) + ix] &= 0x0FFF; // 16bit to 12bit conversionĀ  + } +} void set_sample_rate(uint32_t rate) { i2s_driver_uninstall(I2S_NUM_0); diff --git a/ESP32_Oscilloscope/screen.ino b/ESP32_Oscilloscope/screen.ino index 23fe2a4..e32133c 100644 --- a/ESP32_Oscilloscope/screen.ino +++ b/ESP32_Oscilloscope/screen.ino @@ -178,7 +178,8 @@ void draw_sprite(float freq, spr.drawRect(shift, 0, 70, 30, TFT_WHITE); spr.drawString("P-P: " + String(max_v - min_v) + "V", shift + 5, 5); spr.drawString(frequency, shift + 5, 15); - String offset_line = String((2.0 * v_div) / 1000.0 - offset) + "V"; + //String offset_line = String((2.0 * v_div) / 1000.0 - offset) + "V"; + String offset_line = String((3.0 * v_div) / 1000.0 - offset) + "V"; spr.drawString(offset_line, shift + 40, 59); if (set_value) { @@ -200,7 +201,8 @@ void draw_sprite(float freq, spr.drawString(frequency, shift + 15, 15); spr.drawString(String(int(v_div)) + "mV/div", shift - 100, 5); spr.drawString(String(int(s_div)) + "uS/div", shift - 100, 15); - String offset_line = String((2.0 * v_div) / 1000.0 - offset) + "V"; + //String offset_line = String((2.0 * v_div) / 1000.0 - offset) + "V"; + String offset_line = String((3.0 * v_div) / 1000.0 - offset) + "V"; spr.drawString(offset_line, shift + 100, 112); }