Exemplo n.º 1
0
// 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);
}
Exemplo n.º 2
0
void Board::winScreen(uint8_t highscore, bool isNewHighscore){
  // Set background color to random
  TFTscreen.background(random(255), random(255), random(255));

  // Print "game over"
  TFTscreen.setTextSize(3);
  TFTscreen.stroke(255, 255, 255);
  TFTscreen.setCursor(0, 40);
  TFTscreen.print(uwin_str);


  // Print "press joystick to restart"
  TFTscreen.setTextSize(1);
  TFTscreen.setCursor(0, 10);
  TFTscreen.print(pressagain_str);

  // Print score
  TFTscreen.setCursor(0, 80);
  TFTscreen.setTextSize(2);
  TFTscreen.print(score_str);
  TFTscreen.print(": ");
  TFTscreen.print(highscore);

  // If score is new highcore, print "new highscore!"
  if(isNewHighscore){
    TFTscreen.setTextSize(1);
    TFTscreen.setCursor(0, 100);
    TFTscreen.print(newHighscore);
  }
}
Exemplo n.º 3
0
// 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()]);
}
Exemplo n.º 4
0
// 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);
    }
  }
}
Exemplo n.º 5
0
// 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);
}
Exemplo n.º 6
0
// 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);
}
Exemplo n.º 7
0
// 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());
}
Exemplo n.º 8
0
// 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());
}
Exemplo n.º 9
0
// 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();
}
Exemplo n.º 10
0
// Write hour to screen
void ClockMaster::writeHour(DateTime time_now) {
  tft.stroke(255, 255, 255);
  tft.setTextSize(hourSize);
  tft.setCursor(hourXPos, hourYPos);

  if (time_now.hour() < 10) {
    tft.print("0");
  }

  tft.print(time_now.hour());
}
Exemplo n.º 11
0
// Write day to screen
void ClockMaster::writeDay(DateTime time_now) {
  dayXPos = monthLength + 4; // One space after month
  tft.stroke(255, 255, 255);
  tft.setTextSize(daySize);
  tft.setCursor(dayXPos, dayYPos);

  if (time_now.day() < 10) {
    tft.print("0");
  }

  tft.print(time_now.day());
}
Exemplo n.º 12
0
void Board::init(){
  // Start screen
  TFTscreen.begin();
  // make the background black
  TFTscreen.background(0, 0, 0);

  // Set starting colors
  rgbColour[0] = 255;
  rgbColour[1] = 0;
  rgbColour[2] = 0;

  // Set which color to be incremented and decremented
  decColour = 0;
  incColour = 1;

  TFTscreen.stroke(255, 255, 255);
  // Draw top border left->right
  TFTscreen.line(boardBorderXLeft, boardBorderYTop, boardBorderXRight, boardBorderYTop);
  // Draw right border top->bottom
  TFTscreen.line(boardBorderXLeft, boardBorderYTop, boardBorderXLeft, boardBoarderYBottom);
  // Draw bottom border left->right
  TFTscreen.line(boardBorderXLeft, boardBoarderYBottom, boardBorderXRight, boardBoarderYBottom);
  // Draw left border
  TFTscreen.line(boardBorderXRight, boardBorderYTop, boardBorderXRight, boardBoarderYBottom);

  // Write score
  TFTscreen.setCursor(10, 10);
  TFTscreen.setTextSize(1);
  TFTscreen.print(score_str);
  setScore(0);

  // Write highscore
  TFTscreen.setTextSize(1);
  TFTscreen.stroke(255, 255, 255);
  TFTscreen.setCursor(10, 50);
  TFTscreen.print(high_str);
  TFTscreen.setCursor(10, 60);
  TFTscreen.print(score_str);
}
Exemplo n.º 13
0
// 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();
}
Exemplo n.º 14
0
// Write temperature and Humidity to screen
void ClockMaster::writeTemp(){
  tft.stroke(32, 177, 98);
  tft.setTextSize(2);
  tft.setCursor(tempXPos, tempYPos);
  if(-10 < lastTemp && 10 > lastTemp ){
    tft.print("0");
  }
  tft.print(lastTemp);
  tft.print("C ");
  if(-10 < lastTempF && 10 > lastTempF ){
    tft.print("0");
  }
  tft.print(lastTempF);
  tft.print("F ");
  if(-10 < lastHumidity && 10 > lastHumidity ){
    tft.print("0");
  }
  tft.print(lastHumidity);
  tft.print("h");


}
Exemplo n.º 15
0
// Write month to screen
void ClockMaster::writeMonth(DateTime time_now) {
  tft.stroke(255, 255, 255);
  tft.setTextSize(monthSize);
  tft.setCursor(monthXPos, monthYPos);
  tft.print(monthsOfTheYear[time_now.month() - 1]);
}
Exemplo n.º 16
0
// Draws pellet as only the middle pixel
void Board::drawPelletFast(Pellet pellet){
  TFTscreen.stroke(56, 3, 200);
  TFTscreen.point(pellet.xPos, pellet.yPos);
  TFTscreen.stroke(0,0,0);
}
Exemplo n.º 17
0
// Clear (draw black) single point (1 pixel)
void Board::clearPointFast(int xPoint, int yPoint){
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.point(xPoint, yPoint);
}
Exemplo n.º 18
0
// Write year to screen
void ClockMaster::writeYear(DateTime time_now) {
  tft.stroke(255, 255, 255);
  tft.setTextSize(yearSize);
  tft.setCursor(yearYPos, yearXPos);
  tft.print(time_now.year());
}