Exemple #1
0
void Stat::drawLabel() {
    if (!_hideLabel) {
        tft.setFont(&Inconsolata_g8pt7b);
        tft.setCursor(_pos.x, _pos.y+1+CURSOR_Y_LARGE);
        tft.setTextColor(ILI9341_WHITE);
        tft.print(_labelText);
    }
    tft.fillRect(_value.x, _value.y, _controlWidth, 17, tft.color565(10, 10, 10));
}
Exemple #2
0
unsigned long testFilledTriangles() {
  unsigned long start, t = 0;
  int           i, cx = tft.width()  / 2 - 1,
                   cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(i=min(cx,cy); i>10; i-=5) {
    start = micros();
    tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(0, i, i));
    t += micros() - start;
    tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(i, i, 0));
  }

  return t;
}
Exemple #3
0
void Stat::drawValue() {
    char valStr[8];
    size_t valLength;
    if (validReadingi(_stat)) {
        valLength = (size_t) sprintf(valStr, "%d", _stat);
    } else {
        valLength = (size_t) sprintf(valStr, "-- ");
    }
    if (_lastValLength > 0) {
        if (_lastValDrawn == _stat) {
            return;
        }

        tft.setCursor(_value.x, _value.y + 1 + CURSOR_Y_LARGE);
        tft.setFont(&Inconsolata_g8pt7b);
        tft.setTextColor(tft.color565(10, 10, 10));
        tft.print(_lastVal);

        if (valLength != _lastValLength) {
            tft.setFont(&Inconsolata_g5pt7b);
            tft.print(_unitText);
        }
    }

    tft.setCursor(_value.x, _value.y+1+CURSOR_Y_LARGE);
    tft.setFont(&Inconsolata_g8pt7b);
    tft.setTextColor(ILI9341_WHITE, tft.color565(10, 10, 10));
    tft.print(valStr);
    tft.setFont(&Inconsolata_g5pt7b);
    if (valLength != _lastValLength) {
        tft.setFont(&Inconsolata_g5pt7b);
        tft.print(_unitText);
    }
    memcpy(_lastVal, valStr, valLength+1);
    _lastValDrawn = _stat;
    _lastValLength = valLength;
}
Exemple #4
0
unsigned long testFilledRoundRects() {
  unsigned long start;
  int           i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(i=min(tft.width(), tft.height()); i>20; i-=6) {
    i2 = i / 2;
    tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
  }

  return micros() - start;
}
Exemple #5
0
unsigned long testRoundRects() {
  unsigned long start;
  int           w, i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9341_BLACK);
  w     = min(tft.width(), tft.height());
  start = micros();
  for(i=0; i<w; i+=6) {
    i2 = i / 2;
    tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
  }

  return micros() - start;
}
Exemple #6
0
unsigned long testTriangles() {
  unsigned long start;
  int           n, i, cx = tft.width()  / 2 - 1,
                      cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9341_BLACK);
  n     = min(cx, cy);
  start = micros();
  for(i=0; i<n; i+=5) {
    tft.drawTriangle(
      cx    , cy - i, // peak
      cx - i, cy + i, // bottom left
      cx + i, cy + i, // bottom right
      tft.color565(0, 0, i));
  }

  return micros() - start;
}
Exemple #7
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);
    }
}