| 50 | } |
| 51 | |
| 52 | void TFT_eSPI_Button::drawButton(bool inverted, String long_name) { |
| 53 | uint16_t fill, outline, text; |
| 54 | |
| 55 | if(!inverted) { |
| 56 | fill = _fillcolor; |
| 57 | outline = _outlinecolor; |
| 58 | text = _textcolor; |
| 59 | } else { |
| 60 | fill = _textcolor; |
| 61 | outline = _outlinecolor; |
| 62 | text = _fillcolor; |
| 63 | } |
| 64 | |
| 65 | uint8_t r = min(_w, _h) / 4; // Corner radius |
| 66 | _gfx->fillRoundRect(_x1, _y1, _w, _h, r, fill); |
| 67 | _gfx->drawRoundRect(_x1, _y1, _w, _h, r, outline); |
| 68 | |
| 69 | if (_gfx->textfont == 255) { |
| 70 | _gfx->setCursor(_x1 + (_w / 8), |
| 71 | _y1 + (_h / 4)); |
| 72 | _gfx->setTextColor(text); |
| 73 | _gfx->setTextSize(_textsize); |
| 74 | _gfx->print(_label); |
| 75 | } |
| 76 | else { |
| 77 | _gfx->setTextColor(text, fill); |
| 78 | _gfx->setTextSize(_textsize); |
| 79 | |
| 80 | uint8_t tempdatum = _gfx->getTextDatum(); |
| 81 | _gfx->setTextDatum(_textdatum); |
| 82 | uint16_t tempPadding = _gfx->getTextPadding(); |
| 83 | _gfx->setTextPadding(0); |
| 84 | |
| 85 | if (long_name == "") |
| 86 | _gfx->drawString(_label, _x1 + (_w/2) + _xd, _y1 + (_h/2) - 4 + _yd); |
| 87 | else |
| 88 | _gfx->drawString(long_name, _x1 + (_w/2) + _xd, _y1 + (_h/2) - 4 + _yd); |
| 89 | |
| 90 | _gfx->setTextDatum(tempdatum); |
| 91 | _gfx->setTextPadding(tempPadding); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | bool TFT_eSPI_Button::contains(int16_t x, int16_t y) { |
| 96 | return ((x >= _x1) && (x < (_x1 + _w)) && |
nothing calls this directly
no test coverage detected