Exemple #1
0
unsigned long testFastLines(uint16_t color1, uint16_t color2) {
    unsigned long start;
    int x, y, w = tft.width(), h = tft.height();

    tft.fillScreen(ILI9341_BLACK);
    start = micros();
    for (y = 0; y < h; y += 5) tft.drawFastHLine(0, y, w, color1);
    for (x = 0; x < w; x += 5) tft.drawFastVLine(x, 0, h, color2);

    return micros() - start;
}
Exemple #2
0
void Button::draw() {
    if (_touching) {
        tft.fillRect(_pos.x, _pos.y, _size.w, _size.h, touchColor);
    } else {
        tft.fillRect(_pos.x-1, _pos.y-1, _size.w, _size.h, bgColor);
        // TODO: Better drop shadow
        tft.drawFastVLine(_pos.x-1+_size.w, _pos.y-1, _size.h, ILI9341_BLACK);
        tft.drawFastHLine(_pos.x-1, _pos.y-1+_size.h, _size.w, ILI9341_BLACK);
    }

    Label::draw();
}
Exemple #3
0
void Stat::drawChart() {
    if (_redrawChart) {
        _cur = 0;
        tft.fillRect(_chart.x, _chart.y - 1 /* catch the top of the unit of the axis */,
                     _chartWidth, 32 /* to catch the bottom of the unit on the axis */,
                     ILI9341_BLACK);
        tft.setCursor(_chart.x + 27 - ((int16_t) strlen(_labelText) * 6), _chart.y + 12+CURSOR_Y_SMALL);
        tft.setTextColor(ILI9341_WHITE);
        tft.setFont(&Inconsolata_g5pt7b);
        tft.print(_labelText);
        tft.setCursor(_chart.x + _chartWidth - 45, _chart.y+CURSOR_Y_SMALL);
        tft.print(_max == INT_MIN ? 0 : _max);

        if (_unitText) {
            tft.setTextColor(_chartColor);
            tft.setCursor(_chart.x + _chartWidth - 45, _chart.y + 12+CURSOR_Y_SMALL);
            tft.print(_unitText);
            tft.setTextColor(ILI9341_WHITE);
        }
        tft.setCursor(_chart.x + _chartWidth - 45, _chart.y + 24+CURSOR_Y_SMALL);
        tft.print(_min == INT_MAX ? 0 : _min);
        tft.setFont(&Inconsolata_g8pt7b);
        _redrawChart = false;
        tft.fillRect(_chart.x + 30, _chart.y, _chartWidth - 80, 30, tft.color565(10, 10, 10));
    }

    for ( ; _cur < _end; _cur++) {
        if (invalidReadingi(_historical[_cur])) {
            tft.drawFastVLine(_chart.x+30+_cur, _chart.y, 30, ILI9341_MAROON);
            continue;
        }
        int norm = (int) map(_historical[_cur], _min, _max, 0, 29);
        int x = _chart.x+30+_cur;
        int y = _chart.y+29-norm;
        tft.fillRect(x, y, 1, 1, _chartColor);
    }
}