my esp32 — ESP32-C3 simulation

An interactive ESP32-C3 circuit simulation you can run free in your browser on Velxio, by gaparu75.

Components

Sketch code

// ILI9341 320x240 TFT on ESP32-C3 hardware SPI (FSPI)
// SCK=4 MISO=5 MOSI=6 CS=7 are the arduino-esp32 C3 default SPI pins.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>

#define TFT_SCK   4
#define TFT_MISO  5
#define TFT_MOSI  6
#define TFT_CS    7
#define TFT_DC    3
#define TFT_RST  10

#define RED2RED     0
#define GREEN2GREEN 1
#define BLUE2BLUE   2
#define BLUE2RED    3
#define GREEN2RED   4
#define RED2GREEN   5
#define RAINBOW     6

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
//----------------------------------------------------------------------
unsigned long lastPeakUpdateTime = 0;
const int PEAK_HOLD_TIME = 500;  // Tempo di attesa del picco (ms) prima del decadimento
const int PEAK_DECAY_RATE = 150;  // Velocità di decadimento (ogni quanti ms scende di 1 segmento)

// Variabili di stato del meter
int currentPeak = 0;             // Posizione corrente del segmento di picco
int oldVal = 0;                  // Ultimo valore grafico renderizzato
int oldPeak = 0;                 // Ultimo picco grafico renderizzato
//-----------------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  SPI.begin(TFT_SCK, TFT_MISO, TFT_MOSI, TFT_CS);
  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9341_BLACK);
//------------------------------------------------------------
  tft.drawRect(1, 11, 200, 35,  ILI9341_WHITE); //rett psusx
   tft.drawRect(0, 10, 202, 37,  ILI9341_WHITE);
    tft.fillRect(0, 5, 36, 9,  ILI9341_BLACK);
  tft.drawRect(211, 11, 100, 35,  ILI9341_WHITE);//rett temp
   tft.drawRect(210, 10, 102, 37,  ILI9341_WHITE);
    tft.fillRect(210, 5, 25, 9,  ILI9341_BLACK);
     tft.drawLine(0, 32, 199, 32, ILI9341_WHITE);
  tft.setCursor(210, 5);
  tft.setTextColor(ILI9341_WHITE);
  tft.setTextSize(1);
  tft.println("Temp");
      tft.setCursor(245, 18);
      tft.setTextColor(ILI9341_WHITE);
      tft.setTextSize(2);
      tft.println("36");
      tft.setTextSize(2);
      tft.setCursor(265, 7);
      tft.println(".");
//--------------------------------------------------------------
  tft.drawRect(1, 61, 200, 35,  ILI9341_WHITE); //rett psudx
   tft.drawRect(0, 60, 202, 37,  ILI9341_WHITE);
    tft.fillRect(0, 60, 36, 3,  ILI9341_BLACK);
  tft.drawRect(211, 61, 100, 35,  ILI9341_WHITE);//rett temp
   tft.drawRect(210, 60, 102, 37,  ILI9341_WHITE);
    tft.fillRect(210, 60, 25, 3,  ILI9341_BLACK);
     tft.drawLine(0, 82, 199, 82, ILI9341_WHITE);
  tft.setCursor(210, 55);
  tft.setTextColor(ILI9341_WHITE);
  tft.setTextSize(1);
  tft.println("Temp");
      tft.setCursor(245, 68);
      tft.setTextColor(ILI9341_WHITE);
      tft.setTextSize(2);
      tft.println("36");
      tft.setTextSize(2);
      tft.setCursor(265, 57);
      tft.println(".");
  

  
 // tft.drawLine(30, 100, 200, 100, ILI9341_WHITE);
  tft.drawLine(30, 140, 200, 140, ILI9341_WHITE);
  tft.drawLine(30, 180, 200, 180, ILI9341_WHITE);
  
  tft.setCursor(0, 5);
  tft.setTextC

More projects by gaparu75