Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include "layout.h"
#define SCREEN_W LY_W
#define SCREEN_H LY_H
#define BACKLIGHT_PIN TFT_BL // set by build flags per board
#ifndef BACKLIGHT_PIN
#define BACKLIGHT_PIN TFT_BL // TFT_eSPI: set via -D TFT_BL=N; LovyanGFX: set via -D BACKLIGHT_PIN=N
#endif
#define BACKLIGHT_CH 0
#define BACKLIGHT_FREQ 5000
#define BACKLIGHT_RES 8
Expand Down
112 changes: 14 additions & 98 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
; BambuHelper - Bambu Lab Printer Monitor
; Supports ESP32-S3 Super Mini and ESP32-2432S028 (CYD)
; Supports ESP32-S3 Super Mini, ESP32-2432S028 (CYD), ESP32-C3 Super Mini

; --- Shared library dependencies ---
[common]
lib_deps =
bodmer/TFT_eSPI@^2.5.43
bodmer/TFT_eWidget@^0.0.6
lovyan03/LovyanGFX@^1.1.16
knolleary/PubSubClient@^2.8
bblanchon/ArduinoJson@^7.0

; --- Shared TFT_eSPI + font flags (driver/pins are per-env) ---
common_flags =
-D USER_SETUP_LOADED=1
-D DISABLE_ALL_LIBRARY_WARNINGS=1
-D LOAD_GLCD=1
-D LOAD_FONT2=1
-D LOAD_FONT4=1
-D LOAD_FONT6=1
-D LOAD_FONT7=1
-D LOAD_GFXFF=1
-D SMOOTH_FONT=1

; =============================================================================
; ESP32-S3 Super Mini + ST7789 240x240
; ESP32-S3 Super Mini + ST7789 240x240
; =============================================================================
[env:esp32s3]
platform = espressif32
Expand All @@ -33,67 +20,42 @@ board_build.partitions = partitions_4mb.csv
board_build.arduino.memory_type = qio_qspi
lib_deps = ${common.lib_deps}
build_flags =
${common.common_flags}
-D BOARD_VARIANT=\"esp32s3\"
-D BOARD_IS_S3=1
-D ENABLE_OTA_AUTO=1
-D SPI_FREQUENCY=40000000
; --- Display driver ---
-D ST7789_DRIVER=1
-D TFT_WIDTH=240
-D TFT_HEIGHT=240
-D BACKLIGHT_PIN=13
; --- USB Serial (S3 native USB CDC) ---
-D ARDUINO_USB_CDC_ON_BOOT=1
; --- SPI pins (S3 Super Mini) ---
-D TFT_MOSI=11 ;SDA
-D TFT_SCLK=12 ;SCL
-D TFT_CS=10
-D TFT_DC=9
-D TFT_RST=8 ;14
-D TFT_BL=13
-D USE_FSPI_PORT=1

; =============================================================================
; ESP32-2432S028 (CYD - Cheap Yellow Display) + ILI9341 240x320
; ESP32-2432S028 (CYD - Cheap Yellow Display) + ILI9342 240x320
; =============================================================================
[env:cyd]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
upload_speed = 230400
board_build.partitions = partitions_4mb.csv
board_build.partitions = min_spiffs.csv
lib_deps =
${common.lib_deps}
https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
build_flags =
${common.common_flags}
-D SPI_FREQUENCY=27000000
; --- Display driver ---
; ILI9341_2 works for both ILI9341 and ILI9342 CYD variants
-D ILI9341_2_DRIVER=1
-D TFT_INVERSION_ON=1
-D TFT_WIDTH=240
-D TFT_HEIGHT=320
; --- CYD display SPI pins ---
-D TFT_MOSI=13
-D TFT_SCLK=14
-D TFT_CS=15
-D TFT_DC=2
-D TFT_RST=12
-D TFT_BL=21
; --- CYD touch (XPT2046 on separate SPI bus) ---
-D USE_XPT2046=1
-D TOUCH_CS=33
-D TOUCH_IRQ=36
-D TOUCH_MOSI=32
-D TOUCH_MISO=39
-D TOUCH_CLK=25
-D SPI_TOUCH_FREQUENCY=2500000
-D USE_XPT2046=1
; --- Layout profile ---
-D DISPLAY_CYD=1
-D DISPLAY_240x320=1
-D BOARD_VARIANT=\"cyd\"
-D ENABLE_OTA_AUTO=1
-D BOARD_LOW_RAM=1
-D BACKLIGHT_PIN=21

; =============================================================================
; Waveshare ESP32-S3-Touch-LCD-2 (2.0" ST7789 240x320)
Expand All @@ -108,30 +70,10 @@ board_build.partitions = partitions_4mb.csv
board_build.arduino.memory_type = qio_qspi
lib_deps = ${common.lib_deps}
build_flags =
${common.common_flags}
-D BOARD_VARIANT=\"ws_lcd_200\"
-D ENABLE_OTA_AUTO=1
-D SPI_FREQUENCY=80000000
; --- Display driver ---
-D ST7789_DRIVER=1
-D TFT_WIDTH=240
-D TFT_HEIGHT=320
-D TFT_RGB_ORDER=0
; --- USB Serial (S3 native USB CDC) ---
-D ARDUINO_USB_CDC_ON_BOOT=1
; --- SPI pins (Waveshare ESP32-S3-Touch-LCD-2) ---
-D TFT_MOSI=38
-D TFT_SCLK=39
-D TFT_MISO=40
-D TFT_CS=45
-D TFT_DC=42
-D TFT_RST=-1
-D TFT_BL=1
-D USE_FSPI_PORT=1
; --- Touch (CST816D on I2C) ---
-D USE_CST816=1
-D CST816_SDA=48
-D CST816_SCL=47
; --- Layout profile (same 240x320 as CYD) ---
-D DISPLAY_240x320=1

Expand All @@ -148,24 +90,10 @@ board_build.partitions = partitions_4mb.csv
board_build.arduino.memory_type = qio_qspi
lib_deps = ${common.lib_deps}
build_flags =
${common.common_flags}
-D BOARD_VARIANT=\"ws_lcd_154\"
-D ENABLE_OTA_AUTO=1
-D SPI_FREQUENCY=80000000
; --- Display driver ---
-D ST7789_DRIVER=1
-D TFT_WIDTH=240
-D TFT_HEIGHT=240
; --- USB Serial (S3 native USB CDC) ---
-D ARDUINO_USB_CDC_ON_BOOT=1
; --- SPI pins (Waveshare ESP32-S3-Touch-LCD-1.54) ---
-D TFT_MOSI=39
-D TFT_SCLK=38
-D TFT_CS=21
-D TFT_DC=45
-D TFT_RST=40
-D TFT_BL=46
-D USE_FSPI_PORT=1
; --- Battery power-hold (AXP2101) ---
-D BAT_EN=2
; --- Built-in buttons (from Waveshare button example) ---
Expand Down Expand Up @@ -199,24 +127,12 @@ board = lolin_c3_mini
framework = arduino
monitor_speed = 115200
board_build.partitions = partitions_4mb.csv
extra_scripts = pre:scripts/patch_spi_for_esp32-c3.py
lib_deps = ${common.lib_deps}
build_flags =
${common.common_flags}
-D SPI_FREQUENCY=40000000
; --- Display driver ---
-D ST7789_DRIVER=1
-D TFT_WIDTH=240
-D TFT_HEIGHT=240
; --- USB Serial (C3 native USB CDC) ---
-D ARDUINO_USB_CDC_ON_BOOT=1
; --- SPI pins (C3 Super Mini) ---
-D TFT_MOSI=20 ;SDA
-D TFT_SCLK=21 ;SCL
-D TFT_CS=6
-D TFT_DC=7
-D TFT_RST=10
-D TFT_BL=5
-D BOARD_VARIANT=\"esp32c3\"
-D BOARD_IS_C3=1
-D ENABLE_OTA_AUTO=1
-D BACKLIGHT_PIN=5
; --- USB Serial (C3 native USB CDC) ---
-D ARDUINO_USB_CDC_ON_BOOT=1
-D BOARD_LOW_RAM=1
3 changes: 0 additions & 3 deletions src/clock_pong.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
#include "layout.h"
#include "settings.h"
#include "display_ui.h"
#include <TFT_eSPI.h>
#include <time.h>

extern TFT_eSPI tft;

// ========== Layout constants (from layout profile) ==========
#define ARK_BRICK_ROWS LY_ARK_BRICK_ROWS
#define ARK_BRICK_COLS LY_ARK_COLS
Expand Down
40 changes: 20 additions & 20 deletions src/display_anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
// ---------------------------------------------------------------------------
static uint16_t spinnerAngle = 0;

void drawSpinner(TFT_eSPI& tft, int16_t cx, int16_t cy, int16_t radius,
void drawSpinner(lgfx::LovyanGFX& tft, int16_t cx, int16_t cy, int16_t radius,
uint16_t color) {
// Erase previous arc segment (handle wrap-around)
uint16_t prevStart = (spinnerAngle + 360 - 12) % 360;
uint16_t prevEnd = (prevStart + 60) % 360;
if (prevEnd > prevStart) {
tft.drawSmoothArc(cx, cy, radius, radius - 4,
prevStart, prevEnd, CLR_BG, CLR_BG, false);
tft.drawArc(cx, cy, radius, radius - 4,
prevStart, prevEnd, CLR_BG);
} else {
tft.drawSmoothArc(cx, cy, radius, radius - 4,
prevStart, 360, CLR_BG, CLR_BG, false);
tft.drawSmoothArc(cx, cy, radius, radius - 4,
0, prevEnd, CLR_BG, CLR_BG, false);
tft.drawArc(cx, cy, radius, radius - 4,
prevStart, 360, CLR_BG);
tft.drawArc(cx, cy, radius, radius - 4,
0, prevEnd, CLR_BG);
}

// Advance angle
Expand All @@ -34,20 +34,20 @@ void drawSpinner(TFT_eSPI& tft, int16_t cx, int16_t cy, int16_t radius,

// Draw arc segment (handle wrap-around)
if (arcEnd > arcStart) {
tft.drawSmoothArc(cx, cy, radius, radius - 4,
arcStart, arcEnd, color, CLR_BG, false);
tft.drawArc(cx, cy, radius, radius - 4,
arcStart, arcEnd, color);
} else {
tft.drawSmoothArc(cx, cy, radius, radius - 4,
arcStart, 360, color, CLR_BG, false);
tft.drawSmoothArc(cx, cy, radius, radius - 4,
0, arcEnd, color, CLR_BG, false);
tft.drawArc(cx, cy, radius, radius - 4,
arcStart, 360, color);
tft.drawArc(cx, cy, radius, radius - 4,
0, arcEnd, color);
}
}

// ---------------------------------------------------------------------------
// Animated dots "..."
// ---------------------------------------------------------------------------
void drawAnimDots(TFT_eSPI& tft, int16_t x, int16_t y, uint16_t color) {
void drawAnimDots(lgfx::LovyanGFX& tft, int16_t x, int16_t y, uint16_t color) {
unsigned long ms = millis();
int phase = (ms / 400) % 4;

Expand All @@ -64,7 +64,7 @@ void drawAnimDots(TFT_eSPI& tft, int16_t x, int16_t y, uint16_t color) {
// ---------------------------------------------------------------------------
// Indeterminate slide bar — a glowing segment slides back and forth
// ---------------------------------------------------------------------------
void drawSlideBar(TFT_eSPI& tft, int16_t x, int16_t y, int16_t w, int16_t h,
void drawSlideBar(lgfx::LovyanGFX& tft, int16_t x, int16_t y, int16_t w, int16_t h,
uint16_t color, uint16_t trackColor) {
// Draw track (also erases previous segment position)
tft.fillRoundRect(x, y, w, h, h / 2, trackColor);
Expand Down Expand Up @@ -95,7 +95,7 @@ static unsigned long completionStart = 0;
static bool completionDone = false;
static int16_t prevRing = 0;

void drawCompletionAnim(TFT_eSPI& tft, int16_t cx, int16_t cy, bool reset) {
void drawCompletionAnim(lgfx::LovyanGFX& tft, int16_t cx, int16_t cy, bool reset) {
if (reset) {
completionStart = millis();
completionDone = false;
Expand All @@ -113,18 +113,18 @@ void drawCompletionAnim(TFT_eSPI& tft, int16_t cx, int16_t cy, bool reset) {
int16_t r = 10 + (elapsed * (finalR - 10)) / 400;
// Erase previous ring
if (prevRing > 0 && prevRing != r) {
tft.drawSmoothArc(cx, cy, prevRing, prevRing - 3, 0, 360, CLR_BG, CLR_BG, false);
tft.drawArc(cx, cy, prevRing, prevRing - 3, 0, 360, CLR_BG);
}
tft.drawSmoothArc(cx, cy, r, r - 3, 0, 360, CLR_GREEN, CLR_BG, false);
tft.drawArc(cx, cy, r, r - 3, 0, 360, CLR_GREEN);
prevRing = r;
}
// Phase 2 (400-600ms): settle to final ring
else if (elapsed < 600) {
tft.drawSmoothArc(cx, cy, finalR, finalR - 4, 0, 360, CLR_GREEN, CLR_BG, false);
tft.drawArc(cx, cy, finalR, finalR - 4, 0, 360, CLR_GREEN);
}
// Phase 3 (600ms+): static ring + large checkmark, done
else {
tft.drawSmoothArc(cx, cy, finalR, finalR - 4, 0, 360, CLR_GREEN, CLR_BG, false);
tft.drawArc(cx, cy, finalR, finalR - 4, 0, 360, CLR_GREEN);
// Clear center for checkmark
tft.fillCircle(cx, cy, finalR - 5, CLR_BG);
// Draw 32x32 checkmark centered
Expand Down
10 changes: 5 additions & 5 deletions src/display_anim.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#ifndef DISPLAY_ANIM_H
#define DISPLAY_ANIM_H

#include <TFT_eSPI.h>
#include <LovyanGFX.hpp>

// Rotating arc spinner for connecting screens
void drawSpinner(TFT_eSPI& tft, int16_t cx, int16_t cy, int16_t radius,
void drawSpinner(lgfx::LovyanGFX& tft, int16_t cx, int16_t cy, int16_t radius,
uint16_t color);

// Animated dots "..." that cycle (call each frame, uses millis())
void drawAnimDots(TFT_eSPI& tft, int16_t x, int16_t y, uint16_t color);
void drawAnimDots(lgfx::LovyanGFX& tft, int16_t x, int16_t y, uint16_t color);

// Pulsing glow on arc edge (returns brightness factor 0.5-1.0)
float getPulseFactor();

// Indeterminate slide bar (call each frame — uses millis() internally)
void drawSlideBar(TFT_eSPI& tft, int16_t x, int16_t y, int16_t w, int16_t h,
void drawSlideBar(lgfx::LovyanGFX& tft, int16_t x, int16_t y, int16_t w, int16_t h,
uint16_t color, uint16_t trackColor);

// Completion animation: expanding checkmark ring
void drawCompletionAnim(TFT_eSPI& tft, int16_t cx, int16_t cy, bool reset);
void drawCompletionAnim(lgfx::LovyanGFX& tft, int16_t cx, int16_t cy, bool reset);

#endif // DISPLAY_ANIM_H
Loading