コード例 #1
0
void display_layout2_HomeScreen(Ucglib_ILI9341_18x240x320_HWSPI ucg, float temperature, float humidity, float setpoint) {
  SERIAL_OUT.println("Refresh HOME Screen "); 
  //uso flag_onetime per visualizzare almeno una volta la schermata, anche in assenza di variazione di temperatura
  //flag_onetime_HomeScreen è rimessa a false display_layout1_setpointPage
  if (arrotonda2(temperature) != arrotonda2(temp2_prec) || (arrotonda2(setpoint) != arrotonda2(setpoint2_prec))) {
    if (!flag_onetime2_HomeScreen) {
      ucg.clearScreen();
    }
    //HOMESCREEN
    int temp = (int) temperature;
    int diff = dopovirgola2(temperature);
    //Temperatura
    //ucg.setColor(111, 0, 255);         // Blu Elettrico
    //ucg.setColor(0, 255, 255, 255);    // Bianco
    ucg.setColor(102, 255, 0);           // Verde Chiaro
    ucg.setFontMode(UCG_FONT_MODE_SOLID);
    ucg.setPrintPos(-4, 80);
    ucg.setScale2x2();
    ucg.setFont(ucg_font_inb46_mr);
    ucg.print(temp);
    ucg.undoScale();
    ucg.setFont(ucg_font_inb46_mr);
    ucg.setPrintPos(147, 160);
    ucg.print(diff);
    ucg.drawDisc(143, 156, 3, UCG_DRAW_ALL);
    ucg.drawDisc(187, 116, 3, UCG_DRAW_ALL);
    SERIAL_OUT.print("Refresh Temperature to: "); SERIAL_OUT.print(temp); SERIAL_OUT.print("."); SERIAL_OUT.println(diff);

    //Umidità
    ucg.setColor(30, 144, 255);    // Blu Dodger
    ucg.setFontMode(UCG_FONT_MODE_SOLID);
    ucg.setPrintPos(24, 209);
    ucg.setFont(ucg_font_inb21_mr);
    ucg.print("uR"); ucg.print(humidity, 1);
    ucg.setFont(ucg_font_9x18_mf);
    ucg.setPrintPos(135, 209);
    ucg.print("%");
    //ucg.setFont(ucg_font_profont11_mr);
    //ucg.setPrintPos(60,190);
    ucg.undoScale();
    //ucg.print("UMIDITA'");
    SERIAL_OUT.print("Refresh Humidity to: "); SERIAL_OUT.println(humidity,1); 

    temp2_prec = temp;
    setpoint2_prec = setpoint;
    flag_onetime2_HomeScreen = true;
    SERIAL_OUT.println("Refresh HOME Screen OK ");
  }
}
コード例 #2
0
void display_layout1_printBigChar(Ucglib_ILI9341_18x240x320_HWSPI ucg, float fValTemp) {
  ucg.setFont(FONT_BIG);
#if(FONT_BIG_SCALE2x2)
  ucg.setScale2x2();
#endif
  ucg.setFontPosBaseline();

  //calcolo ingombro testo
  String str = "00";
  const char *c = str.c_str();
  int vW = ucg.getStrWidth(c);

  str = "0";
  c = str.c_str();
  vW_pos_before_point = vW - ucg.getStrWidth(c) / 8; //arretra di un sesto dello spazio di un carattere, per avvicinare il punto
  ucg.setFont(FONT_BIG_MIN_50_PERCENT);
  str = ".";
  c = str.c_str();
  vW += ucg.getStrWidth(c);
  vW_pos_after_point = vW_pos_before_point + ucg.getStrWidth(c) - ucg.getStrWidth(c) / 8; //aggiunge lo spazio del punto meno un sesto
  str = "0";
  c = str.c_str();
  vW += ucg.getStrWidth(c);

  ucg.setFont(FONT_SMALL_CENTIGRAD);
  str = "o";
  c = str.c_str();
  vW += ucg.getStrWidth(c) / 2; //aggiunge metà dello spazio di un carattere. Il ° verrà parzialmente sovrapposto alla vifra decimale

  ucg.setFont(FONT_BIG);
  startW = (ucg.getWidth() - vW) / 2 ;
  baseH = ucg.getHeight() / 2 + ucg.getFontAscent() / 2;
  baseH_Grade = baseH - ucg.getFontAscent() + ucg.getFontAscent() / 6;
  ucg.setPrintPos(startW, baseH );
  sTempToPrint = (int) fValTemp;
  if (((int) fValTemp) <= -10) {
    sTempToPrint = "-- ";
    ucg.print(sTempToPrint);
    SERIAL_OUT.print("sTempToPrint: "); SERIAL_OUT.println(sTempToPrint);
  } else if (((int) fValTemp) >= 100) {
    sTempToPrint = "++ ";
    ucg.print(sTempToPrint);
    SERIAL_OUT.print("sTempToPrint: "); SERIAL_OUT.println(sTempToPrint);
  } else {

    if ((((int) fValTemp) < 10) && ((int) fValTemp > 0)) {
      sTempToPrint = " " + sTempToPrint;
      SERIAL_OUT.print("sTempToPrint: "); SERIAL_OUT.println(sTempToPrint);
    }

    ucg.print(sTempToPrint);
    ucg.setFont(FONT_BIG_MIN_50_PERCENT);
    ucg.setPrintPos(startW + vW_pos_before_point, baseH);
    int diff = dopovigola(fValTemp);
    ucg.print(".");
    ucg.setPrintPos(startW + vW_pos_after_point, baseH);
    ucg.print(diff);

    //print °

    ucg.setFont(FONT_SMALL_CENTIGRAD);
    vW_pos_grade = startW + vW_pos_after_point;   // - FONT_SHIFT_POSITION_TO_SX_CENTIGRAD ;
    ucg.setPrintPos(vW_pos_grade, baseH_Grade);
    ucg.print("o");
  }
#if(FONT_BIG_SCALE2x2)
  ucg.undoScale();
#endif

}