Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
0
// reset the display
void ClockMaster::resetDisplayTime(DateTime newTime, int currentXPos){

  clearTextLine(secondXPos, secondYPos, secondSize, secondLength);
  writeSecond(newTime);

  clearTextLine(minuteXPos, minuteYPos, minuteSize, minuteLength);
  writeMinute(newTime);

  clearTextLine(hourXPos, hourYPos, hourSize, hourLength);
  writeHour(newTime);

  clearTextLine(dayXPos, dayYPos, daySize, dayLength);
  clearTextLine(weekdayXPos, weekdayYPos, weekdaySize, weekdayLength);
  writeDay(newTime);
  writeWeekDay(newTime);

  clearTextLine(monthXPos, monthYPos, monthSize, monthLength);
  writeMonth(newTime);

  clearTextLine(yearXPos, yearYPos, yearSize, yearLength);
  writeYear(newTime);

  clearTextLine(tempXPos, tempYPos, tempSize, tempLength);
  writeTemp();

  // draw current x-position-indicator
  if(lastAlarmXPos != currentXPos){
    // Center x-position-indicator under current number being changed
    clearTextLine(0, 85, 2, 160);
    if(currentXPos != -1){
      int calculatedXPos = 45 * currentXPos + 30;
      tft.setCursor(calculatedXPos, 85);
      tft.print("-");
    }
  }

  lastAlarmXPos = currentXPos;
}
Exemplo n.º 12
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.º 13
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());
}