diff --git a/ESP32_Oscilloscope/ESP32_Oscilloscope.ino b/ESP32_Oscilloscope/ESP32_Oscilloscope.ino index c3840b5..89b6499 100644 --- a/ESP32_Oscilloscope/ESP32_Oscilloscope.ino +++ b/ESP32_Oscilloscope/ESP32_Oscilloscope.ino @@ -14,7 +14,7 @@ #define DEBUG_SERIAL #define DEBUG_BUFF -#define DELAY 1000 +#define DELAY 250 // Width and height of sprite #define WIDTH 240 @@ -27,8 +27,8 @@ #define B_MULT BUFF_SIZE/NUM_SAMPLES #define BUTTON_Ok 32 -#define BUTTON_Plus 35 -#define BUTTON_Minus 15 +#define BUTTON_Plus 15 +#define BUTTON_Minus 35 #define BUTTON_Back 34 TFT_eSPI tft = TFT_eSPI(); // Declare object "tft" diff --git a/ESP32_Oscilloscope/options_handler.ino b/ESP32_Oscilloscope/options_handler.ino index 5cc0310..5a5feb1 100644 --- a/ESP32_Oscilloscope/options_handler.ino +++ b/ESP32_Oscilloscope/options_handler.ino @@ -12,7 +12,7 @@ int voltage_division[6] = { //screen has 4 divisions, 31 pixels each (125 pixels thus, the time division is the number of samples per screen division */ -float time_division[9] = { //screen has 4 divisions, 60 pixel each (240 pixel of width) +float time_division[9] = { //screen has 4 divisions, 60 pixel each (WIDTH pixel of width) 10, 25, 50, diff --git a/ESP32_Oscilloscope/screen.ino b/ESP32_Oscilloscope/screen.ino index 26dfd8b..6ac4457 100644 --- a/ESP32_Oscilloscope/screen.ino +++ b/ESP32_Oscilloscope/screen.ino @@ -12,7 +12,7 @@ void setup_screen() { tft.fillScreen(TFT_BLACK); } -int data[280] = {0}; +int data[HEIGHT] = {0}; float to_scale(float reading) { float temp = WIDTH - @@ -151,7 +151,7 @@ void draw_sprite(float freq, int shift = 150; if (menu) { - spr.drawLine( 0, 120, 280, 120, TFT_WHITE); //center line + spr.drawLine( 0, 120, HEIGHT, 120, TFT_WHITE); //center line spr.fillRect(shift, 0, 102, 135, TFT_BLACK); spr.drawRect(shift, 0, 102, 135, TFT_WHITE); spr.fillRect(shift + 1, 3 + 10 * (opt - 1), 100, 11, TFT_RED); @@ -195,8 +195,8 @@ void draw_sprite(float freq, } } else if (info) { - spr.drawLine( 0, 120, 280, 120, TFT_WHITE); //center line - //spr.drawRect(shift + 10, 0, 280 - shift - 20, 30, TFT_WHITE); + spr.drawLine( 0, 120, HEIGHT, 120, TFT_WHITE); //center line + //spr.drawRect(shift + 10, 0, HEIGHT - shift - 20, 30, TFT_WHITE); spr.drawString("P-P: " + String(max_v - min_v) + "V", shift + 15, 5); spr.drawString(frequency, shift + 15, 15); spr.drawString(String(int(v_div)) + "mV/div", shift - 100, 5); @@ -215,15 +215,15 @@ void draw_sprite(float freq, void draw_grid() { - for (int i = 0; i < 28; i++) { + for (int i = 0; i < (HEIGHT/10); i++) { spr.drawPixel(i * 10, 40, TFT_WHITE); spr.drawPixel(i * 10, 80, TFT_WHITE); spr.drawPixel(i * 10, 120, TFT_WHITE); spr.drawPixel(i * 10, 160, TFT_WHITE); spr.drawPixel(i * 10, 200, TFT_WHITE); } - for (int i = 0; i < 240; i += 10) { - for (int j = 0; j < 280; j += 40) { + for (int i = 0; i < WIDTH; i += 10) { + for (int j = 0; j < HEIGHT; j += 40) { spr.drawPixel(j, i, TFT_WHITE); } } @@ -245,7 +245,7 @@ void draw_channel1(uint32_t trigger0, uint32_t trigger1, uint16_t *i2s_buff, flo trigger0 += index_offset; uint32_t old_index = trigger0; float n_data = 0, o_data = to_scale(i2s_buff[trigger0]); - for (uint32_t i = 1; i < 280; i++) { + for (uint32_t i = 1; i < HEIGHT; i++) { uint32_t index = trigger0 + (uint32_t)((i + 1) * data_per_pixel); if (index < BUFF_SIZE) { if (full_pix && s_div > 40 && current_filter == 0) {