Hi everyone. I recently bought a T-Watch S3 and am currently trying to figure out how to program it. The idea is for it to display the time and date and communicate with a LoRa transceiver on my sailboat.
To do this I started with TFT_eSPI as I already have some experience with it.
I’m a novice in C++ and am currently writing my second class ever. I’d like to create a set of widgets classes that produce sprites for use in my watch.
To do this, I decided to start with a simple circle, just to see if I could get it to work. and I’m sorry to say I didn’t succeed.
main.ino:
#include "SPI.h"
#include "TFT_eSPI.h"
#include "widgettest.h"
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite sprite = TFT_eSprite(&tft);
Testwidged widged = Testwidged(&sprite);
void setup(void) {
tft.init();
tft.setRotation(2);
sprite.createSprite(240,240);
sprite.fillScreen(TFT_BLACK);
sprite.fillCircle(30,30,20,TFT_CYAN);
widged.setsize(20,20);
widged.setxy(60,60);
}
void loop() {
widged.draw();
sprite.pushSprite(0,0);
}
widgettest.h:
#ifndef WIDGETTEST_H
#define WIDGETTEST_H
#include "TFT_eSPI.h"
class Testwidged
{
private:
TFT_eSPI _tft;
TFT_eSprite _widget ;
TFT_eSprite *_basesprite;
int _x;
int _y;
int _size_x;
int _size_y;
public:
Testwidged(){}
Testwidged( TFT_eSprite *basesprite);
void init();
void setxy(int x, int y);
void setsize(int size_x, int size_y);
void draw();
};
#endif //WIDGETTEST_H
widgettest.cpp:
#include "TFT_eSPI.h"
#include "widgettest.h"
Testwidged::Testwidged( TFT_eSprite *basesprite)
{
_basesprite = basesprite;
}
void Testwidged::init()
{
_tft = TFT_eSPI();
_widget = TFT_eSprite(&_tft);
}
void Testwidged::setxy(int x, int y)
{
_x = x;
_y = y;
}
void Testwidged::setsize(int size_x, int size_y)
{
_size_x = size_x;
_size_y = size_y;
}
void Testwidged::draw()
{
_widget.createSprite(_size_x,_size_y);
_widget.fillScreen(TFT_BLACK);
_widget.drawCircle(0,0,(_size_x/2)-2,TFT_RED);
_widget.pushToSprite(_basesprite, _x, _y, TFT_BLACK);
}
output:
Processing twatch-s3 (platform: espressif32@6.3.0; framework: arduino; board: LilyGoWatch-S3)
-------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/LilyGoWatch-S3.html
PLATFORM: Espressif 32 (6.3.0) > LilyGo T-Watch S3 (16M Flash 8M OPI PSRAM )
HARDWARE: ESP32S3 240MHz, 320KB RAM, 16MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.20009.0 (2.0.9)
- tool-esptoolpy @ 1.40501.0 (4.5.1)
- toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
- toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
Converting main.ino
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- TFT_eSPI @ 2.5.43
|-- SPI @ 2.0.0
Building in release mode
Compiling .pio/build/twatch-s3/src/main.ino.cpp.o
Compiling .pio/build/twatch-s3/src/widgettest.cpp.o
In file included from src/widgettest.cpp:2:
src/widgettest.h: In constructor 'Testwidged::Testwidged()':
src/widgettest.h:19:17: error: no matching function for call to 'TFT_eSprite::TFT_eSprite()'
Testwidged(){}
^
In file included from .pio/libdeps/twatch-s3/TFT_eSPI/TFT_eSPI.h:1009,
from src/widgettest.cpp:1:
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:12:12: note: candidate: 'TFT_eSprite::TFT_eSprite(TFT_eSPI*)'
explicit TFT_eSprite(TFT_eSPI *tft);
^~~~~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:12:12: note: candidate expects 1 argument, 0 provided
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:8:7: note: candidate: 'TFT_eSprite::TFT_eSprite(const TFT_eSprite&)'
class TFT_eSprite : public TFT_eSPI {
^~~~~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:8:7: note: candidate expects 1 argument, 0 provided
src/widgettest.cpp: In constructor 'Testwidged::Testwidged(TFT_eSprite*)':
src/widgettest.cpp:5:48: error: no matching function for call to 'TFT_eSprite::TFT_eSprite()'
Testwidged::Testwidged( TFT_eSprite *basesprite)
^
In file included from .pio/libdeps/twatch-s3/TFT_eSPI/TFT_eSPI.h:1009,
from src/widgettest.cpp:1:
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:12:12: note: candidate: 'TFT_eSprite::TFT_eSprite(TFT_eSPI*)'
explicit TFT_eSprite(TFT_eSPI *tft);
^~~~~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:12:12: note: candidate expects 1 argument, 0 provided
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:8:7: note: candidate: 'TFT_eSprite::TFT_eSprite(const TFT_eSprite&)'
class TFT_eSprite : public TFT_eSPI {
^~~~~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:8:7: note: candidate expects 1 argument, 0 provided
src/widgettest.cpp: In member function 'void Testwidged::init()':
src/widgettest.cpp:12:21: error: use of deleted function 'TFT_eSPI& TFT_eSPI::operator=(TFT_eSPI&&)'
_tft = TFT_eSPI();
^
In file included from src/widgettest.cpp:1:
.pio/libdeps/twatch-s3/TFT_eSPI/TFT_eSPI.h:427:7: note: 'TFT_eSPI& TFT_eSPI::operator=(TFT_eSPI&&)' is implicitly deleted because the default definition would be ill-formed:
class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has access to protected members
^~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/TFT_eSPI.h:427:7: error: non-static reference member 'fs::FS& TFT_eSPI::fontFS', can't use default assignment operator
src/widgettest.cpp:13:32: error: use of deleted function 'TFT_eSprite& TFT_eSprite::operator=(const TFT_eSprite&)'
_widget = TFT_eSprite(&_tft);
^
In file included from .pio/libdeps/twatch-s3/TFT_eSPI/TFT_eSPI.h:1009,
from src/widgettest.cpp:1:
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:8:7: note: 'TFT_eSprite& TFT_eSprite::operator=(const TFT_eSprite&)' is implicitly deleted because the default definition would be ill-formed:
class TFT_eSprite : public TFT_eSPI {
^~~~~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:8:7: error: use of deleted function 'TFT_eSPI& TFT_eSPI::operator=(const TFT_eSPI&)'
In file included from src/widgettest.cpp:1:
.pio/libdeps/twatch-s3/TFT_eSPI/TFT_eSPI.h:427:7: note: 'TFT_eSPI& TFT_eSPI::operator=(const TFT_eSPI&)' is implicitly deleted because the default definition would be ill-formed:
class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has access to protected members
^~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/TFT_eSPI.h:427:7: error: non-static reference member 'fs::FS& TFT_eSPI::fontFS', can't use default assignment operator
In file included from /home/bert/Documents/PlatformIO/Projects/ygf/src/main.ino:5:
src/widgettest.h: In constructor 'Testwidged::Testwidged()':
src/widgettest.h:19:17: error: no matching function for call to 'TFT_eSprite::TFT_eSprite()'
Testwidged(){}
^
In file included from .pio/libdeps/twatch-s3/TFT_eSPI/TFT_eSPI.h:1009,
from /home/bert/Documents/PlatformIO/Projects/ygf/src/main.ino:4:
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:12:12: note: candidate: 'TFT_eSprite::TFT_eSprite(TFT_eSPI*)'
explicit TFT_eSprite(TFT_eSPI *tft);
^~~~~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:12:12: note: candidate expects 1 argument, 0 provided
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:8:7: note: candidate: 'TFT_eSprite::TFT_eSprite(const TFT_eSprite&)'
class TFT_eSprite : public TFT_eSPI {
^~~~~~~~~~~
.pio/libdeps/twatch-s3/TFT_eSPI/Extensions/Sprite.h:8:7: note: candidate expects 1 argument, 0 provided
*** [.pio/build/twatch-s3/src/widgettest.cpp.o] Error 1
*** [.pio/build/twatch-s3/src/main.ino.cpp.o] Error 1
======================================================= [FAILED] Took 7.59 seconds =======================================================
* The terminal process "platformio 'run'" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
questions:
- is this a convenient / correct way to achieve this, or are there better ways.
- can someone point me in the right direction, and tell me what I’m doing wrong?
Replies are greatly appreciated. Kind regards, Bert