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


C++ Adafruit_ST7735::fillRect方法代码示例

本文整理汇总了C++中Adafruit_ST7735::fillRect方法的典型用法代码示例。如果您正苦于以下问题:C++ Adafruit_ST7735::fillRect方法的具体用法?C++ Adafruit_ST7735::fillRect怎么用?C++ Adafruit_ST7735::fillRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_ST7735的用法示例。


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

示例1: setup_display

void setup_display(void) {
  
  // initialize the LCD display
//  tft.init();
//  tft.initR(INITR_BLACKTAB);   // initialize a S6D02A1S chip, black tab
  tft.setRotation(1);
  tft.fillScreen(BLACK); //BLACK);
  //tft.fillRect(0, pos, 160, 128-pos, BLACK); // erase old string
  tft.setCursor(0, 119);
  tft.setTextColor(WHITE);
  tft.setTextWrap(true);
//  tft.print("DD4WH SDR 5.00");
  
  // Show mid screen tune position
  tft.drawFastVLine(pos_centre_f, 0,pos+1, RED); //WHITE);
 // tft.drawFastHLine(0, pos,79, YELLOW);// WHITE);
  //tft.drawFastHLine(81, pos,79, YELLOW);

// draw S-Meter layout
  tft.drawFastHLine (pos_x_smeter, pos_y_smeter-1, 9*s_w, WHITE);
  tft.drawFastHLine (pos_x_smeter, pos_y_smeter+3, 9*s_w, WHITE);
  tft.fillRect(pos_x_smeter, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+8*s_w, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+2*s_w, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+4*s_w, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+6*s_w, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+7*s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter+3*s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter+5*s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter+s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter+9*s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.drawFastHLine (pos_x_smeter+9*s_w, pos_y_smeter-1, 3*s_w*2+2, GREEN);
  tft.drawFastHLine (pos_x_smeter+9*s_w, pos_y_smeter+3, 3*s_w*2+2, GREEN);
  tft.fillRect(pos_x_smeter+11*s_w, pos_y_smeter-4, 2, 3, GREEN);
  tft.fillRect(pos_x_smeter+13*s_w, pos_y_smeter-4, 2, 3, GREEN);
  tft.fillRect(pos_x_smeter+15*s_w, pos_y_smeter-4, 2, 3, GREEN);
  tft.drawFastVLine (pos_x_smeter-1, pos_y_smeter-1, 5, WHITE); 
  tft.drawFastVLine (pos_x_smeter+15*s_w+2, pos_y_smeter-1, 5, GREEN);

  tft.setCursor(pos_x_smeter - 4, pos_y_smeter - 13);
  tft.setTextColor(WHITE);
  tft.setTextWrap(true);
  tft.print("S 1");
  tft.setCursor(pos_x_smeter + 28, pos_y_smeter - 13);
  tft.print("3");
  tft.setCursor(pos_x_smeter + 48, pos_y_smeter - 13);
  tft.print("5");
  tft.setCursor(pos_x_smeter + 68, pos_y_smeter - 13);
  tft.print("7");
  tft.setCursor(pos_x_smeter + 88, pos_y_smeter - 13);
  tft.print("9");
  tft.setCursor(pos_x_smeter + 120, pos_y_smeter - 13);
  tft.print("+20dB");

} // end void setupdisplay
开发者ID:DD4WH,项目名称:Teensy-SDR-Rx,代码行数:55,代码来源:display.cpp

示例2: testfillrects

void testfillrects(uint16_t color1, uint16_t color2) {
    tft.fillScreen(ST7735_BLACK);
    for (int16_t x=tft.width()-1; x > 6; x-=6) {
        tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);
        tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:7,代码来源:tft.cpp

示例3: show_tunestep

void show_tunestep(String S) {  // show band
  char string[80]; 
  tft.fillRect(pos_x_tunestep, pos_y_tunestep, 60, 8, BLACK); // erase old string
  tft.setTextColor(WHITE);
  tft.setCursor(pos_x_tunestep, pos_y_tunestep);
  tft.print(S);
}
开发者ID:DD4WH,项目名称:Teensy-SDR-Rx,代码行数:7,代码来源:display.cpp

示例4: show_bandfilter

void show_bandfilter(String bandfiltername, boolean highlight) {  // show band
  tft.fillRect(0, 108, 40, 18, BLACK); // erase old string
  tft.setFont(&FreeSans9pt7b);
  if (highlight) {
    tft.setTextColor(YELLOW);
  } else {
    tft.setTextColor(WHITE);
  }
  tft.setCursor(0, 125);
  tft.print(bandfiltername);
}
开发者ID:AgriVision,项目名称:Teensy_SDR,代码行数:11,代码来源:display.cpp

示例5: show_radiomode

// show radio mode
void show_radiomode(String mode, boolean highlight) {
  tft.fillRect(106, 108, 54, 18, BLACK); // erase old string
  tft.setFont(&FreeSans9pt7b);
  if (highlight) {
    tft.setTextColor(YELLOW);
  } else {
    tft.setTextColor(WHITE);
  }
  tft.setCursor(106, 125);
  tft.print(mode);
}
开发者ID:AgriVision,项目名称:Teensy_SDR,代码行数:12,代码来源:display.cpp

示例6: show_frequency

// show frequency
void show_frequency(long int freq, boolean highlight) {
  uint8_t offsetx = 0;
  tft.setFont(&FreeSans12pt7b);
  char string[80];   // print format stuff
  sprintf(string, "%d.%03d.%03d", freq / 1000000, (freq - freq / 1000000 * 1000000) / 1000,
          freq % 1000 );
  if (freq < 10000000) offsetx = 13;
  tft.fillRect(pos_x_freq, pos_y_freq - 17, 120, 18, BLACK);
  tft.setCursor(pos_x_freq + offsetx, pos_y_freq);
  if (highlight) {
    tft.setTextColor(YELLOW);
  } else {
    tft.setTextColor(WHITE);
  }
  tft.print(string);
}
开发者ID:AgriVision,项目名称:Teensy_SDR,代码行数:17,代码来源:display.cpp

示例7: draw_map_screen

void draw_map_screen() {
#ifdef DEBUG
    // Want to display a small message saying that we are redrawing the map!
    tft.fillRect(78, 148, 50, 12, GREEN);

    tft.setTextSize(1);
    tft.setTextColor(MAGENTA);
    tft.setCursor(80, 150);
    tft.setTextSize(1);

    tft.println("DRAWING...");
#endif

    lcd_image_draw(&map_tiles[current_map_num], &tft
        , screen_map_x, screen_map_y
        , 0, 0, 128, 160);
    
}
开发者ID:hammadj,项目名称:Edmonton-Navigation,代码行数:18,代码来源:map.cpp

示例8: show_waterfall

void show_waterfall(void) {
  // experimental waterfall display for CW -
  // this should probably be on a faster timer since it needs to run as fast as possible to catch CW edges
  //  FFT bins are 22khz/128=171hz wide 
  // cw peak should be around 11.6khz - 
  static uint16_t waterfall[80];  // array for simple waterfall display
  static uint8_t w_index=0,w_avg;
  waterfall[w_index]=0;
  for (uint8_t y=66;y<67;++y)  // sum of bin powers near cursor - usb only
      waterfall[w_index]+=(uint8_t)(abs(myFFT.output[y])); // store bin power readings in circular buffer
  waterfall[w_index]|= (waterfall[w_index]<<5 |waterfall[w_index]<<11); // make it colorful
  int8_t p=w_index;
  for (uint8_t x=158;x>0;x-=2) {
    tft.fillRect(x,65,2,4,waterfall[p]);
    if (--p<0 ) p=79;
  }
  if (++w_index >=80) w_index=0; 
}
开发者ID:DD4WH,项目名称:Teensy-SDR-Rx,代码行数:18,代码来源:display.cpp

示例9: show_s_meter_layout

void show_s_meter_layout() {
  tft.drawFastHLine (pos_x_smeter, pos_y_smeter - 1, 9 * s_w, WHITE);
  tft.drawFastHLine (pos_x_smeter, pos_y_smeter + 3, 9 * s_w, WHITE);
  tft.fillRect(pos_x_smeter, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 8 * s_w, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 2 * s_w, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 4 * s_w, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 6 * s_w, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 7 * s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter + 3 * s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter + 5 * s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter + s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter + 9 * s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.drawFastHLine (pos_x_smeter + 9 * s_w, pos_y_smeter - 1, 3 * s_w * 2 + 2, GREEN);
  tft.drawFastHLine (pos_x_smeter + 9 * s_w, pos_y_smeter + 3, 3 * s_w * 2 + 2, GREEN);
  tft.fillRect(pos_x_smeter + 11 * s_w, pos_y_smeter - 4, 2, 3, GREEN);
  tft.fillRect(pos_x_smeter + 13 * s_w, pos_y_smeter - 4, 2, 3, GREEN);
  tft.fillRect(pos_x_smeter + 15 * s_w, pos_y_smeter - 4, 2, 3, GREEN);
  tft.drawFastVLine (pos_x_smeter - 1, pos_y_smeter - 1, 5, WHITE);
  tft.drawFastVLine (pos_x_smeter + 15 * s_w + 2, pos_y_smeter - 1, 5, GREEN);

  tft.setFont();
  tft.setCursor(pos_x_smeter - 4, pos_y_smeter - 13);
  tft.setTextColor(WHITE);
  tft.setTextWrap(true);
  tft.print("S 1");
  tft.setCursor(pos_x_smeter + 28, pos_y_smeter - 13);
  tft.print("3");
  tft.setCursor(pos_x_smeter + 48, pos_y_smeter - 13);
  tft.print("5");
  tft.setCursor(pos_x_smeter + 68, pos_y_smeter - 13);
  tft.print("7");
  tft.setCursor(pos_x_smeter + 88, pos_y_smeter - 13);
  tft.print("9");
  tft.setCursor(pos_x_smeter + 120, pos_y_smeter - 13);
  tft.print("+20dB");
}
开发者ID:AgriVision,项目名称:Teensy_SDR,代码行数:37,代码来源:display.cpp

示例10: status_msg

void status_msg(char *msg) {
    // messages are strings, so we assume constant, and if they are the
    // same pointer then the contents are the same.  You can force by
    // setting prev_status_msg = 0

    const uint16_t msg_text_height = 10;
    const uint16_t msg_window_height = msg_text_height+2;

    if ( prev_status_msg != msg ) {
        prev_status_msg = msg;
        tft.fillRect(0, display_window_height - msg_window_height, 
            display_window_width, msg_window_height, GREEN);

        tft.setTextSize(1);
        tft.setTextColor(MAGENTA);
        tft.setCursor(0, display_window_height - msg_text_height);
        tft.setTextSize(1); // 10 pixels high

        tft.println(msg);
        }
    }
开发者ID:elake,项目名称:assignment3,代码行数:21,代码来源:client.cpp

示例11: main

int main() {
  // Initialize arduino, serial communication, lcd screen, buttons (and
  // internal pull-up resistors), LED pins, and SD card.
  init();
  Serial.begin(9600);
  Serial3.begin(9600);
  while(Serial3.available()) {Serial3.read();} // Clean the Serial line
  tft.initR(INITR_BLACKTAB);

  pinMode(SEL, INPUT);
  digitalWrite(SEL, HIGH);
  pinMode(Button1, INPUT);
  digitalWrite(Button1, HIGH);
  for (int i = 0; i < 10; ++i) {
    pinMode(i + 22, OUTPUT);
  }
  int click;    // This will be used to continue from the Title Screen

  Serial.print("Initializing SD card...");
  if (!SD.begin(SD_CS)) {
    Serial.println("failed!");
  }
  Serial.println("OK!");

  // do the auto calibration of the cursor (found in Cursor.cpp)
  Initialize_Cursor();


  while(true) {
    // draw the title screen, and set the turn pin to neutral (blue)
    lcd_image_draw(&Images[title], &tft, 0, 0, 0, 0, 128, 160 );
    digitalWrite(bluePin, HIGH);
    while (true) { // leave the title page with a joystick button press.
      click = digitalRead(SEL);
      if (!click) {break;}
    }
    // draw a black screen
    tft.fillScreen(0);
    // draw the border image (note that the numbers (0-9) and
    // letters (A-J) are just for appearance and aren't actually used by
    // the program).
    lcd_image_draw(&Images[border], &tft, 0, 0, 0, 0, 128, 128 );

    // initialize My_Ocean so that each value is 0 (water)
    for( int i=0; i<100; i++ ) {
      My_Ocean[i] = 0;
    }
    // initialize Their_Ocean so that each value is 1 (miss). This needs to
    // be nonzero for the first drawing of the screen (occurs on line 47
    // of Place_Ships.cpp) and will be set to 0 after.
    for( int i=0; i<100; i++ ) {
      Their_Ocean[i] = 1;
    }
    //==================== Initialization complete =================

    // Allows a player to place their ships
    My_Ships = Place_Ships(My_Ocean, Their_Ocean);
    // set Their_Ocean so that each value is 0 (water).
    for( int i=0; i<100; i++ ) {
      Their_Ocean[i] = 0;
    }
    // One arduino should read high, and the other should read low
    // (see wiring instructions for more detail). This determines who
    // gets the first turn.
    bool Turn = digitalRead(13);
    // Initialize the number of ships remaining for each player to 5.
    // can be set to 1 for a "debug" mode to see the victory/reset more
    // quickly.
    int Mine_Alive = 5;
    int Their_Alive = 5;

    // Turn on all the LED's initially (because all 10 ships should be
    // alive).
    for (int i = 0; i < 10; i++) {
      digitalWrite(22+i , HIGH);
    }

    // Connect to opponent. One arduino writes 'R' for ready, then waits
    // to receive a response. The other waits to read 'R' first, then
    // writes it.
    Write_Message("Connecting...");
    if( Turn == 1 ) {
      Serial3.write('R');
      while( Serial3.read() !='R' ) {}
    }
    else {
      while( Serial3.read() !='R' ) {}
      Serial3.write('R');
    }

    //==================== Ready to communicate/play ===============

    // Loop until either player has no ships left.
    while((Mine_Alive != 0) && (Their_Alive != 0)) {

      // My turn
      if( Turn == 1 ) {
        // draw a red square in the top left corner (because we will
        // view what we know of Their_Ocean).
        tft.fillRect(0, 0, 8, 8, 0xF800);
//.........这里部分代码省略.........
开发者ID:DLukeNelson,项目名称:Arduino-Battleship,代码行数:101,代码来源:Battleship.cpp

示例12: show_frequency

// show frequency
void show_frequency(long int freq) { 
    tft.setTextSize(2);
    tft.setTextColor(WHITE);
    uint8_t zaehler;
    uint8_t digits[10];
    zaehler = 8;

          while (zaehler--) {
              digits[zaehler] = ExtractDigit (freq, zaehler);
//              Serial.print(digits[zaehler]);
//              Serial.print(".");
// 7: 10Mhz, 6: 1Mhz, 5: 100khz, 4: 10khz, 3: 1khz, 2: 100Hz, 1: 10Hz, 0: 1Hz
        }
            //  Serial.print("xxxxxxxxxxxxx");

    zaehler = 8;
        while (zaehler--) { // counts from 7 to 0
              if (zaehler < 6) sch = 7; // (khz)
              if (zaehler < 3) sch = 14; // (Hz)
          if (digits[zaehler] != digits_old[zaehler] || !freq_flag) { // digit has changed (or frequency is displayed for the first time after power on)
              if (zaehler == 7) {
                     sch = 0;
                     tft.setCursor(pos_x_frequency + font_width * (8-zaehler) + sch,pos_y_frequency); // set print position
                     tft.fillRect(pos_x_frequency + font_width * (8-zaehler) + sch,pos_y_frequency, font_width,16,BLACK); // delete old digit
                     if (digits[7] != 0) tft.print(digits[zaehler]); // write new digit in white
              }
              if (zaehler == 6) {
                            sch = 0;
                            tft.setCursor(pos_x_frequency + font_width * (8-zaehler) + sch,pos_y_frequency); // set print position
                            tft.fillRect(pos_x_frequency + font_width * (8-zaehler) + sch,pos_y_frequency, font_width,16,BLACK); // delete old digit
                            if (digits[6]!=0 || digits[7] != 0) tft.print(digits[zaehler]); // write new digit in white
              }
               if (zaehler == 5) {
                            sch = 7;
                            tft.setCursor(pos_x_frequency + font_width * (8-zaehler) + sch,pos_y_frequency); // set print position
                            tft.fillRect(pos_x_frequency + font_width * (8-zaehler) + sch,pos_y_frequency, font_width,16,BLACK); // delete old digit
                            if (digits[5] != 0 || digits[6]!=0 || digits[7] != 0) tft.print(digits[zaehler]); // write new digit in white
              }
              
              if (zaehler < 5) { 
              // print the digit
              tft.setCursor(pos_x_frequency + font_width * (8-zaehler) + sch,pos_y_frequency); // set print position
              tft.fillRect(pos_x_frequency + font_width * (8-zaehler) + sch,pos_y_frequency, font_width,16,BLACK); // delete old digit
              tft.print(digits[zaehler]); // write new digit in white
              }
              digits_old[zaehler] = digits[zaehler]; 
        }
        }
  
      tft.setTextSize(1);
      if (digits[7] == 0 && digits[6] == 0)
              tft.fillRect(pos_x_frequency + font_width * 3,pos_y_frequency + 11, 3, 3, BLACK);
      else    tft.fillRect(pos_x_frequency + font_width * 3,pos_y_frequency + 11, 3, 3, YELLOW);
      tft.fillRect(pos_x_frequency + font_width * 7 -4, pos_y_frequency + 11, 3, 3, YELLOW);
      if (!freq_flag) {
            tft.setCursor(pos_x_frequency + font_width * 9 + 16,pos_y_frequency + 7); // set print position
            tft.setTextColor(GREEN);
            tft.print("Hz");
      }
      freq_flag = 1;
      tft.setTextColor(WHITE);

} // END VOID SHOW-FREQUENCY
开发者ID:DD4WH,项目名称:Teensy-SDR-Rx,代码行数:64,代码来源:display.cpp

示例13: show_bandwidth

void show_bandwidth (int M, long int FU, long int FL) {

   tft.drawFastHLine(0,pos+1,160, BLACK); // erase old indicator
   tft.drawFastHLine(0,pos+2,160, BLACK); // erase old indicator 
   tft.drawFastHLine(0,pos+3,160, BLACK); // erase old indicator
   tft.drawFastHLine(0,pos,160, BLACK); // erase old indicator

      bwhelp = FU /100;
      int leU = bwhelp*16/spectrum_span;
      bwhelp = FL /100;
      int leL = bwhelp*16/spectrum_span;
      float kHz = (FU + FL) / 1000.0;
      
  switch (M) {
  case 0: //AM
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("AM"); 
      break;
  case 3: //DSB
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("DSB"); 
      break;
  case 4: //StereoAM
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("SteAM"); 
      break;
  
  case 2: //LSB
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("LSB"); 
      break;
  case 1:  //USB
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("USB"); 
      break;
} // end switch
      //print bandwidth !
        tft.fillRect(4, pos_y_frequency+7, 32, 8, BLACK); // erase old string
        tft.setCursor(4, pos_y_frequency+7);
        sprintf(string,"%02.1fk",kHz);
        tft.print(string);
        tft.setTextColor(WHITE); // set text color to white for other print routines not to get confused ;-)
      // draw upper sideband indicator
      tft.drawFastHLine(pos_centre_f, pos+1, leU, RED);
      tft.drawFastHLine(pos_centre_f, pos+2, leU, RED);
      tft.drawFastHLine(pos_centre_f, pos+3, leU, RED);
      tft.drawFastHLine(pos_centre_f, pos, leU, RED);
      // draw lower sideband indicator   
      left = pos_centre_f - leL; 
      tft.drawFastHLine(left+1, pos+1, leL, RED);
      tft.drawFastHLine(left+1, pos+2, leL, RED);
      tft.drawFastHLine(left+1,pos+3, leL, RED);
      tft.drawFastHLine(left+1,pos, leL, RED);

  tft.fillRect(pos_centre_f  + 160/spectrum_span * 5, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  + 160/spectrum_span * 10, pos, 2, 4, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 5, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f - 160/spectrum_span * 10, pos, 2, 4, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 15, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  + 160/spectrum_span * 15, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 20, pos, 2, 4, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 25, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 30, pos, 2, 4, YELLOW); // erase old string
}  
开发者ID:DD4WH,项目名称:Teensy-SDR-Rx,代码行数:74,代码来源:display.cpp

示例14: show_signalstrength

// show signal strength
void show_signalstrength(String s) {
  tft.setFont(&FreeSans9pt7b);
  tft.fillRect(12, 72, 40, 14, BLACK);
  tft.setCursor(0, 85);
  tft.print(s);
}
开发者ID:AgriVision,项目名称:Teensy_SDR,代码行数:7,代码来源:display.cpp

示例15: loop

void loop() {
    // Though counter-intuitive, game creation cannot be in setup because of varying arduino boot times and boot gibberish
    if (!gameCreated) {
        drawGUI();
        while(!waitUntil(JOYSTICK_BUTTON_PIN, false));
        if (!startNetwork()) {
            tft.fillScreen(ST7735_BLACK); // we must clear all conflicting messages from screen
            tft.setCursor(0,0);
            dualPrint("Network connection failed!");
            dualPrint("Please ensure:");
            dualPrint("1) both arduinos are connected");
            dualPrint("2) both parties pressed the joystick");
            dualPrint("If both are true, consult someone who");
            dualPrint("looks like he knows what he's talking about");
            dualPrint("Reset both Arduinos to try again");
            while(1);
        }
        /* Extensibility Goal:
         * Enable colour selection here, time permissible
         */
        gameCreated = true;
    }
    if (!gameStarted) {
        setSpawns(&player1, &player2);
        setColour(&player1, &player2);
        tft.fillScreen(ST7735_BLACK);
        startCountdown();
        gameStarted = true;
    }
    winner = gameOver(&player1.currentPosition, &player2.currentPosition);
    if (winner) {
        tft.setCursor(0, 80);
        String message;
        switch (winner) {
        case -1:
            message = "YOU SUPER TIE";
            break;
        case 1:
            message = "YOU SUPER WIN";
            player1.score++;
            break;
        case 2:
            message = "YOU SUPER LOSE";
            player2.score++;
            break;
        }
        tft.println(message);
        tft.println("SCORES:");
        tft.print("You: ");
        tft.print(player1.score);
        tft.print(" | Him: ");
        tft.println(player2.score);
        tft.println("Again? <Press Joystick>");
        waitUntil(JOYSTICK_BUTTON_PIN, LOW);
        memset(&wallPositions, 0, 2560); // 2560 is a magic number because size_ts were acting unexpectedly
        gameStarted = false;
        tft.fillScreen(ST7735_BLACK);
    } else {
        // add a wall ad draw car at current position
        addWallPosition(player1.currentPosition);
        addWallPosition(player2.currentPosition);
        tft.fillRect(player1.currentPosition.x, player1.currentPosition.y, 2, 2, player1.colour);
        tft.fillRect(player2.currentPosition.x, player2.currentPosition.y, 2, 2, player2.colour);
        movement_t newDirection = getJoystickInput();
        if (validInput(newDirection, player1.direction)) player1.direction = newDirection;
        sendDeltas(&player1.direction);
        receiveDeltas(&player2.direction);
        player1.currentPosition.x += player1.direction.x;
        player1.currentPosition.y += player1.direction.y;
        player2.currentPosition.x += player2.direction.x;
        player2.currentPosition.y += player2.direction.y;
        delay(75); // this is how we control the game speed
        /* Extensibility Goal:
         * Find a more efficient and reliable way of controlling game speed.
         * Implement it, and allow it to be customized
         */
    }
}
开发者ID:tpavlek,项目名称:arduitron,代码行数:78,代码来源:tron.cpp


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