Exemple #1
0
    static void setrowsdcard(uint32_t number = 0) {
      uint16_t fileCnt = card.getnrfilenames();
      uint32_t i = 0;
      card.getWorkDirName();

      if (fullName[0] != '/') {
        Folderup.setShow();
        Folderup.attachPop(sdfolderUpPopCallback);
        sdfolder.setText(fullName);
      } else {
        Folderup.detachPop();
        Folderup.setHide();
        sdfolder.setText("");
      }

      for (uint8_t row = 0; row < 6; row++) {
        i = row + number;
        if (i < fileCnt) {
          card.getfilename(i);
          printrowsd(row, card.filenameIsDir, fullName);
        } else {
          printrowsd(row, false, "");
        }
      }
      sendCommand("ref 0");
    }
  void lcd_update() {

    if (!NextionON) return;

    nexLoop(nex_listen_list);

    millis_t ms = millis();

    if (ms > next_lcd_update_ms && PageInfo) {

      if (fanSpeed > 0) fantimer.enable();
      else fantimer.disable();

      #if HAS_TEMP_0
        temptoLCD(0, degHotend(0), degTargetHotend(0));
      #endif
      #if HAS_TEMP_1
        temptoLCD(1, degHotend(1), degTargetHotend(1));
      #endif
      #if HAS_TEMP_2
        temptoLCD(2, degHotend(2), degTargetHotend(2));
      #elif HAS_TEMP_BED
        temptoLCD(2, degBed(), degTargetBed());
      #endif

      coordtoLCD();

      #if ENABLED(SDSUPPORT)

        if (card.cardOK) {
          MSD.setPic(7);
          NPlay.setPic(38);
          NStop.setPic(41);
        }
        else {
          MSD.setPic(6);
          NPlay.setPic(39);
          NStop.setPic(42);
        }

        if (card.isFileOpen()) {
          if (card.sdprinting) {
            // Progress bar solid part
            sdbar.setValue(card.percentDone());
            NPlay.setPic(40);
          }
          else {
            NPlay.setPic(38);
          }
        }

      #endif

      next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
    }
  }
Exemple #3
0
/* Rendering home screen */
void renderHomeScreen() {
  dbSerialPrintln("renderHomeScreen");
  writeLocation();

  // Render outside temperature
  char bufTemp[10];
  if(tempScale == 0)
    sprintf(bufTemp, "%.1f", currentOutsideTemperatureC);
  else {
    sprintf(bufTemp, "%.1f", currentOutsideTemperatureC * 1.8 + 32); // Celsius to Fahrenheit conversion
    dbSerialPrint("Temp in F: ");
    dbSerialPrintln(bufTemp);
  }
  t0.setText(bufTemp);

  // Render outside humidity
  char bufHumid[10];;
  sprintf(bufHumid, "%.1f", currentOutsideHumidity);
  t8.setText(bufHumid);

  // Render correct temperature scale based on the selection
  if(tempScale == 0) {
    t1.setText("°C");
    t4.setText("°C");
    t13.setText("°C");
    t15.setText("°C");
    t17.setText("°C");
    t19.setText("°C");
    t21.setText("°C");
    t23.setText("°C");
  }
  else {
    t1.setText("F");
    t4.setText("F");
    t13.setText("F");
    t15.setText("F");
    t17.setText("F");
    t19.setText("F");
    t21.setText("F");
    t23.setText("F");
  }

  /* Render days of week for forecast
  dbSerialPrint("Time: ");
  dbSerialPrint(Time.hour());
  dbSerialPrint(":");
  dbSerialPrintln(Time.minute());
  dbSerialPrint("Day of week: ");
  dbSerialPrintln(Time.weekday());*/

  int day = 0;
  while(day < 4) {
    // Icons for all days
    dbSerialPrintln("weatherData[" + String(day) + "]: " + String(weatherData[day].icon));
    if(weatherData[day].icon > 0) {
      if(day == 0)
        p0.setPic(weatherData[day].icon);
      else if(day == 1)
        p1.setPic(weatherData[day].icon);
      else if(day == 2)
        p2.setPic(weatherData[day].icon);
      else if(day == 3)
        p3.setPic(weatherData[day].icon);
    }

    // Day + 1 forecast info
    if(day == 1) {
      if(langCode==0)
        t5.setText(daysOfWeek_en[weatherData[day].weekday]);
      else
        t5.setText(daysOfWeek_fi[weatherData[day].weekday]);

      if(tempScale == 0)
        t12.setText(String(weatherData[day].minTemp));
      else
        t12.setText(String((int)round(weatherData[day].minTemp * 1.8 + 32)));

      if(tempScale == 0)
        t14.setText(String(weatherData[day].maxTemp));
      else
        t14.setText(String((int)round(weatherData[day].maxTemp * 1.8 + 32)));
    }
    // Day + 2 forecast info
    else if(day == 2) {
      if(langCode==0)
        t6.setText(daysOfWeek_en[weatherData[day].weekday]);
      else
        t6.setText(daysOfWeek_fi[weatherData[day].weekday]);
      //t16.setText(String(weatherData[day].minTemp));
      //t18.setText(String(weatherData[day].maxTemp));

      if(tempScale == 0)
        t16.setText(String(weatherData[day].minTemp));
      else
        t16.setText(String((int)round(weatherData[day].minTemp * 1.8 + 32)));

      if(tempScale == 0)
        t18.setText(String(weatherData[day].maxTemp));
      else
        t18.setText(String((int)round(weatherData[day].maxTemp * 1.8 + 32)));
    }
    // Day +3 foreast info
    else if(day == 3) {
      if(langCode==0)
        t7.setText(daysOfWeek_en[int(weatherData[day].weekday)]);
      else
        t7.setText(daysOfWeek_fi[weatherData[day].weekday]);
      //t20.setText(String(weatherData[day].minTemp));
      //t22.setText(String(weatherData[day].maxTemp));

      if(tempScale == 0)
        t20.setText(String(weatherData[day].minTemp));
      else
        t20.setText(String((int)round(weatherData[day].minTemp * 1.8 + 32)));

      if(tempScale == 0)
        t22.setText(String(weatherData[day].maxTemp));
      else
        t22.setText(String((int)round(weatherData[day].maxTemp * 1.8 + 32)));
    }

    day++;
  }
}
Exemple #4
0
  void lcd_update() {

    if (!NextionON) return;

    nexLoop(nex_listen_list);

    millis_t ms = millis();

    if (ms > next_lcd_update_ms) {

      sendCurrentPageId(&NextionPage);

      if (NextionPage == 1) {
        if (fanSpeed > 0) fantimer.enable();
        else fantimer.disable();

        uint32_t temp_feedrate = 0;
        VSpeed.getValue(&temp_feedrate);
        feedrate_multiplier = (int)temp_feedrate;

        #if HAS(TEMP_0)
          temptoLCD(0, degHotend(0), degTargetHotend(0));
        #endif
        #if HAS(TEMP_1)
          temptoLCD(1, degHotend(1), degTargetHotend(1));
        #endif
        #if HAS(TEMP_2)
          temptoLCD(2, degHotend(2), degTargetHotend(2));
        #elif HAS(TEMP_BED)
          temptoLCD(2, degBed(), degTargetBed());
        #endif

        coordtoLCD();

        #if ENABLED(SDSUPPORT)
          if (card.isFileOpen()) {
            if (SDstatus != 2) {
              SDstatus = 2;
              SD.setValue(2);
              NPlay.setShow();
              NStop.setShow();
            }
            if(IS_SD_PRINTING) {
              // Progress bar solid part
              sdbar.setValue(card.percentDone());
              NPlay.setPic(17);

              // Estimate End Time
              uint16_t time = print_job_timer.duration() / 60;
              uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone();
              if (end_time > (60 * 23)) {
                lcd_setstatus("End --:--");
              }
              else if (end_time >= 0) {
                char temp[30];
                sprintf_P(temp, PSTR("End %i:%i"), end_time / 60, end_time%60);
                lcd_setstatus(temp);
              }
            }
            else {
              NPlay.setPic(16);
            }
          }
          else if (card.cardOK && SDstatus != 1) {
            SDstatus = 1;
            SD.setValue(1);
            MSD1.setShow();
            NPlay.setHide();
            NStop.setHide();
          }
          else if (!card.cardOK && SDstatus != 0) {
            SDstatus = 0;
            SD.setValue(0);
            MSD1.setHide();
            NPlay.setHide();
            NStop.setHide();
          }
        #endif
      }
      else if (NextionPage == 6) {
        coordtoLCD();
      }
      next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
    }
  }
Exemple #5
0
  void lcd_init() {
    HAL::delayMilliseconds(2000);

    for (uint8_t i = 0; i < 10; i++) {
      NextionON = nexInit();
      if (NextionON) break;
      delay(1000);
    }

    if (!NextionON) {
      ECHO_LM(DB, "Nextion LCD not connected!");
    }
    else {
      ECHO_LM(DB, "Nextion LCD connected!");

      Pstart.attachPop(ExitPopCallback);
      Exit1.attachPop(ExitPopCallback);
      Exit3.attachPop(ExitPopCallback);

      #if ENABLED(NEXTION_GFX)
        gfx.color_set(VC_AXIS + X_AXIS, 63488);
        gfx.color_set(VC_AXIS + Y_AXIS, 2016);
        gfx.color_set(VC_AXIS + Z_AXIS, 31);
        gfx.color_set(VC_MOVE, 2047);
        gfx.color_set(VC_TOOL, 65535);
      #endif

      #if ENABLED(SDSUPPORT)
        MSD1.attachPop(setpageSDPopCallback);
        MSD3.attachPop(setpageSDPopCallback);
        MSD5.attachPop(setpageSDPopCallback);
        MSD6.attachPop(setpageSDPopCallback);
        sdlist.attachPop(sdlistPopCallback);
        ScrollUp.attachPop(sdlistPopCallback);
        ScrollDown.attachPop(sdlistPopCallback);
        Exit2.attachPop(ExitPopCallback);
        NPlay.attachPop(PlayPausePopCallback);
        NStop.attachPop(StopPopCallback);
      #endif

      #if HAS_TEMP_0
        hot0.attachPop(hotPopCallback,      &hot0);
      #endif
      #if HAS_TEMP_1
        hot1.attachPop(hotPopCallback,      &hot1);
      #endif
      #if HAS_TEMP_2 || HAS_TEMP_BED
        hot2.attachPop(hotPopCallback,      &hot2);
      #endif

      Fanpic.attachPop(setfanPopCallback,   &Fanpic);
      m11.attachPop(sethotPopCallback,      &m11);
      tup.attachPop(settempPopCallback,     &tup);
      tdown.attachPop(settempPopCallback,   &tdown);
      XYHome.attachPop(setmovePopCallback);
      XYUp.attachPop(setmovePopCallback);
      XYRight.attachPop(setmovePopCallback);
      XYDown.attachPop(setmovePopCallback);
      XYLeft.attachPop(setmovePopCallback);
      ZHome.attachPop(setmovePopCallback);
      ZUp.attachPop(setmovePopCallback);
      ZDown.attachPop(setmovePopCallback);
      SpeedOk.attachPop(ExitPopCallback);
      Benter.attachPop(setgcodePopCallback);

      startimer.enable();
    }
  }