Skip to content

Conversation

@Federicokalik
Copy link

Provenance: This implementation and migration notes were authored by me with assistance from ChatGPT 5.

Summary

This PR adds first-class support for the Waveshare ESP32-C6-LCD-1.47" (ST7789 TFT, 172×320) and updates Netgotchi for ESP-IDF v5 / Arduino core v3 ESP-NOW changes—while keeping existing ESP8266/ESP32 OLED users unaffected by default.

Highlights

  • ✅ ST7789 TFT support via a lightweight compat layer (keeps existing drawing calls)
  • ✅ ESP-NOW v5 API compatibility (legacy “role” API removed/made no-op)
  • ✅ Optional FTP stub (prevents SD_MMC dependency build errors)
  • ✅ Clean builds on ESP32-C6 with Arduino IDE
  • ✅ Updated docs, troubleshooting, and migration guide

Motivation

  • The original code targets ESP8266/ESP32 with monochrome OLED.
  • Newer boards like ESP32-C6 and color TFTs (ST7789) require small but breaking changes: updated ESP-NOW APIs, display handling, and (for some FTP libraries) removal of hard SD_MMC assumptions.

This PR introduces opt-in support for those environments without disrupting existing users.


What’s in this PR

1) Display: ST7789 compatibility layer

  • Adds compat/CompatST7789.h implementing the subset of Adafruit-GFX APIs Netgotchi uses:
    • drawLine, drawCircle, drawPixel, basic text ops
    • setTextColor(fg, bg) supported, mapping legacy 0/1 to BLACK/WHITE for backward compatibility
  • Controlled via USE_ST7789 macro. If not defined, the original OLED path remains unchanged.

Default Waveshare pins (1.47", 172×320):

#define TFT_MOSI 6
#define TFT_SCLK 7
#define TFT_CS   14
#define TFT_DC   15
#define TFT_RST  21
#define TFT_BL   22
#define TFT_W    172
#define TFT_H    320

2) Unified includes for pins / ESP-NOW / Ping

  • New globals.h acts as the single include for files that need buttons/ESP-NOW/ping:
    • pins_local.h (defines BTN_A/B/LEFT/RIGHT, BUZZER_PIN, EXT_PIN_16 if missing)
    • espnow.h (IDF v5 wrapper with legacy callback adapter)
    • ESPping.h (points to ESP32Ping / ESP8266Ping)

Add at the very top of each relevant .ino:

#include "globals.h"

3) ESP-NOW v5 API compatibility

  • Legacy esp_now_set_self_role(ESP_NOW_ROLE_COMBO) is now a no-op (no longer required).
  • Legacy 3-argument recv callbacks (void(uint8_t* mac, uint8_t* data, uint8_t len)) are adapted to the new signature internally.
  • Peer add now uses the struct-based API:
esp_now_peer_info_t peer = {};
memcpy(peer.peer_addr, broadcastAddress, 6);
peer.ifidx   = WIFI_IF_STA;   // or WIFI_IF_AP
peer.channel = 1;             // set to your WiFi channel as needed
peer.encrypt = false;
esp_now_add_peer(&peer);

4) FTP: optional stub to avoid SD_MMC dependency

  • Some FTP libs hard-require SD_MMC, which breaks on ESP32-C6.
  • Introduces:
#define USE_FTP 0  // default off
  • Provides a stub with begin/init/handleFTP/isConnected() plus isClientConnected() alias to preserve existing code paths.
  • Users who need FTP can set USE_FTP 1 and choose a backend compatible with SPIFFS/LittleFS.

5) Deauther module (ESP8266-only) safely excluded on ESP32/ESP32-C6

  • Adds compile guard / stubs so loader.ino calls to deauthergotchi_*() do not break ESP32-C6 builds.
  • Rationale: 8266-specific raw Wi-Fi functions are unavailable on ESP32-C6; active deauth may also be illegal in many regions.

6) Screens & Web UI “matrix”

  • Removes duplicate displayInit() in screens.ino (centralises ST7789 init in the main file).
  • getPixelAt() returns black on ST7789 (no 1-bit framebuffer); the web “matrix” stays stable (just not populated from TFT by design).

7) Minor robustness fixes

  • network.ino adds extern String status; to match the global defined in the main file.
  • FTP stub provides isClientConnected() → alias of isConnected().

Backward compatibility

  • No breaking changes for existing ESP8266/ESP32 OLED users unless they explicitly opt into USE_ST7789.
  • Legacy ESP-NOW callbacks still compile; the wrapper handles the new signature.
  • FTP disabled by default on ESP32-C6; users with SD-capable FTP can enable at build time.

How to build (ESP32-C6)

  1. Arduino IDE → Board: ESP32C6 Dev Module (ESP32 Arduino core v3.x).
  2. Libraries:
    • Adafruit GFX
    • Adafruit ST7735 & ST7789
    • WiFiManager (tzapu)
    • Button2
    • NTPClient
    • ESP32Ping (optional; enables min/avg/max; otherwise avg only)
  3. Define USE_ST7789 1 and keep the Waveshare pin map (see above).
  4. Ensure each relevant .ino begins with:
    #include "globals.h"
  5. If deauthergotchi.ino exists, guard it:
    #if !defined(ESP8266)
    void deauthergotchi_setup() {}
    void deauthergotchi_loop()  {}
    #else
    // original ESP8266 code...
    #endif
  6. (Optional) Enable FTP by setting USE_FTP 1 and selecting a non-SD_MMC backend.

Testing

  • Device: Waveshare ESP32-C6-LCD-1.47"
  • Result: Boots, renders UI on ST7789, serves the web UI, network features compile and run on ESP32-C6.
  • Web “matrix” is intentionally empty when using TFT (no OLED framebuffer).
  • ESP-NOW compiles with new APIs; legacy callback signatures work via the wrapper.
  • FTP is off by default; deauther excluded on ESP32-C6.

Known limitations / Next steps

  • The web “matrix” reflects the old OLED framebuffer; a future enhancement could draw into an offscreen 1-bit buffer to populate the endpoint from TFT output.
  • If FTP is required on ESP32-C6, consider a backend targeting SPIFFS/LittleFS or add a compile-time switch for storage selection.

Documentation

  • Added/updated docs (porting notes and troubleshooting).
  • Authored with the help of ChatGPT 5 for clarity and completeness.

License

All changes follow the project’s existing GPLv3 license.


Checklist

  • Builds on ESP32-C6 with Arduino core v3.x
  • OLED path unchanged unless USE_ST7789 is defined
  • ESP-NOW v5 compatible
  • FTP optional (stubbed by default)
  • Deauther excluded on ESP32-C6
  • Docs updated (including provenance: ChatGPT 5 assisted)

Thanks for reviewing!
Happy to split this into smaller PRs (display vs ESP-NOW vs FTP) if you prefer.

DESKTOP-C1EK6V6\Calicchia Design and others added 4 commits September 23, 2025 15:42
🚀 Major Changes:
- ✅ ESP32-C6 compatibility with Arduino IDE
- ✅ ST7789 1.47" TFT LCD (172×320) support replacing OLED
- ✅ ESP-NOW API updated for ESP32 v3.x (IDF 5.x)
- ✅ FTP disabled with stub implementation (no SD_MMC dependency)
- ✅ Deauther module excluded (ESP8266 only) with safe stubs
- ✅ RGB LED strip integration
- ✅ 3D printed case compatibility

📁 New Files:
- globals.h - Unified include for all .ino files
- pins_local.h - Pin definitions for ESP32-C6
- espnow.h - ESP-NOW compatibility wrapper
- ESPping.h - Ping library mapping
- compat/CompatST7789.h/cpp - ST7789 compatibility layer
- images/fork/ - Fork-specific photos and documentation

📸 Documentation:
- Complete README.md update with fork-specific information
- Added photos of working ESP32-C6 + ST7789 implementation
- 3D printed case showcase with RGB integration
- AI development disclaimer and proper attribution

🔧 Technical Details:
- Pin mapping for Waveshare ESP32-C6-LCD-1.47"
- Color display support with full GUI compatibility
- Enhanced visual indicators with RGB LEDs
- Maintains all original Netgotchi functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Complete README.md update with fork-specific information

Added photos of working ESP32-C6 + ST7789 implementation

3D printed case showcase with RGB integration

AI development disclaimer and proper attribution
@MXZZ
Copy link
Owner

MXZZ commented Sep 24, 2025

I need to test it but it seems like a great job, did claude-ai did all of that or you did it? :-O btw bravo!

@Federicokalik
Copy link
Author

I need to test it but it seems like a great job, did claude-ai did all of that or you did it? :-O btw bravo!

Thanks, claude code only did the upload here haha, the rest is all ChatGPT-5's work 🤖

@itsOwen
Copy link
Collaborator

itsOwen commented Sep 24, 2025

@Federicokalik Did you test it afterwards? or did you just ask AI to write the code and also do the commit 💀

@Federicokalik
Copy link
Author

@Federicokalik Did you test it afterwards? or did you just ask AI to write the code and also do the commit 💀

Sure, tried it over and over again, then once it worked I uploaded everything to "my" fork and opened this PR 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants