当前位置: 首页>>代码示例>>C++>>正文


C++ TFT类代码示例

本文整理汇总了C++中TFT的典型用法代码示例。如果您正苦于以下问题:C++ TFT类的具体用法?C++ TFT怎么用?C++ TFT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TFT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
 // TFT tft ( 21 ,22 ,23  );    // with wiringpi library 
  TFT tft ( 5, 6, 13 );			// with bcm library zou can set in ILI9341.c file
  tft.init();
  tft.setAddrWindow( 0,0, 320, 240 );
  
	
    Ball balls[100];
  
   for ( int i =0; i < 100; i ++ ) {
	 balls[i].x = rand () % 280 +20; 
 	 balls[i].y = rand () % 200 +20; 
     balls[i].color = rand () % 65500;
	 balls[i].r = 2 + rand () % 8;  
   }
    
   do {
		for ( int i =0; i < 100; i ++ ) {
			balls[i].update();
			tft.fillCircle ( balls[i].x,  240 - balls[i].y, balls[i].r , balls[i].color); 
		}
	   tft.updateDisplay ();
  } while(1);
  return 0;
}
开发者ID:Nand-e,项目名称:RPI-TFTLIBS,代码行数:26,代码来源:test.c

示例2: clearPoint

// Clear (draw black) 9x9 square
void Board::clearPoint(int xPoint, int yPoint){
  TFTscreen.stroke(0, 0, 0);
  for(int i = -3; i <= 3; i++){
    for(int j = -3; j <= 3; j++){
      TFTscreen.point(xPoint + i, yPoint + j);
    }
  }
}
开发者ID:IdarV,项目名称:Arduino,代码行数:9,代码来源:board.cpp

示例3: drawPellet

// Draw a 9x9 pellet
void Board::drawPellet(Pellet pellet){
  TFTscreen.stroke(56, 3, 200);
  for(int i = -3; i <= 3; i++){
    for(int j = -3; j <= 3; j++){
      TFTscreen.point(pellet.xPos + i, pellet.yPos + j);
    }
  }
  TFTscreen.stroke(0,0,0);
}
开发者ID:IdarV,项目名称:Arduino,代码行数:10,代码来源:board.cpp

示例4: setHighScore

// Prints highscore to screen
void Board::setHighScore(uint8_t highscore){
  TFTscreen.stroke(0, 72, 255);
  TFTscreen.setCursor(0, 70);

  TFTscreen.setTextSize(3);
  TFTscreen.print(highscore);

  TFTscreen.setTextSize(1);
}
开发者ID:IdarV,项目名称:Arduino,代码行数:10,代码来源:board.cpp

示例5: drawPointFast

// Draws snake body as single point(1 pixel)
void Board::drawPointFast(uint8_t xPoint, uint8_t yPoint){
  // Set new stroke
  TFTscreen.stroke(rgbColour[0], rgbColour[1], rgbColour[2]);

  // Draw 9x9 square
  TFTscreen.point(xPoint, yPoint);

  // Set new colors
  updateColors();
}
开发者ID:IdarV,项目名称:Arduino,代码行数:11,代码来源:board.cpp

示例6: drawPoint

// Draws a 9X9 point with (xPoint, yPoint) as center
void Board::drawPoint(uint8_t xPoint, uint8_t yPoint){
  // set new stroke
  TFTscreen.stroke(rgbColour[0], rgbColour[1], rgbColour[2]);

  //Draw 9x9 square
  for(int i = -3; i <= 3; i++){
    for(int j = -3; j <= 3; j++){
      TFTscreen.point(((int)xPoint) + i, ((int)yPoint) + j);
    }
  }

  // Set new colors
  updateColors();
}
开发者ID:IdarV,项目名称:Arduino,代码行数:15,代码来源:board.cpp

示例7: drawText

void drawText(int16_t x, int16_t y, const String& str, uint16_t color)
{
  int newX = x - str.length() * 5 / 2;
  for(uint32_t ii = 0; ii < str.length(); ++ii)
  {
    TFTscreen.drawChar(newX + ii * 5, y - 4, str[ii], color, 0x0, 1);
  }
}
开发者ID:alban-rochel,项目名称:pixstick,代码行数:8,代码来源:PadConfiguration.cpp

示例8: setScore

// Prints score to screen
void Board::setScore(uint8_t score){
  TFTscreen.setTextSize(3);
  TFTscreen.setCursor(0, 20);

  // Write old score as black, which erases it
  if(score != 0){
    TFTscreen.stroke(0, 0, 0);
    TFTscreen.print(score - 1);
  }

  // Write new score in color of snake
  TFTscreen.setCursor(0, 20);
  TFTscreen.stroke(rgbColour[0], rgbColour[1], rgbColour[2]);
  TFTscreen.print(score);

  // Reset cursor size
  TFTscreen.setTextSize(1);
}
开发者ID:IdarV,项目名称:Arduino,代码行数:19,代码来源:board.cpp

示例9: _valid

PadConfiguration::PadConfiguration(const char* fileName):
  _valid(false),
  _picture(nullptr)
{
Serial.println("[PadConfiguration start]");
  if(!TFTInit)
  {
    TFTscreen.begin();
    TFTInit = true;
  }
  for(uint8_t index; index < BUTTON_ARRAY_SIZE; ++index)
  {
    _mapping[index] = nullptr;
  }

  File myFile;
  myFile = SD.open(fileName);

  if(!myFile)
  {
    Serial.println("[PadConfiguration done: could not open file]");
    return;
  }

  String padConf = readLine(myFile);

  Serial.println(padConf.c_str());

  Serial.println(padConf.length());

  if(padConf.length() != BUTTON_ARRAY_SIZE*2+1)
  {
    Serial.println("[PadConfiguration done: parse error length]");
    Serial.println(padConf.length());
    myFile.close();
    return;
  }

  for(uint8_t index = 0; index < BUTTON_ARRAY_SIZE; ++index)
  {
    switch(padConf.charAt(index*2))
    {
      case 'k':
      {
        _mapping[index] = new InputHandlerKeyboard(padConf.charAt(index*2+1), false, false);
        if(!_mapping[index]->_valid)
        {
          Serial.println("[PadConfiguration done: parse error k]");
          myFile.close(); return;
        }
        break;
      }
      case 'K':
      {
        _mapping[index] = new InputHandlerKeyboard(padConf.charAt(index*2+1), true, false);
        if(!_mapping[index]->_valid)
        {
          Serial.println("[PadConfiguration done: parse error K]");
          myFile.close(); return;
        }
        break;
      }
      case 'F':
      {
        _mapping[index] = new InputHandlerKeyboard(padConf.charAt(index*2+1), false, true);
        if(!_mapping[index]->_valid)
        {
          Serial.println("[PadConfiguration done: parse error F]");
          myFile.close(); return;
        }
        break;
      }
      case 'P':
      {
        _mapping[index] = new InputHandlerPad(padConf.charAt(index*2+1));
        if(!_mapping[index]->_valid)
        {
          Serial.println("[PadConfiguration done: parse error P]");
          myFile.close(); return;
        }
        break;
      }
      case 'X':
      /*{
        _mapping[index] = new InputHandlerDualShock3(padConf.charAt(index*2+1));
        if(!_mapping[index]->_valid)
        {
          Serial.println("[PadConfiguration done: parse error X]");
          myFile.close(); return;
        }
        break;
      }*/
      case '-':
      {
        _mapping[index] = nullptr;
        break;
      }
      default:
      {myFile.close(); Serial.println("[PadConfiguration done: parse error]"); return;}
    }
//.........这里部分代码省略.........
开发者ID:alban-rochel,项目名称:pixstick,代码行数:101,代码来源:PadConfiguration.cpp

示例10: BUTTON2_X

void PadConfiguration::drawMapping()
{
  TFTscreen.fillScreen(0);

  // Draw grid

  /*TFTscreen.drawFastHLine(0, 78, 160, 0xFFFF);
  TFTscreen.drawFastHLine(0, 103, 160, 0xFFFF);
  TFTscreen.drawFastVLine(40, 78, 50, 0xFFFF);
  TFTscreen.drawFastVLine(80, 78, 50, 0xFFFF);
  TFTscreen.drawFastVLine(120, 78, 50, 0xFFFF);*/

#define BUTTON_RADIUS 10
#define BUTTON1_X 60
#define BUTTON1_Y 90
#define BUTTON2_X (BUTTON1_X + 2 * BUTTON_RADIUS + 4)
#define BUTTON2_Y (BUTTON1_Y - BUTTON_RADIUS)
#define BUTTON3_X (BUTTON2_X + 2 * BUTTON_RADIUS + 4)
#define BUTTON3_Y (BUTTON2_Y - 0.5 * BUTTON_RADIUS)
#define BUTTON4_X (BUTTON3_X + 2 * BUTTON_RADIUS + 4)
#define BUTTON4_Y BUTTON3_Y
#define BUTTON5_X BUTTON1_X
#define BUTTON5_Y (BUTTON1_Y - 2 * BUTTON_RADIUS - 4)
#define BUTTON6_X BUTTON2_X
#define BUTTON6_Y (BUTTON2_Y - 2 * BUTTON_RADIUS - 4)
#define BUTTON7_X BUTTON3_X
#define BUTTON7_Y (BUTTON3_Y - 2 * BUTTON_RADIUS - 4)
#define BUTTON8_X BUTTON4_X
#define BUTTON8_Y (BUTTON4_Y - 2 * BUTTON_RADIUS - 4)
#define BUTTONSTART_X (BUTTON1_X - 3 * BUTTON_RADIUS)
#define BUTTONSTART_Y (BUTTON1_Y + 2 * BUTTON_RADIUS)
#define Y_OFFSET (-5)
#define ALT_Y_OFFSET 5

#define GET_STRING(i) (_mapping[i] ? _mapping[i]->mappingString() : String("-"))
#define GET_COLOR(i) (_mapping[i] ? _mapping[i]->mappingColor() : 0b1000010000010000)

  TFTscreen.drawCircle(BUTTON1_X, BUTTON1_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON1_X, BUTTON1_Y + Y_OFFSET, GET_STRING(BUTTON_1_INDEX), GET_COLOR(BUTTON_1_INDEX));
  drawText(BUTTON1_X, BUTTON1_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_1_INDEX), GET_COLOR(ALT_BUTTON_1_INDEX));
  
  TFTscreen.drawCircle(BUTTON2_X, BUTTON2_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON2_X, BUTTON2_Y + Y_OFFSET, GET_STRING(BUTTON_2_INDEX), GET_COLOR(BUTTON_2_INDEX));
  drawText(BUTTON2_X, BUTTON2_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_2_INDEX), GET_COLOR(ALT_BUTTON_2_INDEX));
  
  TFTscreen.drawCircle(BUTTON3_X, BUTTON3_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON3_X, BUTTON3_Y + Y_OFFSET, GET_STRING(BUTTON_3_INDEX), GET_COLOR(BUTTON_3_INDEX));
  drawText(BUTTON3_X, BUTTON3_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_3_INDEX), GET_COLOR(ALT_BUTTON_3_INDEX));
  
  TFTscreen.drawCircle(BUTTON4_X, BUTTON4_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON4_X, BUTTON4_Y + Y_OFFSET, GET_STRING(BUTTON_4_INDEX), GET_COLOR(BUTTON_4_INDEX));
  drawText(BUTTON4_X, BUTTON4_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_4_INDEX), GET_COLOR(ALT_BUTTON_4_INDEX));
  
  TFTscreen.drawCircle(BUTTON5_X, BUTTON5_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON5_X, BUTTON5_Y + Y_OFFSET, GET_STRING(BUTTON_5_INDEX), GET_COLOR(BUTTON_5_INDEX));
  drawText(BUTTON5_X, BUTTON5_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_5_INDEX), GET_COLOR(ALT_BUTTON_5_INDEX));
  
  TFTscreen.drawCircle(BUTTON6_X, BUTTON6_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON6_X, BUTTON6_Y + Y_OFFSET, GET_STRING(BUTTON_6_INDEX), GET_COLOR(BUTTON_6_INDEX));
  drawText(BUTTON6_X, BUTTON6_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_6_INDEX), GET_COLOR(ALT_BUTTON_6_INDEX));
  
  TFTscreen.drawCircle(BUTTON7_X, BUTTON7_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON7_X, BUTTON7_Y + Y_OFFSET, GET_STRING(BUTTON_7_INDEX), GET_COLOR(BUTTON_7_INDEX));
  drawText(BUTTON7_X, BUTTON7_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_7_INDEX), GET_COLOR(ALT_BUTTON_7_INDEX));
  
  TFTscreen.drawCircle(BUTTON8_X, BUTTON8_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON8_X, BUTTON8_Y + Y_OFFSET, GET_STRING(BUTTON_8_INDEX), GET_COLOR(BUTTON_8_INDEX));
  drawText(BUTTON8_X, BUTTON8_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_8_INDEX), GET_COLOR(ALT_BUTTON_8_INDEX));
  
  TFTscreen.drawCircle(BUTTONSTART_X, BUTTONSTART_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTONSTART_X, BUTTONSTART_Y + Y_OFFSET, GET_STRING(BUTTON_START_INDEX), GET_COLOR(BUTTON_START_INDEX));
  drawText(BUTTONSTART_X, BUTTONSTART_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_START_INDEX), GET_COLOR(ALT_BUTTON_START_INDEX));

#define STICK_X 36
#define STICK_Y 36
#define STICK_WIDTH 6
#define STICK_LENGTH 12

  TFTscreen.drawRect(STICK_X - STICK_LENGTH,
                     STICK_Y - STICK_WIDTH/2,
                     2 * STICK_LENGTH,
                     STICK_WIDTH,
                     0xFFFF);

  TFTscreen.drawRect(STICK_X - STICK_WIDTH/2,
                     STICK_Y - STICK_LENGTH,
                     STICK_WIDTH,
                     2 * STICK_LENGTH,
                     0xFFFF);

  drawText(STICK_X, STICK_Y - STICK_LENGTH - 5, _mapping[0]->mappingString(), _mapping[0]->mappingColor());
  drawText(STICK_X, STICK_Y + STICK_LENGTH + 5, _mapping[1]->mappingString(), _mapping[1]->mappingColor());
  drawText(STICK_X - STICK_LENGTH - 10, STICK_Y, _mapping[2]->mappingString(), _mapping[2]->mappingColor());
  drawText(STICK_X + STICK_LENGTH + 10, STICK_Y, _mapping[3]->mappingString(), _mapping[3]->mappingColor());

}
开发者ID:alban-rochel,项目名称:pixstick,代码行数:96,代码来源:PadConfiguration.cpp

示例11: drawMapping

void PadConfiguration::drawPicture()
{
  if(_picture == nullptr)
  {
    drawMapping();
    return;
  }

          uint8_t* pointer = _picture;
        uint16_t current(0);
#define READ_8 current = *pointer; ++pointer;
#define READ_16 current = *((uint16_t*)pointer); ++pointer; ++pointer;

        READ_16;
        TFTscreen.fillScreen(current);

        READ_8;
        uint16_t numColors(current);
        for(uint16_t currentColor = 0; currentColor < numColors; ++currentColor)
        {
            READ_16;
            uint16_t color = current;

            READ_16;
            uint32_t numRects(current);
            for(uint16_t currentRect = 0; currentRect < numRects; ++currentRect)
            {
                READ_8;
                int16_t x(current);
                READ_8;
                int16_t y(current);
                READ_8;
                int16_t w(current);
                READ_8;
                int16_t h(current);
                TFTscreen.fillRect(x, y, w, h, color);
            }

            READ_16;
            uint16_t numVLines(current);
            for(uint16_t currentVLine = 0; currentVLine < numVLines; ++currentVLine)
            {
                READ_8;
                int16_t x(current);
                READ_8;
                int16_t y(current);
                READ_8;
                int16_t l(current);

                TFTscreen.drawFastVLine(x, y, l, color);
            }

            READ_16;
            uint16_t numHLines(current);
            for(uint16_t currentHLine = 0; currentHLine < numHLines; ++currentHLine)
            {
                READ_8;
                int16_t x(current);
                READ_8;
                int16_t y(current);
                READ_8;
                int16_t l(current);

                TFTscreen.drawFastHLine(x, y, l, color);
            }

            READ_16;
            uint16_t numPix(current);
            for(uint16_t currentPix = 0; currentPix < numPix; ++currentPix)
            {
                READ_8;
                int16_t x(current);
                READ_8;
                int16_t y(current);

                TFTscreen.drawPixel(x, y, color);
            }
        }

#undef READ_8
#undef READ_16
}
开发者ID:alban-rochel,项目名称:pixstick,代码行数:82,代码来源:PadConfiguration.cpp

示例12: clearPointFast

// Clear (draw black) single point (1 pixel)
void Board::clearPointFast(int xPoint, int yPoint){
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.point(xPoint, yPoint);
}
开发者ID:IdarV,项目名称:Arduino,代码行数:5,代码来源:board.cpp

示例13: writeWeekDay

// Write weekday to screen
void ClockMaster::writeWeekDay(DateTime time_now){
  tft.stroke(weekdayColor);
  tft.setTextSize(weekdaySize);
  tft.setCursor(weekdayXPos, weekdayYPos);

  tft.print(daysOfTheWeek[time_now.dayOfTheWeek()]);
}
开发者ID:IdarV,项目名称:Arduino,代码行数:8,代码来源:ClockMaster.cpp

示例14: writeMinute

// Write minute to screen
void ClockMaster::writeMinute(DateTime time_now) {
  tft.stroke(minuteColor);
  tft.setTextSize(hourSize);
  tft.setCursor(minuteXPos, minuteYPos);
  if (time_now.minute() < 10) {
    tft.print("0");
  }
  tft.print(time_now.minute());
}
开发者ID:IdarV,项目名称:Arduino,代码行数:10,代码来源:ClockMaster.cpp

示例15: writeSecond

// Write second to screen
void ClockMaster::writeSecond(DateTime time_now) {
  tft.stroke(255, 255, 255);
  tft.setTextSize(secondSize);
  tft.setCursor(secondXPos, secondYPos);
  if (time_now.second() < 10) {
    tft.print("0");
  }
  tft.print(time_now.second());
}
开发者ID:IdarV,项目名称:Arduino,代码行数:10,代码来源:ClockMaster.cpp


注:本文中的TFT类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。