Fixed ok button reset problem. The TFTe user configuration is used now to decide which diesplay is used in the esp32 osci implementation.

This commit is contained in:
Kai Lauterbach 2024-02-09 10:28:34 +01:00
parent 1a54d4bc59
commit cfc8bcfba9
3 changed files with 45 additions and 19 deletions

View file

@ -6,6 +6,7 @@
#include <driver/adc.h>
#include <soc/syscon_reg.h>
#include <User_Setup.h>
#include <TFT_eSPI.h>
#include <SPI.h>
@ -17,8 +18,21 @@
#define DEBUG_DELAY 250
// Width and height of sprite
#ifdef ILI9341_DRIVER
#warning "Use ILI9341 display settings."
#define DISPLAY_HEIGHT 240
#define DISPLAY_WIDTH 320
#endif
#ifdef ST7789_DRIVER
#warning "Use ST7789 display settings."
#define DISPLAY_HEIGHT 240
#define DISPLAY_WIDTH 280
#endif
#ifndef DISPLAY_HEIGHT
#error "No display driver defined"
#endif
#define ADC_CHANNEL ADC1_CHANNEL_5 // GPIO33
#define NUM_SAMPLES 1000 // number of samples
@ -114,6 +128,10 @@ void IRAM_ATTR btback()
void setup() {
Serial.begin(115200);
esp_reset_reason_t reset_reason = esp_reset_reason();
Serial.print("Reset reason: ");
Serial.println(reset_reason);
configure_i2s(1000000);
setup_screen();
@ -193,6 +211,7 @@ void core1_task(void *pvParameters)
if (stop_change)
{
i2s_adc_enable(I2S_NUM_0);
i2s_zero_dma_buffer(I2S_NUM_0);
stop_change = false;
}
ADC_Sampling(i2s_buff);
@ -202,7 +221,8 @@ void core1_task(void *pvParameters)
{
if (!stop_change)
{
i2s_adc_disable(I2S_NUM_0);
// TODO the disable function causes an esp32 reset
//i2s_adc_disable(I2S_NUM_0);
i2s_zero_dma_buffer(I2S_NUM_0);
stop_change = true;
}
@ -210,7 +230,7 @@ void core1_task(void *pvParameters)
// Serial.println("CORE1");
vTaskDelay(pdMS_TO_TICKS(300));
}
else
else // else single trigger
{
float old_mean = 0;
while (single_trigger)

View file

@ -132,6 +132,7 @@ void button()
{
set_value = 0;
btnbk = 0;
btnok = 0;
}
}
else
@ -143,8 +144,8 @@ void button()
{
opt = 1;
}
Serial.print("option : ");
Serial.println(opt);
//Serial.print("option : ");
//Serial.println(opt);
btnpl = 0;
}
if (btnmn == 1)
@ -154,8 +155,8 @@ void button()
{
opt = 9;
}
Serial.print("option : ");
Serial.println(opt);
//Serial.print("option : ");
//Serial.println(opt);
btnmn = 0;
}
if (btnbk == 1)
@ -172,29 +173,19 @@ void button()
break;
case Vdiv:
set_value = true;
break;
case Sdiv:
set_value = true;
break;
case Offset:
case TOffset:
set_value = true;
break;
case Stop:
stop = !stop;
Serial.print("Stop : ");
Serial.println(stop);
//Serial.print("Stop : ");
//Serial.println(stop);
set_value = false;
break;
case TOffset:
set_value = true;
// set_value = false;
break;
case Single:
single_trigger = true;
set_value = false;

View file

@ -1,7 +1,12 @@
void setup_screen() {
// Initialise the TFT registers
tft.init();
#ifdef ILI9341_DRIVER
tft.setRotation(3);
#endif
#ifdef ST7789_DRIVER
tft.setRotation(1);
#endif
// Optionally set colour depth to 8 or 16 bits, default is 16 if not spedified
spr.setColorDepth(8);
@ -165,7 +170,12 @@ void draw_sprite(float freq,
draw_channel1(trigger, 0, i2s_buff, sample_rate);
}
#ifdef ILI9341_DRIVER
int shift = DISPLAY_WIDTH - 130;
#endif
#ifdef ST7789_DRIVER
int shift = DISPLAY_WIDTH - 110;
#endif
if (menu) {
spr.drawLine( 0, DISPLAY_HEIGHT/2, DISPLAY_WIDTH, DISPLAY_HEIGHT/2, TFT_WHITE); //center line
spr.fillRect(shift, 0, (DISPLAY_HEIGHT/2)-18, (DISPLAY_HEIGHT/2)+15, TFT_BLACK);
@ -199,7 +209,12 @@ void draw_sprite(float freq,
spr.drawString(offset_line, shift + 25, (DISPLAY_HEIGHT/2)-8);
if (set_value) {
#ifdef ILI9341_DRIVER
uint16_t t_left = shift+161;
#endif
#ifdef ST7789_DRIVER
uint16_t t_left = shift+149; // previously hard coeded value 229
#endif
// Plus symbols while setting a value
spr.fillRect(t_left, 0, 11, 11, TFT_BLUE);
spr.drawRect(t_left, 0, 11, 11, TFT_WHITE);