Embarrassing ESP-32 display question

I'm basically a newbie at Arduino / ESP-32 stuff (but have some PIC experience). Sorry if this is in the wrong section -- just started today! And already I've got a really, really embarrassingly dumb question. I mean "how do you blink" level dumb. :roll_eyes:

I'm working with a touch display module (display and ESP32 on one board). Found this example on Github which draws dots as you move your finger around the screen. There are 4 buttons which let you choose different colors for the dots. I think I grasp the syntax of drawing the buttons, how the touch is detected, how the colors change, the screen orientation, the LCD communication setup, etc. But what's got me just shamefully flummoxed is...what's the command that's actually printing the dots? I mean, it has to be shockingly obvious but I'm not seeing it. I've commented out what I think might do it (like the printf statements) but it doesn't seem to stop it from working.

Please post the code, using code tags, and clearly point out the parts causing the difficulty. Post a link to the "touch display module".

Hardly anyone will go off site to see code.

1 Like

Sorry! Didn't want to go throwing code all over the place like confetti. Wasn't sure what the custom is around here.

#include <Wire.h>
#include "SPI.h"
#include <LovyanGFX.hpp>
#include "makerfabs_pin.h"
#include "FT6236.h"


#define FT6236_TOUCH


const int i2c_touch_addr = TOUCH_I2C_ADD;



struct LGFX_Config
{
    static constexpr spi_host_device_t spi_host = ESP32_TSC_9488_LCD_SPI_HOST;
    static constexpr int dma_channel = 1;
    static constexpr int spi_sclk = ESP32_TSC_9488_LCD_SCK;
    static constexpr int spi_mosi = ESP32_TSC_9488_LCD_MOSI;
    static constexpr int spi_miso = ESP32_TSC_9488_LCD_MISO;
};

static lgfx::LGFX_SPI<LGFX_Config> TFT;
static LGFX_Sprite sprite(&TFT);
static lgfx::Panel_ILI9488 panel;



int last_pos[2] = {0, 0};
int draw_color = TFT_WHITE;

void setup()
{

    Serial.begin(115200);
    while (!Serial)
        ; // Leonardo: wait for serial monitor
    Serial.println("\n NS2009 test");

 
    Wire.begin(ESP32_TSC_9488_I2C_SDA, ESP32_TSC_9488_I2C_SCL);
    byte error, address;

    Wire.beginTransmission(i2c_touch_addr);
    error = Wire.endTransmission();

    if (error == 0)
    {
        Serial.print("I2C device found at address 0x");
        Serial.print(i2c_touch_addr, HEX);
        Serial.println("  !");
    }
    else if (error == 4)
    {
        Serial.print("Unknown error at address 0x");
        Serial.println(i2c_touch_addr, HEX);
    }



    set_tft();
    TFT.begin();
   
    TFT.fillScreen(TFT_BLACK);
    TFT.fillRect(0, 0, 80, 40, TFT_RED);
    TFT.fillRect(80, 0, 80, 40, TFT_GREEN);
    TFT.fillRect(160, 0, 80, 40, TFT_BLUE);
    TFT.fillRect(240, 0, 80, 40, TFT_YELLOW);

}

void loop()
{

    int pos[2] = {0, 0};


    ft6236_pos(pos);
    Serial.printf("%d,%d\n", pos[0], pos[1]);
    if (0 < pos[1] && pos[1] < 40)
    {
        if (0 < pos[0] && pos[0] < 80)
        {
            draw_color = TFT_RED;
        }
        else if (80 < pos[0] && pos[0] < 160)
        {
            draw_color = TFT_GREEN;
        }

        else if (160 < pos[0] && pos[0] < 240)
        {
            draw_color = TFT_BLUE;
        }
        else if (240 < pos[0] && pos[0] < 320)
        {
            draw_color = TFT_YELLOW;
        }
    }
    else
    {
        TFT.fillRect(pos[0], pos[1], 3, 3, draw_color);
    }
}

int filter(int last_pos[2], int pos[2], int level)
{
    int temp = (last_pos[0] - pos[0]) * (last_pos[0] - pos[0]) + (last_pos[1] - pos[1]) * (last_pos[1] - pos[1]);
    last_pos[0] = pos[0];
    last_pos[1] = pos[1];
    if (temp > level)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}


void set_tft()
{
    
    panel.freq_write = 60000000;
    
    panel.freq_fill = 60000000;
    
    panel.freq_read = 16000000;

    panel.spi_mode = 0;
    
    panel.spi_mode_read = 0;

    panel.len_dummy_read_pixel = 8;

    panel.spi_read = true;

    panel.spi_3wire = false;

    panel.spi_cs = ESP32_TSC_9488_LCD_CS;

    panel.spi_dc = ESP32_TSC_9488_LCD_DC;

    panel.gpio_rst = ESP32_TSC_9488_LCD_RST;

    panel.gpio_bl = ESP32_TSC_9488_LCD_BL;

    panel.pwm_ch_bl = -1;

    panel.backlight_level = true;

    panel.invert = false;

    panel.rgb_order = false;
    
    panel.memory_width = ESP32_TSC_9488_LCD_WIDTH;
    panel.memory_height = ESP32_TSC_9488_LCD_HEIGHT;
   
    panel.panel_width = ESP32_TSC_9488_LCD_WIDTH;
    panel.panel_height = ESP32_TSC_9488_LCD_HEIGHT;
   
    panel.offset_x = 0;
    panel.offset_y = 0;
    
    panel.rotation = 0;
  
    panel.offset_rotation = 0;
   
    TFT.setPanel(&panel);
}

draws 3x3 pixel

OMG tysm! Jeez...I had it in my head (somehow -- don't ask me why!) that was for the "default" white color of the dot before you picked one of the button-controlled colors. Which I see now is clearly "int draw_color = TFT_WHITE;"

And now...I can blink!!!!! :grin:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.