Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector media buttons #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
39 changes: 21 additions & 18 deletions examples/graphicstest/graphicstest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,26 @@ void tftPrintTest() {
tft.print(" seconds.");
}

void mediabuttons() {
// play
void mediabuttons()
{
const int border = 6; // border around screen
const int margin = 14; // margin inside button
static int w = tft.width();
static int h = tft.height();

const int bh = (h-3*border) / 2; // button height
const int bw = (w-2*border); // button width
const int br = 6; // border radius

// Play button
tft.fillScreen(ST77XX_BLACK);
tft.fillRoundRect(25, 10, 78, 60, 8, ST77XX_WHITE);
tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_RED);
delay(500);
// pause
tft.fillRoundRect(25, 90, 78, 60, 8, ST77XX_WHITE);
tft.fillRoundRect(39, 98, 20, 45, 5, ST77XX_GREEN);
tft.fillRoundRect(69, 98, 20, 45, 5, ST77XX_GREEN);
delay(500);
// play color
tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_BLUE);
delay(50);
// pause color
tft.fillRoundRect(39, 98, 20, 45, 5, ST77XX_RED);
tft.fillRoundRect(69, 98, 20, 45, 5, ST77XX_RED);
// play color
tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_GREEN);
tft.fillRoundRect(border, border, bw, bh, br, ST77XX_WHITE);
tft.fillTriangle(border+margin, border+margin, border+margin, border+bh-margin, w-border-margin, border+bh/2, ST77XX_RED);

// Pause button
const int h2 = h/2;
const int barw = (bw-3*margin)/2; // bar width
tft.fillRoundRect(border, h2+border, bw, bh, br, ST77XX_WHITE);
tft.fillRoundRect(border+margin, h2+border+margin, barw, bh-2*margin, br/2, ST77XX_GREEN);
tft.fillRoundRect(border+margin+barw+margin, h2+border+margin, barw, bh-2*margin, br/2, ST77XX_GREEN);
}