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
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ jobs:
cp ${pioenv}/firmware.bin firmware_output/${pioenv}.bin
cp ${pioenv}/merged-firmware.bin firmware_output/${pioenv}_full.bin

- name: Build & Package esp32-s3-N16R8-extuart Firmware
run: |
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=\"${{ github.ref_name }}\" -D SHA=$GITHUB_SHA"
pioenv=esp32-s3-N16R8-extuart
pio run --environment ${pioenv}
mkdir ${pioenv}
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin ${pioenv}/boot_app0.bin
cp .pio/build/${pioenv}/firmware.bin ${pioenv}/firmware.bin
cp .pio/build/${pioenv}/bootloader.bin ${pioenv}/bootloader.bin
cp .pio/build/${pioenv}/partitions.bin ${pioenv}/partitions.bin
cd ${pioenv}
esptool.py --chip esp32-s3 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 80m --flash_size 16MB 0x0000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin
cd ..
cp ${pioenv}/firmware.bin firmware_output/${pioenv}.bin
cp ${pioenv}/merged-firmware.bin firmware_output/${pioenv}_full.bin

- name: Build & Package esp32-s3-N8R8 Firmware
run: |
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=\"${{ github.ref_name }}\" -D SHA=$GITHUB_SHA"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ dkms.conf
.clang_complete
.gcc-flags.json
.pio
.vscode

### Other files
.idea
Expand Down
9 changes: 9 additions & 0 deletions lib/Seeed_GFX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
idf_component_register(SRCS "TFT_eSPI.cpp"
INCLUDE_DIRS "."
"Extensions"
REQUIRES driver arduino-esp32
)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-misleading-indentation")
107 changes: 107 additions & 0 deletions lib/Seeed_GFX/Extensions/Button.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/***************************************************************************************
** Code for the GFX button UI element
** Grabbed from Adafruit_GFX library and enhanced to handle any label font
***************************************************************************************/
TFT_eSPI_Button::TFT_eSPI_Button(void) {
_gfx = nullptr;
_xd = 0;
_yd = 0;
_textdatum = MC_DATUM;
_label[9] = '\0';
currstate = false;
laststate = false;
}

// Classic initButton() function: pass center & size
void TFT_eSPI_Button::initButton(
TFT_eSPI *gfx, int16_t x, int16_t y, uint16_t w, uint16_t h,
uint16_t outline, uint16_t fill, uint16_t textcolor,
char *label, uint8_t textsize)
{
// Tweak arguments and pass to the newer initButtonUL() function...
initButtonUL(gfx, x - (w / 2), y - (h / 2), w, h, outline, fill,
textcolor, label, textsize);
}

// Newer function instead accepts upper-left corner & size
void TFT_eSPI_Button::initButtonUL(
TFT_eSPI *gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h,
uint16_t outline, uint16_t fill, uint16_t textcolor,
char *label, uint8_t textsize)
{
_x1 = x1;
_y1 = y1;
_w = w;
_h = h;
_outlinecolor = outline;
_fillcolor = fill;
_textcolor = textcolor;
_textsize = textsize;
_gfx = gfx;
strncpy(_label, label, 9);
}

// Adjust text datum and x, y deltas
void TFT_eSPI_Button::setLabelDatum(int16_t x_delta, int16_t y_delta, uint8_t datum)
{
_xd = x_delta;
_yd = y_delta;
_textdatum = datum;
}

void TFT_eSPI_Button::drawButton(bool inverted, String long_name) {
uint16_t fill, outline, text;

if(!inverted) {
fill = _fillcolor;
outline = _outlinecolor;
text = _textcolor;
} else {
fill = _textcolor;
outline = _outlinecolor;
text = _fillcolor;
}

uint8_t r = min(_w, _h) / 4; // Corner radius
_gfx->fillRoundRect(_x1, _y1, _w, _h, r, fill);
_gfx->drawRoundRect(_x1, _y1, _w, _h, r, outline);

if (_gfx->textfont == 255) {
_gfx->setCursor(_x1 + (_w / 8),
_y1 + (_h / 4));
_gfx->setTextColor(text);
_gfx->setTextSize(_textsize);
_gfx->print(_label);
}
else {
_gfx->setTextColor(text, fill);
_gfx->setTextSize(_textsize);

uint8_t tempdatum = _gfx->getTextDatum();
_gfx->setTextDatum(_textdatum);
uint16_t tempPadding = _gfx->getTextPadding();
_gfx->setTextPadding(0);

if (long_name == "")
_gfx->drawString(_label, _x1 + (_w/2) + _xd, _y1 + (_h/2) - 4 + _yd);
else
_gfx->drawString(long_name, _x1 + (_w/2) + _xd, _y1 + (_h/2) - 4 + _yd);

_gfx->setTextDatum(tempdatum);
_gfx->setTextPadding(tempPadding);
}
}

bool TFT_eSPI_Button::contains(int16_t x, int16_t y) {
return ((x >= _x1) && (x < (_x1 + _w)) &&
(y >= _y1) && (y < (_y1 + _h)));
}

void TFT_eSPI_Button::press(bool p) {
laststate = currstate;
currstate = p;
}

bool TFT_eSPI_Button::isPressed() { return currstate; }
bool TFT_eSPI_Button::justPressed() { return (currstate && !laststate); }
bool TFT_eSPI_Button::justReleased() { return (!currstate && laststate); }
44 changes: 44 additions & 0 deletions lib/Seeed_GFX/Extensions/Button.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/***************************************************************************************
// The following button class has been ported over from the Adafruit_GFX library so
// should be compatible.
// A slightly different implementation in this TFT_eSPI library allows the button
// legends to be in any font, allow longer labels and to adjust text positioning
// within button
***************************************************************************************/

class TFT_eSPI_Button
{
public:
TFT_eSPI_Button(void);
// "Classic" initButton() uses centre & size
void initButton(TFT_eSPI *gfx, int16_t x, int16_t y,
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
uint16_t textcolor, char *label, uint8_t textsize);

// New/alt initButton() uses upper-left corner & size
void initButtonUL(TFT_eSPI *gfx, int16_t x1, int16_t y1,
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
uint16_t textcolor, char *label, uint8_t textsize);

// Adjust text datum and x, y deltas
void setLabelDatum(int16_t x_delta, int16_t y_delta, uint8_t datum = MC_DATUM);

void drawButton(bool inverted = false, String long_name = "");
bool contains(int16_t x, int16_t y);

void press(bool p);
bool isPressed();
bool justPressed();
bool justReleased();

private:
TFT_eSPI *_gfx;
int16_t _x1, _y1; // Coordinates of top-left corner of button
int16_t _xd, _yd; // Button text datum offsets (wrt centre of button)
uint16_t _w, _h; // Width and height of button
uint8_t _textsize, _textdatum; // Text size multiplier and text datum for button
uint16_t _outlinecolor, _fillcolor, _textcolor;
char _label[10]; // Button text is 9 chars maximum unless long_name used

bool currstate, laststate; // Button states
};
Loading
Loading