LoveClock — ESP32 simulation

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

Components

Sketch code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <RTClib.h>
#include <Adafruit_BME280.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

#define BUTTON_NEXT 25

const unsigned long UPDATE_INTERVAL = 1000;

// --------------------------------------------------
// DEVICES
// --------------------------------------------------

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
RTC_DS3231 rtc;
Adafruit_BME280 bme;

// --------------------------------------------------
// VARIABLES
// --------------------------------------------------

uint8_t currentScreen = 0;
bool lastButtonState = HIGH;
unsigned long lastUpdate = 0;

const DateTime relationshipStart(2026, 4, 3, 16, 30, 0);

// --------------------------------------------------
// ICONS
// --------------------------------------------------

const uint8_t degreeIcon[] = {
  0b00110000,
  0b01001000,
  0b01001000,
  0b00110000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000
};

const uint8_t heartIcon[] = {
  0b01100110,
  0b11111111,
  0b11111111,
  0b11111111,
  0b01111110,
  0b00111100,
  0b00011000,
  0b00000000
};

const uint8_t arrowUpIcon[] = {
  0b00011000,
  0b00111100,
  0b01111110,
  0b00011000,
  0b00011000,
  0b00011000,
  0b00011000,
  0b00000000
};

const uint8_t arrowDownIcon[] = {
  0b00011000,
  0b00011000,
  0b00011000,
  0b00011000,
  0b01111110,
  0b00111100,
  0b00011000,
  0b00000000
};

const uint8_t arrowLeftIcon[] = {
  0b00010000,
  0b00110000,
  0b01111110,
  0b11111111,
  0b01111110,
  0b00110000,
  0b00010000,
  0b00000000
};

const uint8_t arrowRightIcon[] = {
  0b00001000,
  0b00001100,
  0b01111110,
  0b11111111,
  0b01111110,
  0b00001100,
  0b00001000,
  0b00000000
};

const uint8_t sunIcon[] = {
  0b00011000,
  0b10011001,
  0b01011010,
  0b00111100,
  0b00111100,
  0b01011010,
  0b10011001,
  0b00011000
};

const uint8_t cloudIcon[] = {
  0b00000000,
  0b00011100,
  0b00111110,
  0b01111111,
  0b11111111,
  0b11111111,
  0b01111110,
  0b00000000
};

const uint8_t rainIcon[] = {
  0b00011100,
  0b00111110,
  0b01111111,
  0b11111111,
  0b00010000,
  0b00100100,
  0b00010010,
  0b00001000
};

const uint8_t thermometerIcon[] = {
  0b00011000,
  0b00011000,
  0b00011000,
  0b00011000,
  0b00011000,
  0b00111100,
  0b00111100,
  0b00011000
};

// --------------------------------------------------
// GET ICON
// --------------------------------------------------

const uint8_t* getIcon(const String& name) {

  if (name == "degree")      return degreeIcon;
  if (name == "heart")       return heartIcon;
  if (name == "up")          return arrowUpIcon;
  if (name == "down")        return arrowDownIcon;
  if (name == "left")        return arrowLeftIcon;
  if (name == "right")       return arrowRightIcon;
  if (name == "sun")         return sunIcon;
  if (name == "cloud")       return cloudIcon;
  if (name == "rain")        return rainIcon;
  if (name == "thermometer") return thermometerIcon;

  return nullptr;
}